-
Notifications
You must be signed in to change notification settings - Fork 5
/
emit-all
executable file
·43 lines (30 loc) · 1.35 KB
/
emit-all
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
#!/usr/bin/env bash
set -eo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source "$DIR/helpers/functions"
rm -rf configs/*
umask 0077
mkdir -p "configs/"
for server_config in "servers/"*.conf; do
server_name="$(basename "$server_config" .conf)"
echo "$server_name..."
server_updatecmd=$(get_value "$server_config" "UpdateCmd")
if [[ -z "$server_updatecmd" ]]; then
"$DIR/emit-server" --wg-conf "$server_name" > "configs/${server_name}.conf"
fi
for client_config in "clients/"*.conf; do
client_name="$(basename "$client_config" .conf)"
client_updatecmd=$(get_value "$client_config" "UpdateCmd_$server_name" "UpdateCmd")
if ! peer_allowed "$client_config" "$server_config"; then
continue
fi
if [[ -z "$client_updatecmd" ]]; then
echo "$server_name:$client_name..."
mkdir -p "configs/${client_name}/"
"$DIR/emit-client" --wg-conf "$server_name" "$client_name" > "configs/${client_name}/${server_name}.conf"
"$DIR/emit-client" --wg-conf --default "$server_name" "$client_name" > "configs/${client_name}/${server_name}def.conf"
"$DIR/emit-client" --qr-png "$server_name" "$client_name" > "configs/${client_name}/${server_name}.png"
"$DIR/emit-client" --qr-png --default "$server_name" "$client_name" > "configs/${client_name}/${server_name}def.png"
fi
done
done