-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsync_meshkeys_gw.sh
executable file
·51 lines (38 loc) · 1.17 KB
/
sync_meshkeys_gw.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# stop on any error
set -e
# sites to sync
SITES="mwu mzig wiig"
# site definitions
mwu_REMOTE="https://github.com/freifunk-mwu/peers-ffmwu.git"
mwu_LOCAL="/home/admin/clones/peers-ffmwu"
mzig_REMOTE="https://github.com/freifunk-mwu/ffmz-infrastructure-peers.git"
mzig_LOCAL="/etc/fastd/mzigvpn-1406/peers"
wiig_REMOTE="https://github.com/freifunk-mwu/ffwi-infrastructure-peers.git"
wiig_LOCAL="/etc/fastd/wiigvpn-1406/peers"
# sync git repositories for all sites
for SITE in ${SITES}; do
REMOTE="$(eval echo \$${SITE}_REMOTE)"
LOCAL="$(eval echo \$${SITE}_LOCAL)"
echo --- sync site ${SITE} ---
# create directory if necessary
mkdir -p ${LOCAL}
GIT="git -C ${LOCAL}"
# check if directory is a git repository
if ! $(${GIT} rev-parse --git-dir > /dev/null 2>&1) ; then
git clone "${REMOTE}" "${LOCAL}"
else
${GIT} reset --hard origin/HEAD
${GIT} clean -f -d
${GIT} pull
fi
LIMITER="/opt/go/bin/fastd-limiter"
# check if fastd-limiter is installed
if [ -f ${LIMITER} ]; then
${LIMITER} keys
fi
# if site has a matching fastd instance reload it
if [ -d "/etc/fastd/${SITE}vpn-1406" ]; then
sudo systemctl reload fastd@${SITE}vpn-1406
fi
done