forked from mainsail-crew/MainsailOS
-
-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathstart_chroot_script
More file actions
87 lines (69 loc) · 3.07 KB
/
Copy pathstart_chroot_script
File metadata and controls
87 lines (69 loc) · 3.07 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
#!/usr/bin/env bash
# Preinstall customized config.txt
# Written by Stephan Wendel <me@stephanwe.de> aka KwadFan
# This file may distributed under GPLv3
# Copyright 2021
########
# shellcheck enable=require-variable-braces
## Source error handling, leave this in place
set -Eex
# Set DEBIAN_FRONTEND to noninteractive
if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then
export DEBIAN_FRONTEND=noninteractive
fi
## Source CustomPIOS common.sh
# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap
# Step 1: Copy msos_config.txt
echo_green "Copying temporary file ..."
unpack /filesystem/tmp /tmp root
echo_green "Merge RatOS configuration with default config.txt ..."
# Step 2: Copy default config to "/tmp"
cp "${PICONFIG_CONFIG_TXT_FILE}" /tmp
# Step 3: Move default config to backup file
mv "${PICONFIG_CONFIG_TXT_FILE}" "${PICONFIG_CONFIG_BAK_FILE}"
echo_green "Disable kms and enable fkms - temporary workaround for BTT pi TFT touch screens"
sed -i 's/^dtoverlay=vc4-kms-v3d/#dtoverlay=vc4-kms-v3d/' /tmp/config.txt
# Step 4: Concatenate files to config
cat /tmp/config.txt /tmp/msos_config.txt >/tmp/config.new
# Step 5: Copy new config to "/boot/config.txt"
cp /tmp/config.new "${PICONFIG_CONFIG_TXT_FILE}"
# Step 6: Cleanup
rm -f /tmp/*config*
# Step 7: Copy default cmdline.txt to backup file
cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}"
# Step 8: Disable serial console to enable Hardware Serial (PL011).
echo_green "Disable Serial Linux console ..."
sed -i 's/console=serial0,115200 //' "${PICONFIG_CMDLINE_TXT_FILE}"
# Step 9: Enable i2c modules
# Also needs corresponding bits in config.txt (see #196)
echo_green "Enabling i2c-dev"
# Enable i2c_bcm2708 is disabled
[[ -f /etc/modprobe.d/raspi-blacklist.conf ]] && sed /etc/modprobe.d/raspi-blacklist.conf -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
[[ -f /etc/modules ]] || touch /etc/modules
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/" # Uncomment i2c_dev
if ! grep -q "^i2c[-_]dev" /etc/modules; then # Add if doesn't exist
printf "i2c-dev\n" >>/etc/modules
fi
# install common i2c helpers
check_install_pkgs i2c-tools
# Step 10: Disable bluetooth and related services
echo_green "Disabling Bluetooth related services..."
systemctl_if_exists disable hciuart.service
systemctl_if_exists disable bluetooth.service
systemctl_if_exists disable bluealsa.service
# Step 11: Increase swapfile size
if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then
echo_green "Increasing swap file size to ${PICONFIG_SWAP_SIZE} Mb. Limit to ${PICONFIG_SWAP_MAX} Mb"
sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${PICONFIG_SWAP_SIZE}"'/' "${PICONFIG_SWAP_CONF_FILE}"
sed -i 's/^#CONF_MAXSWAP.*/'CONF_MAXSWAP="${PICONFIG_SWAP_MAX}"'/' "${PICONFIG_SWAP_CONF_FILE}"
fi
# Step 12: Enable autologin (required for Pi3's, Pi4's do this by default, for some reason)
echo_green "Enable autologin..."
systemctl set-default multi-user.target
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $BASE_USER --noclear %I \$TERM
EOF