aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/xds-start-server.sh
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-26 15:32:06 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-26 15:32:06 +0200
commit49497b5b1e2a40ae9fac8bd43ecdfeed4d00e248 (patch)
treeb8b94704e5977f04a35e24639f56e0fe75e2c7bf /scripts/xds-start-server.sh
parentcbbddf9a84163975a0a9110e384426567467cfd1 (diff)
Fix webapp location for install and startup.
Diffstat (limited to 'scripts/xds-start-server.sh')
-rwxr-xr-xscripts/xds-start-server.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/xds-start-server.sh b/scripts/xds-start-server.sh
index 66da261..9a6ff05 100755
--- a/scripts/xds-start-server.sh
+++ b/scripts/xds-start-server.sh
@@ -5,20 +5,23 @@
[ -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
-[[ -f ${XDS_CONFFILE} ]] || { mv ${XDS_CONFFILE} ${XDS_CONFFILE}.old; }
-
-cat <<EOF > ${XDS_CONFFILE}
+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 <<EOF > ${XDS_CONFFILE}
{
- "webAppDir": "webapp/dist",
+ "webAppDir": "${XDS_WWWDIR}",
"shareRootDir": "${XDS_SHAREDIR}",
"logsDir": "${LOGDIR}",
"sdkRootDir": "/xdt/sdk",
@@ -30,6 +33,7 @@ cat <<EOF > ${XDS_CONFFILE}
}
}
EOF
+fi
echo "### Configuration in config.json: "
cat ${XDS_CONFFILE}
@@ -39,9 +43,9 @@ mkdir -p ${LOGDIR}
LOG_XDS=${LOGDIR}/xds-server.log
echo "### Start XDS server"
-echo " $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1"
+echo "nohup $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1"
if [ "$1" != "-dryrun" ]; then
- $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1 &
+ nohup $BINDIR/xds-server --config $XDS_CONFFILE -log $LOGLEVEL > $LOG_XDS 2>&1 &
pid_xds=$(jobs -p)
echo "pid=${pid_xds}"
fi