diff --git a/kickstart/files/kickstart.cfg b/kickstart/files/kickstart.cfg index f0e044fb..f35b14ba 100644 --- a/kickstart/files/kickstart.cfg +++ b/kickstart/files/kickstart.cfg @@ -142,6 +142,21 @@ function report_failure_with_msg() reboot -f } +######################################################################## +# Name : check_rc_with_msg +# Purpose : Check given return code, reporting failure if non-zero +# Parameters: \$1 is the exit code to check +# \$2 is the failure message string +# Return : Does not return if exit code is non-zero +######################################################################## +function check_rc_with_msg { + local rc=\${1} + msg=\${2} + if [ \${rc} -ne 0 ]; then + report_failure_with_msg "\${msg} [rc=\${rc}]" + fi +} + ######################################################################## # Name : get_disk # Parameters: \$1 - any disk path @@ -371,6 +386,20 @@ function is_usb_install() fi } +######################################################################### +# Name : is_cloudinit_enabled +# Returns : true :0 +# false:1 +######################################################################### +function is_cloudinit_enabled() +{ + if grep -q 'cloud-init=enabled' /proc/cmdline; then + return 0 + else + return 1 + fi +} + ######################################################################### # Name : check_prestage # Returns : true :0 @@ -3046,6 +3075,25 @@ if [ "${controller}" = true ] ; then fi fi + # TODO remove + if [ -d /instboot/seed ]; then + ilog "Copying cloud-init seed to to ${backup_mount_release}" + cp -r /instboot/seed ${backup_mount_release} + rc=$? + if [ ${rc} -ne 0 ]; then + report_failure_with_msg "Unable to copy from /instboot/seed to /opt/platform-backup/${sw_release} [rc=${rc}]" + fi + fi + # TODO remove + if [ -d /instboot/factory-install ]; then + ilog "Copying factory-install to to ${backup_mount_release}" + cp -r /instboot/factory-install ${backup_mount_release} + rc=$? + if [ ${rc} -ne 0 ]; then + report_failure_with_msg "Unable to copy from /instboot/factory-install to /opt/platform-backup/${sw_release} [rc=${rc}]" + fi + fi + umount "${backup_mount}" fi else @@ -3352,6 +3400,17 @@ if [ "${storage}" = true ] ; then ln -s /usr/share/starlingx/pmon.d/syslog-ng.conf ${IMAGE_ROOTFS}/etc/pmon.d/syslog-ng.conf fi +if is_cloudinit_enabled; then + ilog "Enabling cloud-init services" + mkdir -p "${IMAGE_ROOTFS}"/etc/systemd/system/cloud-init.target.wants + check_rc_with_msg $? "mkdir failed (cloud-init.target.wants)" + ln -s /usr/lib/systemd/system/cloud-config.service "${IMAGE_ROOTFS}"/etc/systemd/system/cloud-init.target.wants/cloud-config.service && \ + ln -s /usr/lib/systemd/system/cloud-init-local.service "${IMAGE_ROOTFS}"/etc/systemd/system/cloud-init.target.wants/cloud-init-local.service && \ + ln -s /usr/lib/systemd/system/cloud-init.service "${IMAGE_ROOTFS}"/etc/systemd/system/cloud-init.target.wants/cloud-init.service && \ + ln -s /usr/lib/systemd/system/cloud-final.service "${IMAGE_ROOTFS}"/etc/systemd/system/cloud-init.target.wants/cloud-final.service + check_rc_with_msg $? "Failed to setup cloud-init services" +fi + if [ -e "/instboot/ks-addon.cfg" ]; then ilog "Running kickstart addon script" source /instboot/ks-addon.cfg