update.sh 969 Bytes
Newer Older
1
#!/bin/bash
Johannes Kiesel's avatar
Johannes Kiesel committed
2
#    Update the webis command from Git
3 4 5 6
#
#    Copyright 2015-today
#
#    Project WEBIS
7
scriptPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Martin Heinrich's avatar
Martin Heinrich committed
8 9
. ${scriptPath}/../../libs/bashhelper.sh
. ${scriptPath}/../../libs/shflags
Steve Goering's avatar
Steve Goering committed
10

11
check_tools "git"
Steve Goering's avatar
Steve Goering committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

#
#    Define usage screen.
#
usage() {
    echo "
Usage:
    $(basename "$0")

Description:
    Perform update of toolkit.

Examples:
    $(basename "$0")
"
    exit 1
}

#
#    Define command line arguments and parse them.
#
FLAGS_HELP=$(usage)
export FLAGS_HELP
FLAGS "$@" || exit 1  # Parse command line arguments.
eval set -- "${FLAGS_ARGV}"
37 38 39 40 41

#
#
#
main() {
42 43
    cd "$webiscmdrootpath"

44
    if git_repo_has_updates; then
45
        logInfo "Updating webis-cmd."
46 47 48 49
        local cmd="git"
        if [ ! -w "$(pwd)" ]; then
            cmd="sudo git"
        fi
Michael Völske's avatar
Michael Völske committed
50
        $cmd pull --rebase origin master
51 52
    else
        logInfo "No update needed."
53
    fi
54 55 56 57 58
}

#
#    Start programm with parameters.
#
59
set -e
60
main "$@"