-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_install.sh
More file actions
executable file
·115 lines (99 loc) · 3.96 KB
/
Copy pathbase_install.sh
File metadata and controls
executable file
·115 lines (99 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash -e
# do not continue unless run as root
if [ $UID -ne 0 ]; then
echo "Please run this program as root or using sudo."
exit 1
fi
# check if our config file exists
if ! test -s ./base_install.conf ; then
echo "Config file ./base_install.conf not found!"
exit 1
fi
# check for media presence
while ! (test -L /dev/disk/by-label/bootfs && \
test -L /dev/disk/by-label/rootfs); do
echo "No partitions labelled bootfs and rootfs found."
echo "Try removing and reinserting the media."
echo "Sleeping 30 seconds and trying again ..."
sleep 30
done
# source our config variables
source ./base_install.conf
# override settings with custom file if present
if [ -s ./custom/config/base_install_custom.conf ]; then
echo "Custom base install config file found in './custom/config/', overriding default settings."
source ./custom/config/base_install_custom.conf
elif [ -s ./base_install_custom.conf ]; then
echo "Custom base install config file found, overriding default settings."
source ./base_install_custom.conf
fi
# source branch-specific config if present
if [ -s ./base_install_branch_specific.conf ]; then
source ./base_install_branch_specific.conf
fi
# override branch-specific settings with custom file if present
BRANCHNAME="$(git rev-parse --abbrev-ref HEAD)"
if [ -s ./custom/config/base_install_branch_specific_${BRANCHNAME}_custom.conf ]; then
echo "Custom branch-specific base install config file found in './custom/config/', overriding default settings."
source ./custom/config/base_install_branch_specific_${BRANCHNAME}_custom.conf
elif [ -s ./base_install_branch_specific_custom.conf ]; then
echo "Custom branch-specific base install config file found, overriding default settings."
source ./base_install_branch_specific_custom.conf
fi
# TODO check that all required variables are set
# log start
echo "Start time: $(date)"
#set dynamic variables
export MOUNTPOINT=$(mktemp -d)
export TEMPIMAGEDIR=$(mktemp -d -p $TEMPIMAGEDIRROOT)
# set BASEDEV and PARTITIONxyz variables depending on removable storage type
export BASEDEV=$(realpath /dev/disk/by-label/bootfs | sed -e 's/[0-9]$//')
if echo -n "$BASEDEV" | grep -q "mmc" ; then
export BASEDEV=$(echo -n "$BASEDEV" | sed -e 's/p$//')
export PARTONE="${BASEDEV}p1"
export PARTTWO="${BASEDEV}p2"
export PARTTHREE="${BASEDEV}p3"
export PARTFIVE="${BASEDEV}p5"
export PARTSIX="${BASEDEV}p6"
export PARTSEVEN="${BASEDEV}p7"
export PARTEIGHT="${BASEDEV}p8"
else
export PARTONE="${BASEDEV}1"
export PARTTWO="${BASEDEV}2"
export PARTTHREE="${BASEDEV}3"
export PARTFIVE="${BASEDEV}5"
export PARTSIX="${BASEDEV}6"
export PARTSEVEN="${BASEDEV}7"
export PARTEIGHT="${BASEDEV}8"
fi
# now run our configuration steps
echo "Now executing all our base install/config scripts ..."
if test -d ./base_install_scripts.d ; then
run-parts --exit-on-error ./base_install_scripts.d
else
echo "Directory ./base_install_scripts.d not found!"
exit 1
fi
# log end
echo "End time: $(date)"
####################
# TODO
# - try mkfs and rsync -avPAHXx --numeric-ids origin destination/ instead of dd - is it faster?
# - note: rsync now supports -HS --inplace and possibly --no-whole-file as well
# - update-rc.d alsa-utils disable
# - update-rc.d dnsmasq disable
# - watchdog is messed up?
# - try combining systemd and userland watchdog settings
# - what's the output of wdctl?
# - what happens when using a minimal Linux image (straight out of the imager), only with the watchdog-userland package?
# manual mount commands for an attempted switch to sysvinit:
# mount /dev/sda7 /mnt/
# mount /dev/sda3 /mnt/boot/firmware/
# mount --bind /dev /mnt/dev
# mount -t devpts none /mnt/dev/pts
# mount -t proc none /mnt/proc
# mount --bind /sys /mnt/sys
# chroot /mnt/
# apt install --allow-remove-essential sysvinit-core initscripts orphan-sysvinit-scripts rsyslog watchdog ntpsec-ntpdate uuid netcat-openbsd fake-hwclock systemd-sysv- systemd- apparmor- bluez-
# apt purge systemd-timesyncd systemd-zram-generator network-manager cloud-init
# apt autopurge -y