forked from jeffchannell/gp-okta-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·82 lines (73 loc) · 2.09 KB
/
install.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# Tested on Xubuntu 19.10 and CentOS 8
set -e
# make sure script is running as root
if ! [ $(id -u) = 0 ]; then
>&2 echo "Script should be run as root"
exit 1
fi
function install_conf {
if [ ! -f /etc/gp-okta.conf ]; then
echo "export VPN_SERVER=${1}" > /etc/gp-okta.conf
fi
}
function install_gp_saml_gui {
if [ ! -d /opt/gp-saml-gui ]; then
git clone https://github.com/dlenski/gp-saml-gui.git /opt/gp-saml-gui
fi
}
function install_hipreport {
HIPREPORT_SRC='https://raw.githubusercontent.com/dlenski/openconnect/master/hipreport.sh'
HIPREPORT_SCRIPT=/usr/libexec/openconnect/hipreport.sh
# mkdir for sources, if not available
if [ ! -d /usr/libexec/openconnect ]; then
mkdir -p /usr/libexec/openconnect
fi
# download HIP report script
if [ ! -f "${HIPREPORT_SCRIPT}" ]; then
wget -O "${HIPREPORT_SCRIPT}" "${HIPREPORT_SRC}"
chmod +x "${HIPREPORT_SCRIPT}"
fi
}
# read desired VPN server here
VPN_SERVER_ATTEMPTS=3
VPN_SERVER=
if [ -f /etc/gp-okta.conf ]; then
source /etc/gp-okta.conf
fi
while [ "" = "${VPN_SERVER}" ]; do
read -p "VPN Server: " VPN_SERVER
if [ "" = "${VPN_SERVER}" ]; then
VPN_SERVER_ATTEMPTS=$(($VPN_SERVER_ATTEMPTS-1))
fi
if [ 0 = $VPN_SERVER_ATTEMPTS ]; then
exit 1
fi
done
if [ "" = "${VPN_SERVER}" ]; then
>&2 echo "VPN Server not set. Edit /etc/gp-okta.conf before starting VPN."
fi
# ubuntu
if ! [[ $(command -v "apt") = "" ]]; then
apt update
apt -y install \
git wget openconnect \
python3-gi gir1.2-gtk-3.0 gir1.2-webkit2-4.0 \
python3-lxml python3-requests gir1.2-appindicator3-0.1
install_conf "${VPN_SERVER}"
install_hipreport
install_gp_saml_gui
# centos
elif ! [[ $(command -v "yum") = "" ]]; then
yum -y update
yum -y install epel-release
yum -y install openconnect vpnc-script
yum -y install git
install_conf "${VPN_SERVER}"
install_hipreport
install_gp_saml_gui
# unknown
else
>&2 echo "You are not running a Debian/Red Hat derivative. Sorry."
exit 1
fi