Updates and improvements

install.sh
  installScripts function:
    update script not being copied over to /opt therefore update funcion was probably broken.
    changed script to copy all .sh scripts from .pivpn/scripts directory.

Issue #871: fix backup script
  I was probably very drunk when i first wrote this backup script.
  fixed it, now works with new code refactoring,
  loads vars from setupVars
  Added backup for wireguard
  Moved script to global pivpnscripts.
  Added backup script to bash-completion
  Added backup script to pivpn script

update.sh
  Commented the update from master branch to avoid users trying to update test from master.

Updated LatestChages.md
This commit is contained in:
4s3ti 2020-01-08 19:38:38 +01:00
parent 8096af7ad0
commit dd6bb069f0
6 changed files with 46 additions and 43 deletions

View file

@ -5,6 +5,31 @@ patch release notes.
Everytime Test branch is merged into master, a new entry should be created with the date and changes being merged. Everytime Test branch is merged into master, a new entry should be created with the date and changes being merged.
## Jan 8th 2020
Updates and improvements
Issue #871: fix backup script
install.sh
installScripts function:
update script not being copied over to /opt therefore update funcion was probably broken.
changed script to copy all .sh scripts from .pivpn/scripts directory.
Issue #871: fix backup script
I was probably very drunk when i first wrote this backup script.
fixed it, now works with new code refactoring,
loads vars from setupVars
Added backup for wireguard
Moved script to global pivpnscripts.
Added backup script to bash-completion
Added backup script to pivpn script
update.sh
Commented the update from master branch to avoid users trying to update test from master.
Updated LatestChages.md
## Jan 7th 2020 ## Jan 7th 2020
Changes for FR #897 Changes for FR #897

View file

@ -1893,7 +1893,7 @@ installScripts(){
$SUDO chmod 0755 /opt/pivpn $SUDO chmod 0755 /opt/pivpn
fi fi
$SUDO cp /etc/.pivpn/scripts/uninstall.sh /opt/pivpn/ $SUDO cp /etc/.pivpn/scripts/*.sh /opt/pivpn/
$SUDO cp /etc/.pivpn/scripts/$VPN/*.sh /opt/pivpn/ $SUDO cp /etc/.pivpn/scripts/$VPN/*.sh /opt/pivpn/
$SUDO chmod 0755 /opt/pivpn/*.sh $SUDO chmod 0755 /opt/pivpn/*.sh
$SUDO cp /etc/.pivpn/scripts/$VPN/pivpn /usr/local/bin/pivpn $SUDO cp /etc/.pivpn/scripts/$VPN/pivpn /usr/local/bin/pivpn

View file

@ -1,36 +0,0 @@
#!/bin/bash
setupVars="/etc/pivpn/setupVars.conf"
backupdir=pivpnbackup
openvpndir=/etc/openvpn
ovpnsdir=${install_home}/ovpns
date=$(date +%Y-%m-%d-%H%M%S)
if [ ! -f "${setupVars}" ]; then
echo "::: Missing setup vars file!"
exit 1
fi
source "${setupVars}"
backup_openvpn(){
if [[ ! -d $install_home/$backupdir ]]; then
mkdir $install_home/$backupdir
fi
cp -r $openvpndir $ovpnsdir $backupdir 2&>1
backupzip=$date-pivpnbackup.tgz
tar -czf $backupzip -C ${install_home} $backupdir 2&>1
echo -e "Backup crated to $install_home/$backupdir/$backupzip \nTo restore the backup, follow instructions at:\nhttps://github.com/pivpn/pivpn/wiki/FAQ#how-can-i-migrate-my-configs-to-another-pivpn-instance"
}
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 0
fi
fi
backup_openvpn

View file

@ -50,9 +50,18 @@ updatefromtest(){
##Clone and copy pivpn scripts to /opt/pivpn ##Clone and copy pivpn scripts to /opt/pivpn
cloneandupdate(){ cloneandupdate(){
git clone "$pivpnrepo" "$pivpnlocalpath" ##This is to be removed after merge.
cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts" ##Alert for users trying to update from master.
cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir" if [ $VPN == "wireguard" ]; then
echo "ERROR: You have installed pivpn from test branch."
echo "Wireguard not yet available on master, please use -t flag"
exit 1
fi
## Remove Above and uncomment below when test is moved to master
# git clone "$pivpnrepo" "$pivpnlocalpath"
# cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
# cp "${pivpnlocalpath}"/scripts/$VPN/*.sh "$pivpnscripts"
# cp "${pivpnlocalpath}"/scripts/$VPN/bash-completion "$bashcompletiondir"
} }
##same as cloneandupdate() but from test branch ##same as cloneandupdate() but from test branch
@ -97,4 +106,3 @@ else
esac esac
done done
fi fi

View file

@ -4,8 +4,8 @@ _pivpn()
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
dashopts="-a -c -d -l -qr -r -h -u -up" dashopts="-a -c -d -l -qr -r -h -u -up -bk"
opts="add clients debug list qrcode remove help uninstall update" opts="add clients debug list qrcode remove help uninstall update backup"
if [ "${#COMP_WORDS[@]}" -eq 2 ] if [ "${#COMP_WORDS[@]}" -eq 2 ]
then then
if [[ ${cur} == -* ]] ; then if [[ ${cur} == -* ]] ; then

View file

@ -54,6 +54,10 @@ updateScripts(){
exit 0 exit 0
} }
backup(){
$SUDO /opt/pivpn/backup.sh
}
showHelp(){ showHelp(){
echo "::: Control all PiVPN specific functions!" echo "::: Control all PiVPN specific functions!"
echo ":::" echo ":::"
@ -69,6 +73,7 @@ showHelp(){
echo "::: -h, help Show this help dialog" echo "::: -h, help Show this help dialog"
echo "::: -u, uninstall Uninstall pivpn from your system!" echo "::: -u, uninstall Uninstall pivpn from your system!"
echo "::: -up, update Updates PiVPN Scripts" echo "::: -up, update Updates PiVPN Scripts"
echo "::: -bk, Backup Backup vpn configs and user profiles"
exit 0 exit 0
} }
@ -87,5 +92,6 @@ case "$1" in
"-h" | "help" ) showHelp;; "-h" | "help" ) showHelp;;
"-u" | "uninstall" ) uninstallServer;; "-u" | "uninstall" ) uninstallServer;;
"-up" | "update" ) updateScripts "$@" ;; "-up" | "update" ) updateScripts "$@" ;;
"-bk" | "backup" ) backup ;;
* ) showHelp;; * ) showHelp;;
esac esac