-
Notifications
You must be signed in to change notification settings - Fork 1
/
vpn-connect
executable file
·58 lines (40 loc) · 1.24 KB
/
vpn-connect
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
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
uname=$(uname)
username=$(cat ./username)
key=$(pass show redhat.com/associate-password | tr -d '\n')
if [ "$key" == "" ]; then
key=$(cat ./key)
fi
token=$(./getpw)
if [ "$uname" == "Darwin" ]; then
sleep 3
pgrep -u "$(whoami)" Viscosity
while [[ $? -eq 0 ]]; do
osascript -e 'quit app "Viscosity"'
sleep 3
pgrep -u "$(whoami)" Viscosity
done
connfile="$HOME/Library/Application Support/Viscosity/OpenVPN/1/config.conf"
sed -i '' "s#auth-user-pass#auth-user-pass /tmp/vpnpw#g" "$connfile"
pgrep -u "$(whoami)" Viscosity
while [[ $? -eq 1 ]]; do
sleep 2
/Applications/Viscosity.app/Contents/MacOS/Viscosity &
sleep 2
pgrep -u "$(whoami)" Viscosity
done
sleep 5
echo "$username" > /tmp/vpnpw
echo "$key$token" >> /tmp/vpnpw
echo "$key$token"
osascript -e "tell application \"Viscosity\" to connect \"Red Hat Global VPN\""
sleep 5
sed -i '' "s#auth-user-pass /tmp/vpnpw#auth-user-pass#g" "$connfile"
cat /tmp/vpnpw
rm /tmp/vpnpw
else
vpn=$(cat ./uuid)
echo "vpn.secrets.password:$key$token" > /tmp/vpnpw
sudo nmcli con up uuid $vpn passwd-file /tmp/vpnpw
sudo rm -f /tmp/vpnpw
fi