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

Fix and improve update check

parent 7004e5c0
......@@ -43,14 +43,18 @@ main() {
if git_repo_has_updates; then
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
logInfo "No update needed."
fi
}
#
# Start programm with parameters.
#
set -e
main "$@"
#!/bin/bash
# -*- coding: utf-8 ; mode: python -*-
"true" '''\'
set -e
RP="${BASH_SOURCE[0]}"
while [ -h "$RP" ]; do
DIR="$( cd -P "$( dirname "$RP" )" && pwd )"
......@@ -9,17 +10,27 @@ while [ -h "$RP" ]; do
done
rootpath="$(cd "$(dirname "$RP")" && pwd -P)"
. ${rootpath}/libs/bashhelper.sh
if $(cd "$webiscmdrootpath" ; git_repo_has_updates ); then
logWarn "Your webis-cmd is outdated. Please run 'webis core update'"
fi
(cd "$webiscmdrootpath"
if [ "$1 $2" != "core update" ] && git_repo_has_updates; then
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
command -v python3 > /dev/null
if [ $? -eq 0 ]; then
if command -v python3 > /dev/null; then
exec env python3 "$0" "$@"
fi
command -v python > /dev/null
if [ $? -eq 0 ]; then
if command -v python > /dev/null; then
exec env python "$0" "$@"
else
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