summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-13 15:42:09 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-13 17:22:13 +0200
commit5756bd350d585660cce53a28dc66bfcf162ecca1 (patch)
treecbb0c3a013c70fd48365effe90b5bd95e03e4c44 /scripts
parent6849b490ccfe2f5ed2bb577758edf30445691378 (diff)
Set install dir to /opt/AGL and move conf to $HOME/.xds-server
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/xds-docker-create-container.sh15
-rwxr-xr-xscripts/xds-server-start.sh79
-rwxr-xr-xscripts/xds-utils/get-syncthing.sh4
3 files changed, 15 insertions, 83 deletions
diff --git a/scripts/xds-docker-create-container.sh b/scripts/xds-docker-create-container.sh
index d041a22..52dfda3 100755
--- a/scripts/xds-docker-create-container.sh
+++ b/scripts/xds-docker-create-container.sh
@@ -63,15 +63,14 @@ done
[ "$ID" = "" ] && ID=0
-docker ps -a |grep "$IMAGE" > /dev/null
-[ "$?" = "0" ] && { echo "Image name already exist ! (use -h option to read help)"; exit 1; }
-
-
USER=$(id -un)
echo "Using instance ID #$ID (user $(id -un))"
NAME=agl-xds-$(hostname|cut -f1 -d'.')-$ID-$USER
+docker ps -a |grep "$NAME" > /dev/null
+[ "$?" = "0" ] && { echo "Image name already exist ! (use -h option to read help)"; exit 1; }
+
MIRRORDIR=$HOME/ssd/localmirror_$ID
XDTDIR=$HOME/ssd/xdt_$ID
SHAREDDIR=$HOME/$DOCKER_USER/docker/share
@@ -100,11 +99,11 @@ if [ "$?" != "0" ]; then
fi
if ($FORCE); then
- echo "Stoping xds-server..."
- docker exec --user $DOCKER_USER ${NAME} bash -c "/usr/local/bin/xds-server-stop.sh" || exit 1
+ echo "Stopping xds-server..."
+ docker exec -t ${NAME} bash -c "systemctl stop xds-server" || exit 1
sleep 1
echo "Starting xds-server..."
- docker exec --user $DOCKER_USER ${NAME} bash -c "nohup /usr/local/bin/xds-server-start.sh" || exit 1
+ docker exec -t ${NAME} bash -c "systemctl start xds-server" || exit 1
fi
echo "Copying your identity to container $NAME"
@@ -115,7 +114,7 @@ max=30
count=0
while [ $res -ne 0 ] && [ $count -le $max ]; do
sleep 1
- docker exec ${NAME} bash -c "systemctl status ssh" 2>/dev/null 1>&2
+ docker exec ${NAME} bash -c "systemctl status ssh" 2>/dev/null 1>&2
res=$?
echo -n "."
count=$(expr $count + 1);
diff --git a/scripts/xds-server-start.sh b/scripts/xds-server-start.sh
index 7985759..58e1952 100755
--- a/scripts/xds-server-start.sh
+++ b/scripts/xds-server-start.sh
@@ -1,77 +1,10 @@
#!/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=info
-[ -z "$LOGDIR" ] && LOGDIR=/tmp/xds-server/logs
-[ -z "PORT_SRV" ] && PORT_SRV=8000
-[ -z "$PORT_GUI" ] && PORT_GUI=8384
-[ -z "$API_KEY" ] && API_KEY="1234abcezam"
-[ -z "$UPDATE_XDS_TARBALL" ] && UPDATE_XDS_TARBALL=1
-
-[[ -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 <<EOF > ${XDS_CONFFILE}
-{
- "HTTPPort": ${PORT_SRV},
- "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
-if [ "${UPDATE_XDS_TARBALL}" = 1 ]; then
- 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
-fi
-
+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
-
-exit 0
+nohup $BINDIR/xds-server $* &
+exit $?
diff --git a/scripts/xds-utils/get-syncthing.sh b/scripts/xds-utils/get-syncthing.sh
index 6041cd5..00ead6b 100755
--- a/scripts/xds-utils/get-syncthing.sh
+++ b/scripts/xds-utils/get-syncthing.sh
@@ -6,7 +6,7 @@
# XXX - may be cleanup
# Used as temporary HACK while waiting merge of #165
#[ -z "$SYNCTHING_INOTIFY_VERSION" ] && { SYNCTHING_INOTIFY_VERSION=master; SYNCTHING_INOTIFY_CMID=af6fbf9d63f95a0; }
-[ -z "$DESTDIR" ] && DESTDIR=/usr/local/bin
+[ -z "$DESTDIR" ] && DESTDIR=/opt/AGL/xds/server
[ -z "$TMPDIR" ] && TMPDIR=/tmp
[ -z "$GOOS" ] && GOOS=$(go env GOOS)
[ -z "$GOARCH" ] && GOARCH=$(go env GOARCH)
@@ -94,4 +94,4 @@ else
fi
fi
-echo "DONE: syncthing and syncthing-inotify successfuly installed in ${DESTDIR}" \ No newline at end of file
+echo "DONE: syncthing and syncthing-inotify successfuly installed in ${DESTDIR}"