Up2bpq

Recent version is up2bpq-stable
https://ham.packet-radio.net/packet/up2bpq/up2bpq-stable

I have called the update script Up2bpq-stable.. Why, it`s using the stable version of BPQ32.

Some of the changelog

# 01-12-2019
# Add setcap to the linbpq.start file.
# After update change the linbpq.start file “setcap command and start line”.
# Add -q option to wget to suspres the output.
# Add hosttype check to download the right linbpq or pilinbpq.
# Make it possible to run the script from everywhere in het system (source ~/.bashrc).
# Add the bin directory in home dir ~/bin.
# Shorten the directory paths, adding ~/ in front of it.
# The script is using the Stable release.

You can run the script via a crontab.

crontab -e

To run /home/pd9q/up2bpq-stable five minutes after midnight, every day, enter:
5 0 * * * /home/pd9q/bin/up2bpq-stable

#!/bin/bash
# Up2bpq Version v2.0.2 12-01-2019 by Niels PD9Q
# Fist Version V1 greated on 10-02-2019
# Check version numbers of Pilinbpq and Linbpq against version numbers on the local machine.
# Hold the timestamp. Add version number and timestamp to the file and copy to archive.
# Copy the new version to the Linbpq directory and rerun Linbpq with the new version.
#
# 01-12-2019
# Add setcap to the linbpq.start file.
# After update change the linbpq.start file "setcap command and start line".
# Add -q option to wget to suspres the output.
# Add hosttype check to download the right linbpq or pilinbpq.
# Make it possible to run the script from everywhere in het system (source ~/.bashrc).
# Add the bin directory in home dir ~/bin.
# Shorten the directory paths, adding ~/ in front of it.
# The script is using the Stable release.
#
# 10-11-2019
# Add first check, to do something about the errors.
# Add email option, now you get the version number en changelog mailed to you.
# Try to meet the posix standards.
#
# Meet the standard of posix
set -o posix
# Enable debugging
set -xv
#
#
# Global variables.
# Please change the variables to your own needs.
user=$USER                                            # This is the user who ownes/runs Linbpq
mail=pd9q-(@)-packet-radio.net                        # Set your e-mail adres
home=~/linbpq                                         # This is the main directory of linbpq (home/USER/linbpq)
work=~/linbpq/up2bpq                                  # This is the working directory for up2bpq
changelog=~/linbpq/up2bpq/changelog                   # This is the changelog directory
archive=~/linbpq/up2bpq/archive                       # This is the archive directory to save older versions of pilinbpq/linbpq
logfile=~/linbpq/up2bpq/log-up2bpq.txt                # Logfile (not in use yet)
#
# Start of the main script
# Check if required directory exist
if [ ! -d "$home" ]; then
        mkdir -p -v "$home"
fi
#
if [ ! -d "$work" ]; then
        mkdir -p -v "$work"
fi
#
if [ ! -d "$archive" ]; then
        mkdir -p -v "$archive"
fi
#
if [ ! -d "$changelog" ]; then
        mkdir -p -v "$changelog"
fi
if [ ! -d ~/bin ]; then
        mkdir -p -v ~/bin
fi
#
# Copy the script to the bin directory
if [ ! -f ~/bin/up2bpq-stable ]; then
        cp -p up2bpq-stable ~/bin
fi
# Export PATH and source bashrc
# Log out and login again and you can run the script from everywhere in the system
        export PATH=~/bin:$PATH
        chmod a+x ~/.bashrc
        PS1='$ '
        source ~/.bashrc
#
# Check hosttype
if [[ $HOSTTYPE == *86* ]];
then
 export LINBPQ=linbpq;
  else
 export LINBPQ=pilinbpq;
 fi
#
# Fist check if linbpq exist
if [ ! -f "$home"/linbpq_* ]; then
        nowdat=$(date "+%Y-%m-%d")
        wget -q -N http://www.cantab.net/users/john.wiseman/Downloads/$LINBPQ -O "$home"/linbpq
        chmod +x "$home"/linbpq
        oldlin=$("$home"/linbpq -V | grep Version | cut -d' ' -f7)
        cp -p "$home"/linbpq "$home"/linbpq_"$oldlin"_"$nowdat" ; rm -f "$home"/linbpq
        echo "# Pilinbpq Start File v1.1" > "$home"/linbpq.start
        echo 'sudo setcap "CAP_NET_ADMIN=ep CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep"' linbpq_"$oldlin"_"$nowdat" >> "$home"/linbpq.start
        echo "cd "$home"" >> "$home"/linbpq.start
        echo "sudo -u $user ./linbpq_"$oldlin"_"$nowdat"" >> "$home"/linbpq.start
        chmod +x "$home"/linbpq.start
fi

# Find the recent version number (linbpq_6.0.19.1_2019-10-5?)
find=$(ls "$home"/linbpq_*)

# Getting the files from BPQ32 the stable release
wget -q -N http://www.cantab.net/users/john.wiseman/Downloads/$LINBPQ -O "$work"/linbpq

if [ $? -ne  0 ]; then
        echo "Download FAILED...Try again later"
        exit 1
fi

# Chmod the file
chmod +x "$work"/linbpq

# Compare the version numbers
oldvertxt=$($find -V | grep Version | cut -d' ' -f7)
newvertxt=$("$work"/linbpq -V | grep Version | cut -d' ' -f7)

# Convert to numbers for comparision
#
oldver=$(echo "$oldvertxt" | sed s'/[.]//g') newver=$(echo "$newvertxt" | sed s'/[.]//g')


if [ "$newver" -le "$oldver" ]; then
        echo Version "$oldvertxt" is current. No update available
        echo Nothing to do, so sit down and relax
        rm -f "$work"/linbpq
        exit 0 &>/dev/null

else
        echo Version "$newvertxt" available. Upgrading now
        now=$(date "+%Y-%m-%d")
        cp -p "$work"/linbpq "$home"/linbpq_"$newvertxt"_"$now"
        cp -p "$work"/linbpq "$archive"/linbpq_"$newvertxt"_"$now"
        sed -i "s,linbpq_.*$,linbpq_"$newvertxt"_"$now"," "$home"/linbpq.start
        # Email the new version number and the changlog
        wget -q https://www.cantab.net/users/john.wiseman/Documents/NodeChangeLog.html -P "$changelog" &>/dev/null
        sed -e '1,20d' -e 's/<[^>]*>//g' "$changelog"/NodeChangeLog.html > "$changelog"/changelog.txt
        sed -e "3s/Version/Version-new/" -n -e '/Version-new/,/Version/ p' "$changelog"/changelog.txt  | mail -s "Changelog of BPQ32" "$mail"
        echo "Linbpq is replaced by "$newvertxt" old version was "$oldvertxt"" | mail -s "Update BPQ32 new version" "$mail"
        rm -f "$changelog"/NodeChangeLog.* ; rm -f "$changelog"/changelog.txt
        # No reason to exist any more.
        rm -f "$home"/linbpq_"$oldvertxt"_*
        rm -f "$work"/linbpq
        sleep 5
        # Change to your own needs
        #sudo systemctl restart linbpq
        #sudo reboot
        #sudo shutdown -r now
fi
exit 0