-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathemit-client
executable file
·43 lines (32 loc) · 935 Bytes
/
emit-client
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
#!/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_client() {
emit_config_pre
emit_config_interface "$client_config" "$server_config"
emit_config_peer "$server_config" "$client_config"
emit_config_post "$client_config"
}
if [[ -n "$SHOW_HELP" ]] || [[ $# -ne 2 ]]; then
usage "<server-config>" "<client-config>"
exit 1
fi
server_name="$1"
server_config="servers/$server_name.conf"
client_name="$2"
client_config="clients/$client_name.conf"
if [[ ! -e "$server_config" ]]; then
stderr "The $server_config does not exist!"
exit 1
fi
if [[ ! -e "$client_config" ]]; then
stderr "The $client_config does not exist!"
exit 1
fi
if ! peer_allowed "$client_config" "$server_config"; then
stderr "The $client_config cannot connect to $server_config."
exit 1
fi
"${MODE}_mode" emit_client