Skip to content

Commit

Permalink
Merge pull request #19 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 25, 2023
2 parents 399f05c + 26d24fe commit e259348
Showing 1 changed file with 45 additions and 30 deletions.
75 changes: 45 additions & 30 deletions tools/strongswan.install.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
#!/bin/sh
set -xe
network_name='your_netowrk_here'
VPN_Gateway='your_gateway_here'
VPN_Username='your_username_here'
VPN_Password='your_password_here'

# Read user input for network_name
printf "Enter the network name: "
read network_name

# Read user input for VPN_Gateway
printf "Enter the VPN gateway: "
read VPN_Gateway

# Read user input for VPN_Username
printf "Enter your VPN username: "
read VPN_Username

# Read user input for VPN_Password
printf "Enter your VPN password: "
stty -echo
read VPN_Password
stty echo
echo # Move to a new line after password input

# 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
# 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
;;
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
Expand All @@ -39,13 +54,13 @@ if [ -f /etc/os-release ]; then

# 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"
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
# 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 e259348

Please sign in to comment.