Skip to content

Instantly share code, notes, and snippets.

@albertmoravec
Created August 13, 2019 10:28
Show Gist options
  • Save albertmoravec/fec5fbaef0ac90253b7ee7f5b46d10d8 to your computer and use it in GitHub Desktop.
Save albertmoravec/fec5fbaef0ac90253b7ee7f5b46d10d8 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as sudo"
exit 1
fi
echo "Installing wireguard packages"
sudo curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
sudo yum -y install epel-release
sudo yum -y install wireguard-dkms wireguard-tools
read -p "Enter location of .conf file for wireguard: " wg_config_file_orig
read "Enter title of interface to be used (new name, default: wg0): " wireguard_interface
if [ "$wireguard_interface" = "" ]; then
wireguard_interface="wg0"
fi
final_conf_destination="/etc/wireguard/${wireguard_interface}"
cp $wg_config_file_orig $final_conf_destination
echo "Initiating wireguard startup sequence"
wg-quick up $wireguard_interface
echo "Enabling wg-quick service"
systemctl enable wg-quick@$wireguard_interface
echo "Printing status of wireguard"
wg show
echo "Configuration of $wireguard_interface: "
ip add show dev $wireguard_interface
echo "Done!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment