From: mwolson_admin Date: Sun, 28 Oct 2007 23:01:55 +0000 (-0400) Subject: run-in-pagsh: misc improvements X-Git-Url: http://git.hcoop.net/clinton/scripts.git/commitdiff_plain/92bce8a1d48fc2405ebd14242d221ba697880506 run-in-pagsh: misc improvements - Run rm command in k5start. - Instead of using environment variable NAME, just make it the first argument to the script. - Add Emacs hint for fontifying this as a shell script. --- diff --git a/run-in-pagsh b/run-in-pagsh index 80176f4..f354c0e 100755 --- a/run-in-pagsh +++ b/run-in-pagsh @@ -1,24 +1,26 @@ #!/usr/bin/pagsh.openafs +# -*- Shell-Script -*- # # Usage: # -# NAME=name run-in-pagsh command arguments ... +# 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: # -# NAME=interchange run-in-pagsh ~/interchange/bin/interchange +# 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 "$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." +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." @@ -26,9 +28,10 @@ elif test ! -d "~/.run"; then fi # Use a different PID file for each program. -K5PID=~/.run/${NAME}.pid +K5PID=~/.run/$1.pid # The command to run. +shift CMD="$*" # Your keytab file. @@ -37,7 +40,7 @@ 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" + k5start -qtU -f "$KTAB" -- rm -f "$K5PID" fi # Start fresh k5start daemon which will be refreshing tickets every 540 min