diff --git a/LatestUpdate.md b/LatestUpdate.md index 45e9f2e..dacab55 100644 --- a/LatestUpdate.md +++ b/LatestUpdate.md @@ -5,9 +5,20 @@ patch release notes. Everytime Test branch is merged into master, a new entry should be created with the date and changes being merged. -## Sept 1st 2019 +## Oct 12th 2019 -Latest changes merged from test branch +* Changed pivpn command exit codes from 1 to 0 + - exit code 1 means general error hence should not be used for exiting successfully +* added backup script to backup openvpn and pivpn generated certificates +* added update script to update /opt/pivpn scripts, -t | --test | test update from test branch +* Fixed hostname length issue #831 + - the script now checks for hostname length right at the beginning and prompts for a new one. + - HOST_NAME to host_name, as best practice variables with capitals, should be used by system variables only. +* fixed ubuntu 18.04 being detected as not supported OS, now fully supported and tested. +* changed how scripts are copied to /opt/pivpn, it hat a lot of long repetitive lines, now it copies all *.sh files making it easier to manage when adding new scripts/features +* Changed how supported OS are presented when maybeOS_Support() is called. + +## Sept 1st 2019 * Added support for Buster * .ovpn12 files making use of iOS keychain diff --git a/auto_install/install.sh b/auto_install/install.sh index b021052..ac2e190 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -70,7 +70,10 @@ If you think you received this message in error, you can post an issue on the Gi function maybeOS_Support() { if (whiptail --backtitle "Not Supported OS" --title "Not Supported OS" --yesno "You are on an OS that we have not tested but MAY work. -Currently this installer supports Raspbian and Debian (Jessie and Stretch), Devuan (Jessie) and Ubuntu from 14.04 (trusty) to 17.04 (zesty). +Currently suppoerted: + Raspbian, Debian, Devuan (Jessie, strech, buster) + Ubuntu from 14.04 (trusty) to 18.04 (zesty). + Would you like to continue anyway?" ${r} ${c}) then echo "::: Did not detect perfectly supported OS but," echo "::: Continuing installation at user's own risk..." @@ -86,7 +89,7 @@ distro_check() { if hash lsb_release 2>/dev/null; then PLAT=$(lsb_release -si) - OSCN=$(lsb_release -sc) # We want this to be trusty xenial or jessie + OSCN=$(lsb_release -sc) # We want this to be trusty xenial, jessie, stretch, buster else # else get info from os-release @@ -105,7 +108,7 @@ distro_check() { case ${PLAT} in Ubuntu|Raspbian|Debian|Devuan) case ${OSCN} in - trusty|xenial|jessie|stretch|buster) + trusty|xenial|jessie|stretch|buster|bionic) ;; *) maybeOS_Support @@ -386,6 +389,7 @@ function valid_domain() local domain=$1 local stat=1 + if [[ $domain =~ ^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}\.[a-zA-Z]{2,}$ ]]; then stat=$? fi @@ -401,13 +405,8 @@ installScripts() { $SUDO chown "$INSTALL_USER":root /opt/pivpn $SUDO chmod 0755 /opt/pivpn fi - $SUDO cp /etc/.pivpn/scripts/makeOVPN.sh /opt/pivpn/makeOVPN.sh - $SUDO cp /etc/.pivpn/scripts/clientStat.sh /opt/pivpn/clientStat.sh - $SUDO cp /etc/.pivpn/scripts/listOVPN.sh /opt/pivpn/listOVPN.sh - $SUDO cp /etc/.pivpn/scripts/removeOVPN.sh /opt/pivpn/removeOVPN.sh - $SUDO cp /etc/.pivpn/scripts/uninstall.sh /opt/pivpn/uninstall.sh - $SUDO cp /etc/.pivpn/scripts/pivpnDebug.sh /opt/pivpn/pivpnDebug.sh - $SUDO chmod 0755 /opt/pivpn/{makeOVPN,clientStat,listOVPN,removeOVPN,uninstall,pivpnDebug}.sh + $SUDO cp /etc/.pivpn/scripts/*.sh /opt/pivpn/ + $SUDO chmod 0755 /opt/pivpn/*.sh $SUDO cp /etc/.pivpn/pivpn /usr/local/bin/pivpn $SUDO chmod 0755 /usr/local/bin/pivpn $SUDO cp /etc/.pivpn/scripts/bash-completion /etc/bash_completion.d/pivpn @@ -755,11 +754,11 @@ setCustomDomain() { confOpenVPN() { # Grab the existing Hostname - HOST_NAME=$(hostname -s) - # Generate a random UUID for this server so that we can use verify-x509-name later that is unique for this server installation. - NEW_UUID=$(&1 1>&2 2>&3) + $SUDO hostnamectl set-hostname "${host_name}" + if [[ ${#host_name} -le 28 && $host_name =~ ^[a-zA-Z0-9][a-zA-Z0-9-]{1,28}$ ]]; then + echo "::: Hostname valid and length OK, proceeding..." + fi + + done + else + echo "::: Hostname length OK" + fi + +} + ######## SCRIPT ############ @@ -1330,9 +1348,13 @@ main() { fi fi + # Check for supported distribution distro_check + # Checks for hostname Length + checkhostname + # Check arguments for the undocumented flags for var in "$@"; do case "$var" in diff --git a/pivpn b/pivpn index 8f82a93..de55586 100644 --- a/pivpn +++ b/pivpn @@ -6,24 +6,24 @@ if [[ ! $EUID -eq 0 ]];then export SUDO="sudo" else echo "::: Please install sudo or run this as root." - exit 1 + exit 0 fi fi function makeOVPNFunc { shift $SUDO /opt/pivpn/makeOVPN.sh "$@" - exit 1 + exit 0 } function listClientsFunc { $SUDO /opt/pivpn/clientStat.sh - exit 1 + exit 0 } function listOVPNFunc { $SUDO /opt/pivpn/listOVPN.sh - exit 1 + exit 0 } function debugFunc { @@ -33,24 +33,41 @@ function debugFunc { echo "::: Debug output completed above." echo "::: Copy saved to /tmp/debug.txt" echo "::: " - exit 1 + exit 0 } function removeOVPNFunc { shift $SUDO /opt/pivpn/removeOVPN.sh "$@" - exit 1 + exit 0 } function uninstallFunc { $SUDO /opt/pivpn/uninstall.sh - exit 1 + exit 0 } function versionFunc { printf "\e[1mVersion 1.9\e[0m\n" } +function update { + + shift + $SUDO /opt/pivpn/update.sh "$@" + exit 0 + + +} + +function backup { + + $SUDO /opt/pivpn/backup.sh + exit 0 + +} + + function helpFunc { echo "::: Control all PiVPN specific functions!" echo ":::" @@ -64,7 +81,9 @@ function helpFunc { 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 + echo "::: -up, update Updates PiVPN Scripts" + echo "::: -bk, backup Backup Openvpn and ovpns dir" + exit 0 } if [[ $# = 0 ]]; then @@ -81,5 +100,7 @@ case "$1" in "-h" | "help" ) helpFunc;; "-u" | "uninstall" ) uninstallFunc;; "-v" ) versionFunc;; +"-up"| "update" ) update "$@" ;; +"-bk"| "backup" ) backup;; * ) helpFunc;; esac diff --git a/scripts/bash-completion b/scripts/bash-completion index e217755..f317bc4 100644 --- a/scripts/bash-completion +++ b/scripts/bash-completion @@ -4,8 +4,8 @@ _pivpn() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - dashopts="-a -c -d -l -r -h -u" - opts="debug add clients list revoke uninstall help" + dashopts="-a -c -d -l -r -h -u -up" + opts="debug add clients list revoke uninstall help update" if [ "${#COMP_WORDS[@]}" -eq 2 ] then if [[ ${cur} == -* ]] ; then