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