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

65 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

#!/sbin/openrc-run
# vim:set ts=8 noet ft=sh:
#
description="CloudBender - main phase"
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
ebegin "CloudBender"
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
if [ "$CLOUD" == "aws" ]; then
set_hostname $CUSTOMHOSTNAME
2023-08-18 15:17:00 +00:00
# if fixed hostname use persistent sshd keys
[ -n "$CUSTOMHOSTNAME" ] && persistent_sshd_hostkeys "/_ssh/${ARTIFACT}/${CONGLOMERATE}/${HOSTNAME}"
2023-08-18 15:17:00 +00:00
associate_eip $INSTANCE_ID $ELASTICIP && PUBLIC_IP_ADDRESS=$ELASTICIP
fi
2023-10-05 16:46:40 +00:00
register_service_dns
is_enabled $PROMETHEUS_ENABLED && setup_prometheus $PROMETHEUS_ALLOW
2023-10-05 16:46:40 +00:00
is_enabled $LOGGING_ENABLED && setup_fluentbit $LOGGING_HOST
# cleanup previous reboot logs
rm -f /tmp/shutdown.log
eend 0
}
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"
is_enabled $ZDT_CLOUDBENDER_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-10-05 16:46:40 +00:00
eend 0
}