2ad9279
#!/bin/sh
2ad9279
#
2ad9279
# myproxy-server - Server for X.509 Public Key Infrastructure (PKI) security credentials
2ad9279
#
2ad9279
# chkconfig: - 55 25
2ad9279
# description:  Server for X.509 Public Key Infrastructure (PKI) security credentials
2ad9279
#
2ad9279
### BEGIN INIT INFO
2ad9279
# Provides: myproxy-server
2ad9279
# Required-Start:  $local_fs $network $syslog
2ad9279
# Required-Stop:  $local_fs $syslog
2ad9279
# Should-Start:  $syslog
2ad9279
# Should-Stop:  $network $syslog
2ad9279
# Default-Stop:
2ad9279
# Default-Start:
2ad9279
# Short-Description: Startup the MyProxy server daemon
2ad9279
# Description: Server for X.509 Public Key Infrastructure (PKI) security credentials
2ad9279
### END INIT INFO
2ad9279
2ad9279
# Source function library.
2ad9279
. /etc/rc.d/init.d/functions
2ad9279
2ad9279
exec="/usr/sbin/myproxy-server"
2ad9279
prog=$(basename $exec)
2ad9279
2ad9279
# Defaults
2ad9279
MYPROXY_USER=myproxy
2ad9279
MYPROXY_OPTIONS="-s /var/lib/myproxy"
2ad9279
X509_USER_CERT=/etc/grid-security/myproxy/hostcert.pem
2ad9279
X509_USER_KEY=/etc/grid-security/myproxy/hostkey.pem
2ad9279
2ad9279
# Override defaults here.
2ad9279
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
2ad9279
2ad9279
# A few sanity checks 
2ad9279
[ ! -r $X509_USER_KEY ]  && echo -n "$prog: No hostkey file"  && failure && echo && exit 5
2ad9279
[ ! -r $X509_USER_CERT ] && echo -n "$prog: No hostcert file" && failure && echo && exit 5
2ad9279
2ad9279
lockfile=/var/lock/subsys/$prog
2ad9279
2ad9279
2ad9279
start() {
03d6121
    status $prog > /dev/null && echo -n $"$prog already running: " && success  && echo && exit 0
2ad9279
    echo -n $"Starting $prog: "
2ad9279
    daemon --user $MYPROXY_USER X509_USER_CERT=$X509_USER_CERT X509_USER_KEY=$X509_USER_KEY $exec $MYPROXY_OPTIONS
2ad9279
    retval=$?
2ad9279
    echo
2ad9279
    [ $retval -eq 0 ] && touch $lockfile
2ad9279
    return $retval
2ad9279
}
2ad9279
2ad9279
stop() {
2ad9279
    echo -n $"Stopping $prog: "
2ad9279
    killproc $prog
2ad9279
    retval=$?
2ad9279
    echo
2ad9279
    [ $retval -eq 0 ] && rm -f $lockfile
2ad9279
    return $retval
2ad9279
}
2ad9279
2ad9279
restart() {
2ad9279
    stop
2ad9279
    start
2ad9279
}
2ad9279
2ad9279
case "$1" in
2ad9279
    start|stop|restart)
2ad9279
        $1
2ad9279
        ;;
2ad9279
    force-reload)
2ad9279
        restart
2ad9279
        ;;
2ad9279
    status)
2ad9279
        status $prog
2ad9279
        ;;
2ad9279
    try-restart|condrestart)
2ad9279
        if status $prog >/dev/null ; then
2ad9279
            restart
2ad9279
        fi
2ad9279
	;;
2ad9279
    reload)
2ad9279
        # If config can be reloaded without restarting, implement it here,
2ad9279
        # remove the "exit", and add "reload" to the usage message below.
2ad9279
        # For example:
2ad9279
        status $prog >/dev/null || exit 7
2ad9279
        killproc $prog -HUP
2ad9279
        ;;
2ad9279
    *)
2ad9279
        echo $"Usage: $0 {start|stop|status|restart|reload|try-restart|force-reload}"
2ad9279
        exit 2
2ad9279
esac