Commit 78d0ff23 authored by root's avatar root

Reworked for my use, Added Multi service ability

parent 37b54749
# Automate Wireguard configuration
Script to configure pointtopoint tunnel with [wireguard](https://www.wireguard.io/).
Script to configure point2point tunnel with [wireguard](https://www.wireguard.io/).
## Usage
``` bash
wg genkey | tee privatekey | wg pubkey > publickey
cat privatekey publickey
cp wireguard.sh-template wireguard.sh
cp wireguard.sh-template wireguard-<peer>.sh
# set your ips, privatekey and peers
$EDITOR wireguard.sh
$EDITOR wireguard-<peer>.sh
```
``` bash
# install systemd service
ln -s $(readlink -f wireguard.service) /etc/systemd/system/wireguard.service
systemctl start wireguard
ln -s $(readlink -f [email protected]) /etc/systemd/system/[email protected]<peer>.service
systemctl enable [email protected]<peer>
systemctl start [email protected]<peer>
```
``` bash
# manual
./wireguard start
./wireguard.sh start
```
pushd /etc/wireguard/
sed -i "s/PRIVATE_KEY=\"\"/PRIVATE_KEY=\"$(sed 's:/:\\/:g' privatekey)\"/" wireguard.sh
popd
[Unit]
Description=Wireguard vpn peer %i
StartLimitIntervalSec=0
# when resolving remote endpoint addresses
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/etc/wireguard/wireguard-%i.sh start
ExecStop=/etc/wireguard/wireguard-%i.sh stop
RestartSec=2s
Restart=on-failure
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment