-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvpn.sh
39 lines (33 loc) · 1.1 KB
/
vpn.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
#
# Installiert WireGuard
#
[ $# -eq 0 ] && { export LERNMAAS=/opt/wireguard; } || { export LERNMAAS=$1; }
sudo add-apt-repository -y ppa:wireguard/wireguard
sudo apt-get update
sudo apt-get install -y wireguard
sudo chmod 750 /etc/wireguard
# Aktivierung nur wenn Konfigurationsdatei = hostname vorhanden ist
if [ -f "/etc/wireguard/$(hostname).conf" ]
then
sudo mv /etc/wireguard/$(hostname).conf /etc/wireguard/wg0.conf
sudo chown root:root /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/wg0.conf
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
# Aktivierung durch MAAS AZ
elif [ -f ${LERNMAAS}/wireguard ]
then
export NO=$(hostname | cut -d- -f 2)
if [ "${NO}" != "" ]
then
cd ${LERNMAAS}
sed 's/ /\n/g' wireguard | base64 -d | sudo tar xzf - ${NO}.conf
if [ -f "${NO}.conf" ]
then
sudo mv ${NO}.conf /etc/wireguard/wg0.conf
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
fi
fi
fi