-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep.sh
44 lines (32 loc) · 736 Bytes
/
step.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
40
41
42
43
44
#!/bin/bash
LOG=log
UP=login-pass
echo ${config} | base64 -D -o client.ovpn > /dev/null 2>&1
echo ${login} >> ${UP}
echo ${password} >> ${UP}
echo "" > ${LOG}
if [ -n "$login" ]; then
echo "Connecting with login and password"
sudo openvpn --config client.ovpn --auth-user-pass ${UP} --daemon OVPN_DAEMON --verb 1 --log ${LOG}
else
echo "Connecting without login and password"
sudo openvpn --config client.ovpn --daemon OVPN_DAEMON --verb 1 --log ${LOG}
fi
if [ $? -ne 0 ]; then
cat ${LOG}
exit 1
fi
for i in {1..20}
do
if [[ $(tail -1 ${LOG}) == *"Initialization Sequence Completed"* ]]; then
cat ${LOG}
echo "CONNECTED!"
exit
fi
if [[ $i == 20 ]]; then
cat ${LOG}
echo "FAIL"
exit 1
fi
sleep 1
done