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

51 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/sbin/openrc-run
# vim:set ts=8 noet ft=sh:
#
2023-08-18 15:17:00 +00:00
description="CloudBender - setup meta_data, mount additional volumes, send shutdown messages"
depend() {
2023-08-18 15:17:00 +00:00
need net
before sshd
after tiny-cloud-main
}
start() {
2023-08-18 15:17:00 +00:00
source /usr/lib/cloudbender/common.sh
2023-08-18 15:17:00 +00:00
get_meta_data
import_meta_data
2023-08-18 15:17:00 +00:00
# various initial OS tweaks
setup_instance
2023-08-18 15:17:00 +00:00
# mount extra optional volumes
mount_volumes "$VOLUMES"
2023-08-18 15:17:00 +00:00
# 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() {
2023-08-18 15:17:00 +00:00
source /usr/lib/cloudbender/common.sh
2023-08-18 15:17:00 +00:00
import_meta_data
2023-08-18 15:17:00 +00:00
unmount_volumes "$VOLUMES"
2023-08-18 15:17:00 +00:00
[ -n "$DEBUG" ] && [ -r /tmp/shutdown.log ] && SHUTDOWNLOG="$(cat /tmp/shutdown.log)"
2023-08-18 15:17:00 +00:00
[ -n "$RC_REBOOT" ] && ACTION="rebooting" || ACTION="terminated"
[ -z "$DISABLE_SCALING_EVENTS" ] && /var/lib/cloud/sns_alarm.sh "Instance $ACTION" "" Info "$SHUTDOWNLOG"
2023-08-18 15:17:00 +00:00
eend $?
}