-
Notifications
You must be signed in to change notification settings - Fork 15
/
wsl-vpnkit.service
executable file
·49 lines (42 loc) · 866 Bytes
/
wsl-vpnkit.service
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
#!/usr/bin/env sh
WSLVPNKIT_PATH="/usr/local/bin/wsl-vpnkit-start.sh"
PID_PATH="/var/run/wsl-vpnkit.pid"
LOG_PATH="/var/log/wsl-vpnkit.log"
cmd="/sbin/start-stop-daemon --startas /bin/sh --make-pidfile --remove-pidfile --pidfile ${PID_PATH}"
ret=0
start()
{
# using `wsl.exe` allows the daemon to keep running in the background even when you close your terminal
"%%SYSTEM_ROOT%%/system32/wsl.exe" -d "%%WSL_DISTRO_NAME%%" --user root -- $cmd --oknodo --background --start -- -c "exec ${WSLVPNKIT_PATH} >> ${LOG_PATH} 2>&1"
ret=$?
}
stop()
{
$cmd --oknodo --stop
ret=$?
}
status()
{
$cmd --status
ret=$?
echo "status is $ret"
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: wsl-vpnkit {start|stop|restart|status}"
exit 1
esac
exit $ret