Skip to content

Commit 395c263

Browse files
authored
Merge pull request #194 from linuxserver/wg-svc
Optimize wg and coredns services
2 parents 65e9b61 + ea59898 commit 395c263

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

readme-vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ app_setup_block: |
121121
122122
# changelog
123123
changelogs:
124-
- { date: "12.10.22:", desc: "Add Alpine branch." }
124+
- { date: "12.10.22:", desc: "Add Alpine branch. Optimize wg and coredns services." }
125125
- { date: "09.10.22:", desc: "Switch back to iptables-legacy due to issues on some hosts." }
126126
- { date: "04.10.22:", desc: "Rebase to Jammy. Upgrade to s6v3." }
127127
- { date: "16.05.22:", desc: "Improve NAT handling in server mode when multiple ethernet devices are present." }

root/defaults/Corefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
. {
22
loop
3+
health
34
forward . /etc/resolv.conf
45
}

root/etc/s6-overlay/s6-rc.d/init-wireguard-confs/run

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ else
162162
echo "**** No client conf found. Provide your own client conf as \"/config/wg0.conf\" and restart the container. ****"
163163
sleep infinity
164164
fi
165-
echo "**** Disabling CoreDNS ****"
166-
rm -rf /etc/services.d/coredns
165+
printf "false" > /run/s6/container_environment/USE_COREDNS
167166
fi
168167

169168
# set up CoreDNS
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/usr/bin/with-contenv bash
22

33
if netstat -apn | grep -q ":53 "; then
4-
echo "Another service is using port 53, disabling CoreDNS"
5-
sleep infinity
4+
USE_COREDNS="false"
5+
fi
6+
7+
if [[ ${USE_COREDNS} == "false" ]]; then
8+
s6-notifyoncheck -d -n 300 -w 1000 -c "echo **** Disabling CoreDNS ****" \
9+
sleep infinity
10+
elif grep -q "health" /config/coredns/Corefile; then
11+
exec \
12+
s6-notifyoncheck -d -n 300 -w 1000 -c "redirfd -w 1 /dev/null curl -s http://localhost:8080/health" \
13+
cd /config/coredns \
14+
/app/coredns -dns.port=53
615
else
7-
exec \
8-
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z -u 127.0.0.1 53" \
9-
cd /config/coredns \
10-
/app/coredns -dns.port=53
16+
exec \
17+
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -zu localhost 53" \
18+
cd /config/coredns \
19+
/app/coredns -dns.port=53
1120
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/svc-wireguard/finish
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
wg-quick down wg0
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
#!/usr/bin/with-contenv bash
22

3-
_term() {
4-
echo "Caught SIGTERM signal!"
5-
wg-quick down wg0
6-
}
7-
8-
trap _term SIGTERM
9-
103
wg-quick up wg0
11-
12-
sleep infinity &
13-
14-
wait
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
longrun
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/svc-wireguard/run

0 commit comments

Comments
 (0)