diff --git a/auto_install/install.sh b/auto_install/install.sh index c423c18..f34230c 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -2243,9 +2243,20 @@ installScripts(){ # $SUDO chmod -R 0755 ${pivpnScriptDir} fi $SUDO install -v -m 755 -t ${pivpnScriptDir} ${pivpnFilesDir}/scripts/*.sh - $SUDO install -v -m 755 -t ${pivpnScriptDir}/${VPN} ${pivpnFilesDir}/scripts/${VPN}/*.sh - $SUDO install -v -m 755 -t /usr/local/bin /${pivpnFilesDir}/scripts/pivpn - $SUDO cp "${pivpnFilesDir}/scripts/${VPN}/bash-completion" /etc/bash_completion.d/pivpn + $SUDO install -v -m 755 -t ${pivpnScriptDir}/${VPN} ${pivpnFilesDir}/scripts/${VPN}/*.sh + # line for the single command being installed + $SUDO ln -s -T ${pivpnFilesDir}/scripts/${VPN}/pivpn pivpn + # if the other protocol file exists + if [ ${VPN} -eq 'wireguard' ]; then + othervpn='openvpn' + else + othervpn='wireguard' + fi + if [ -r "${setupConfigDir}/${othervpn}/${setupVarsFile} ] then; + # dont need a link, copy the common script to the location instead + $SUDO install -v -m 755 -t /usr/local/bin /${pivpnFilesDir}/scripts/pivpn + fi + $SUDO cp "${pivpnFilesDir}/scripts/${VPN}/bash-completion" /etc/bash_completion.d/pivpn $SUDO chown root:root /etc/bash_completion.d/pivpn $SUDO chmod 755 /etc/bash_completion.d/pivpn # shellcheck disable=SC1091 diff --git a/scripts/backup.sh b/scripts/backup.sh index 8711c96..adf5b43 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -2,7 +2,32 @@ backupdir=pivpnbackup date=$(date +%Y%m%d-%H%M%S) -setupVars="/etc/pivpn/setupVars.conf" + +# Find the rows and columns. Will default to 80x24 if it can not be detected. +screen_size=$(stty size 2>/dev/null || echo 24 80) +rows=$(echo "$screen_size" | awk '{print $1}') +columns=$(echo "$screen_size" | awk '{print $2}') + +# Divide by two so the dialogs take up half of the screen, which looks nice. +r=$(( rows / 2 )) +c=$(( columns / 2 )) +# Unless the screen is tiny +r=$(( r < 20 ? 20 : r )) +c=$(( c < 70 ? 70 : c )) + + chooseVPNCmd=(whiptail --backtitle "Setup PiVPN" --title "Installation mode" --separate-output --radiolist "Choose a VPN to update (press space to select):" "${r}" "${c}" 2) + VPNChooseOptions=(WireGuard "" on + OpenVPN "" off) + + if VPN=$("${chooseVPNCmd[@]}" "${VPNChooseOptions[@]}" 2>&1 >/dev/tty) ; then + echo "::: Using VPN: $VPN" + VPN="${VPN,,}" + else + echo "::: Cancel selected, exiting...." + exit 1 + fi + +setupVars="/etc/pivpn/${VPN}/setupVars.conf" if [ ! -f "${setupVars}" ]; then echo "::: Missing setup vars file!" diff --git a/scripts/update.sh b/scripts/update.sh index 609c273..eed1ce8 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -6,7 +6,32 @@ pivpnrepo="https://github.com/pivpn/pivpn.git" pivpnlocalpath="/etc/.pivpn" pivpnscripts="/opt/pivpn/" bashcompletiondir="/etc/bash_completion.d/" -setupVars="/etc/pivpn/setupVars.conf" + +# Find the rows and columns. Will default to 80x24 if it can not be detected. +screen_size=$(stty size 2>/dev/null || echo 24 80) +rows=$(echo "$screen_size" | awk '{print $1}') +columns=$(echo "$screen_size" | awk '{print $2}') + +# Divide by two so the dialogs take up half of the screen, which looks nice. +r=$(( rows / 2 )) +c=$(( columns / 2 )) +# Unless the screen is tiny +r=$(( r < 20 ? 20 : r )) +c=$(( c < 70 ? 70 : c )) + + chooseVPNCmd=(whiptail --backtitle "Setup PiVPN" --title "Installation mode" --separate-output --radiolist "Choose a VPN to update (press space to select):" "${r}" "${c}" 2) + VPNChooseOptions=(WireGuard "" on + OpenVPN "" off) + + if VPN=$("${chooseVPNCmd[@]}" "${VPNChooseOptions[@]}" 2>&1 >/dev/tty) ; then + echo "::: Using VPN: $VPN" + VPN="${VPN,,}" + else + echo "::: Cancel selected, exiting...." + exit 1 + fi + +setupVars="/etc/pivpn/${VPN}/setupVars.conf" if [ ! -f "${setupVars}" ]; then echo "::: Missing setup vars file!"