2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
21 if [[ $1 == -r ]]; then
28 Usage: ${0##*/} [OPTIONS] HOST
29 "distro setup full" using fai.
31 Note: relies on other repos and paths specific to Ian's system.
32 Note: disables btrbk.timer. If it was active before, it should
33 be manual reenabled after completion.
35 --no-r Don't ssh to host and reboot.
36 -k ssh to host and kexec, don't use pxe. implies --no-r
37 -h|--help Print help and exit.
39 Note: Uses GNU getopt options parsing style
44 ##### begin command line parsing ########
48 temp
=$
(getopt
-l help,no-r hk
"$@") || usage
1
52 --no-r) reboot
=false
; shift ;;
53 -k) kexec
=true
; reboot
=false
; shift ;;
56 *) echo "$0: Internal error!" ; exit 1 ;;
61 ##### end command line parsing ########
63 e ser stop btrbk.timer
64 if [[ ! $host ]]; then
65 echo "$0: error: expected 1 arg of hostname"
69 e
() { echo "$@"; "$@"; }
75 cleanup
() { pxe-server
; }
76 e pxe-server
$host fai
79 # untested, this caused hang using here doc.
80 ssh $host "touch /tmp/keyscript-off; sudo reboot" ||
: &
88 for ((i
=0; i
<240; i
++)); do
89 if timeout
-s 9 10 ssh $host :; then
97 echo "$0: error: timeout"
100 while [[ $
(ser is-active btrbk.service
) == active
]]; do