2014-03-31 23:18:29 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# Simple script to update fastd peers from git upstream
|
|
|
|
# and only send HUP to fastd when changes happend.
|
|
|
|
|
2014-08-20 18:24:26 +02:00
|
|
|
if [[ "$1" == "-v" ]]; then
|
|
|
|
VERBOSE=1
|
|
|
|
fi
|
|
|
|
|
2014-03-31 23:18:29 +02:00
|
|
|
# CONFIGURE THIS TO YOUR PEER DIRECTORY
|
|
|
|
FASTD_PEERS=/etc/fastd/ffhh-mesh-vpn/peers
|
|
|
|
|
|
|
|
function getCurrentVersion() {
|
|
|
|
# Get hash from latest revision
|
|
|
|
git log --format=format:%H -1
|
|
|
|
}
|
|
|
|
|
|
|
|
cd $FASTD_PEERS
|
|
|
|
|
|
|
|
# Get current version hash
|
|
|
|
GIT_REVISION=$(getCurrentVersion)
|
|
|
|
|
|
|
|
# Automagically commit local changes
|
|
|
|
# This preserves local changes
|
2014-08-20 19:06:19 +02:00
|
|
|
git commit --quiet -m "CRON: auto commit" > /dev/null
|
2014-03-31 23:18:29 +02:00
|
|
|
|
|
|
|
# Pull latest changes from upstream
|
2014-08-20 18:24:26 +02:00
|
|
|
git fetch --quiet
|
|
|
|
git merge origin/master --quiet -m "Auto Merge"
|
2014-03-31 23:18:29 +02:00
|
|
|
|
|
|
|
# Get new version hash
|
|
|
|
GIT_NEW_REVISION=$(getCurrentVersion)
|
|
|
|
|
|
|
|
if [ $GIT_REVISION != $GIT_NEW_REVISION ]
|
|
|
|
then
|
|
|
|
# Version has changed we need to update
|
2014-08-20 18:24:26 +02:00
|
|
|
test -n "$VERBOSE" && echo "Reload fastd peers"
|
2014-03-31 23:18:29 +02:00
|
|
|
kill -HUP $(pidof fastd)
|
|
|
|
fi
|
|
|
|
|