-
Notifications
You must be signed in to change notification settings - Fork 237
reresolve-dns.sh: Add support for wireguard-tools on Mac OS X (interface utunX), debugging, bash 3.2, and improved logging for cron jobs
#28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
On Mac OS X and while using `wg-quick` it is possible that the config base filename be `wg1.conf` while the actual interface name is something like `utun4`. In this case, this improvement allows us to enter something like: ```bash sudo ./reresolve-dns.sh /opt/homebrew/etc/wireguard/wg1.conf utun4 ``` (on Mac OS X, when installing wireguard-tools using homebrew, elevated privileges are needed when running `wg`) Signed-off-by: Orwa Diraneyya <107997002+diraneyya@users.noreply.github.com>
In this improvement, redirecting output using `>>` results in a more meaningful output Signed-off-by: Orwa Diraneyya <107997002+diraneyya@users.noreply.github.com>
|
In the second commit I added better logging when using a cron job: */2 * * * * sudo $HOME/repos/wireguard/reresolve-dns.sh /opt/homebrew/etc/wireguard/wg1.conf utun4 >> /tmp/wireguard-wg1.log |
Since the shebang line refers to bash at /bin/bash and since on most Mac OS X systems this location contains an outdated bash version (3.2), I have added a polyfill for the $EPOCHSECONDS env variable which otherwise would lead to this script failing on early bash versions that do not support it. I took this path because it is always better to support older bash versions regardless of the choice of interpreter and since it was all that we needed to run the script on bash 3.2 Signed-off-by: Orwa Diraneyya <107997002+diraneyya@users.noreply.github.com>
|
I noticed that the script was not doing what it is supposed to do on Mac OS X. After some investigations I realised it was the shebang line which refers to I have fixed the issue by polyfilling the |
utunX), bash 3.2, and better logging for cron jobs
utunX), bash 3.2, and better logging for cron jobsutunX), bash 3.2, and better logging for cron jobs
It is possible now to retain xtrace output for each exit code using carefully crafted cron job invocation while also attaching useful information Signed-off-by: Orwa Diraneyya <107997002+diraneyya@users.noreply.github.com>
Signed-off-by: Orwa Diraneyya <107997002+diraneyya@users.noreply.github.com>
utunX), bash 3.2, and better logging for cron jobsutunX), debugging, bash 3.2, and improved logging for cron jobs
|
Recommended cronjob spec: * * * * SUDO_ASKPASS="$HOME"/.config/askpass sudo -A \
PATH="$PATH:/opt/homebrew/bin" DEBUG=1 \
"$HOME"/.config/wireguard/reresolve-dns.sh \
/opt/homebrew/etc/wireguard/wgX.conf utunX \
>>/tmp/wireguard.log 2>/tmp/wireguard.debug || \
cp /tmp/wireguard.debug /tmp/wireguard.debug."$?"This cron job will:
|
On Mac OS X and while using
wg-quickit is possible that the config base filename bewg1.confwhile the actual interface name is something likeutun4. In this case, this improvement allows us to enter something like:(on Mac OS X, when installing wireguard-tools using homebrew, elevated privileges are needed when running
wg)