Blob Blame History Raw
#!/bin/sh

### BEGIN INIT INFO
# Provides:          openstack-swift-account
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Stop:      0 1 6
# Short-Description: Swift account server
# Description:       Account server for swift.
### END INIT INFO

# openstack-swift-account: swift account server
#
# chkconfig: - 98 02
# description: Account server for swift.

. /etc/rc.d/init.d/functions
. /usr/share/openstack-swift/functions

name="account"
subserv="server"
identity="openstack-swift-account"

[ -e "/etc/sysconfig/openstack-swift-$name" ] && . "/etc/sysconfig/openstack-swift-$name"

lockfile="/var/lock/subsys/openstack-swift-$name-$subserv"

start() {
    swift_action "$name" "$subserv" start "$identity"
    retval=$?
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    swift_action "$name" "$subserv" stop "$identity"
    retval=$?
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

shutdown() {
    swift_action "$name" "$subserv" shutdown "$identity"
    retval=$?
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

rh_status() {
    swift_action "$name" "$subserv" status "$identity"
}

rh_status_q() {
    rh_status &> /dev/null
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    shutdown)
        $1
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|shutdown|condrestart|try-restart}"
        exit 2
esac
exit $?