26 lines
524 B
Text
26 lines
524 B
Text
|
|
import sys
|
||
|
|
|
||
|
|
isup = "does not exist." not in $(ip link show dev wg0 2>&1)
|
||
|
|
|
||
|
|
try:
|
||
|
|
match sys.argv[1]:
|
||
|
|
case "toggle":
|
||
|
|
if isup:
|
||
|
|
footclient wg-quick down wg0
|
||
|
|
else:
|
||
|
|
footclient wg-quick up wg0
|
||
|
|
case "status":
|
||
|
|
if isup:
|
||
|
|
print("u")
|
||
|
|
else:
|
||
|
|
print("d")
|
||
|
|
case _:
|
||
|
|
raise RuntimeError
|
||
|
|
|
||
|
|
except (RuntimeError, IndexError):
|
||
|
|
print('"toggle" or "status" must be provided')
|
||
|
|
exit(1)
|
||
|
|
|
||
|
|
exit(0)
|
||
|
|
|