aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-07-24 17:25:31 +0200
committerEddy Pedroni <epedroni@pm.me>2025-07-24 17:27:09 +0200
commit8d3dfa11baa8b2be32e0a9d31575469e1a7037b8 (patch)
treeacb766d74b925f8fb59325919b08fcb42148f104
parent7f85c4bbdbf52cddcf3be7b39c7d645c7fe80388 (diff)
Add deployment files
-rw-r--r--Makefile17
-rw-r--r--daemon/Makefile1
-rw-r--r--deployment/midi-router.service10
-rw-r--r--deployment/start-daemon.sh13
4 files changed, 41 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e0bd992
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+build-daemon:
+ cd daemon && make
+
+install: deployment/midi-router.service deployment/start-daemon.sh
+ mkdir -p ~/.config/systemd/user
+ install -o eddy -g eddy -m 644 deployment/midi-router.service ~/.config/systemd/user
+ chmod 755 deployment/start-daemon.sh
+ systemctl --user daemon-reload
+ systemctl --user enable midi-router.service
+ systemctl --user restart midi-router.service
+
+uninstall:
+ systemctl --user disable --now midi-router.service
+ rm ~/.config/systemd/user/midi-router.service
+ systemctl --user daemon-reload
+
+.PHONY: build-daemon install uninstall
diff --git a/daemon/Makefile b/daemon/Makefile
index 4b08c32..c42a690 100644
--- a/daemon/Makefile
+++ b/daemon/Makefile
@@ -1,5 +1,6 @@
TARGET_EXEC := midi-router-daemon
+CXX := clang++
BUILD_DIR := ./build
SRC_DIRS := ./src
diff --git a/deployment/midi-router.service b/deployment/midi-router.service
new file mode 100644
index 0000000..3488f3e
--- /dev/null
+++ b/deployment/midi-router.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=MIDI router daemon
+After=network-online.target sound.target
+
+[Service]
+WorkingDirectory=/home/eddy/git/midi-router
+ExecStart=/home/eddy/git/midi-router/deployment/start-daemon.sh
+
+[Install]
+WantedBy=default.target
diff --git a/deployment/start-daemon.sh b/deployment/start-daemon.sh
new file mode 100644
index 0000000..1021fa5
--- /dev/null
+++ b/deployment/start-daemon.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/bash
+
+# Wait until git server is reachable
+until ping -c1 git.0xf7.com >/dev/null 2>&1; do :; done
+
+# Get latest version
+git pull
+
+# Build daemon
+make build-daemon
+
+# Start
+./daemon/build/midi-router-daemon