fix lid close, other improvements
[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 fcopy -riB /etc/apt/preferences.d
15 # ian: i'm guessing fai does this already
16 #fcopy -riB /etc/apt/sources.list.d
17
18
19 keyfile=/var/lib/fai/config/distro-install-common/luks/host-$HOSTNAME
20 f=$target/root/keyscript
21 cat > $f <<EOFOUTER
22 #!/bin/sh
23 cat <<'EOF'
24 $(cat $keyfile)
25 EOF
26 EOFOUTER
27 chmod 700 $f
28
29
30 # for hosts which don't have these data volumes, copy the specific
31 # files we need.
32 if ifclass demohost; then
33 files=(/var/lib/fai/config/distro-install-common/luks/host-demohost)
34 elif ifclass tp; then
35 files=(/var/lib/fai/config/distro-install-common/luks/host-tp)
36 fi
37 if [[ ${files[0]} ]]; then
38 d=$target/q/root/luks
39 mkdir -p $d
40 chmod 700 $d
41 cp -p ${files[@]} $d
42 fi
43
44
45 #### This bit is duplicated in rootsshsync, except we skip
46 #### update-initramfs and add $target
47 ####
48 # We generally shouldn't need this, because we don't ssh in on the 1st
49 # reboot since we initially embed the luks key, and with distro-begin,
50 # we run rootsshsync around the same time as we remove it. However, it
51 # could be helpful in case of problems.
52
53 auth_dir=$target/etc/dropbear/initramfs/
54 candidate=$(apt-cache policy dropbear-initramfs | awk '$1 == "Candidate:" { print $2 }' | head -n1 ||:)
55 if [[ $candidate ]] && dpkg --compare-versions "$candidate" lt 2020.81-4; then
56 auth_dir=$target/etc/dropbear-initramfs
57 fi
58 auth_file=$auth_dir/authorized_keys
59 mkdir -p $auth_dir
60 if [[ ! -e $auth_file ]] || ! diff -q /root/.ssh/authorized_keys $auth_file; then
61 cp -p /root/.ssh/authorized_keys $auth_file
62 fi