alpine-overlay/kubezero/zdt-base/cloudbender.init

51 lines
1.0 KiB
Bash
Executable File

#!/sbin/openrc-run
# vim:set ts=8 noet ft=sh:
#
description="CloudBender - setup meta_data, mount additional volumes, send shutdown messages"
depend() {
need net
before sshd
after tiny-cloud-main
}
start() {
source /usr/lib/cloudbender/common.sh
get_meta_data
import_meta_data
# various initial OS tweaks
setup_instance
# mount extra optional volumes
mount_volumes "$VOLUMES"
# add optional ssh keys, eg. via IAM for AWS
configure_sshd
set_hostname $CUSTOMHOSTNAME
# if fixed hostname use persistent sshd keys
[ -n "$CUSTOMHOSTNAME" ] && persistent_sshd_hostkeys "/_ssh/${ARTIFACT}/${CONGLOMERATE}/${HOSTNAME}"
eend $?
}
stop() {
source /usr/lib/cloudbender/common.sh
import_meta_data
unmount_volumes "$VOLUMES"
[ -n "$DEBUG" ] && [ -r /tmp/shutdown.log ] && SHUTDOWNLOG="$(cat /tmp/shutdown.log)"
[ -n "$RC_REBOOT" ] && ACTION="rebooting" || ACTION="terminated"
[ -z "$DISABLE_SCALING_EVENTS" ] && /var/lib/cloud/sns_alarm.sh "Instance $ACTION" "" Info "$SHUTDOWNLOG"
eend $?
}