icvpn/scripts/post-merge

31 lines
581 B
Plaintext
Raw Normal View History

#!/bin/bash
# post-merge hook for Debian systems
#
# 1. copy to .git/hooks
2014-12-28 20:45:52 +01:00
# 2. to test run ".git/hooks/post-merge"
2014-09-04 13:29:31 +02:00
# 3. create cronjob running "git pull -q -C /etc/tinc/icvpn/"
#
2014-09-04 13:29:31 +02:00
fail() {
echo "$1" >&2
exit 1
}
2014-09-04 13:29:31 +02:00
BASE=$(git rev-parse --show-toplevel)
TINCCFG=$BASE/tinc.conf
test -w $TINCCFG || fail "ERR: $TINCCFG is not writeable"
2014-09-04 13:29:31 +02:00
sed -i '/^ConnectTo/d' $TINCCFG
while read HOST; do
2014-09-04 13:29:31 +02:00
# skip hosts without address
grep -iq '^Address' -- hosts/"$HOST" || continue
echo "ConnectTo = $HOST" >> $TINCCFG
done < metanodes
/usr/sbin/invoke-rc.d tinc reload icvpn
exit 0