File google-accounts-manager.suse of Package google-daemon.3436

#! /bin/sh
# Copyright 2013 SUSE LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.
#
### BEGIN INIT INFO
# Provides:    gce_manage_accounts
# X-Start-Before:    ssh
# Required-Start:    $network
# Required-Stop:     $null
# Default-Start:     2 3 5
# Default-Stop:
# Short-Description: Google Compute Engine accounts manager service
# Description:       This launches the Google Compute Engine accounts manager
#        daemon.
### END INIT INFO

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Google Compute Engine accounts manager service"
NAME=manage_accounts
DAEMON=/usr/share/google/google_daemon/manage_accounts.py
DAEMON_ARGS="--daemon"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/google-manage-accounts

. /etc/rc.status
rc_reset

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

start() {
    # One-shot run prior to daemonizing.
    $DAEMON --interval=-1

    /sbin/startproc -p $PIDFILE $DAEMON $DAEMON_ARGS
}

stop() {
    /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other code
    # that waits for the process to drop all resources that could be
    # needed by services started subsequently.  A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
    [ "$?" = 2 ] && return 2
     # Many daemons don't delete their pidfiles when they exit.
    rm -f $PIDFILE
    return "$RETVAL"
}

reload() {
    /sbin/start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  return 0
}

case "$1" in
    start)
        $1
        rc_status -v
        ;;
    stop)
        $1
        rc_status -v
        ;;
    reload)
        $1
        rc_status -v
        ;;
    restart|force-reload)
        stop
        start
        ;;
    status)
        /sbin/checkproc -p $PIDFILE $DAEMON
        rc_status -v
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|reload|restart|force-reload}"
    exit 3
    ;;
esac
openSUSE Build Service is sponsored by