Commit 55c64d2b authored by Janek Bevendorff's avatar Janek Bevendorff

Fix and improve update check

parent 7004e5c0
...@@ -43,14 +43,18 @@ main() { ...@@ -43,14 +43,18 @@ main() {
if git_repo_has_updates; then if git_repo_has_updates; then
logInfo "Updating webis-cmd." logInfo "Updating webis-cmd."
git pull --rebase origin master local cmd="git"
if [ ! -w "$(pwd)" ]; then
cmd="sudo git"
fi
"$cmd" pull --rebase origin master
else else
logInfo "No update needed." logInfo "No update needed."
fi fi
} }
# #
# Start programm with parameters. # Start programm with parameters.
# #
set -e
main "$@" main "$@"
#!/bin/bash #!/bin/bash
# -*- coding: utf-8 ; mode: python -*- # -*- coding: utf-8 ; mode: python -*-
"true" '''\' "true" '''\'
set -e
RP="${BASH_SOURCE[0]}" RP="${BASH_SOURCE[0]}"
while [ -h "$RP" ]; do while [ -h "$RP" ]; do
DIR="$( cd -P "$( dirname "$RP" )" && pwd )" DIR="$( cd -P "$( dirname "$RP" )" && pwd )"
...@@ -9,17 +10,27 @@ while [ -h "$RP" ]; do ...@@ -9,17 +10,27 @@ while [ -h "$RP" ]; do
done done
rootpath="$(cd "$(dirname "$RP")" && pwd -P)" rootpath="$(cd "$(dirname "$RP")" && pwd -P)"
. ${rootpath}/libs/bashhelper.sh . ${rootpath}/libs/bashhelper.sh
if $(cd "$webiscmdrootpath" ; git_repo_has_updates ); then (cd "$webiscmdrootpath"
logWarn "Your webis-cmd is outdated. Please run 'webis core update'" if [ "$1 $2" != "core update" ] && git_repo_has_updates; then
fi logWarn "Your webis-cmd is outdated. You need to update your installation before you can use it."
if ! yes_no_prompt "Do you want to update now?" "y"; then
logError "Canceling update. Please re-run the command or update manually with '${0} core update'."
exit 1
fi
if ! "$0" core update; then
logError "Update failed."
exit 1
fi
logInfo "Update successful, relaunching webis-cmd..."
exec "$0" "$@"
fi
)
# try running as python3, if that fails fall back to (any) python # try running as python3, if that fails fall back to (any) python
command -v python3 > /dev/null if command -v python3 > /dev/null; then
if [ $? -eq 0 ]; then
exec env python3 "$0" "$@" exec env python3 "$0" "$@"
fi fi
command -v python > /dev/null if command -v python > /dev/null; then
if [ $? -eq 0 ]; then
exec env python "$0" "$@" exec env python "$0" "$@"
else else
echo -e "\033[91m[ERROR] Install Python and try again!" 1>&2 echo -e "\033[91m[ERROR] Install Python and try again!" 1>&2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment