Skip to content

Instantly share code, notes, and snippets.

@akhepcat
Created September 6, 2024 17:24
Show Gist options
  • Save akhepcat/c331693478ca69aa70ee1ece84045104 to your computer and use it in GitHub Desktop.
Save akhepcat/c331693478ca69aa70ee1ece84045104 to your computer and use it in GitHub Desktop.
# This is just some things to do after first boot
# YMMV
#
## First, some local defines
# if you define these, they'll be added as a default connection
SSID=""
WIFIPW=""
###########################################
### Initial updates
apt-get update
apt-get -y install joe git build-essential gawk aptitude libdate-manip-perl i2c-tools
### basic repos we want
cd /usr/local/src
for repo in profile-repo arm-misc WhatsMyIP
do
git clone https://github.com/akhepcat/${repo}
done
### resolve the:
## W: http://raspbian.raspberrypi.com/raspbian/dists/bookworm/InRelease:
## Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
git clone https://github.com/kstr0k/migrate-apt-keys
migrate-apt-keys/migrate-apt-keys
aptitude -y dist-upgrade
apt-get autoclean
apt-get autoremove
### install our default profile
cd /usr/local/src/profile-repo
./install_profile
rm -f ~/.*_local
### permissions fixups
luser=$(grep users /etc/group | cut -f 4 -d:)
cd /usr/local
chown -R ${luser} src
su -l ${luser} -c "cd /usr/local/src/profile-repo; ./install_profile; rm -f ~/.*_local"
### add some boot options
if [ -r /boot/firmware/cmdline.txt ]
then
FWD="/boot/firmware" # both cmdline.txt and config.txt are in /boot/firmware
elif [ -r /boot/cmdline.txt ]
then
FWD="/boot" # both cmdline.txt and config.txt are in /boot
else
FWD=""
fi
if [ -n "${FWD}" ]
then
[[ -z "$(grep vc4.force_hotplug ${FWD}/cmdline.txt)" ]] && sed -i 's/$/ vc4.force_hotplug=1/;' ${FWD}/cmdline.txt
if [ -z "$(grep 'consoleblank' ${FWD}/cmdline.txt)" ]
then
sed -i 's/$/ consoleblank=0/;' ${FWD}/cmdline.txt
else
sed -i 's/\(consoleblank\)\(=[0-9]\+\)/\1=0/;' ${FWD}/cmdline.txt
fi
# enable arm i2c
sed -i 's/^.*\(dtparam=i2c_arm\)=.*/\1=on/;' ${FWD}/config.txt
## common to ALL pi hardware
# for cli-only systems, gpu_mem=16 is best for maximizing system memory
# - obviously don't do that on GUI enabled systems!
# print from the beginning, up to and including the keyword "[all]"
sed -n '1,\|\[all\]|p' ${FWD}/config.txt > ${FWD}/config.txt.new
cat >> ${FWD}/config.txt.new <<EOF
gpu_mem=16
EOF
# finish printing from after that keyword "[all]" to EOF
sed -n '\|\[all\]|,$p' ${FWD}/config.txt | sed '1d' >> ${FWD}/config.txt.new
mv ${FWD}/config.txt.new ${FWD}/config.txt
## end all common config.txt
else
echo "can't find cmdline.txt in either /boot or /boot/firmware"
fi
if [ -d /etc/NetworkManager/system-connections -a -n "${SSID}" ]
then
# for generic wireless access when not plugged into ethernet
nmcli dev wifi connect "${SSID}" password "${WIFIPW}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment