small bug fixes and improvements
[automated-distro-installer] / dsfull
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3 # This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
4
5 # distro setup full. (assuming we already synced data files to the host)
6
7 set -eE -o pipefail
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
9
10 reboot=true
11 if [[ $1 == -r ]]; then
12 reboot=false
13 shift
14 fi
15
16 host=$1
17
18 if [[ ! $host || $host == -h ]]; then
19 echo "$0: error: expected 1 arg of hostname"
20 exit 1
21 fi
22
23 set -x
24 if $reboot; then
25 ssh $host sudo bash <<'EOF' || [[ $? == 255 ]]
26 touch /tmp/keyscript-off
27 reboot
28 EOF
29 fi
30
31 pxe-server fai $host
32 while ! ssh $host :; do
33 sleep 5
34 done
35 dsremote $host