Compare commits

...

2 Commits

Author SHA1 Message Date
John Mertz da77896e0f Add description for stream-podcasts.pl and setup-wireguard.sh 2020-12-01 05:13:20 -05:00
John Mertz 5dfdf7085a Script to install wireguard and generate config 2020-12-01 05:06:41 -05:00
2 changed files with 91 additions and 6 deletions

View File

@ -10,6 +10,12 @@ Just a simple script to toggle Alsa mute.
Add a noise-cancelled version of existing interfaces to Pulseaudio.
**audio/stream-podcasts.pl**
Commandline podcast streamer. Fetchs the feed for desired podcasts, find items
published today, then plays them in order. Given arguments, it will use those
as feeds, otherwise it will use the hash listed in the script.
## i3
I haven't used i3 in earnest for quite some time since moving to Sway, so it is
@ -191,15 +197,22 @@ Launch nmtui in floating window (bottom-right). If already running, kill it.
## Miscellaneous
**send-to-kodi.sh**
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local
file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my
local media server IP.
**apply-gruvbox.sh**
A single theme version of the one provided
[here](https://raw.githubusercontent.com/Mayccoll/Gogh). Applies the theme to a
variety of terminals. Not really necessary after cloning the 'dotfiles'
repository.
**send-to-kodi.sh**
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local
file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my
local media server IP.
**setup_wireguard.sh**
Script to install WireGuard and generate a config file. Requires modification
with the server public IP, server public key, and change to first 3 octets if
necessary. Will attempt to resolve dependencies and has a special case for
Raspberry Pi (detected with `uname -m` as 'arm'.

72
setup-wireguard.sh Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
SERVER_KEY='abcdefghijklmnopqrstuvwxyz0123456789abcdefg=';
SERVER_IP='1.1.1.1';
WG_BLOCK='10.10.0';
if [[ $1 == '' ]]; then
echo "Need last octet as argument"
exit
elif grep -Pq '^[0-9]*$' <<< $(echo $1); then
echo "Good"
else
echo "Argument must be a number representing the last octet"
exit
fi
sudo apt update
if grep -Pq '^arm' <<< $(uname -m); then
sudo apt install -y wireguard wireguard-dkms wireguard-tools raspberrypi-kernel raspberrypi-kernel-headers resolvconf
else
sudo apt install -y wireguard wireguard-tools linux-headers-$(uname -r) resolvconf
fi
if [[ "`which wg 2> /dev/null`" == '' ]]; then
echo "Failed to install wireguard"
exit
fi
wg genkey | sudo tee /etc/wireguard/client_private.key | wg pubkey | sudo tee /etc/wireguard/client_public.key
if [[ "`sudo cat /etc/wireguard/client_public.key 2> /dev/null`" == '' ]]; then
echo "Failed to create keys"
exit
fi
echo "[Interface]
Address = 10.10.0.${1}/24
DNS = 10.10.0.1
PrivateKey = $(sudo cat /etc/wireguard/client_private.key)
[Peer]
PublicKey = $SERVER_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = $SERVER_IP:51820
PersistentKeepalive = 25" > wg0.conf
sudo mv wg0.conf /etc/wireguard/
sudo chown root:root /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/wg0.conf
sudo systemctl enable wg-quick@wg0
echo "On server run:
sudo systemctl stop wg-quick@wg0
Then append the following to /etc/wireguard/wg0.conf:
[Peer]
PublicKey = $(sudo cat /etc/wireguard/client_public.key)
AllowedIPs = $WG_BLOCK.${1}/32
Then start it again with
sudo systemctl start wg-quick@wg0
Then on this client, enable and start wireguard:
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
"