-
Notifications
You must be signed in to change notification settings - Fork 5
/
emit-server
executable file
·53 lines (37 loc) · 1.09 KB
/
emit-server
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
52
#!/usr/bin/env bash
set -eo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source "$DIR/helpers/functions"
source "$DIR/helpers/cmd-emit"
emit_server() {
emit_config_pre
emit_config_interface "$server_config"
for other_server_config in "servers/"*.conf; do
[[ "$other_server_config" == "$server_config" ]] && continue
if ! peer_allowed "$other_server_config" "$server_config"; then
continue
fi
if ! peer_allowed "$server_config" "$other_server_config"; then
continue
fi
emit_config_peer "$other_server_config" "$server_config"
done
for client_config in "clients/"*.conf; do
if ! peer_allowed "$client_config" "$server_config"; then
continue
fi
emit_config_peer "$client_config" "$server_config"
done
emit_config_post "$server_config"
}
if [[ -n "$SHOW_HELP" ]] || [[ $# -ne 1 ]]; then
usage "<server-config>"
exit 1
fi
server_name="$1"
server_config="servers/$server_name.conf"
if [[ ! -e "$server_config" ]]; then
stderr "The $server_config does not exist!"
exit 1
fi
"${MODE}_mode" emit_server