fix various arch issues
[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 scp -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null \
15 /p/c/machine_specific/$host/filesystem/etc/ssh/* root@$host:/etc/ssh
16
17 if [[ -e /var/cache/pacman/pkg ]]; then
18 darkhttpd /var/cache/pacman/pkg &
19 mirror=http://$HOSTNAME:8080
20 fi
21 faid=/a/bin/fai
22 fai_files=(
23 distro-install-common
24 hooks/partition.DEFAULT
25 class/50-host-classes
26
27 )
28 sudo scp -r /a/bin/fai/arch-init{,-chroot} \
29 /a/bin/fai/encrypt \
30 ${fai_files[@]/#//a/bin/fai/fai/config/} \
31 /a/bin/devbyid \
32 /q/root/luks /q/root/shadow root@$host:
33 # creating shadow file string:
34 # on debian, you can use mkpasswd -m sha-512 to generate a pass.
35 # arch doesn't have this program. instead, you can do passwd,
36 # and extract it from the shadow file.
37 ssh root@$host bash -x ./arch-init $host $mirror
38
39 #ssh root@$host reboot now || [[ $? == 255 ]]
40
41 # next up is:
42 # ssh $host /a/bin/distro-begin
43
44 if [[ -e /var/cache/pacman/pkg ]]; then
45 killall darkhttpd
46 fi
47 # todo: this doesn't work. figure out why.
48 #kill $!