homelab/scripts/dsnet/script.sh

44 lines
1.1 KiB
Bash
Raw Normal View History

2022-12-31 22:46:38 +01:00
#!/bin/bash
set -euo pipefail
source "$HL_LIB"
_assert_vars HL_TIMEZONE HL_DOMAIN;
_ch_001-install_wireguard() {
sudo apt-get install -y wireguard;
}
_ch_002-install_dsnet() {
sudo curl -L https://github.com/naggie/dsnet/releases/latest/download/dsnet-linux-amd64 -o /usr/bin/dsnet
sudo chmod +x /usr/bin/dsnet
}
_ch_003-init_dsnet() {
sudo dsnet init
# copy the fresh config if there isn't one already
[ -f /data/dsnetconfig.json ] || sudo cp /etc/dsnetconfig.json /data/dsnetconfig.json
sudo rm /etc/dsnetconfig.json
sudo ln -s /data/dsnetconfig.json /etc/dsnetconfig.json
}
_ch_004-install_service() {
sudo cp dsnet.service /etc/systemd/system/dsnet.service
sudo systemctl daemon-reload
}
_ch_005-enable_ip_forwarding() {
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv6.conf.all.forwarding=1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf
}
_ch_006-run_service() {
sudo systemctl enable --now dsnet.service
}
_run_checkpoints