mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-21 04:10:20 +00:00
deee38b20e
- Add curl as a dependency for those who run the script without 'curl URL | bash'. - Use POSIX 'command -v' instead of 'hash'. - Check if packages have actually been installed and abort execution if they have not. - Fixed issue with getStaticIPv4Settings() that prevented existing network settings to be used as static IP settings when running the script unattended with empty $IPv4addr and $IPv4gw variables. - Exit if processing wireguard-linux-compat fails. - Exit if 50unattended-upgrades fails to extract. - Exit clientSTAT.sh if the wg0 interface is not available. - Moved the Self Check to a single script since dedicated versions were very similar. - Add 'pivpn -wg' to update WireGuard for users running Raspbian with armv6l kernel.
104 lines
2.4 KiB
Bash
Executable file
104 lines
2.4 KiB
Bash
Executable file
#!/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"
|
|
else
|
|
echo "::: Please install sudo or run this as root."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
makeConf(){
|
|
shift
|
|
$SUDO /opt/pivpn/makeCONF.sh "$@"
|
|
exit 0
|
|
}
|
|
|
|
listConnected(){
|
|
$SUDO /opt/pivpn/clientSTAT.sh
|
|
exit 0
|
|
}
|
|
|
|
debug(){
|
|
$SUDO /opt/pivpn/pivpnDEBUG.sh
|
|
exit 0
|
|
}
|
|
|
|
listClients(){
|
|
$SUDO /opt/pivpn/listCONF.sh
|
|
exit 0
|
|
}
|
|
|
|
showQrcode(){
|
|
shift
|
|
$SUDO /opt/pivpn/qrcodeCONF.sh "$@"
|
|
exit 0
|
|
}
|
|
|
|
removeClient(){
|
|
shift
|
|
$SUDO /opt/pivpn/removeCONF.sh "$@"
|
|
exit 0
|
|
}
|
|
|
|
uninstallServer(){
|
|
$SUDO /opt/pivpn/uninstall.sh
|
|
exit 0
|
|
}
|
|
|
|
updateScripts(){
|
|
shift
|
|
$SUDO /opt/pivpn/update.sh "$@"
|
|
exit 0
|
|
}
|
|
|
|
updateWireGuard(){
|
|
$SUDO /opt/pivpn/wgUPDATE.sh
|
|
exit 0
|
|
}
|
|
|
|
backup(){
|
|
$SUDO /opt/pivpn/backup.sh
|
|
}
|
|
|
|
showHelp(){
|
|
echo "::: Control all PiVPN specific functions!"
|
|
echo ":::"
|
|
echo "::: Usage: pivpn <command> [option]"
|
|
echo ":::"
|
|
echo "::: Commands:"
|
|
echo "::: -a, add Create a client conf profile"
|
|
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 clients"
|
|
echo "::: -qr, qrcode Show the qrcode of a client for use with the mobile app"
|
|
echo "::: -r, remove Remove a client"
|
|
echo "::: -h, help Show this help dialog"
|
|
echo "::: -u, uninstall Uninstall pivpn from your system!"
|
|
echo "::: -up, update Updates PiVPN Scripts"
|
|
echo "::: -wg, wgupdate Updates WireGuard"
|
|
echo "::: -bk, backup Backup VPN configs and user profiles"
|
|
exit 0
|
|
}
|
|
|
|
if [ $# = 0 ]; then
|
|
showHelp
|
|
fi
|
|
|
|
# Handle redirecting to specific functions based on arguments
|
|
case "$1" in
|
|
"-a" | "add" ) makeConf "$@";;
|
|
"-c" | "clients" ) listConnected;;
|
|
"-d" | "debug" ) debug;;
|
|
"-l" | "list" ) listClients;;
|
|
"-qr" | "qrcode" ) showQrcode "$@";;
|
|
"-r" | "remove" ) removeClient "$@";;
|
|
"-h" | "help" ) showHelp;;
|
|
"-u" | "uninstall" ) uninstallServer;;
|
|
"-up" | "update" ) updateScripts "$@" ;;
|
|
"-wg" | "wgupdate" ) updateWireGuard ;;
|
|
"-bk" | "backup" ) backup ;;
|
|
* ) showHelp;;
|
|
esac
|