-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path70-add-vpn
More file actions
executable file
·61 lines (50 loc) · 1.25 KB
/
70-add-vpn
File metadata and controls
executable file
·61 lines (50 loc) · 1.25 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# add-vnp
if [[ ${vpnFlag:-false} == true ]]; then
log_info 'Installing VPN.'
else
log_info 'VPN skipped.'
return;
fi
# Capture current working directory.
cwd=$(pwd)
log_info 'Updating system.'
sudo pacman -Sy --noconfirm
log_info 'Installing required packages.'
sudo pacman -S --noconfirm \
git \
rust \
cargo \
iproute2 \
openssl \
remmina \
freerdp \
libvncserver
log_info 'Cloning snx-rs.'
cd /opt
if [[ ! -d snx-rs ]]; then
sudo git clone https://github.com/ancwrd1/snx-rs.git
sudo chown -R "$USER":"$USER" snx-rs
else
sudo git pull https://github.com/ancwrd1/snx-rs.git
fi
log_info 'Building snx-rs.'
cd /opt/snx-rs
cargo build --release
log_info 'Installing snx-rs binary.'
sudo install -m755 target/release/snx-rs /usr/local/bin/snx-rs
log_info 'Creating global snx-rs config...'
sudo mkdir -p /etc/snx-rs
# TODO: Remove ignore-server-cert = true when switched to VPN hostname.
cat > /tmp/config.toml <<EOF
server-name = "${VPN_SERVER}"
login-type = "${VPN_LOGIN_TYPE}"
tunnel-type = "${VPN_TUNNEL_TYPE}"
ignore-server-cert = true
ike-persist = true
port-knock = true
EOF
sudo mv -vf /tmp/config.toml /etc/snx-rs/config.toml
sudo chown root /etc/snx-rs/config.toml
# Return to starting directory.
cd "$cwd"