Skip to content

Commit

Permalink
Merge pull request #17 from Ant0wan/Ant0wan-patch-1
Browse files Browse the repository at this point in the history
Update strongswan.install.sh
  • Loading branch information
Ant0wan authored Jul 24, 2023
2 parents ec80ee4 + 4c15fca commit 596ad0a
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions tools/strongswan.install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
#!/bin/sh
set -xe
network_name=''
VPN_Gateway=''
VPN_Username=''
VPN_Password=''
cacerts='/etc/strongswan/ipsec.d/cacerts/cacert.pem'
dnf install -y NetworkManager-strongswan NetworkManager-strongswan-gnome strongswan-charon-nm strongswan strongswan-sqlite
# libtnc strongswan-tnc-imcvs
wget https://curl.se/ca/cacert.pem -O "$cacerts"
sudo nmcli connection add type vpn con-name "$network_name" ifname "*" vpn-type strongswan \
vpn.data "address=$VPN_Gateway, method=eap, user=$VPN_Username, virtual=yes, encap=yes" \
vpn.secrets "password=$VPN_Password" \
ipv4.method "auto" \
ipv6.method "auto"
network_name='your_netowrk_here'
VPN_Gateway='your_gateway_here'
VPN_Username='your_username_here'
VPN_Password='your_password_here'

# Check if /etc/os-release exists
if [ -f /etc/os-release ]; then
# Source the /etc/os-release file to get the ID variable
. /etc/os-release

# Check the distribution ID and use the appropriate package manager
case "$ID" in
fedora|centos|rhel)
# Use dnf if the distribution is Fedora, CentOS, or RHEL
package_manager="dnf"
packages="NetworkManager-strongswan NetworkManager-strongswan-gnome strongswan-charon-nm strongswan strongswan-sqlite"
cacerts='/etc/strongswan/ipsec.d/cacerts/cacert.pem'
;;
debian|ubuntu)
# Use apt-get if the distribution is Debian or Ubuntu
package_manager="apt-get"
packages="strongswan strongswan-nm network-manager-strongswan"
cacerts='/etc/ipsec.d/cacerts/cacerts.pem'
;;
*)
# If the distribution is not recognized, exit with an error
echo "Unsupported distribution: $ID"
exit 1
;;
esac

# Install packages using the identified package manager
sudo "$package_manager" install -y $packages

# Download the CA certificate from a trusted source
sudo wget https://curl.se/ca/cacert.pem -O "$cacerts"

# Create a new VPN connection with NetworkManager using strongSwan plugin
sudo nmcli connection add type vpn con-name "$network_name" ifname "*" vpn-type strongswan \
vpn.data "address=$VPN_Gateway, method=eap, user=$VPN_Username, virtual=yes, encap=yes" \
vpn.secrets "password=$VPN_Password" \
ipv4.method "auto" \
ipv6.method "auto"

else
# If /etc/os-release is not found, exit with an error
echo "Unable to identify the Linux distribution."
exit 1
fi

0 comments on commit 596ad0a

Please sign in to comment.