3 # copyright Thomas Lange 2001-2016, lange@debian.org
5 error
=0; trap 'error=$(($?>$error?$?:$error))' ERR
# save maximum error code
7 # remove crypt password from format.log
8 if [ -f $LOGDIR/format.log
]; then
9 perl
-i -pane "s/Executing: yes '.+?' \| cryptsetup/Executing: yes 'XXXXXXXXXXXXX' | cryptsetup/" $LOGDIR/format.log
12 if [ "$FAI_ACTION" = "dirinstall" -o $do_init_tasks -eq 0 ] ; then
15 # check if mdadm has been forgotten
16 if grep -q active
/proc
/mdstat
2>/dev
/null
; then
17 if [ ! -d $target/etc
/mdadm
]; then
18 echo ERROR
: Found Software RAID
, but the mdadm package was not installed
23 if [ -f $target/etc
/crypttab
] && [ ! -f $target/sbin
/cryptsetup
]; then
24 echo ERROR
: Encrypted devices used
, but the crypsetup package was not installed.
25 echo ERROR
: You want to add cryptsetup-initramfs or dracut to some package_config
file.
28 usedm
=$
(dmsetup
ls 2>/dev
/null |
egrep -v '^live-rw|^live-base|^No devices found' |
wc -l)
29 if [ $usedm -ne 0 ]; then
30 if [ ! -d $target/etc
/lvm
]; then
31 echo ERROR
: Found lvm devices
, but the lvm2 package was not installed
37 # remove backup files from cfengine, but only if cfengine is installed
38 if [ -x /usr
/sbin
/cfagent
] ||
[ -x $target/usr
/sbin
/cfagent
] ; then
41 find $target/$path -maxdepth 20 -name \
*.cfedited
-o -name \
*.cfsaved |
xargs -r rm
45 [ "$FAI_DEBMIRROR" ] &&
46 ainsl
/etc
/fstab
"#$FAI_DEBMIRROR $MNTPOINT nfs ro 0 0"
49 if [ $do_init_tasks -eq 1 ] ; then
51 no|
"") hwopt
="--localtime" ;;
54 hwclock $hwopt --systohc || true
57 # Make sure everything is configured properly
58 if ifclass DEBIAN
; then
59 $ROOTCMD apt-get
-f install -y
62 if [ $FAI_ACTION = "install" ]; then
63 lskernels
=$
(echo $target/boot
/vmlinu
*)
64 if [ ! -f ${lskernels%% *} ]; then
65 echo "ERROR: No kernel was installed. Have a look at shell.log" >&2
71 fcopy
-iSM /etc
/apt
/sources.list
76 # if release is not set, try to determine it
78 if [ -n "$release" ]; then
81 if [ ! -f $target/etc
/os-release
]; then
85 dists
="jessie stretch buster bullseye bookworm trixie forky noble jammy focal bionic xenial trusty"
87 if grep -iq $d $target/etc
/os-release
; then
94 # if installation was done from CD, replace useless sources.list
96 if [ -f $target/etc
/apt
/sources.list
] && [ -n "$release" ]; then
97 if grep -q 'file generated by fai-cd' $target/etc
/apt
/sources.list
; then
98 echo "Create new sources.list for $release"
99 cat <<EOF > $target/etc/apt/sources.list
100 deb $apt_cdn/debian $release main contrib non-free non-free-firmware
101 deb $security_cdn/debian-security ${secsuite} main contrib non-free non-free-firmware
102 #deb [trusted=yes] http://fai-project.org/download $release koeln
105 # if the package fai-server was installed, enable the project's repository
106 if dpkg-query
--admindir=$target/var
/lib
/dpkg
-W fai-server
>/dev
/null
2>&1; then
107 fai-sed
'/fai-project.org/s/^#//' /etc
/apt
/sources.list
111 # install default sources.list for Debian based distributions
112 if [ -d $target/etc
/apt
] && [ ! -f $target/etc
/apt
/sources.list
]; then
113 fcopy
-Svc DEBIAN_DEFAULT
/etc
/apt
/sources.list
116 # older releases do not have the non-free-firmware section
117 if [ -n "$release" ] && [[ "buster bullseye" =~
"$release" ]]; then
118 sed -i -e 's/non-free-firmware//g' $target/etc
/apt
/sources.list
121 # for ARM architecture, we may need the kernel and initrd to boot or flash the device
122 if ifclass ARM64
; then
123 cp -pv $target/boot
/vmlinuz
* $target/boot
/initrd
* $FAI_RUNDIR