-
-
Notifications
You must be signed in to change notification settings - Fork 366
Expand file tree
/
Copy path10-config-raspberry
More file actions
104 lines (79 loc) · 3.06 KB
/
10-config-raspberry
File metadata and controls
104 lines (79 loc) · 3.06 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
#!/bin/bash
set -xe
export LC_ALL=C
########################################
# Functions and Basic Configuration #
########################################
# Load common functions and set up cleanup trap
source /common.sh
install_cleanup_trap
# Load additional configuration (e.g., BASE_USER)
source /files/00-config
########################################
# Configuration & Install deps #
########################################
SWAP_CONF_FILE="/etc/dphys-swapfile"
SWAP_SIZE="256"
SWAP_MAX="1024"
DEPS=(i2c-tools)
apt-get install --yes "${DEPS[@]}"
########################################
# Add boot-config.txt to #
# /boot/config.txt #
########################################
cat /files/boot-config.txt >> "$BOOT_PATH"/config.txt
########################################
# Disable serial console to enable #
# Hardware Serial (PL011). #
########################################
sed -i 's/console=serial0,115200 //' "$BOOT_PATH"/cmdline.txt
########################################
# Enable i2c modules #
########################################
if [[ -f /etc/modprobe.d/raspi-blacklist.conf ]]; then
sed /etc/modprobe.d/raspi-blacklist.conf -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
fi
[[ -f /etc/modules ]] || touch /etc/modules
# Uncomment i2c_dev if it exists
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/"
# Add if doesn't exist
if ! grep -q "^i2c[-_]dev" /etc/modules; then
printf "i2c-dev\n" >>/etc/modules
fi
########################################
# Disable bluetooth and related #
# services #
########################################
systemctl_if_exists disable hciuart.service
systemctl_if_exists disable bluetooth.service
if ! grep "bookworm" /etc/os-release; then
systemctl_if_exists disable bluealsa.service
fi
########################################
# Increase swapfile size #
########################################
if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then
echo_green "Increasing swap file size to ${SWAP_SIZE} Mb. Limit to ${SWAP_MAX} Mb"
sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${SWAP_SIZE}"'/' "${SWAP_CONF_FILE}"
sed -i 's/^#CONF_MAXSWAP.*/'CONF_MAXSWAP="${SWAP_MAX}"'/' "${SWAP_CONF_FILE}"
fi
########################################
# Finalize user setup and set password #
########################################
if [ -f /usr/lib/userconf-pi/userconf ]; then
hash="$(echo "$BASE_PASSWORD" | openssl passwd -6 -stdin)"
/usr/lib/userconf-pi/userconf "$BASE_USER" "${hash}"
fi
systemctl_if_exists disable userconfig.service
########################################
# Enable getty #
########################################
systemctl_if_exists enable getty@tty1.service
########################################
# Enable sshd #
########################################
if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then
/usr/lib/raspberrypi-sys-mods/imager_custom enable_ssh
else
systemctl_if_exists enable ssh
fi