Last active
July 25, 2017 20:02
-
-
Save Mausy5043/d1aa29af76fab960fa1e1fc0c53baf7b to your computer and use it in GitHub Desktop.
Script to build and install `raspberrypi-ua-netinst` on the Pi itself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BRANCH="devel" | |
# Build RASPBERRYPI-UA-NETINST using the NFS-mounted /mnt/backup/... | |
CLOPT="$@" #CLI parameters will be passed to mod-ua.sh | |
install_package() | |
{ | |
# See if packages are installed and install them. | |
package=$1 | |
echo "*********************************************************" | |
echo "* Requesting $package" | |
# status=$(dpkg-query -W -f='${Status} ${Version}\n' $package 2>/dev/null | wc -l) | |
status=$(dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -c "ok installed") | |
if [ "$status" -eq 0 ]; then | |
echo "* Installing $package" | |
sudo apt-get -yuV install $package | |
echo "*********************************************************" | |
dpkg-query -W -f='${Status} ${Version}\n' $package | |
else | |
echo -n "* Already installed !!! " | |
dpkg-query -W -f='${Version}\n' $package | |
echo "*********************************************************" | |
fi | |
} | |
date | |
install_package "curl" | |
install_package "zip" | |
install_package "cpio" | |
sudo mount /mnt/backup || echo "Backup already mounted" | |
WHERE="/mnt/backup/$(hostname)/builder" | |
rm -rf "$WHERE" | |
mkdir -p "$WHERE" | |
pushd "$WHERE" | |
if [ ! -e "./pi-netinst.branch" ]; then | |
echo "Setting branch..." | |
echo "$BRANCH" > "./pi-netinst.branch" | |
fi | |
git clone https://github.com/FooDeas/raspberrypi-ua-netinst.git | |
git clone https://github.com/Mausy5043/mod-raspberrypi-ua-netinst.git | |
if [ -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then | |
sudo cp -v /etc/wpa_supplicant/wpa_supplicant.conf ./wpa.conf | |
sudo chown pi:pi ./wpa.conf | |
fi | |
pushd ./mod-raspberrypi-ua-netinst | |
./mod-ua.sh -n "$(hostname)" "$CLOPT" | |
if [ $? -ne 0 ]; then | |
echo "ERROR encountered in mod-ua.sh" | |
exit 1 | |
fi | |
popd | |
tree -apsD ./raspberrypi-ua-netinst/build_dir/bootfs | |
if [ $? -ne 0 ]; then | |
echo "ERROR encountered." | |
exit 1 | |
fi | |
echo | |
echo | |
echo "****************************************************" | |
echo "* *" | |
echo "* The next step may render your Pi useless!!! *" | |
echo "* *" | |
echo "****************************************************" | |
echo | |
echo | |
# clear the keyboard-buffer | |
while read -r -t 0; do read -r; done; | |
read -p "OVERWRITE /boot with the new installation? [N/y] " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
# do dangerous stuff | |
pushd ./raspberrypi-ua-netinst/build_dir/bootfs | |
sudo rm -rf /boot/* | |
sudo cp -rv * /boot/ | |
tree -apsD /boot | |
popd | |
fi | |
popd | |
sudo umount /mnt/backup | |
echo | |
echo "READY" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment