Skip to content

Commit d21c255

Browse files
committed
isc can be used with docker too
1 parent ed1afde commit d21c255

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Homepage: https://github.com/ipitio/closure
44
Standards-Version: 3.9.2
55

66
Package: closure
7-
Version: 1.7.4
7+
Version: 1.7.5
88
Maintainer: ipitio <[email protected]>
99
Depends: curl, flatpak, gpg, hostapd, isc-dhcp-server, iw, macchanger, netplan.io, network-manager, net-tools, qrencode, rfkill, wireguard, wireless-tools, wget
1010
Recommends: containerd.io, docker-ce, docker-ce-cli, docker-buildx-plugin, docker-compose-plugin

lib.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,16 @@ start_hostapd() {
187187
fi
188188

189189
sudo hostapd -i "$wiface" -P /run/hostapd.pid -B hostapd/"$config".conf
190-
sudo iw dev "$wiface" set power_save off
190+
sudo iw dev "$wiface" set power_save off 2>/dev/null
191191
local octet
192192
octet=$(ifconfig "$wiface" | grep -zoP '(?<=inet 10\.42\.)\S+(?=\.1)')
193193

194194
if [ -z "$octet" ]; then
195195
octet=$((1 + $( (
196196
ifconfig | grep -zoP '(?<=10\.42\.)\S+(?=\.1)'
197197
echo 1
198-
) | grep -v 255 | sort -ru | head -n1)))
198+
) | grep -v 255 | sort -ru | head -n1))) 2>/dev/null
199+
[ -n "$octet" ] || octet=1
199200
sudo ifconfig "$wiface" 10.42."$octet".1 netmask 255.255.255.0
200201
fi
201202

restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "lib.sh"
88
sudo sysctl -w net.ipv4.ip_forward=0
99
sudo sysctl -w net.ipv6.conf.all.forwarding=0
1010
eval "cast pre-down ${*@Q}"
11-
sudo docker ps | grep -q wireguard && sudo docker compose stop wireguard || sudo wg-quick down "$CLS_INTERN_IFACE"
11+
sudo docker ps | grep -q wireguard && sudo docker compose stop wireguard || sudo wg-quick down "$CLS_INTERN_IFACE" 2>/dev/null
1212

1313
# shellcheck disable=SC2009
1414
ps -aux | grep -P "^[^-]+$this_dir/start.sh" | awk '{print $2}' | while read -r pid; do sudo kill -9 "$pid" &>/dev/null; done

start.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ source "lib.sh"
1313
pids=$(ps -o ppid=$$)
1414
ps -aux | grep -P "^[^-]+$this_dir/start.sh" | awk '{print $2}' | while read -r pid; do grep -q "$pid" <<<"$pids" || sudo kill -9 "$pid" &>/dev/null; done
1515

16-
if [ "${CLS_WG_ONLY:-false}" = "false" ]; then
16+
if [ ! "${CLS_WG_ONLY:-false}" = "true" ]; then
1717
[ -d config ] || sudo mkdir config
1818
[[ -f config/wifis.json && -s config/wifis.json ]] || echo "{}" | sudo tee config/wifis.json
1919

@@ -79,13 +79,12 @@ if [ "$CLS_DOCKER" = "true" ]; then
7979
sudo ip6tables -L -t "$table" | grep -q "$chain" || sudo ip6tables -N "$chain" -t "$table"
8080
done
8181
done
82-
else
83-
sudo sysctl -w net.ipv4.ip_forward=0
84-
sudo sysctl -w net.ipv6.conf.all.forwarding=0
85-
for iface in $(wg | grep -oP '(?<=interface: ).+'); do sudo wg-quick down "$iface"; done
86-
wg | grep -oP '(?<=^interface: ).+' | while read -r iface; do sudo wg-quick down "$iface" &>/dev/null; done
8782
fi
8883

84+
sudo sysctl -w net.ipv4.ip_forward=0
85+
sudo sysctl -w net.ipv6.conf.all.forwarding=0
86+
for iface in $(wg | grep -oP '(?<=interface: ).+'); do sudo wg-quick down "$iface"; done
87+
wg | grep -oP '(?<=^interface: ).+' | while read -r iface; do sudo wg-quick down "$iface" &>/dev/null; done
8988
eval "cast pre-up ${*@Q}"
9089

9190
(
@@ -138,8 +137,9 @@ eval "cast pre-up ${*@Q}"
138137

139138
if [ "$CLS_DOCKER" = "true" ]; then
140139
# prod starts wg
141-
if [ "${CLS_WG_ONLY:-false}" = "false" ] || ! sudo docker ps | grep -qE "pihole.*Up"; then
140+
if [ ! "${CLS_WG_ONLY:-false}" = "true" ] || ! sudo docker ps | grep -qE "pihole.*Up"; then
142141
sudo docker compose down
142+
sudo docker compose ps -aq | xargs -r sudo docker rm -f
143143
sudo systemctl restart docker
144144
sudo docker network prune -f
145145
until [ -n "$CLS_LOCAL_IP" ]; do
@@ -165,9 +165,10 @@ else
165165
sudo wg-quick down "$iface"
166166
sudo wg-quick up "$iface"
167167
done
168-
restart_isc
169168
fi
170169

170+
restart_isc
171+
171172
if [[ "$CLS_TYPE_NODE" == "haas" && -n "$CLS_SAAH_PEER" ]]; then
172173
[[ -d "wireguard/config/peer_$CLS_SAAH_PEER" ]] || exec sudo bash wireguard/add.sh "$CLS_SAAH_PEER" -- ${@@Q}
173174
saah_ip="$(grep -oP '(?<=Address = ).+' "wireguard/config/peer_$CLS_SAAH_PEER/peer_$CLS_SAAH_PEER.conf" 2>/dev/null)"

0 commit comments

Comments
 (0)