mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
Fix update scripts from test branch
This commit is contained in:
parent
a6087f8bda
commit
41984e5f40
4 changed files with 32 additions and 16 deletions
|
@ -125,8 +125,8 @@ main(){
|
|||
if [ -z "$UpdateCmd" ] || [ "$UpdateCmd" = "Reconfigure" ]; then
|
||||
:
|
||||
elif [ "$UpdateCmd" = "Update" ]; then
|
||||
### To do: test the update script and implement update for WireGuard as well
|
||||
$SUDO /opt/pivpn/update.sh
|
||||
$SUDO /opt/pivpn/update.sh "$@"
|
||||
exit 0
|
||||
elif [ "$UpdateCmd" = "Repair" ]; then
|
||||
source "$setupVars"
|
||||
runUnattended=true
|
||||
|
|
|
@ -6,7 +6,14 @@ pivpnrepo="https://github.com/pivpn/pivpn.git"
|
|||
pivpnlocalpath="/etc/.pivpn"
|
||||
pivpnscripts="/opt/pivpn/"
|
||||
bashcompletiondir="/etc/bash_completion.d/"
|
||||
setupVars="/etc/pivpn/setupVars.conf"
|
||||
|
||||
if [ ! -f "${setupVars}" ]; then
|
||||
echo "::: Missing setup vars file!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "${setupVars}"
|
||||
|
||||
###Functions
|
||||
##Updates scripts
|
||||
|
@ -16,7 +23,7 @@ updatepivpnscripts(){
|
|||
echo "going do update PiVPN Scripts"
|
||||
if [[ -d "$pivpnlocalpath" ]]; then
|
||||
if [[ -n "$pivpnlocalpath" ]]; then
|
||||
sudo rm -rf "${pivpnlocalpath}/../.pivpn"
|
||||
rm -rf "${pivpnlocalpath}/../.pivpn"
|
||||
cloneandupdate
|
||||
fi
|
||||
else
|
||||
|
@ -32,7 +39,7 @@ updatefromtest(){
|
|||
echo "PiVPN Scripts updating from test branch"
|
||||
if [[ -d "$pivpnlocalpath" ]]; then
|
||||
if [[ -n "$pivpnlocalpath" ]]; then
|
||||
rm -rf "{$pivpnlocalpath}/../.pivpn"
|
||||
rm -rf "${pivpnlocalpath}/../.pivpn"
|
||||
cloneupdttest
|
||||
fi
|
||||
else
|
||||
|
@ -41,22 +48,23 @@ updatefromtest(){
|
|||
echo "PiVPN Scripts updated have been updated from test branch"
|
||||
}
|
||||
|
||||
##Clone and copy pivpn scripts to /op/
|
||||
##Clone and copy pivpn scripts to /opt/pivpn
|
||||
cloneandupdate(){
|
||||
sudo git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||
sudo cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||
sudo cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir"
|
||||
git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||
cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||
cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir"
|
||||
}
|
||||
|
||||
##same as cloneandupdate() but from test branch
|
||||
##and falls back to master branch again after updating
|
||||
cloneupdttest(){
|
||||
sudo git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||
sudo git -C "$pivpnlocalpath" checkout test
|
||||
sudo git -C "$pivpnlocalpath" pull origin test
|
||||
sudo cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||
sudo cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir"
|
||||
sudo git -C "$pivpnlocalpath" checkout master
|
||||
git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||
git -C "$pivpnlocalpath" checkout test
|
||||
git -C "$pivpnlocalpath" pull origin test
|
||||
cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||
cp "${pivpnlocalpath}"/scripts/$VPN/*.sh "$pivpnscripts"
|
||||
cp "${pivpnlocalpath}"/scripts/$VPN/bash-completion "$bashcompletiondir"
|
||||
git -C "$pivpnlocalpath" checkout master
|
||||
}
|
||||
|
||||
scriptusage(){
|
|
@ -4,8 +4,8 @@ _pivpn()
|
|||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
dashopts="-a -c -d -l -qr -r -h -u"
|
||||
opts="add clients debug list qrcode remove help uninstall"
|
||||
dashopts="-a -c -d -l -qr -r -h -u -up"
|
||||
opts="add clients debug list qrcode remove help uninstall update"
|
||||
if [ "${#COMP_WORDS[@]}" -eq 2 ]
|
||||
then
|
||||
if [[ ${cur} == -* ]] ; then
|
||||
|
|
|
@ -48,6 +48,12 @@ uninstallServer(){
|
|||
exit 0
|
||||
}
|
||||
|
||||
updateScripts(){
|
||||
shift
|
||||
$SUDO /opt/pivpn/update.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
showHelp(){
|
||||
echo "::: Control all PiVPN specific functions!"
|
||||
echo ":::"
|
||||
|
@ -62,6 +68,7 @@ showHelp(){
|
|||
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"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
@ -79,5 +86,6 @@ case "$1" in
|
|||
"-r" | "remove" ) removeClient "$@";;
|
||||
"-h" | "help" ) showHelp;;
|
||||
"-u" | "uninstall" ) uninstallServer;;
|
||||
"-up" | "update" ) updateScripts "$@" ;;
|
||||
* ) showHelp;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue