X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=scripts%2Fxds-server-start.sh;h=90ef68d55d1eea81970ccee952edf9a0cda1ab6e;hb=780aa41657c49e6ed01569d96dbde370006cdf92;hp=8814eb876fc19347dea2a6846efbff20661493ce;hpb=472d4b34027f37b05f10d5558d28d6c6bca74ff2;p=src%2Fxds%2Fxds-server.git diff --git a/scripts/xds-server-start.sh b/scripts/xds-server-start.sh index 8814eb8..90ef68d 100755 --- a/scripts/xds-server-start.sh +++ b/scripts/xds-server-start.sh @@ -1,70 +1,27 @@ #!/bin/bash - -# Configurable variables -[ -z "$BINDIR" ] && BINDIR=/usr/local/bin -[ -z "$XDS_CONFFILE" ] && XDS_CONFFILE=$HOME/.xds/config.json -[ -z "$XDS_SHAREDIR" ] && XDS_SHAREDIR=$HOME/.xds/share -[ -z "$ST_CONFDIR" ] && ST_CONFDIR=$HOME/.xds/syncthing-config -[ -z "$XDS_WWWDIR" ] && XDS_WWWDIR=webapp/dist -[ -z "$LOGLEVEL" ] && LOGLEVEL=warn -[ -z "$LOGDIR" ] && LOGDIR=/tmp/xds-server/logs -[ -z "$PORT_GUI" ] && PORT_GUI=8384 -[ -z "$API_KEY" ] && API_KEY="1234abcezam" - -[[ -f $BINDIR/xds-server ]] || { echo "Cannot find xds-server in BINDIR !"; exit 1; } - -# Create config.json file when needed -if [ ! -f "${XDS_CONFFILE}" ]; then - mv ${XDS_CONFFILE} ${XDS_CONFFILE}.old - [ ! -f "$XDS_WWWDIR/index.html" ] && XDS_WWWDIR=$BINDIR/www-xds-server - [ ! -f "$XDS_WWWDIR/index.html" ] && XDS_WWWDIR=/var/www/xds-server - [ ! -f "$XDS_WWWDIR/index.html" ] && { echo "Cannot determine XDS-server webapp directory."; exit 1; } - cat < ${XDS_CONFFILE} -{ - "webAppDir": "${XDS_WWWDIR}", - "shareRootDir": "${XDS_SHAREDIR}", - "logsDir": "${LOGDIR}", - "sdkRootDir": "/xdt/sdk", - "syncthing": { - "binDir": "${BINDIR}", - "home": "${ST_CONFDIR}", - "gui-address": "http://localhost:${PORT_GUI}", - "gui-apikey": "${API_KEY}" - } -} -EOF -fi - -echo "### Configuration in config.json: " -cat ${XDS_CONFFILE} -echo "" - -mkdir -p ${LOGDIR} -LOG_XDS=${LOGDIR}/xds-server.log - -# Download xds-agent tarball -SCRIPT_GET_XDS_TARBALL=$BINDIR/xds-utils/get-xds-agent.sh -if [ ! -f ${SCRIPT_GET_XDS_TARBALL} ]; then - SCRIPT_GET_XDS_TARBALL=$(dirname $0)/xds-utils/get-xds-agent.sh -fi -if [ -f ${SCRIPT_GET_XDS_TARBALL} ]; then - TARBALLDIR=${XDS_WWWDIR}/assets/xds-agent-tarballs - [ ! -d "$TARBALLDIR" ] && TARBALLDIR=$BINDIR/www-xds-server/assets/xds-agent-tarballs - [ ! -d "$TARBALLDIR" ] && TARBALLDIR=$(grep webAppDir ~/.xds/config.json|cut -d '"' -f 4)/assets/xds-agent-tarballs - if [ -d "$TARBALLDIR" ]; then - DEST_DIR=$TARBALLDIR $SCRIPT_GET_XDS_TARBALL - else - echo "WARNING: cannot download / update xds-agent tarballs (DESTDIR error)" - fi -else - echo "WARNING: cannot download / update xds-agent tarballs" -fi - + ########################################################################### +# Copyright 2017 IoT.bzh +# +# author: Sebastien Douheret +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +BINDIR=/opt/AGL/bin +[[ -f $BINDIR/xds-server ]] || BINDIR=$(which xds-server) +[[ -f $BINDIR/xds-server ]] || BINDIR=/usr/local/bin ;# for backward compat +[[ -f $BINDIR/xds-server ]] || { echo "Cannot find xds-server executable !"; exit 1; } echo "### Start XDS server" -echo "nohup $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1" -if [ "$1" != "-dryrun" ]; then - nohup $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1 & - pid_xds=$(jobs -p) - echo "pid=${pid_xds}" -fi +nohup $BINDIR/xds-server $* & +exit $?