mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
add missing bang to shebang. correct usage of cp. correct wrong copy target dir. safeguard sudo-rm-rf. safeguard against variable expansion into IFS chars. clean up whitespace.
Signed-off-by: corbolais <corbolais@gmail.com>
This commit is contained in:
parent
4466f1503c
commit
47c84e6a45
1 changed files with 25 additions and 32 deletions
|
@ -4,8 +4,8 @@
|
||||||
###Main Vars
|
###Main Vars
|
||||||
pivpnrepo="https://github.com/pivpn/pivpn.git"
|
pivpnrepo="https://github.com/pivpn/pivpn.git"
|
||||||
pivpnlocalpath="/etc/.pivpn"
|
pivpnlocalpath="/etc/.pivpn"
|
||||||
pivpnscripts="/opt/pivpn/scripts"
|
pivpnscripts="/opt/pivpn/"
|
||||||
bashcompletiondir="/etc/bash_completion.d/pivpn"
|
bashcompletiondir="/etc/bash_completion.d/"
|
||||||
|
|
||||||
|
|
||||||
###Functions
|
###Functions
|
||||||
|
@ -14,11 +14,11 @@ updatepivpnscripts(){
|
||||||
##We don't know what sort of changes users have made.
|
##We don't know what sort of changes users have made.
|
||||||
##Lets remove first /etc/.pivpn dir then clone it back again
|
##Lets remove first /etc/.pivpn dir then clone it back again
|
||||||
echo "going do update PiVPN Scripts"
|
echo "going do update PiVPN Scripts"
|
||||||
if [[ -d $pivpnlocalpath ]]; then
|
if [[ -d "$pivpnlocalpath" ]]; then
|
||||||
|
if [[ -n "$pivpnlocalpath" ]]; then
|
||||||
sudo rm -rf $pivpnlocalpath
|
sudo rm -rf "${pivpnlocalpath}/../.pivpn"
|
||||||
cloneandupdate
|
cloneandupdate
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
cloneandupdate
|
cloneandupdate
|
||||||
fi
|
fi
|
||||||
|
@ -30,54 +30,47 @@ updatefromtest(){
|
||||||
##We don't know what sort of changes users have made.
|
##We don't know what sort of changes users have made.
|
||||||
##Lets remove first /etc/.pivpn dir then clone it back again
|
##Lets remove first /etc/.pivpn dir then clone it back again
|
||||||
echo "PiVPN Scripts updating from test branch"
|
echo "PiVPN Scripts updating from test branch"
|
||||||
if [[ -d /etc/.pivpn ]]; then
|
if [[ -d "$pivpnlocalpath" ]]; then
|
||||||
|
if [[ -n "$pivpnlocalpath" ]]; then
|
||||||
rm -rf /etc/.pivpn
|
rm -rf "{$pivpnlocalpath}/../.pivpn"
|
||||||
cloneupdttest
|
cloneupdttest
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
cloneupdttest
|
cloneupdttest
|
||||||
|
|
||||||
fi
|
fi
|
||||||
echo "PiVPN Scripts updated have been updated from test branch"
|
echo "PiVPN Scripts updated have been updated from test branch"
|
||||||
}
|
}
|
||||||
|
|
||||||
##Clone and copy pivpn scripts to /op/
|
##Clone and copy pivpn scripts to /op/
|
||||||
cloneandupdate(){
|
cloneandupdate(){
|
||||||
|
sudo git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||||
sudo git clone $pivpnrepo $pivpnlocalpath
|
sudo cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||||
sudo cp -r $pivpnlocalpath/scripts $pivpnscripts
|
sudo cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir"
|
||||||
sudo cp $pivpnlocalpath/scripts/bash-completion $bashcompletiondir
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
##same as cloneandupdate() but from test branch
|
##same as cloneandupdate() but from test branch
|
||||||
##and falls back to master branch again after updating
|
##and falls back to master branch again after updating
|
||||||
cloneupdttest(){
|
cloneupdttest(){
|
||||||
|
sudo git clone "$pivpnrepo" "$pivpnlocalpath"
|
||||||
sudo git clone $pivpnrepo $pivpnlocalpath
|
sudo git -C "$pivpnlocalpath" checkout test
|
||||||
sudo git -C $pivpnlocalpath checkout test
|
sudo git -C "$pivpnlocalpath" pull origin test
|
||||||
sudo git -C $pivpnlocalpath pull origin test
|
sudo cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts"
|
||||||
sudo cp -r $pivpnlocalpath/scripts $pivpnscripts
|
sudo cp "${pivpnlocalpath}"/scripts/bash-completion "$bashcompletiondir"
|
||||||
sudo cp $pivpnlocalpath/scripts/bash-completion $bashcompletiondir
|
sudo git -C "$pivpnlocalpath" checkout master
|
||||||
sudo git -C $pivpnlocalpath checkout master
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptusage(){
|
scriptusage(){
|
||||||
echo -e "Updates pivpn scripts,\n
|
echo -e "Updates pivpn scripts,
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pivpn update | updates from master branch
|
pivpn update | updates from master branch
|
||||||
pivpn update -t or --test | updates from test branch"
|
pivpn update -t or --test | updates from test branch"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## SCRIPT
|
## SCRIPT
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
updatepivpnscripts
|
updatepivpnscripts
|
||||||
|
|
||||||
else
|
else
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
Loading…
Reference in a new issue