#!/usr/bin/pagsh.openafs # -*- Shell-Script -*- # # Usage: # # run-in-pagsh name command [arguments] ... # # The first argument, `name', is a short description of the program to # call, without any spaces. It is used for making a PID file, which # ensures that only one instance of your command is running. # # Example: # # run-in-pagsh interchange ~/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 "$2"; then echo "Error: not enough arguments." echo "Usage: run-in-pagsh name command [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/$1.pid # The command to run. shift 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"` k5start -qtU -f "$KTAB" -- 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