icvpn/scripts/post-merge
Martin Weinelt e3247d7cb5 Introduce the concept of metanodes
updates the README file, and makes the post-merge script read the
metanodes file instead of the whole hosts/ directory.
2015-04-18 16:34:39 +02:00

31 lines
581 B
Bash
Executable file

#!/bin/bash
# post-merge hook for Debian systems
#
# 1. copy to .git/hooks
# 2. to test run ".git/hooks/post-merge"
# 3. create cronjob running "git pull -q -C /etc/tinc/icvpn/"
#
fail() {
echo "$1" >&2
exit 1
}
BASE=$(git rev-parse --show-toplevel)
TINCCFG=$BASE/tinc.conf
test -w $TINCCFG || fail "ERR: $TINCCFG is not writeable"
sed -i '/^ConnectTo/d' $TINCCFG
while read HOST; do
# 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