compilAndInstall.sh 1.95 KB
#!/bin/sh

usage="
    \n ### Install ddserver###
    \n
    \n    Usage : $0 -d <Destination path> -u <DDService URL> -r <DD.res directory path> -b <DDBASE path> [-l <User local directory. By default, it's /usr/local>] [-p <Proxy host:port>] [-a <Proxy user name:password for authentication>]
    \n
    \n            $0 -d /opt/tools/DDServer -u http://amdadev.fr/DDService -r /var/amda-data/ -b /var/amda-data/DDBASE -l /opt/local -p 'myproxy.fr:9090' -a 'username:userpwd'
    \n
    \n
    \n ###"

USERLOCAL_ROOT='/usr/lib'

while getopts "d:u:r:b:l:p:a:h" options; do
    case $options in
        d ) INSTALL_DIR=`echo $OPTARG`;;
        u ) DDSERVICE_URL=`echo $OPTARG`;;
        r ) DDRESPATH=`echo $OPTARG`;;
        b ) DDBASEPATH=`echo $OPTARG`;;
        l ) USERLOCAL_ROOT=`echo $OPTARG`;;
        p ) PROXY_HOST=`echo $OPTARG`;;
        a ) PROXY_USERPWD=`echo $OPTARG`;;
        h ) echo -e $usage
            exit 1;;
        \? ) echo -e $usage
            exit 1;;
        * ) echo -e $usage
            exit 1;;
    esac
done

if [ "$INSTALL_DIR" = "" ]
then
    echo "[ERROR] Missing INSTALL_DIR definition"
    echo -e $usage
    exit 1
fi

if [ "$DDSERVICE_URL" = "" ]
then
    echo "[ERROR] Missing DDSERVICE_URL definition"
    echo -e $usage
    exit 1
fi

if [ "$DDBASEPATH" = "" ]
then
    echo "[ERROR] Missing DDBASE definition"
    echo -e $usage
    exit 1
fi

if [ "$DDRESPATH" = "" ]
then
    echo "[ERROR] Missing DDBASE definition"
    echo -e $usage
    exit 1
fi

export INSTALL_DIR DDSERVICE_URL DDRESPATH DDBASEPATH USERLOCAL_ROOT PROXY_HOST PROXY_USERPWD

cmake -E make_directory build
if [[ $? != 0 ]]; then exit 1; fi

cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ..
if [[ $? != 0 ]]; then exit 1; fi

cmake --build build
if [[ $? != 0 ]]; then exit 1; fi

sudo make -C build install VERBOSE=1
if [[ $? != 0 ]]; then exit 1; fi

# Post install
sudo ln -s ${DDBASEPATH} ${INSTALL_DIR}/DDService/BASE

exit 0