aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus <heckyel@riseup.net>2023-12-25 05:24:17 +0800
committerJesus <heckyel@riseup.net>2023-12-25 05:24:17 +0800
commit32190623efdae071410a7375058234dfad45d2ee (patch)
treebbf7ba2ecdabc51616ec07b58554acc258cea79d
parenta1db584b8fe66c00e1b9ead5a98cc7ad833dd15a (diff)
downloadbook-32190623efdae071410a7375058234dfad45d2ee.tar.lz
book-32190623efdae071410a7375058234dfad45d2ee.tar.xz
book-32190623efdae071410a7375058234dfad45d2ee.zip
wsl: update
-rw-r--r--wsl/README.md38
1 files changed, 36 insertions, 2 deletions
diff --git a/wsl/README.md b/wsl/README.md
index 424d5e5..e1dfe1e 100644
--- a/wsl/README.md
+++ b/wsl/README.md
@@ -1,5 +1,6 @@
## Force DNS Usage inside VPN
+### SystemD
```bash
$ cat /etc/systemd/system/vpn-dns.service
[Unit]
@@ -7,15 +8,48 @@ Description=VPN DNS Configuration
[Service]
Type=oneshot
-ExecStart=/bin/vpn-dns.sh
+ExecStart=/bin/vpn-dns
Environment=TERM=xterm
[Install]
WantedBy=multi-user.target
```
+### OpenRC
+
+```bash
+#!/sbin/openrc-run
+# Distributed under the terms of the GNU General Public License v3 or later
+name="vpn-dns"
+description="VPN DNS Configuration"
+pidfile="/var/run/vpn-dns.pid"
+command="/bin/vpn-dns"
+
+depend() {
+ use net
+}
+
+start() {
+ ebegin "Starting ${name}"
+ start-stop-daemon --start --exec "${command}" --pidfile "${pidfile}"
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${name}"
+ start-stop-daemon --signal HUP --pidfile "${pidfile}"
+ eend $?
+}+
+
+stop() {
+ ebegin "Stopping ${name}"
+ start-stop-daemon --quiet --stop --exec "${command}" --pidfile "${pidfile}"
+ eend $?
+}
+```
+
```bash
-$ cat /bin/vpn-dns.sh
+$ cat /bin/vpn-dns
#!/bin/bash
echo "Getting current DNS servers, this takes a couple of seconds"