| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 | #!/usr/bin/env bash#Paul Klumpp 2012-11-19cwd=$(pwd)q2srv=$cwd/../q2srv/cd $cwdfunction checkuser {    if [ "${USER}" == "root" ]; then        echo "Nono! Don't run this as root! Don't!"        echo "Switch to a normal user!"        echo        exit    fi}function checkinstalled {    if [ "$1" != "" ]; then        woot=$(which "$1" 2> /dev/null)        if [ -f "$woot" ]; then            echo 1        else            echo 0        fi    fi}function systemcheck {    software="git make cc realpath lua screen"    for soft in $software; do        see=$(checkinstalled "$soft")        if [ $see -eq 0 ]; then            echo "'$soft' not found on your system. Please have a system administrator install it!"            exit        fi    done}function checkdir {    that=$(pwd | sed -e "s/^.\+\///")    if [ "$that" == "q2compile" ]; then        echo "Not allowed from this directory"        exit    fi}level=0function checkargs {    if [ "$1" == "" ]; then        echo "Usage: $0 <first/update>"        echo        echo "  first: gets git baseserver directory, compiles and puts binaries into that directory"        echo "  update: updates git baseserver directory"        echo        exit    fi    case "$1" in        first)            level=3        ;;        update)            level=2        ;;    esac}function main {    checkuser    checkdir    checkargs $*    systemcheck    repo[1]="aq2-basesrv"    url[1]="https://gitlab.netdome.biz/pklumpp/aq2-base-server.git"    ARCH=$(uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)    for idx in ${!repo[*]}; do        echo        # get sources        if [ $level -gt 0 ]; then            echo "$idx: ${repo[$idx]} from ${url[$idx]}"            if [ ! -d "${repo[$idx]}" ]; then                echo "git dir missing, we get it"                GIT_SSL_NO_VERIFY=true git clone ${url[$idx]} ${repo[$idx]}            else                echo "git dir exists, we update it"                cd $cwd/${repo[$idx]}                 GIT_SSL_NO_VERIFY=true git pull                cd ..            fi        fi        case "$level" in            3)                # first install                # get gits, compile everything cleanly and put it into baseserver directory                cd $cwd/${repo[$idx]}                cd q2compile && ./make_and_put_all.sh clean            ;;            2)                # update check                # get gits, compile everything and put it into baseserver directory                cd $cwd/${repo[$idx]}                cd q2compile && ./make_and_put_all.sh update            ;;        esac        cd $cwd        echo    done}main $*# vim: expandtab tabstop=4 autoindent:# kate: space-indent on; indent-width 4; mixedindent off;
 |