pivpn/scripts/pivpn

50 lines
1.2 KiB
Text
Raw Normal View History

2020-05-03 16:55:48 +00:00
#!/bin/bash
# Must be root to use this tool
if [ $EUID -ne 0 ];then
if dpkg-query -s sudo &> /dev/null; then
export SUDO="sudo"
2020-05-03 16:55:48 +00:00
else
echo "::: Please install sudo or run this as root."
exit 1
fi
2020-05-03 16:55:48 +00:00
fi
2020-05-05 08:24:20 +00:00
scriptDir="/opt/pivpn"
uninstallServer(){
$SUDO ${scriptDir}/uninstall.sh
exit "$?"
}
2020-05-03 16:55:48 +00:00
2020-05-29 15:46:04 +00:00
backup(){
$SUDO ${scriptDir}/backup.sh
exit "$?"
2020-05-29 15:46:04 +00:00
}
2020-05-03 16:55:48 +00:00
showHelp(){
echo "::: To pass off to the pivpn command for each protocol"
echo ":::"
echo "::: Usage: pivpn wg <command> [option]"
echo "::: Usage: pivpn ovpn <command> [option]"
2020-05-03 16:55:48 +00:00
echo ":::"
echo "::: -h, help Show this help dialog"
echo "::: -u, uninstall Uninstall pivpn from your system!"
2020-05-29 15:46:04 +00:00
echo "::: -bk, backup Backup VPN configs and user profiles"
2020-05-03 16:55:48 +00:00
exit 0
}
if [ $# = 0 ]; then
showHelp
fi
# Handle redirecting to specific functions based on arguments
case "$1" in
2020-05-04 23:05:10 +00:00
wg ) "${scriptDir}/wireguard/pivpn.sh" "${@:2}";;
ovpn ) "${scriptDir}/openvpn/pivpn.sh" "${@:2}";;
2020-05-03 16:55:48 +00:00
"-h" | "help" ) showHelp;;
"-u" | "uninstall" ) uninstallServer;;
2020-05-29 15:46:04 +00:00
"-bk" | "backup" ) backup ;;
2020-05-03 16:55:48 +00:00
* ) showHelp;;
esac