hwe kernel to fix btrfs-send bug
[automated-distro-installer] / arch-init-remote
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 set -x
19
20 set -eE -o pipefail
21 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
22
23 usage() {
24 cat <<EOF
25 Usage: ${0##*/} [-h|--help] HOSTNAME
26 install arch after it's been booted into it's setup env
27 EOF
28 exit $1
29 }
30 case $1 in
31 -h|--help) usage ;;
32 esac
33
34 if [[ ! $1 ]]; then
35 echo "error: expect a hostname in \$1 "
36 usage 1
37 fi
38 host=$1
39
40
41 scp -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null \
42 /p/c/machine_specific/$host/filesystem/etc/ssh/* root@$host:/etc/ssh
43
44 if [[ -e /var/cache/pacman/pkg ]]; then
45 darkhttpd /var/cache/pacman/pkg &
46 mirror=http://$HOSTNAME:8080
47 fi
48
49 rsync -rlpthvi --relative /a/bin/fai/ root@$host:/
50 rsync /a/bin/fai/ root@$host:/a/bin/fai/
51 sudo scp -r /q/root/luks /q/root/shadow root@$host:
52 # creating shadow file string:
53 # on debian, you can use mkpasswd -m sha-512 to generate a pass.
54 # arch doesn't have this program. instead, you can do passwd,
55 # and extract it from the shadow file.
56 ssh root@$host bash -x /a/bin/fai/arch-init $host $mirror
57
58 ssh root@$host reboot || [[ $? == 255 ]]
59
60 # next up is sync data, then
61 # ssh $host /a/bin/distro-begin
62
63 if [[ -e /var/cache/pacman/pkg ]]; then
64 killall darkhttpd
65 fi
66 # todo: this doesn't work. figure out why.
67 #kill $!