916bccc8 |
1 | #!/usr/bin/pagsh.openafs |
2 | # |
3 | # Usage: |
4 | # |
5 | # NAME=name run-in-pagsh command arguments ... |
6 | # |
7 | # Example: |
8 | # |
9 | # NAME=interchange run-in-pagsh ~/interchange/bin/interchange |
10 | # |
11 | # Make sure that the ~/.run directory exists and is writable. |
12 | # See http://wiki2.hcoop.net/MemberManual/RunningUnattendedCommands |
13 | # for instructions on how to accomplish this. |
14 | |
15 | # Sanity checks |
16 | if test -z "$NAME"; then |
17 | echo "Error: you must set the NAME environment variable before" \ |
18 | "running this script." |
19 | exit 1 |
20 | elif test -z "$1"; then |
21 | echo "Error: you must provide the command to run and its arguments." |
22 | exit 1 |
23 | elif test ! -d "~/.run"; then |
24 | echo "Error: the ~/.run directory must exist before running this script." |
25 | exit 1 |
26 | fi |
27 | |
28 | # Use a different PID file for each program. |
29 | K5PID=~/.run/${NAME}.pid |
30 | |
31 | # The command to run. |
32 | CMD="$*" |
33 | |
34 | # Your keytab file. |
35 | KTAB=/etc/keytabs/user.daemon/$USER |
36 | |
37 | # Terminate current k5start process, if one is running. |
38 | if test -f "$K5PID"; then |
39 | kill `cat -- "$K5PID"` |
40 | rm -f "$K5PID" |
41 | fi |
42 | |
43 | # Start fresh k5start daemon which will be refreshing tickets every 540 min |
44 | /usr/bin/k5start -U -b -K 540 -t -p "$K5PID" -f "$KTAB" |
45 | |
46 | # Run actual service with arguments as provided on command line |
47 | $CMD |