From: Amélia Coutard-Sander <git@ameliathe1st.gay>
Date: Mon, 25 Nov 2024 21:20:46 +0000 (+0100)
Subject: Basic daemon
X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=e80229df0bbc56910ae49874981ac7420b6816b6;p=git-over-gnunet.git

Basic daemon
---

diff --git a/daemon.sh b/daemon.sh
new file mode 100755
index 0000000..ac6e7d7
--- /dev/null
+++ b/daemon.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+mktempfifo() {
+	name="$(mktemp -u)"
+	mkfifo "$name" || mktempfifo
+}
+
+if test -z $1 || test -z $2 || ! test -z $3; then
+	echo >&2 "Usage: $0 <service> <passphrase>"
+	exit 1
+fi
+
+service="$1"
+passphrase="$2"
+
+echo >&2 "Running $service on port $passphrase-git-$service."
+
+mktempfifo
+while < "$name" gnunet-cadet -o "$passphrase-git-$service" | git "$service" . > "$name"; test 130 != "$?"; do
+	rm "$name"
+	mktempfifo
+done
+
+rm $name
+
+echo >&2 "Terminating $service on port $passphrase-$service."