summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-02-09 16:59:15 +0100
committerGuido Günther <agx@sigxcpu.org>2017-02-09 17:15:40 +0100
commitc52a81288630c53b4bbefcb15bfd4e8868cc5163 (patch)
treef220df3484c5a8dedaa0195523bda4bacdca66a8
parent48ca448bfca0c23ba44c3a8137610f81d546ae61 (diff)
Add systemd user unitHEADmaster
We use /bin/sh so we have an absolute path
-rw-r--r--Makefile13
-rw-r--r--README.mdwn8
-rw-r--r--priv/simplec.service10
-rwxr-xr-xsimplec10
4 files changed, 39 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 33198e9..a50d917 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
ERL ?= erl
APP := simplec
+USER_UNITS := ~/.config/systemd/user/
+SERVICE := $(APP).service
.PHONY: deps
@@ -26,6 +28,17 @@ test: all
tags:
find . -name "*.[he]rl" -print | etags -
+install_user: test
+ cp priv/$(SERVICE) $(USER_UNITS)/$(SERVICE)
+ mkdir -p ~/bin/
+ ln -s $$(realpath .)/$(APP) ~/bin/$(APP)
+ systemctl --user enable $(SERVICE)
+
+uninstall_user:
+ systemctl --user stop $(SERVICE)
+ systemctl --user disable $(SERVICE)
+ rm -f $(USER_UNITS)/$(SERVICE) ~/bin/$(APP)
+
DEPSOLVER_PLT=$(CURDIR)/.depsolver_plt
$(DEPSOLVER_PLT):
dialyzer --output_plt $(DEPSOLVER_PLT) --build_plt \
diff --git a/README.mdwn b/README.mdwn
index 8da725c..186b6af 100644
--- a/README.mdwn
+++ b/README.mdwn
@@ -7,3 +7,11 @@ It also prints the vm names and IPs to stdout for easy c'n'p.
To build and run do a:
make && make && ./simplec
+
+If you want to install it as a systemd user service for the current user use:
+
+ make install_user
+
+and to get rid of it again use:
+
+ make uninstall_user
diff --git a/priv/simplec.service b/priv/simplec.service
new file mode 100644
index 0000000..2a654ab
--- /dev/null
+++ b/priv/simplec.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Simplec: simple vm interface
+
+[Service]
+Type=simple
+ExecStart=/bin/sh -c "exec ${HOME}/bin/simplec"
+Restart=always
+
+[Install]
+WantedBy=default.target
diff --git a/simplec b/simplec
index ca544e8..d2d5480 100755
--- a/simplec
+++ b/simplec
@@ -1,3 +1,9 @@
#!/bin/sh
-`dirname $0`
-exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s simplec
+BIN=$(realpath $0)
+cd $(dirname $BIN)
+
+if [ ! -t 1 ]; then
+ ARGS=-noinput
+fi
+
+exec erl $ARGS -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s simplec