File google-address-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:    google-address-manager
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: Manage GCE address manager
# Description:       The address manager handles network configuration in GCE
### 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

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

. /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() {
    /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"
}

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