Update vnstat to latest build and rc.

This commit is contained in:
Darren 'Tadgy' Austin 2022-10-11 00:51:59 +01:00
commit 419fff7a19
5 changed files with 63 additions and 35 deletions

View file

@ -3,6 +3,34 @@
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
install_file() {
# $1 = Path of file to process (without leading /, with .new extension)
[[ -z "$1" ]] || [[ ! -e "$1" ]] && return
local OLDFILE="${1%.new}"
if [[ ! -e "$OLDFILE" ]]; then
mv "$1" "$OLDFILE"
elif [[ -L "$OLDFILE" ]]; then
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " is a symbolic link - the incoming .new file was not written"
echo " to it in order to prevent clobbering something important."
echo
elif [[ "$(md5sum <"$OLDFILE")" == "$(md5sum <"$1")" ]]; then
rm -f "$1"
else
# |--------|-----------------------------------------------------------|
echo "WARNING: $OLDFILE"
echo " has been customised since original installation and was not"
echo " replaced with the incoming .new file."
echo
fi
}
# Install new configuration files.
install_file "etc/default/vnstatd.new"
# Add service start to rc.local
RC="rc.vnstatd"
fgrep "/etc/rc.d/$RC" etc/rc.d/rc.local >/dev/null 2>&1 || {