change partitioning to use lvm, refactor for fsf server
[automated-distro-installer] / fai / config / hooks / instsoft.DEFAULT
1 #!/bin/bash
2
3 # These are things we can do before package_config packages get installed.
4
5 # exit for any vm except demohost, or if we are doing a dirinstall
6 if ifclass VM && ! ifclass demohost || ifclass VOL_BULLSEYE_BOOTSTRAP || [[ ! $FAI_ACTION || $FAI_ACTION = dirinstall ]]; then
7 exit 0
8 fi
9
10 if ifclass FSF; then
11 exit 0
12 fi
13
14 keyfile=/var/lib/fai/config/distro-install-common/luks/host-$HOSTNAME
15 f=$target/root/keyscript
16 cat > $f <<EOFOUTER
17 #!/bin/sh
18 cat <<'EOF'
19 $(cat $keyfile)
20 EOF
21 EOFOUTER
22 chmod 700 $f
23
24
25 # for hosts which don't have these data volumes, copy the specific
26 # files we need.
27 if ifclass demohost; then
28 files=(/var/lib/fai/config/distro-install-common/luks/host-demohost)
29 elif ifclass tp; then
30 files=(/var/lib/fai/config/distro-install-common/luks/host-tp)
31 fi
32 if [[ ${files[0]} ]]; then
33 d=$target/q/root/luks
34 mkdir -p $d
35 chmod 700 $d
36 cp -p ${files[@]} $d
37 fi
38
39
40 #### this bit is duplicated in rootsshsync, except we skip update-initramfs,
41 # since I suspect its not needed. I'm not sure any of this is needed
42 # since we initially embed the key, and with distro-begin, we run rootsshsync
43 # around the same time as we remove it.
44 d=/etc/initramfs-tools
45 if [[ -e $d ]] && ! diff -q /root/.ssh/authorized_keys $d/root/.ssh/authorized_keys &>/dev/null; then
46 mkdir -p $d/root/.ssh /etc/dropbear-initramfs
47 chmod 700 $d/root $d/root/.ssh
48 cp -p /root/.ssh/authorized_keys $d/root/.ssh/authorized_keys
49 cp -p /root/.ssh/authorized_keys /etc/dropbear-initramfs
50 if [[ -e /root/.ssh/authorized_keys2 ]]; then
51 cat /root/.ssh/authorized_keys2 >>/etc/dropbear-initramfs
52 fi
53 fi