summaryrefslogtreecommitdiff
path: root/script/with-metanews
diff options
context:
space:
mode:
Diffstat (limited to 'script/with-metanews')
-rwxr-xr-xscript/with-metanews24
1 files changed, 24 insertions, 0 deletions
diff --git a/script/with-metanews b/script/with-metanews
new file mode 100755
index 0000000..7d1e8cc
--- /dev/null
+++ b/script/with-metanews
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+if [[ -z "$METANEWS_LOG" ]]; then
+ METANEWS_LOG="/dev/null"
+fi
+
+$(dirname $0)/metanews >>"$METANEWS_LOG" 2>/dev/null &
+serverpid="$!"
+
+while [[ ! -e ~/.metanews-server ]]; do
+ sleep 0.1
+done
+addr="$(cat ~/.metanews-server)"
+
+function cleanup {
+ rm ~/.metanews-server
+ tail --pid $serverpid -f /dev/null
+}
+trap cleanup EXIT
+
+env \
+ NNTPSERVER="${addr%%:*}" \
+ NNTPPORT="${addr##*:}" \
+ "$@"