65 lines
1.3 KiB
Bash
Executable File
65 lines
1.3 KiB
Bash
Executable File
#!/sbin/openrc-run
|
|
# vim:set ts=8 noet ft=sh:
|
|
#
|
|
|
|
description="CloudBender - main phase"
|
|
|
|
depend() {
|
|
need net
|
|
before sshd
|
|
after tiny-cloud-main
|
|
}
|
|
|
|
start() {
|
|
source /usr/lib/cloudbender/common.sh
|
|
|
|
ebegin "CloudBender"
|
|
|
|
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
|
|
|
|
if [ "$CLOUD" == "aws" ]; then
|
|
set_hostname $CUSTOMHOSTNAME
|
|
|
|
# if fixed hostname use persistent sshd keys
|
|
[ -n "$CUSTOMHOSTNAME" ] && persistent_sshd_hostkeys "/_ssh/${ARTIFACT}/${CONGLOMERATE}/${HOSTNAME}"
|
|
|
|
associate_eip $INSTANCE_ID $ELASTICIP && PUBLIC_IP_ADDRESS=$ELASTICIP
|
|
fi
|
|
|
|
register_service_dns
|
|
|
|
is_enabled $PROMETHEUS_ENABLED && setup_prometheus $PROMETHEUS_ALLOW
|
|
is_enabled $LOGGING_ENABLED && setup_fluentbit $LOGGING_HOST
|
|
|
|
# cleanup previous reboot logs
|
|
rm -f /tmp/shutdown.log
|
|
|
|
eend 0
|
|
}
|
|
|
|
|
|
stop() {
|
|
source /usr/lib/cloudbender/common.sh
|
|
|
|
import_meta_data
|
|
|
|
unmount_volumes "$VOLUMES"
|
|
|
|
is_enabled $ZDT_CLOUDBENDER_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 0
|
|
}
|