File google-shutdown-scripts.suse of Package google-compute-engine.5968

#!/bin/sh
# Copyright 2016 Google Inc. All Rights Reserved.
# Copyright 2016 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_shutdown_scripts
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs $syslog docker kubelet
# Default-Start:     6
# Default-Stop:      0 6
# Short-Description: Google Compute Engine Shutdown Scripts
# Description:       Runs user specified shutdown scripts from metadata.
### END INIT INFO

NAME=google-shutdown-scripts
SCRIPTNAME=/etc/init.d/$NAME

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

case "$1" in
    stop)
        echo -n "Stopping $NAME "
        # This is a one shot script, do not run with startproc
        /usr/bin/google_metadata_script_runner --script-type shutdown

        # Remember status and be verbose
        rc_status -v
        ;;
    *)
        echo $"Usage: $0 stop"
        exit 1
        ;;
esac
openSUSE Build Service is sponsored by