New Raspberry Pi Update Template
From KlavoWiki
Jump to navigationJump to search
For a new Raspberry Pi I run the following script to make changes just the way I like.
vi /home/pi/template.sh
#!/bin/bash
# Are you Root?
if [[ ${EUID} -ne 0 ]]; then
echo " !!! This tool must be run as root"
exit 1
fi
# Enable SSH
update-rc.d ssh enable
# Regenerate SSH Keys
rm -f /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
# Install VIM
apt -y install vim
# Set timezone to Brisbane, Australia
timedatectl set-timezone Australia/Brisbane
# Enable root SSH remote login
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin Yes/' /etc/ssh/sshd_config
systemctl restart ssh
# configure ll alias
cat >> /root/.profile << EOF
alias ll='ls -la --color --group-directories-first --time-style="+%Y-%m-%d %H:%M"'
EOF
cat >> /boot/config.txt << EOF
# Set GPU RAM to 16MB
gpu_mem=16
EOF
# Set VIM cut/paste insert
cat > /root/.vimrc << EOF
set mouse=r
syntax on
EOF
# Disable Wi-Fi and Bluetooth
cat > /etc/modprobe.d/blacklist-radios.conf << EOF
#Wi-Fi
blacklist brcmfmac
blacklist brcmutil
#Bluetooth
blacklist btbcm
blacklist hci_uart
EOF
systemctl disable hciuart
# Create update scripts to update OS
cat > /usr/sbin/update << EOF
#!/bin/bash
if [[ ${EUID} -ne 0 ]]; then
echo " !!! This tool must be run as root"
exit 1
fi
apt-get update
apt-get -y full-upgrade
apt-get -y dist-upgrade
apt-get -y autoclean
apt-get -y autoremove
echo
echo
echo Updates Completed
echo
EOF
chmod +x /usr/sbin/update
# Run update scripts and update rPi firmware
update
sudo SKIP_WARNING=1 rpi-update
sudo bash /home/pi/template.sh reboot