Skip to content

Commit ce6a0d2

Browse files
committed
fix sed, sudo, and wg-quick
1 parent c9de469 commit ce6a0d2

9 files changed

Lines changed: 16 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Keep in mind that:
5353
- Unbound connects to Cloudflare's servers using DoT by default, but you can uncomment its volume in `compose.yml` to use it as a recursive resolver.
5454
- To configure Pi-hole more extensively, such as by enabling DHCP, see the [Pi-hole documentation](https://github.com/pi-hole/docker-pi-hole/tree/2024.07.0?tab=readme-ov-file#environment-variables).
5555
- The hooks may be useful, for example, if you'd like to coordinate with an external, outbound VPN on a Hub or SaaH. All arguments given to `start.sh`and `stop.sh` are passed to their respective hooks.
56-
- For AP+STA mode, define as many `X@[iface].conf` files as bands the device supports, where X is an integer band.
56+
- For AP+STA mode, you can define as many `X@[iface].conf` files as bands the device supports, where X is an integer band.
5757

5858
> [!NOTE]
5959
> The WireGuard service in the Compose file must be configured whether or not you'll use Docker ([docs](https://docs.linuxserver.io/images/docker-wireguard)).
@@ -68,7 +68,7 @@ Create or update a node in two or three steps:
6868
1. Install the package by either:
6969
- pasting the one-liner or block below;
7070
- downloading it from [Releases](https://github.com/ipitio/closure/releases); or
71-
- copying this repo to `/opt/closure`, then ensuring `rc.local` is executable and moved to `/etc`.
71+
- copying this repo to `/opt/closure`, then ensuring the executable `rc.local` is moved to `/etc`.
7272

7373
```{bash}
7474
curl -sSLNZ https://ipitio.github.io/closure/i | sudo bash

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.6.17
7+
Version: 1.6.18
88
Maintainer: ipitio <21136719+ipitio@users.noreply.github.com>
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

init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if [ "$CLS_DOCKER" = "true" ]; then
171171
sudo docker compose build
172172
fi
173173

174-
sudo sed -i 's/#\?DNSStubListener=.*/DNSStubListener=no/g' /etc/systemd/resolved.conf
174+
sudo sed -i 's/\#\?DNSStubListener=.*/DNSStubListener=no/g' /etc/systemd/resolved.conf
175175
sudo systemctl restart systemd-resolved
176176
sudo systemctl disable isc-dhcp-server &>/dev/null
177177
sudo systemctl stop hostapd &>/dev/null

kickstart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
script_path="$(dirname "$(readlink -f "$0")")"
55
sudo -i bash <<EOF
66
pushd "$script_path" || exit 1
7-
CLS_WG_ONLY=${CLS_WG_ONLY:-false} bash start.sh ${@@Q} > ks.log
7+
CLS_WG_ONLY=${CLS_WG_ONLY:-false} bash start.sh ${@@Q} &>start.log
88
popd || exit 1
99
EOF

lib.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ user_exists() { id "$1" &>/dev/null; }
4040

4141
sudo() {
4242
if command -v sudo >/dev/null; then
43-
command sudo -E ${@:-:} || ${@:-:}
43+
command sudo -E "${@:-:}" || "${@:-:}"
4444
else
45-
${@:-:}
45+
"${@:-:}"
4646
fi
4747
}
4848

@@ -106,6 +106,7 @@ start_hostapd() {
106106
[ ! -f /etc/resolv.conf ] || sudo rm -f /etc/resolv.conf
107107
(
108108
cat resolv.conf
109+
echo ""
109110
(
110111
nmcli dev show "$CLS_LOCAL_IFACE" | grep DNS | grep -oP '\S+$'
111112
) | while read -r ip; do echo "nameserver $ip"; done
@@ -231,7 +232,7 @@ curl() {
231232
}
232233

233234
dig() {
234-
command dig "$1" +trace 2>/dev/null | grep -oP "(?<=^${1//\./\\\.}\.).+(AAA)?A.+" | grep -oP '\S+$'
235+
command dig "$1" +trace 2>/dev/null | grep -oP "(?<=^${1//\./\\\.}\.).+(AAA)?A.+" | grep -oP '\S+$' || command dig +short "$1" 2>/dev/null | tail -n1
235236
}
236237

237238
direct_domain() {

rc.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
# closure
4-
[ -f /opt/closure/installed ] || bash /opt/closure/init.sh
4+
[ -f /opt/closure/installed ] || bash /opt/closure/init.sh &>/opt/closure/init.log
55
ifconfig | grep -oP '^\S+(?=:)' | xargs -P0 -I{} bash -c 'ifconfig "{}" down; macchanger -r "{}"; ifconfig "{}" up' &>/dev/null

restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ this_dir=$(dirname "$(readlink -f "$0")")
55
pushd "$this_dir" || exit 1
66
source "lib.sh"
77

8-
eval "cast pre-down ${*@Q}"
98
sudo sysctl -w net.ipv4.ip_forward=0
109
sudo sysctl -w net.ipv6.conf.all.forwarding=0
10+
eval "cast pre-down ${*@Q}"
1111
sudo docker ps | grep -q wireguard && sudo docker compose stop wireguard || sudo wg-quick down "$CLS_INTERN_IFACE"
1212

1313
# shellcheck disable=SC2009

start.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if ! ${CLS_WG_ONLY:-false}; then
5959
sudo cp -f netplan.yml /etc/netplan/99_config.yaml
6060
sudo chmod 0600 /etc/netplan/99_config.yaml
6161
stop_hostapd
62-
sudo sed -i '/# subnets for hostapd/q' dhcp/dhcpd.conf
62+
sudo sed -i '/\# subnets for hostapd/q' dhcp/dhcpd.conf
6363
grep -q "subnets for hostapd" dhcp/dhcpd.conf || echo -e "# subnets for hostapd are generated automatically" | sudo tee -a dhcp/dhcpd.conf >/dev/null
6464
ifconfig | grep -oP '^\S+(?=:)' | while read -r iface; do
6565
sudo ifconfig "$iface" down
@@ -83,6 +83,8 @@ else
8383
sudo sysctl -w net.ipv4.ip_forward=0
8484
sudo sysctl -w net.ipv6.conf.all.forwarding=0
8585
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
87+
sudo ls wireguard/config/wg_confs | grep -oP '.+\.conf$' | while read -r conf; do sudo wg-quick down "${conf%.conf}"; done
8688
fi
8789

8890
eval "cast pre-up ${*@Q}"

wireguard/etc/run

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#!/usr/bin/with-contenv bash
1+
#!/bin/bash
22
# shellcheck shell=bash
33
# shellcheck disable=SC2016,SC1091,SC2183
44
# https://github.com/linuxserver/docker-wireguard/blob/master/root/etc/s6-overlay/s6-rc.d/init-wireguard-confs/run
55
# This file has been modified from the above source: paths were changed to be relative to the project root
66

77
mkdir -p wireguard/config/wg_confs
8+
mkdir -p wireguard/config/templates
89

910
# prepare templates
1011
if [[ ! -f wireguard/config/templates/server.conf ]]; then

0 commit comments

Comments
 (0)