#! /bin/bash
# Copyright 2013 Google Inc. 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.

# Run shutdown scripts that should happen as soon as the instances
# begin to power down.
#
# Do NOT "set -e"
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin

declare -r SHUTDOWN_SCRIPT=/var/run/google.shutdown.script

# NOTE
# Make sure that the shutdown script completes within 90 seconds, so
# that the OS has time to complete its shutdown, including flushing
# buffers to disk.
#
# The shutdown script blocks other shutdown operations from proceeding.
/usr/share/google/fetch_script ${SHUTDOWN_SCRIPT} shutdown
/usr/share/google/run-scripts ${SHUTDOWN_SCRIPT} shutdown
