summaryrefslogtreecommitdiffstats
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
parent6849b490ccfe2f5ed2bb577758edf30445691378 (diff)
Set install dir to /opt/AGL and move conf to $HOME/.xds-server
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--Makefile20
-rw-r--r--README.md20
-rw-r--r--conf.d/etc/default/xds-server6
-rw-r--r--conf.d/etc/xds-server/config.json (renamed from conf.d/.config/xds/server/config.json)5
-rw-r--r--conf.d/service/xds-server.service3
-rw-r--r--config.json.in6
-rw-r--r--lib/syncthing/st.go2
-rw-r--r--lib/webserver/server.go4
-rw-r--r--lib/xdsconfig/config.go26
-rw-r--r--lib/xdsconfig/fileconfig.go32
-rw-r--r--main.go35
-rwxr-xr-xscripts/xds-docker-create-container.sh15
-rwxr-xr-xscripts/xds-server-start.sh79
-rwxr-xr-xscripts/xds-utils/get-syncthing.sh4
14 files changed, 117 insertions, 140 deletions
diff --git a/Makefile b/Makefile
index d731be4..3331ee8 100644
--- a/Makefile
+++ b/Makefile
@@ -31,9 +31,9 @@ ifneq ($(origin INSTALL_WEBAPP_DIR), undefined)
DESTDIR_WWW := $(INSTALL_WEBAPP_DIR)
endif
-# Configurable variables for installation (default /usr/local/...)
+# Configurable variables for installation (default /opt/AGL/...)
ifeq ($(origin DESTDIR), undefined)
- DESTDIR := /usr/local/bin
+ DESTDIR := /opt/AGL/xds/server
endif
ifeq ($(origin DESTDIR_WWW), undefined)
DESTDIR_WWW := $(DESTDIR)/www
@@ -130,7 +130,7 @@ conffile:
cat config.json.in \
| sed -e s,"webapp/dist","$(DESTDIR_WWW)",g \
| sed -e s,"\./bin","",g \
- > $(DESTDIR)/config.json
+ > $(DESTDIR)/config.json.in
.PHONY: install
install:
@@ -142,20 +142,24 @@ install:
mkdir -p $(DESTDIR_WWW) \
&& cp -a webapp/dist/* $(DESTDIR_WWW)
-.PHONY: package
-package: clean
+.PHONY: _package
+_package: clean
make -f $(ROOT_SRCDIR)/Makefile all install DESTDIR=$(PACKAGE_DIR)/xds-server
make -f $(ROOT_SRCDIR)/Makefile conffile DESTDIR=$(PACKAGE_DIR)/xds-server DESTDIR_WWW=www
cp -r $(ROOT_SRCDIR)/conf.d $(PACKAGE_DIR)/xds-server
rm -f $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE)
(cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./xds-server)
-.PHONY: package-all
-package-all:
+# On support Linux for now
+.PHONY: package
+package:
@echo "# Build linux amd64..."
- GOOS=linux GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package
+ GOOS=linux GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile _package
make -f $(ROOT_SRCDIR)/Makefile clean
+.PHONY: package-all
+package-all: package
+
vendor: tools/glide glide.yaml
$(LOCAL_TOOLSDIR)/glide install --strip-vendor
diff --git a/README.md b/README.md
index 7512aba..edac7c4 100644
--- a/README.md
+++ b/README.md
@@ -134,16 +134,16 @@ XDS server is started as a service by Systemd.
/lib/systemd/system/xds-server.service
```
-This Systemd service starts a bash script `/usr/local/bin/xds-server-start.sh`
+This Systemd service starts a bash script `/opt/AGL/xds/server/xds-server-start.sh`
If you needed you can change default setting by defining specific environment
variables in `/etc/default/xds-server`.
-For example to control log level, just set LOGLEVEL env variable knowing that
+For example to control log level, just set LOG_LEVEL env variable knowing that
supported *level* are: panic, fatal, error, warn, info, debug.
```bash
seb@laptop ~$ ssh -p 2222 devel@localhost
-devel@docker ~$ echo 'LOGLEVEL=debug' | sudo tee --append /etc/default/xds-server > /dev/null
+devel@docker ~$ echo 'LOG_LEVEL=debug' | sudo tee --append /etc/default/xds-server > /dev/null
devel@docker ~$ sudo systemctl restart xds-server.service
devel@docker ~$ tail -f /tmp/xds-server/logs/xds-server.log
```
@@ -162,10 +162,10 @@ Intel corei7-64:
seb@laptop ~$ ssh -p 2222 devel@localhost
# Install ARM64 SDK (automatic download)
-devel@docker ~$ sudo /usr/local/bin/xds-utils/install-agl-sdks.sh --arch aarch64
+devel@docker ~$ sudo /opt/AGL/xds/server/xds-utils/install-agl-sdks.sh --arch aarch64
# Install Intel corei7-64 SDK (using an SDK tarball that has been built or downloaded manually)
-devel@docker ~$ sudo /usr/local/bin/xds-utils/install-agl-sdks.sh --arch corei7-64 --file /tmp/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-
+devel@docker ~$ sudo /opt/AGL/xds/server/xds-utils/install-agl-sdks.sh --arch corei7-64 --file /tmp/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain-
3.99.1+snapshot.sh
```
@@ -234,7 +234,7 @@ Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Make
make all
```
-And to install `xds-server` (by default in `/usr/local/bin`):
+And to install `xds-server` (by default in `/opt/AGL/xds/server`):
```bash
make install
@@ -266,8 +266,8 @@ make build FLAVOUR=xds
Here is the logic to determine which `config.json` file will be used:
1. from command line option: `--config myConfig.json`
-1. `$HOME/.xds/config.json` file
-1. `<current dir>/config.json` file
+1. `$HOME/.xds-server/config.json` file
+1. `/etc/xds-server/config.json` file
1. `<xds-server executable dir>/config.json` file
Supported fields in configuration file are (all fields are optional and example
@@ -287,12 +287,12 @@ below corresponds to the default values):
{
"httpPort": 8000,
"webAppDir": "webapp/dist",
- "shareRootDir": "${HOME}/.xds/projects",
+ "shareRootDir": "${HOME}/.xds-server/projects",
"logsDir": "/tmp/logs",
"sdkRootDir": "/xdt/sdk",
"syncthing": {
"binDir": "./bin",
- "home": "${HOME}/.xds/syncthing-config",
+ "home": "${HOME}/.xds-server/syncthing-config",
"gui-address": "http://localhost:8384",
"gui-apikey": "123456789",
}
diff --git a/conf.d/etc/default/xds-server b/conf.d/etc/default/xds-server
index 858530d..0818638 100644
--- a/conf.d/etc/default/xds-server
+++ b/conf.d/etc/default/xds-server
@@ -2,10 +2,10 @@
# this file is used for service environment in /lib/systemd/system/xds-server.service
# JSON config file to use
-#APP_CONFIG=/home/devel/.config/xds/server/config.json
+APP_CONFIG=/home/devel/.config/xds/server/config.json
# Logging level (supported levels: panic, fatal, error, warn, info, debug)
-#LOG_LEVEL=info
+LOG_LEVEL=info
# Filename where logs will be redirected (default stdout)
-#LOG_FILENAME=/tmp/xds/logs/xds-server.logs
+LOG_FILENAME=/tmp/xds-server/logs/xds-server.log
diff --git a/conf.d/.config/xds/server/config.json b/conf.d/etc/xds-server/config.json
index 19700cf..02d87bf 100644
--- a/conf.d/.config/xds/server/config.json
+++ b/conf.d/etc/xds-server/config.json
@@ -1,12 +1,11 @@
{
"webAppDir": "www",
"httpPort": "8000",
- "shareRootDir": "${HOME}/.xds/share",
- "logsDir": "/tmp/xds-server/logs",
+ "shareRootDir": "${HOME}/.xds-server/projects",
"sdkRootDir": "/xdt/sdk",
"syncthing": {
"binDir": "",
- "home": "${HOME}/.xds/syncthing-config",
+ "home": "${HOME}/.xds-server/syncthing-config",
"gui-address": "http://localhost:8384"
}
}
diff --git a/conf.d/service/xds-server.service b/conf.d/service/xds-server.service
index e938d3f..6da12c0 100644
--- a/conf.d/service/xds-server.service
+++ b/conf.d/service/xds-server.service
@@ -5,7 +5,8 @@ Description=XDS Server
User=devel
Type=forking
EnvironmentFile=-/etc/default/xds-server
-ExecStart=/opt/AGL/xds/xds-server-start.sh
+ExecStart=/opt/AGL/xds/server/xds-server-start.sh
+ExecStop=/opt/AGL/xds/server/xds-server-stop.sh
[Install]
WantedBy=multi-user.target
diff --git a/config.json.in b/config.json.in
index 274c7b4..6116439 100644
--- a/config.json.in
+++ b/config.json.in
@@ -1,12 +1,12 @@
{
- "webAppDir": "webapp/dist",
+ "webAppDir": "www",
"httpPort": "8000",
- "shareRootDir": "${HOME}/.xds/share",
+ "shareRootDir": "${HOME}/.xds-server/projects",
"logsDir": "/tmp/xds-server/logs",
"sdkRootDir": "/xdt/sdk",
"syncthing": {
"binDir": "./bin",
- "home": "${HOME}/.xds/syncthing-config",
+ "home": "${HOME}/.xds-server/syncthing-config",
"gui-address": "http://localhost:8384"
}
}
diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go
index 5086994..c76db5a 100644
--- a/lib/syncthing/st.go
+++ b/lib/syncthing/st.go
@@ -114,7 +114,7 @@ func NewSyncThing(conf *xdsconfig.Config, log *logrus.Logger) *SyncThing {
if binDir == "" {
if binDir, err = filepath.Abs(filepath.Dir(os.Args[0])); err != nil {
- binDir = "/usr/local/bin"
+ binDir = "/opt/AGL/bin"
}
}
diff --git a/lib/webserver/server.go b/lib/webserver/server.go
index 8639b66..a2fdf6f 100644
--- a/lib/webserver/server.go
+++ b/lib/webserver/server.go
@@ -116,7 +116,9 @@ func (s *Server) Serve() error {
// Serve in the background
serveError := make(chan error, 1)
go func() {
- fmt.Printf("Web Server running on localhost:%s ...\n", s.cfg.FileConf.HTTPPort)
+ msg := fmt.Sprintf("Web Server running on localhost:%s ...\n", s.cfg.FileConf.HTTPPort)
+ s.log.Infof(msg)
+ fmt.Printf(msg)
serveError <- http.ListenAndServe(":"+s.cfg.FileConf.HTTPPort, s.router)
}()
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go
index 82ca97f..53d1639 100644
--- a/lib/xdsconfig/config.go
+++ b/lib/xdsconfig/config.go
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
+ "path/filepath"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
@@ -62,6 +63,7 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
ShareRootDir: DefaultShareDir,
SdkRootDir: DefaultSdkRootDir,
HTTPPort: DefaultPort,
+ LogsDir: "",
},
Log: log,
}
@@ -80,11 +82,35 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
}
c.Log.Infoln("Share root directory: ", c.FileConf.ShareRootDir)
+ // Where Logs are redirected:
+ // default 'stdout' (logfile option default value)
+ // else use file (or filepath) set by --logfile option
+ // that may be overwritten by LogsDir field of config file
+ logF := c.Options.LogFile
+ logD := c.FileConf.LogsDir
+ if logF != "stdout" {
+ if logD != "" {
+ lf := filepath.Base(logF)
+ if lf == "" || lf == "." {
+ lf = "xds-server.log"
+ }
+ logF = filepath.Join(logD, lf)
+ } else {
+ logD = filepath.Dir(logF)
+ }
+ }
+ if logD == "" || logD == "." {
+ logD = "/tmp/xds/logs"
+ }
+ c.Options.LogFile = logF
+ c.FileConf.LogsDir = logD
+
if c.FileConf.LogsDir != "" && !common.Exists(c.FileConf.LogsDir) {
if err := os.MkdirAll(c.FileConf.LogsDir, 0770); err != nil {
return nil, fmt.Errorf("Cannot create logs dir: %v", err)
}
}
+ c.Log.Infoln("Logs file: ", c.Options.LogFile)
c.Log.Infoln("Logs directory: ", c.FileConf.LogsDir)
return &c, nil
diff --git a/lib/xdsconfig/fileconfig.go b/lib/xdsconfig/fileconfig.go
index 2dbf884..a0724af 100644
--- a/lib/xdsconfig/fileconfig.go
+++ b/lib/xdsconfig/fileconfig.go
@@ -13,7 +13,7 @@ import (
const (
// ConfigDir Directory in user HOME directory where xds config will be saved
- ConfigDir = ".xds"
+ ConfigDir = ".xds-server"
// GlobalConfigFilename Global config filename
GlobalConfigFilename = "config.json"
// FoldersConfigFilename Folders config filename
@@ -42,8 +42,8 @@ type FileConfig struct {
// readGlobalConfig reads configuration from a config file.
// Order to determine which config file is used:
// 1/ from command line option: "--config myConfig.json"
-// 2/ $HOME/.xds/config.json file
-// 3/ <current_dir>/config.json file
+// 2/ $HOME/.xds-server/config.json file
+// 3/ /etc/xds-server/config.json file
// 4/ <xds-server executable dir>/config.json file
func readGlobalConfig(c *Config, confFile string) error {
@@ -55,14 +55,20 @@ func readGlobalConfig(c *Config, confFile string) error {
searchIn = append(searchIn, path.Join(usr.HomeDir, ConfigDir,
GlobalConfigFilename))
}
- cwd, err := os.Getwd()
- if err == nil {
- searchIn = append(searchIn, path.Join(cwd, "config.json"))
- }
- exePath, err := filepath.Abs(filepath.Dir(os.Args[0]))
+
+ searchIn = append(searchIn, "/etc/xds-server/config.json")
+
+ exePath := os.Args[0]
+ exeAbsPath, err := filepath.Abs(os.Args[0])
if err == nil {
- searchIn = append(searchIn, path.Join(exePath, "config.json"))
+ exePath, err = filepath.EvalSymlinks(exeAbsPath)
+ if err == nil {
+ exePath = filepath.Dir(exePath)
+ } else {
+ exePath = filepath.Dir(exeAbsPath)
+ }
}
+ searchIn = append(searchIn, path.Join(exePath, "config.json"))
var cFile *string
for _, p := range searchIn {
@@ -75,7 +81,6 @@ func readGlobalConfig(c *Config, confFile string) error {
// No config file found
return nil
}
-
c.Log.Infof("Use config file: %s", *cFile)
// TODO move on viper package to support comments in JSON and also
@@ -117,12 +122,17 @@ func readGlobalConfig(c *Config, confFile string) error {
if fCfg.HTTPPort == "" {
fCfg.HTTPPort = c.FileConf.HTTPPort
}
+ if fCfg.LogsDir == "" {
+ fCfg.LogsDir = c.FileConf.LogsDir
+ }
// Resolve webapp dir (support relative or full path)
fCfg.WebAppDir = strings.Trim(fCfg.WebAppDir, " ")
if !strings.HasPrefix(fCfg.WebAppDir, "/") && exePath != "" {
+ cwd, _ := os.Getwd()
+
// Check first from current directory
- for _, rootD := range []string{cwd, exePath} {
+ for _, rootD := range []string{exePath, cwd} {
ff := path.Join(rootD, fCfg.WebAppDir, "index.html")
if common.Exists(ff) {
fCfg.WebAppDir = path.Join(rootD, fCfg.WebAppDir)
diff --git a/main.go b/main.go
index 4fd49e9..a51a7a8 100644
--- a/main.go
+++ b/main.go
@@ -101,6 +101,14 @@ func handlerSigTerm(ctx *Context) {
os.Exit(0)
}
+// Helper function to log message on both stdout and logger
+func logPrint(ctx *Context, format string, args ...interface{}) {
+ fmt.Printf(format, args...)
+ if ctx.Log.Out != os.Stdout {
+ ctx.Log.Infof(format, args...)
+ }
+}
+
// XDS Server application main routine
func xdsApp(cliCtx *cli.Context) error {
var err error
@@ -115,36 +123,31 @@ func xdsApp(cliCtx *cli.Context) error {
}
ctx.Config = cfg
- // Logs redirected into a file when logsDir is set
- logfilename := cliCtx.GlobalString("logfile")
+ // Logs redirected into a file when logfile option or logsDir config is set
ctx.Config.LogVerboseOut = os.Stderr
if ctx.Config.FileConf.LogsDir != "" {
- if logfilename != "stdout" {
- if logfilename == "" {
- logfilename = "xds-server.log"
- }
- // is it an absolute path ?
- logFile := logfilename
- if logfilename[0] == '.' || logfilename[0] != '/' {
- logFile = filepath.Join(ctx.Config.FileConf.LogsDir, logfilename)
- }
- fmt.Printf("Logging file: %s\n", logFile)
+ if ctx.Config.Options.LogFile != "stdout" {
+ logFile := ctx.Config.Options.LogFile
+
fdL, err := os.OpenFile(logFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
msgErr := fmt.Sprintf("Cannot create log file %s", logFile)
return cli.NewExitError(msgErr, int(syscall.EPERM))
}
ctx.Log.Out = fdL
+
+ logPrint(ctx, "Logging file: %s\n", logFile)
}
logFileHTTPReq := filepath.Join(ctx.Config.FileConf.LogsDir, "xds-server-verbose.log")
- fmt.Printf("Logging file for HTTP requests: %s\n", logFileHTTPReq)
fdLH, err := os.OpenFile(logFileHTTPReq, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
msgErr := fmt.Sprintf("Cannot create log file %s", logFileHTTPReq)
return cli.NewExitError(msgErr, int(syscall.EPERM))
}
ctx.Config.LogVerboseOut = fdLH
+
+ logPrint(ctx, "Logging file for HTTP requests: %s\n", logFileHTTPReq)
}
// Create syncthing instance when section "syncthing" is present in config.json
@@ -159,17 +162,17 @@ func xdsApp(cliCtx *cli.Context) error {
if err != nil {
return cli.NewExitError(err, -4)
}
- fmt.Printf("Syncthing started (PID %d)\n", ctx.SThgCmd.Process.Pid)
+ logPrint(ctx, "Syncthing started (PID %d)\n", ctx.SThgCmd.Process.Pid)
ctx.Log.Infof("Starting Syncthing-inotify...")
ctx.SThgInotCmd, err = ctx.SThg.StartInotify()
if err != nil {
return cli.NewExitError(err, -4)
}
- fmt.Printf("Syncthing-inotify started (PID %d)\n", ctx.SThgInotCmd.Process.Pid)
+ logPrint(ctx, "Syncthing-inotify started (PID %d)\n", ctx.SThgInotCmd.Process.Pid)
// Establish connection with local Syncthing (retry if connection fail)
- fmt.Printf("Establishing connection with Syncthing...\n")
+ logPrint(ctx, "Establishing connection with Syncthing...\n")
time.Sleep(2 * time.Second)
maxRetry := 30
retry := maxRetry
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}"