Created
January 24, 2017 15:40
-
-
Save Mausy5043/6e790215159d4606285591c30ec9e658 to your computer and use it in GitHub Desktop.
Script to build and install `raspbian-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 | |
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='${Status} ${Version}\n' $package | |
echo "*********************************************************" | |
fi | |
} | |
date | |
install_package "curl" | |
install_package "zip" | |
install_package "cpio" | |
where="$HOME/builder" | |
#where=/mnt/ramdisk | |
# Create a RAMDISK | |
rm -rf "$where" | |
mkdir -p "$where" | |
# TOTAL=`free -m | grep "\-\/\+" | awk '{print $4}M'` | |
# RAM=`echo "$TOTAL - 10" |bc`"M" | |
# echo "RAMdisk size: $RAM" | |
# sudo mount -t tmpfs -o size=$RAM none $where | |
pushd "$where" | |
echo "v1.1.x" > "./netinst.branch" | |
git clone https://github.com/debian-pi/raspbian-ua-netinst.git | |
git clone https://github.com/Mausy5043/mod-raspbian-ua-netinst.git | |
if [ -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then | |
cp /etc/wpa_supplicant/wpa_supplicant.conf ./wpa.conf | |
fi | |
pushd ./mod-raspbian-ua-netinst | |
./mod-ua.sh -n "$(hostname)" "$CLOPT" | |
popd | |
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 ./raspbian-ua-netinst/bootfs | |
sudo rm -rf /boot/* | |
sudo cp -rv * /boot/ | |
ls -la /boot | |
popd | |
fi | |
popd | |
#sudo umount $where | |
echo | |
echo "READY" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment