-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoclock_vpn_start.sh
More file actions
executable file
·43 lines (30 loc) · 1.24 KB
/
oclock_vpn_start.sh
File metadata and controls
executable file
·43 lines (30 loc) · 1.24 KB
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
40
41
42
43
#!/bin/sh
# check if launched as root, and if not, relaunch
[ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@"
username="U02F1D4A0TZ"
password="$(/usr/bin/zenity --password --title='VPN Passphrase')"
if [ -z $password ]
then
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" sudo -u baptiste -E /usr/bin/notify-send "O'Clock VPN" "No password provided." -u critical
exit
fi
echo $username > /tmp/pass.txt
echo $password >> /tmp/pass.txt
sh -c 'openvpn --config /home/baptiste/Documents/Oclock/openvpn-client-conf-baptiste-delphin/oclock.ovpn --auth-user-pass /tmp/pass.txt > /var/log/oclock_vpn.log 2>&1 &'
sed -i '1 i\nameserver 192.168.82.1' /etc/resolv.conf
printf "%s" "waiting for remote host ..."
count=0
while ! ping -c 1 -n -w 1 doc.lan &> /dev/null
do
printf "%c" "."
((count=count+1))
if [ $count = 3 ]
then
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" sudo -u baptiste -E /usr/bin/notify-send "O'Clock VPN" "Cannot establish VPN connection." -u critical
sed -i '/nameserver 192.168.82.1/d' /etc/resolv.conf
exit
fi
done
printf "\n%s\n" "VPN connection established !"
rm /tmp/pass.txt
DISPLAY=:0 sudo -u baptiste notify-send "O'Clock VPN" "VPN connection established." -u normal