2013-10-09 10:48:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-09-03 15:06:59 +02:00
|
|
|
# post-merge hook for Debian systems
|
2013-10-09 10:48:57 +02:00
|
|
|
#
|
2014-09-03 15:06:59 +02:00
|
|
|
# 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-03 15:06:59 +02:00
|
|
|
#
|
|
|
|
|
2015-05-11 15:15:14 +02:00
|
|
|
PATH=/usr/sbin:$PATH
|
|
|
|
|
2014-09-04 13:29:31 +02:00
|
|
|
fail() {
|
|
|
|
echo "$1" >&2
|
|
|
|
exit 1
|
2014-09-03 15:06:59 +02:00
|
|
|
}
|
|
|
|
|
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-03 15:06:59 +02:00
|
|
|
|
2014-09-04 13:29:31 +02:00
|
|
|
sed -i '/^ConnectTo/d' $TINCCFG
|
2014-09-03 15:06:59 +02:00
|
|
|
|
2015-04-18 16:34:39 +02:00
|
|
|
while read HOST; do
|
2014-09-04 13:29:31 +02:00
|
|
|
# skip hosts without address
|
2015-04-18 16:34:39 +02:00
|
|
|
grep -iq '^Address' -- hosts/"$HOST" || continue
|
2014-09-03 15:06:59 +02:00
|
|
|
|
2015-04-18 16:34:39 +02:00
|
|
|
echo "ConnectTo = $HOST" >> $TINCCFG
|
|
|
|
done < metanodes
|
2014-09-03 15:06:59 +02:00
|
|
|
|
2015-08-07 16:00:52 +02:00
|
|
|
if hash tinc 2>/dev/null; then
|
2015-05-11 15:15:14 +02:00
|
|
|
# prefer the command line interface that comes with tinc1.1 if it exists
|
|
|
|
tinc -n icvpn reload
|
|
|
|
else
|
|
|
|
invoke-rc.d tinc reload icvpn
|
|
|
|
fi
|
2013-10-09 10:48:57 +02:00
|
|
|
|
2014-09-03 15:06:59 +02:00
|
|
|
exit 0
|