better error output
[automated-distro-installer] / arch-init-remote
1 #!/bin/bash -l
2
3 set -x
4
5 set -eE -o pipefail
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
7
8 if [[ ! $1 ]]; then
9 echo "error: expect a hostname in \$1 "
10 exit 1
11 fi
12 host=$1
13
14 [[ $host == frodo ]] && scp /a/c/machine_specific/frodo/subdir_files/.ssh/* frodo:.ssh/
15 if [[ -e /var/cache/pacman/pkg ]]; then
16 darkhttpd /var/cache/pacman/pkg &
17 url=http://$HOSTNAME:8080
18 fi
19 faid=/a/bin/fai
20 fai_files=(
21 distro-install-common
22 hooks/partition.DEFAULT
23 class/50-host-classes
24 )
25 sudo scp -r /a/bin/fai/arch-init{,-chroot} \
26 ${fai_files[@]/#//a/bin/fai/fai/config/} \
27 /a/bin/devbyid \
28 /q/root/luks /q/root/shadow root@$host:
29 # creating shadow file string:
30 # on debian, you can use mkpasswd -m sha-512 to generate a pass.
31 # arch doesn't have this program. instead, you can do passwd,
32 # and extract it from the shadow file.
33 ssh root@$host bash -x ./arch-init $host $url
34 ssh root@$host reboot now || [[ $? == 255 ]]
35 # next up is:
36 # ssh $host /a/bin/distro-begin
37
38 killall darkhttpd
39 # todo: this doesn't work. figure out why.
40 #kill $!