use latest btrfs-progs to match linux-libre
[automated-distro-installer] / arch-init-remote
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
5
6 set -x
7
8 set -eE -o pipefail
9 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
10
11 usage() {
12 cat <<EOF
13 Usage: ${0##*/} [-h|--help] HOSTNAME
14 install arch after it's been booted into it's setup env
15 EOF
16 exit $1
17 }
18 case $1 in
19 -h|--help) usage ;;
20 esac
21
22 if [[ ! $1 ]]; then
23 echo "error: expect a hostname in \$1 "
24 usage 1
25 fi
26 host=$1
27
28
29 scp -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null \
30 /p/c/machine_specific/$host/filesystem/etc/ssh/* root@$host:/etc/ssh
31
32 if [[ -e /var/cache/pacman/pkg ]]; then
33 darkhttpd /var/cache/pacman/pkg &
34 mirror=http://$HOSTNAME:8080
35 fi
36
37 rsync -rlpthvi --relative /a/bin/fai/ root@$host:/
38 rsync /a/bin/fai/ root@$host:/a/bin/fai/
39 sudo scp -r /q/root/luks /q/root/shadow root@$host:
40 # creating shadow file string:
41 # on debian, you can use mkpasswd -m sha-512 to generate a pass.
42 # arch doesn't have this program. instead, you can do passwd,
43 # and extract it from the shadow file.
44 ssh root@$host bash -x /a/bin/fai/arch-init $host $mirror
45
46 ssh root@$host reboot || [[ $? == 255 ]]
47
48 # next up is sync data, then
49 # ssh $host /a/bin/distro-begin
50
51 if [[ -e /var/cache/pacman/pkg ]]; then
52 killall darkhttpd
53 fi
54 # todo: this doesn't work. figure out why.
55 #kill $!