Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wmantly
Last active October 29, 2022 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmantly/0582f656eb48d177225195acd38a8f50 to your computer and use it in GitHub Desktop.
Save wmantly/0582f656eb48d177225195acd38a8f50 to your computer and use it in GitHub Desktop.
  • ingnore current wife network
iwgetid --ap --raw >> /etc/theta_wg/ignore.txt
  • Download the tray icone
wget https://dashboard.snapcraft.io/site_media/appmedia/2018/11/unnamed.png -O /root/wg.png
  • service names
systemctl --user enable wifi-wg
systemctl --user start wifi-wg

/etc/wireguard/wg0.conf ~/.config/systemd/user/wifi-wg.service

vi sudo

%sudo ALL=(ALL) NOPASSWD: /usr/bin/wg-quick down wg0, /usr/sbin/wpa_cli -i wlo1 -a /home/william/wpa.sh
#!/bin/bash
watch --color WG_COLOR_MODE=always wg
[Interface]
Address = 10.4.253.5/32
PrivateKey = ***
PostUp = alltray "xterm /root/watch_wg.sh -xrm 'XTerm.vt100.allowTitleOps: false' -T 'Wireguard -- Ron'" -i /root/wg.png&
PostDown = ps aux | grep -i alltray | grep -i ron | awk '{print $2}' | xargs sudo kill -9
PostDown = ps aux | grep -i xterm | grep -i ron | awk '{print $2}' | xargs sudo kill -9
PostUp = sysctl -w net.ipv6.conf.all.disable_ipv6=1
PostUp = sysctl -w net.ipv6.conf.default.disable_ipv6=1
PostDown = sysctl -w net.ipv6.conf.all.disable_ipv6=0
PostDown = sysctl -w net.ipv6.conf.default.disable_ipv6=0
[Peer]
PublicKey = **
Endpoint = ron.theta42.com:51871
AllowedIPs = 0.0.0.0/0, 192.168.1.0/24
[Unit]
Description=Auto WiFi Wireguard connect
After=network.target
StartLimitIntervalSec=0
[Service]
Environment="DISPLAY=:0"
Restart=always
ExecStart=sudo wpa_cli -i wlo1 -a /home/william/wpa.sh
[Install]
WantedBy=graphical.target
#!/bin/bash
# redirect all output into a logfile
# exec 1>> /tmp/test.log 2>&1
case "$2" in
CONNECTED)
# do stuff on connect with wlan0
sleep 2;
if grep -Fxq `iwgetid --ap --raw` /etc/theta_wg/ignore.txt
then
echo "none"
else
# code if not found
wg-quick up wg0-ron
fi
;;
DISCONNECTED)
# do stuff on disconnect with wlan0
wg-quick down wg0-ron
;;
*)
>&2 echo empty or undefined event for wlan0: "$2"
exit 1
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment