Bugfixes and improvements, check update notes

This commit is contained in:
4s3ti 2019-10-12 18:34:37 +02:00
parent d5215e2747
commit 9f20f50e61
4 changed files with 82 additions and 28 deletions

View file

@ -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

View file

@ -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=$(</proc/sys/kernel/random/uuid)
# Create a unique server name using the host name and UUID
SERVER_NAME="${HOST_NAME}_${NEW_UUID}"
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=$(</proc/sys/kernel/random/uuid)
# Create a unique server name using the host name and UUID
SERVER_NAME="${host_name}_${NEW_UUID}"
declare -A ECDSA_MAP=(["256"]="prime256v1" ["384"]="secp384r1" ["521"]="secp521r1")
@ -1258,7 +1257,7 @@ Run 'pivpn help' to see what else you can do!\n\nIf you run into any issue, plea
All incomplete posts or bug reports will be ignored or deleted.\n\nThank you for using PiVPN." ${r} ${c}
if (whiptail --title "Reboot" --yesno --defaultno "It is strongly recommended you reboot after installation. Would you like to reboot now?" ${r} ${c}); then
whiptail --title "Rebooting" --msgbox "The system will now reboot." ${r} ${c}
printf "\nRebooting system...\n"
jkkprintf "\nRebooting system...\n"
$SUDO sleep 3
$SUDO shutdown -r now
fi
@ -1307,6 +1306,25 @@ clone_or_update_repos() {
fi
}
checkhostname(){
###Checks for hostnamesize
host_name=$(hostname -s)
if [[ ! ${#host_name} -le 28 ]]; then
until [[ ${#host_name} -le 28 && $host_name =~ ^[a-zA-Z0-9][a-zA-Z0-9-]{1,28}$ ]]; do
host_name=$(whiptail --inputbox "Your hostname is too long.\nEnter new hostname with less then 28 characters\nNo special characters allowed." \
--title "Hostname too long" ${r} ${c} 3>&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

37
pivpn
View file

@ -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

View file

@ -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