mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
76 lines
1.9 KiB
Bash
76 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Must be root to use this tool
|
|
if [[ ! $EUID -eq 0 ]];then
|
|
#echo "::: You are root."
|
|
#else
|
|
#echo "::: Sudo will be used for this tool."
|
|
# Check if it is actually installed
|
|
# If it isn't, exit because the pivpn cannot be invoked without privileges.
|
|
if [[ $(dpkg-query -s sudo) ]];then
|
|
export SUDO="sudo"
|
|
else
|
|
echo "::: Please install sudo or run this as root."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
function makeOVPNFunc {
|
|
$SUDO /opt/pivpn/makeOVPN.sh
|
|
exit 1
|
|
}
|
|
|
|
function listOVPNFunc {
|
|
$SUDO /opt/pivpn/listOVPN.sh
|
|
exit 1
|
|
}
|
|
|
|
function debugFunc {
|
|
$SUDO /opt/pivpn/pivpnDebug.sh
|
|
exit 1
|
|
}
|
|
|
|
function removeOVPNFunc {
|
|
$SUDO /opt/pivpn/removeOVPN.sh
|
|
exit 1
|
|
}
|
|
|
|
function uninstallFunc {
|
|
$SUDO /opt/pivpn/uninstall.sh
|
|
exit 1
|
|
}
|
|
|
|
function versionFunc {
|
|
printf "\e[1mVersion 1.0\e[0m\n"
|
|
}
|
|
|
|
function helpFunc {
|
|
echo "::: Control all PiVPN specific functions!"
|
|
echo ":::"
|
|
echo "::: Usage: pivpn [options]"
|
|
echo ":::"
|
|
echo "::: Options:"
|
|
echo "::: -a, add Create a client ovpn profile"
|
|
echo "::: -d, debug Start a debugging session if having trouble"
|
|
echo "::: -l, list List all valid and revoked certificates"
|
|
echo "::: -r, revoke Revoke a client ovpn profile"
|
|
echo "::: -h, help Show this help dialog"
|
|
echo "::: -u, uninstall Uninstall PiVPN from your system!"
|
|
exit 1
|
|
}
|
|
|
|
if [[ $# = 0 ]]; then
|
|
helpFunc
|
|
fi
|
|
|
|
# Handle redirecting to specific functions based on arguments
|
|
case "$1" in
|
|
"-a" | "add" ) makeOVPNFunc;;
|
|
"-d" | "debug" ) debugFunc;;
|
|
"-l" | "list" ) listOVPNFunc;;
|
|
"-r" | "revoke" ) removeOVPNFunc;;
|
|
"-h" | "help" ) helpFunc;;
|
|
"-u" | "uninstall" ) uninstallFunc;;
|
|
"-v" ) versionFunc;;
|
|
* ) helpFunc;;
|
|
esac
|