2023-04-26 17:22:52 +00:00
|
|
|
#!/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"
|
2023-04-26 17:22:52 +00:00
|
|
|
|
|
|
|
depend() {
|
2023-08-18 15:17:00 +00:00
|
|
|
need net
|
|
|
|
before sshd
|
|
|
|
after tiny-cloud-main
|
2023-04-26 17:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2023-08-18 15:17:00 +00:00
|
|
|
source /usr/lib/cloudbender/common.sh
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
get_meta_data
|
|
|
|
import_meta_data
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
# various initial OS tweaks
|
|
|
|
setup_instance
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
# mount extra optional volumes
|
|
|
|
mount_volumes "$VOLUMES"
|
2023-04-26 17:22:52 +00:00
|
|
|
|
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 $?
|
2023-04-26 17:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stop() {
|
2023-08-18 15:17:00 +00:00
|
|
|
source /usr/lib/cloudbender/common.sh
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
import_meta_data
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
unmount_volumes "$VOLUMES"
|
2023-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
[ -n "$DEBUG" ] && [ -r /tmp/shutdown.log ] && SHUTDOWNLOG="$(cat /tmp/shutdown.log)"
|
2023-04-26 17:22:52 +00:00
|
|
|
|
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-04-26 17:22:52 +00:00
|
|
|
|
2023-08-18 15:17:00 +00:00
|
|
|
eend $?
|
2023-04-26 17:22:52 +00:00
|
|
|
}
|