aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-10-20 14:30:33 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-10-20 14:36:43 +0200
commit2d90eac319979dba64371258b30e61e77a15db7d (patch)
tree3b89b5efcf4b4476852a9944a12d5c9a6e3502fd
parent77ab312b87324090ec6cb619d11f792b53fdddbd (diff)
parent7843cfd903cf7770df81c91193068900fb563e59 (diff)
Merge branch 'master' into wipv0.3.0-rc1
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--Makefile18
-rw-r--r--conf.d/etc/default/xds-agent5
-rw-r--r--conf.d/etc/profile.d/xds-agent.sh4
-rw-r--r--conf.d/etc/xds-agent/config.json (renamed from agent-config.json.in)2
-rw-r--r--conf.d/usr/lib/systemd/user/xds-agent.service (renamed from xds-agent.service)2
-rw-r--r--lib/syncthing/st.go2
-rw-r--r--lib/xdsconfig/configfile.go5
-rwxr-xr-xscripts/get-syncthing.sh4
-rwxr-xr-xscripts/install.sh44
9 files changed, 71 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 3329ead..db4d874 100644
--- a/Makefile
+++ b/Makefile
@@ -81,7 +81,7 @@ build: vendor xds webapp
xds: scripts tools/syncthing/copytobin
@echo "### Build XDS agent (version $(VERSION), subversion $(SUB_VERSION)) - $(BUILD_MODE)";
- @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent$(EXT) -ldflags "$(GORELEASE) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" .
+ @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent$(EXT) -ldflags "$(GO_LDFLAGS) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" .
test: tools/glide
go test --race $(shell $(LOCAL_TOOLSDIR)/glide novendor)
@@ -117,14 +117,19 @@ webapp/install:
@if [ -d ${DESTDIR}/usr/local/etc ]; then rm -rf ${DESTDIR}/usr; fi
.PHONY: install
-install: all
- mkdir -p $(DESTDIR) && cp $(LOCAL_BINDIR)/* $(DESTDIR)
- mkdir -p $(DESTDIR_WWW) && cp -a webapp/dist/* $(DESTDIR_WWW)
+install:
+ @test -e $(LOCAL_BINDIR)/xds-agent$(EXT) || { echo "Please execute first: make all\n"; exit 1; }
+ @test -e $(LOCAL_BINDIR)/syncthing$(EXT) -a -e $(LOCAL_BINDIR)/syncthing-inotify$(EXT) || { echo "Please execute first: make all\n"; exit 1; }
+ export DESTDIR=$(DESTDIR) && export DESTDIR_WWW=$(DESTDIR_WWW) && $(ROOT_SRCDIR)/scripts/install.sh
+
+.PHONY: uninstall
+uninstall:
+ export DESTDIR=$(DESTDIR) && export DESTDIR_WWW=$(DESTDIR_WWW) && $(ROOT_SRCDIR)/scripts/install.sh uninstall
package: clean tools/syncthing vendor build
- @mkdir -p $(PACKAGE_DIR)/xds-agent
- @cp agent-config.json.in $(PACKAGE_DIR)/xds-agent/agent-config.json
+ @mkdir -p $(PACKAGE_DIR)/xds-agent $(PACKAGE_DIR)/scripts
@cp -a $(LOCAL_BINDIR)/* $(PACKAGE_DIR)/xds-agent
+ @cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/xds-agent
cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./xds-agent
.PHONY: package-all
@@ -174,6 +179,7 @@ help:
@echo " build"
@echo " package"
@echo " install"
+ @echo " uninstall"
@echo " clean"
@echo " distclean"
@echo ""
diff --git a/conf.d/etc/default/xds-agent b/conf.d/etc/default/xds-agent
new file mode 100644
index 0000000..93d56cb
--- /dev/null
+++ b/conf.d/etc/default/xds-agent
@@ -0,0 +1,5 @@
+# defaults file for XDS Agent
+# this file is used for service environment in /usr/lib/systemd/user/xds-agent.service
+
+# Logging level (supported levels: panic, fatal, error, warn, info, debug)
+LOG_LEVEL=info
diff --git a/conf.d/etc/profile.d/xds-agent.sh b/conf.d/etc/profile.d/xds-agent.sh
new file mode 100644
index 0000000..78eff4f
--- /dev/null
+++ b/conf.d/etc/profile.d/xds-agent.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#---------- AGL xds-agent tool options Start ---------"
+[ ":${PATH}:" != *":%%XDS_INSTALL_BIN_DIR%%:"* ] && export PATH=%%XDS_INSTALL_BIN_DIR%%:${PATH}
diff --git a/agent-config.json.in b/conf.d/etc/xds-agent/config.json
index e8599cb..7c7d7cb 100644
--- a/agent-config.json.in
+++ b/conf.d/etc/xds-agent/config.json
@@ -9,7 +9,7 @@
],
"syncthing": {
"home": "${HOME}/.xds/agent/syncthing-config",
- "gui-address": "http://localhost:8384",
+ "gui-address": "http://localhost:8386",
"gui-apikey": "1234abcezam"
}
}
diff --git a/xds-agent.service b/conf.d/usr/lib/systemd/user/xds-agent.service
index 66788dc..1fd038b 100644
--- a/xds-agent.service
+++ b/conf.d/usr/lib/systemd/user/xds-agent.service
@@ -2,7 +2,7 @@
Description=XDS Agent
[Service]
-User=claneys
+EnvironmentFile=-/etc/default/xds-agent
ExecStart=/opt/AGL/xds/agent/xds-agent &
[Install]
diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go
index 924f407..031a2ac 100644
--- a/lib/syncthing/st.go
+++ b/lib/syncthing/st.go
@@ -98,7 +98,7 @@ func NewSyncThing(conf *xdsconfig.Config, log *logrus.Logger) *SyncThing {
}
if url == "" {
- url = "http://localhost:8384"
+ url = "http://localhost:8386"
}
if url[0:7] != "http://" {
url = "http://" + url
diff --git a/lib/xdsconfig/configfile.go b/lib/xdsconfig/configfile.go
index 6eaaf6a..e3737f4 100644
--- a/lib/xdsconfig/configfile.go
+++ b/lib/xdsconfig/configfile.go
@@ -38,8 +38,7 @@ type FileConfig struct {
// Order to determine which config file is used:
// 1/ from command line option: "--config myConfig.json"
// 2/ $HOME/.xds/agent/agent-config.json file
-// 3/ <current_dir>/agent-config.json file
-// 4/ <executable dir>/agent-config.json file
+// 3/ /etc/xds-agent/config.json file
func readGlobalConfig(c *Config, confFile string) error {
@@ -53,8 +52,6 @@ func readGlobalConfig(c *Config, confFile string) error {
searchIn = append(searchIn, "/etc/xds-agent/agent-config.json")
- searchIn = append(searchIn, path.Join(common.GetExePath(), "agent-config.json"))
-
var cFile *string
for _, p := range searchIn {
if _, err := os.Stat(p); err == nil {
diff --git a/scripts/get-syncthing.sh b/scripts/get-syncthing.sh
index 3455122..772c09a 100755
--- a/scripts/get-syncthing.sh
+++ b/scripts/get-syncthing.sh
@@ -43,7 +43,7 @@ if [ "$?" != 0 ]; then
exit 1
fi
-gpg -q --keyserver pool.sks-keyservers.net --recv-keys 37C84554E7E0A261E4F76E1ED26E6ED000654A3E || exit 1
+${GPG} -q --keyserver pool.sks-keyservers.net --recv-keys 37C84554E7E0A261E4F76E1ED26E6ED000654A3E || exit 1
tarball="syncthing-${GOOS_ST}-${GOARCH}-v${SYNCTHING_VERSION}.${TB_EXT}" \
&& curl -sfSL "https://github.com/syncthing/syncthing/releases/download/v${SYNCTHING_VERSION}/${tarball}" -O \
@@ -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}"
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 0000000..357c5e8
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Install XDS agent as a user systemd service
+
+DESTDIR=${DESTDIR:-/opt/AGL/xds/agent}
+DESTDIR_WWW=${DESTDIR_WWW:-${DESTDIR}/www}
+
+ROOT_SRCDIR=$(cd $(dirname "$0")/.. && pwd)
+
+install() {
+ mkdir -p ${DESTDIR} && cp ${ROOT_SRCDIR}/bin/* ${DESTDIR} || exit 1
+ mkdir -p ${DESTDIR_WWW} && cp -a ${ROOT_SRCDIR}/webapp/dist/* ${DESTDIR_WWW} || exit 1
+
+ cp ${ROOT_SRCDIR}/conf.d/etc/xds-agent /etc/ || exit 1
+ cp ${ROOT_SRCDIR}/conf.d/etc/default/xds-agent /etc/default/ || exit 1
+
+ FILE=/etc/profile.d/xds-agent.sh
+ sed -e "s;%%XDS_INSTALL_BIN_DIR%%;${DESTDIR};g" ${ROOT_SRCDIR}/conf.d/${FILE} > ${FILE} || exit 1
+
+ FILE=/usr/lib/systemd/user/xds-agent.service
+ sed -e "s;/opt/AGL/xds/agent;${DESTDIR};g" ${ROOT_SRCDIR}/conf.d/${FILE} > ${FILE} || exit 1
+
+ echo ""
+ echo "To enable xds-agent service, execute: systemctl --user enable xds-agent"
+ echo "and to start xds-agent service, execute: systemctl --user start xds-agent"
+}
+
+uninstall() {
+ rm -rf "${DESTDIR}"
+ rm -f /etc/xds-agent /etc/profile.d/xds-agent.sh /usr/lib/systemd/user/xds-agent.service
+}
+
+if [ "$1" == "uninstall" ]; then
+ echo -n "Are-you sure you want to remove ${DESTDIR} [y/n]? "
+ read answer
+ if [ "${answer}" = "y" ]; then
+ uninstall
+ echo "xds-agent sucessfully uninstalled."
+ else
+ echo "Uninstall canceled."
+ fi
+else
+ install
+fi