run-in-pagsh: New script to run something in a PAG
authormwolson_admin <mwolson_admin@mire.hcoop.net>
Sun, 28 Oct 2007 22:42:17 +0000 (18:42 -0400)
committermwolson_admin <mwolson_admin@mire.hcoop.net>
Sun, 28 Oct 2007 22:42:17 +0000 (18:42 -0400)
run-in-pagsh [new file with mode: 0755]

diff --git a/run-in-pagsh b/run-in-pagsh
new file mode 100755 (executable)
index 0000000..80176f4
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/pagsh.openafs
+#
+# Usage:
+#
+#    NAME=name run-in-pagsh command arguments ...
+#
+# Example:
+#
+#    NAME=interchange run-in-pagsh ~/interchange/bin/interchange
+#
+# Make sure that the ~/.run directory exists and is writable.
+# See http://wiki2.hcoop.net/MemberManual/RunningUnattendedCommands
+# for instructions on how to accomplish this.
+
+# Sanity checks
+if test -z "$NAME"; then
+    echo "Error: you must set the NAME environment variable before" \
+        "running this script."
+    exit 1
+elif test -z "$1"; then
+    echo "Error: you must provide the command to run and its arguments."
+    exit 1
+elif test ! -d "~/.run"; then
+    echo "Error: the ~/.run directory must exist before running this script."
+    exit 1
+fi
+
+# Use a different PID file for each program.
+K5PID=~/.run/${NAME}.pid
+
+# The command to run.
+CMD="$*"
+
+# Your keytab file.
+KTAB=/etc/keytabs/user.daemon/$USER
+
+# Terminate current k5start process, if one is running.
+if test -f "$K5PID"; then
+    kill `cat -- "$K5PID"`
+    rm -f "$K5PID"
+fi
+
+# Start fresh k5start daemon which will be refreshing tickets every 540 min
+/usr/bin/k5start -U -b -K 540 -t -p "$K5PID" -f "$KTAB"
+
+# Run actual service with arguments as provided on command line
+$CMD