mirror of
https://github.com/pivpn/pivpn.git
synced 2025-04-26 17:20:12 +00:00
more dual
This commit is contained in:
parent
5330454f2b
commit
4e3a58702f
4 changed files with 13 additions and 25 deletions
110
scripts/openvpn/pivpn.sh
Executable file
110
scripts/openvpn/pivpn.sh
Executable file
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Must be root to use this tool
|
||||
if [[ ! $EUID -eq 0 ]];then
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
scriptdir="/opt/pivpn"
|
||||
vpn="openvpn"
|
||||
|
||||
function makeOVPNFunc {
|
||||
shift
|
||||
$SUDO ${scripdir}/${vpn}/makeOVPN.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
function listClientsFunc {
|
||||
shift
|
||||
$SUDO ${scripdir}/${vpn}/clientStat.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
function listOVPNFunc {
|
||||
$SUDO ${scripdir}/${vpn}/listOVPN.sh
|
||||
exit 0
|
||||
}
|
||||
|
||||
function debugFunc {
|
||||
echo "::: Generating Debug Output"
|
||||
$SUDO ${scripdir}/${vpn}/pivpnDebug.sh | tee /tmp/debug.txt
|
||||
echo "::: "
|
||||
echo "::: Debug output completed above."
|
||||
echo "::: Copy saved to /tmp/debug.txt"
|
||||
echo "::: "
|
||||
exit 0
|
||||
}
|
||||
|
||||
function removeOVPNFunc {
|
||||
shift
|
||||
$SUDO ${scripdir}/${vpn}/removeOVPN.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
function uninstallFunc {
|
||||
$SUDO ${scripdir}/uninstall.sh
|
||||
exit 0
|
||||
}
|
||||
|
||||
function versionFunc {
|
||||
printf "\e[1mVersion 1.9\e[0m\n"
|
||||
}
|
||||
|
||||
function update {
|
||||
|
||||
shift
|
||||
$SUDO ${scripdir}/update.sh "$@"
|
||||
exit 0
|
||||
|
||||
|
||||
}
|
||||
|
||||
function backup {
|
||||
|
||||
$SUDO ${scripdir}/backup.sh
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
function helpFunc {
|
||||
echo "::: Control all PiVPN specific functions!"
|
||||
echo ":::"
|
||||
echo "::: Usage: pivpn <command> [option]"
|
||||
echo ":::"
|
||||
echo "::: Commands:"
|
||||
echo "::: -a, add [nopass] Create a client ovpn profile, optional nopass"
|
||||
echo "::: -c, clients List any connected clients to the server"
|
||||
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!"
|
||||
echo "::: -up, update Updates PiVPN Scripts"
|
||||
echo "::: -bk, backup Backup Openvpn and ovpns dir"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
helpFunc
|
||||
fi
|
||||
|
||||
# Handle redirecting to specific functions based on arguments
|
||||
case "$1" in
|
||||
"-a" | "add" ) makeOVPNFunc "$@";;
|
||||
"-c" | "clients" ) listClientsFunc "$@";;
|
||||
"-d" | "debug" ) debugFunc;;
|
||||
"-l" | "list" ) listOVPNFunc;;
|
||||
"-r" | "revoke" ) removeOVPNFunc "$@";;
|
||||
"-h" | "help" ) helpFunc;;
|
||||
"-u" | "uninstall" ) uninstallFunc;;
|
||||
"-v" ) versionFunc;;
|
||||
"-up"| "update" ) update "$@" ;;
|
||||
"-bk"| "backup" ) backup;;
|
||||
* ) helpFunc;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue