Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
Add up/down script. See issue Lochnair#136
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Vorwerk <info@fossores.de>
  • Loading branch information
SoerenBusse authored and FossoresLP committed Feb 27, 2020
1 parent b092190 commit 200d5c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ syntax:expression: pattern $VAR(@) "^wg[0-9]+$" \

create: ip link show dev $VAR(@) &>/dev/null || sudo ip link add dev $VAR(@) type wireguard

delete: sudo ip link del dev $VAR(@)
delete: (eval "$VAR(down-command/@)" >/dev/null || exit 1) && sudo ip link del dev $VAR(@)

end: if [ "$COMMIT_ACTION" != DELETE ]; then
sudo ip link set down dev $VAR(@)
end:
if [ "$COMMIT_ACTION" != DELETE ]; then
eval "$VAR(down-command/@) >/dev/null" || exit 1;
sudo ip link set down dev $VAR(@)
if [ ! -n "$VAR(./disable)" ]; then
sudo ip link set up dev $VAR(@)
eval "$VAR(up-command/@) >/dev/null" || exit 1;
if [ "$VAR(route-allowed-ips/@)" == "true" ]; then
[ -n "$VAR(./route-table)" ] && tnum="$VAR(./route-table/@)"
for i in $(sudo wg show $VAR(@) allowed-ips | sed 's/^.*\t//;s/ /\n/g' | sort -nr -k 2 -t /); do
if [ $i == "(none)" ]; then continue; fi
[[ $(sudo ip route get "$i" 2>/dev/null) == *dev\ $VAR(@)\ * ]] || sudo ip route add "$i" dev $VAR(@)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: txt
help: Script or command executed before the interface goes down
val_help: txt; Command
val_help: txt; Executable script in /config/scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: txt
help: Script or command executed after the interface went up
val_help: txt; Command
val_help: txt; Executable script in /config/scripts

0 comments on commit 200d5c9

Please sign in to comment.