Last active
November 4, 2021 12:58
-
-
Save bjpetit/4493e0926d8c55570796c8448d249216 to your computer and use it in GitHub Desktop.
Update linbpq on the raspberry pi
This file contains hidden or 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 | |
# Download latest RPi BPQ binaries | |
# If arg 1 is beta then make beta binary active | |
# If arg 1 is anything else, release or NULL then make | |
# release binary active | |
# If arg 2 is Y then restart linbpq after updates | |
# otherwise prompt for restart | |
# Location of linbpq install. Modify this path if | |
# linbpq is running out of a different directory. | |
BPQHOME=/opt/linbpq | |
echo "### Updating linbpq in ${BPQHOME} ###" | |
if [ "${1^^}" = "BETA" ]; then | |
BPQ_BINARY="pilinbpq.beta" | |
echo "### Updating binaries and activating linbpq beta ###" | |
else | |
BPQ_BINARY="pilinbpq.release" | |
echo "### Updating binaries and activating linbpq release ###" | |
fi | |
if [ "${2^^}" = "Y" ]; then | |
RESTART_BPQ="Y" | |
echo "### Automatically restarting linbpq service ###" | |
fi | |
# Create bin directories | |
mkdir -p ${BPQHOME}/bin | |
mkdir -p ${BPQHOME}/oldbin | |
# Clean up old bin files | |
rm -v ${BPQHOME}/oldbin/*.older | |
# Save off current binaries | |
for f in ${BPQHOME}/oldbin/*; do | |
mv -v ${f} ${f}.older | |
done | |
# Save off a copy of everything in bin | |
mv -v ${BPQHOME}/bin/* ${BPQHOME}/oldbin | |
echo "" | |
# change to bin directory | |
# binaries will live here and linbpq will be a symlink | |
# to the binary we want to run, release or beta | |
cd ${BPQHOME}/bin/ | |
# Download release binary | |
wget http://www.cantab.net/users/john.wiseman/Downloads/pilinbpq | |
if [ $? != 0 ]; then | |
echo "Failed to download release bpq" | |
exit 1 | |
fi | |
mv -v pilinbpq pilinbpq.release | |
chmod 755 pilinbpq.release | |
# Download beta binary | |
wget http://www.cantab.net/users/john.wiseman/Downloads/Beta/pilinbpq | |
if [ $? != 0 ]; then | |
echo "Failed to download beta bpq" | |
exit 1 | |
fi | |
mv -v pilinbpq pilinbpq.beta | |
chmod 755 pilinbpq.beta | |
# Download APRS binary | |
wget http://www.cantab.net/users/john.wiseman/Downloads/Beta/piBPQAPRS | |
if [ $? != 0 ]; then | |
echo "Failed to download bpq APRS" | |
exit 1 | |
fi | |
chmod 755 piBPQAPRS | |
# Link in the selected binary, release or beta | |
rm ${BPQHOME}/linbpq | |
ln -s ${BPQHOME}/bin/${BPQ_BINARY} ${BPQHOME}/linbpq | |
echo "" | |
echo "Active binary..." | |
ls -l ${BPQHOME}/linbpq | |
echo "" | |
echo "" | |
if [ "${RESTART_BPQ}" = "Y" ]; then | |
RESPONSE="y" | |
else | |
echo "Restart linbpq?" | |
echo -n "Y/N?>" | |
read RESPONSE | |
fi | |
if [ "${RESPONSE^^}" = "Y" ]; then | |
sudo systemctl restart linbpq | |
fi | |
sudo systemctl status linbpq | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment