| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# SysV-style boot script for MyProxy |
| 4 |
# |
| 5 |
# chkconfig: 345 99 06 |
| 6 |
# description: MyProxy online credential repository |
| 7 |
|
| 8 |
# Set GLOBUS_LOCATION as appropriate for your installation. |
| 9 |
GLOBUS_LOCATION="" |
| 10 |
export GLOBUS_LOCATION |
| 11 |
|
| 12 |
if [ -z $GLOBUS_LOCATION ]; then |
| 13 |
echo "GLOBUS_LOCATION is not set." |
| 14 |
echo "Please edit $0 to set GLOBUS_LOCATION." |
| 15 |
exit 1 |
| 16 |
fi |
| 17 |
|
| 18 |
if [ -e ${GLOBUS_LOCATION}/share/globus/globus-script-initializer ]; then |
| 19 |
. ${GLOBUS_LOCATION}/share/globus/globus-script-initializer |
| 20 |
elif [ -e ${GLOBUS_LOCATION}/libexec/globus-script-initializer ]; then |
| 21 |
. ${GLOBUS_LOCATION}/libexec/globus-script-initializer |
| 22 |
else |
| 23 |
echo "globus-script-initializer not found in" |
| 24 |
echo "${GLOBUS_LOCATION}/share/globus or" |
| 25 |
echo "${GLOBUS_LOCATION}/libexec." |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
. ${libexecdir}/globus-sh-tools.sh |
| 29 |
|
| 30 |
MYPROXY=${GLOBUS_LOCATION}/sbin/myproxy-server |
| 31 |
PID_FILE=${localstatedir}/myproxy.pid |
| 32 |
|
| 33 |
# Optional server configuration arguments follow. |
| 34 |
# Uncomment and modify to change default settings. |
| 35 |
#LISTEN="-l myserver.mydomain.com" |
| 36 |
#PORT="-p 7512" |
| 37 |
#CONFIG="-c ${GLOBUS_LOCATION}/etc/myproxy-server.config" |
| 38 |
#STORE="-s ${GLOBUS_LOCATION}/var/lib/myproxy" |
| 39 |
#VERBOSE="-verbose" |
| 40 |
|
| 41 |
# By default, the myproxy-server uses /etc/grid-security/hostcert.pem |
| 42 |
# and /etc/grid-security/hostkey.pem. Uncomment and modify the |
| 43 |
# following lines to configure the myproxy-server to find its |
| 44 |
# certificate and key in alternate locations. |
| 45 |
#X509_USER_CERT="/usr/local/etc/myproxycert.pem" |
| 46 |
#X509_USER_KEY="/usr/local/etc/myproxykey.pem" |
| 47 |
#export X509_USER_CERT X509_USER_KEY |
| 48 |
|
| 49 |
do_start() |
| 50 |
{ |
| 51 |
if [ ! -x $MYPROXY ]; then |
| 52 |
echo "$MYPROXY is not executable. Skipping MyProxy startup." |
| 53 |
exit 1 |
| 54 |
fi |
| 55 |
if [ ! -d $localstatedir ]; then |
| 56 |
mkdir -p $localstatedir |
| 57 |
fi |
| 58 |
echo -n "Starting up MyProxy server... " |
| 59 |
$MYPROXY $LISTEN $PORT $CONFIG $STORE $VERBOSE -P $PID_FILE |
| 60 |
if [ $? -eq 0 ]; then |
| 61 |
echo "done." |
| 62 |
else |
| 63 |
echo "Failed to start MyProxy server!" |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
} |
| 67 |
|
| 68 |
do_stop() |
| 69 |
{ |
| 70 |
echo -n "Stopping the MyProxy server... " |
| 71 |
pid=`cat $PID_FILE` |
| 72 |
kill -TERM $pid |
| 73 |
rm -f $PID_FILE |
| 74 |
echo "done." |
| 75 |
} |
| 76 |
|
| 77 |
do_reconfig() |
| 78 |
{ |
| 79 |
echo -n "Reconfiguring the MyProxy server... " |
| 80 |
pid=`cat $PID_FILE` |
| 81 |
kill -HUP $pid |
| 82 |
echo "done." |
| 83 |
} |
| 84 |
|
| 85 |
case "$1" in |
| 86 |
start) |
| 87 |
if [ ! -f $PID_FILE ]; then |
| 88 |
do_start |
| 89 |
else |
| 90 |
pid=`cat $PID_FILE` |
| 91 |
psout=`ps -A | grep $pid | grep -v grep | awk "{if (\\\$1 == $pid) print}"` |
| 92 |
if [ "x$psout" = "x" ]; then |
| 93 |
echo "Found stale myproxy-server pid file... removing it." |
| 94 |
rm -f $PID_FILE |
| 95 |
do_start |
| 96 |
else |
| 97 |
echo "MyProxy server is already running!" |
| 98 |
fi |
| 99 |
fi |
| 100 |
;; |
| 101 |
|
| 102 |
stop) |
| 103 |
if [ -f $PID_FILE ] ; then |
| 104 |
do_stop |
| 105 |
else |
| 106 |
echo "The server's pid file does not exist! Are you sure the server is running?" |
| 107 |
fi |
| 108 |
;; |
| 109 |
|
| 110 |
reconfig) |
| 111 |
if [ -f $PID_FILE ] ; then |
| 112 |
do_reconfig |
| 113 |
else |
| 114 |
echo "The server's pid file does not exist! Are you sure the server is running?" |
| 115 |
fi |
| 116 |
;; |
| 117 |
|
| 118 |
restart) |
| 119 |
$0 stop |
| 120 |
$0 start |
| 121 |
;; |
| 122 |
|
| 123 |
*) |
| 124 |
echo "Usage: $0 (start|stop|restart)" |
| 125 |
exit 1 |
| 126 |
esac |
| 127 |
|
| 128 |
exit 0 |