From c3957f2cd9a9ea836e4b829c09bd03508bf8e897 Mon Sep 17 00:00:00 2001 From: Thomas H Jones II Date: Wed, 23 Oct 2024 06:47:23 -0400 Subject: [PATCH 1/3] Revert "Merge pull request #32 from ferricoxide/Issue_31" This reverts commit 0568609447698e4166363d1b152b290c684e15c4, reversing changes made to ade4c98d5a1b4f04dc16490765269cc2f9a69a6a. --- AWSutils.sh | 67 ++-------------------------------------------------- PostBuild.sh | 29 ----------------------- 2 files changed, 2 insertions(+), 94 deletions(-) diff --git a/AWSutils.sh b/AWSutils.sh index 6d499e6..7f6beb2 100755 --- a/AWSutils.sh +++ b/AWSutils.sh @@ -351,11 +351,8 @@ function InstallCfnBootstrap { err_exit "Failed making cfn-hup service executable" err_exit "Using alternatives to configure cfn-hup symlink and initscript..." NONE - chroot "${CHROOTMNT}" alternatives --verbose --install /opt/aws/bin/cfn-hup cfn-hup /usr/local/bin/cfn-hup 1 || \ - err_exit "Failed configuring cfn-hup symlink" - - # Install systemd-supporting content - InstallCfnBootstrap_systemd + chroot "${CHROOTMNT}" alternatives --verbose --install /opt/aws/bin/cfn-hup cfn-hup /usr/local/bin/cfn-hup 1 --initscript cfn-hup || \ + err_exit "Failed configuring cfn-hup symlink and initscript" err_exit "Cleaning up install files..." NONE rm -rf "${CHROOTMNT}${TMPDIR}" || \ @@ -363,66 +360,6 @@ function InstallCfnBootstrap { fi } -# Install systemd bits -function InstallCfnBootstrap_systemd { - local SVC_NAME="cfn-hup" - local ETC_DIR="${CHROOTMNT}/etc/systemd/system" - local SVC_FILE="${ETC_DIR}/${SVC_NAME}.service" - local OS_VERSION - - SVC_NAME="cfn-hup" - ETC_DIR="${CHROOTMNT}/etc/systemd/system" - SVC_FILE="${ETC_DIR}/${SVC_NAME}.service" - OS_VERSION="$( - awk -F "=" '/^VERSION=/{ print $2 }' /etc/os-release | \ - sed -e 's/"//g' | \ - cut -d '.' -f 1 - )" - - if [[ ${OS_VERSION} -ge 9 ]] - then - err_exit "EL 9+ distros want systemd units..." NONE - - if [[ ! -d ${ETC_DIR} ]] - then - err_exit "Creating ${ETC_DIR}" NONE - install -dDm 0755 "${ETC_DIR}" || \ - err_exit "Failed creating ${ETC_DIR}" - fi - - if [[ ! -f ${SVC_FILE} ]] - then - err_exit "Installing systemd unit-file for ${SVC_NAME}..." NONE - install -bDm 0644 <( - echo "[Unit]" - echo "Description=cfn-hup Service" - echo "After=network.target" - echo "" - echo "[Service]" - echo "ExecStart=/usr/local/bin/cfn-hup" - echo "Type=forking" - echo "PIDFile=/run/cfn-hup.pid" - echo "" - echo "[Install]" - echo "WantedBy=multi-user.target" - ) "${SVC_FILE}" || \ - err_exit "Failed installing systemd unit-file for ${SVC_NAME}" - fi - - if [[ ! -d ${CHROOTMNT}/etc/cfn ]] - then - err_exit "Creating /etc/cfn directory" NONE - install -Z "system_u:object_r:etc_t:s0" -dDm 0755 -o root \ - -g root /etc/cfn || err_exit "Failed creating /etc/cfn directory" NONE - fi - - chroot "${CHROOTMNT}" /usr/bin/systemctl disable "${SVC_NAME}.service" || \ - err_exit "FAILED" - fi - - return -} - # shellcheck disable=SC2016,SC1003 function ProfileSetupAwsCli { install -bDm 0644 -o root -g root <( diff --git a/PostBuild.sh b/PostBuild.sh index af24ca2..f40dd46 100755 --- a/PostBuild.sh +++ b/PostBuild.sh @@ -278,32 +278,6 @@ function ConfigureNetworking { chroot "${CHROOTMNT}" systemctl enable NetworkManager } -# EL9 is more annoying about SysV-isms -function ConfigureRcLocalGenerator { - local GENERATOR_DIR="${CHROOTMNT}/etc/systemd/system-generators" - local GENERATOR_FIL="${GENERATOR_DIR}/systemd-rc-local-generator" - - # Ensure systemd file is present - if [[ ! -f ${GENERATOR_FIL} ]] - then - printf "Creating %s... " "${GENERATOR_DIR}" - install -Z "system_u:object_r:etc_t:s0" -dDm 0755 -o root -g root \ - "${GENERATOR_DIR}" || err_exit "Failed creating ${GENERATOR_DIR}" - echo "Success!" - - printf "Creating %s... " "${GENERATOR_FIL}" - install -bDm 0600 -o root -g root /dev/null "${GENERATOR_FIL}" || \ - err_exit "Failed creating ${GENERATOR_FIL}" - echo "Success!" - - printf "Setting SELinux label on %s... " "${GENERATOR_FIL}" - chcon -u system_u -r object_r -t etc_t "${GENERATOR_FIL}" || \ - err_exit "Failed creating ${GENERATOR_FIL}" - echo "Success!" - fi -} - - # Firewalld config function FirewalldSetup { err_exit "Setting up baseline firewall rules..." NONE @@ -687,9 +661,6 @@ CreateFstab # Set /tmp as a tmpfs SetupTmpfs -# Ensure no systemd-rc-local-generator log-spamming -ConfigureRcLocalGenerator - # Configure logging ConfigureLogging From 80cc35f8201de02ad9da4f4e838471a07bdd0fb5 Mon Sep 17 00:00:00 2001 From: Thomas H Jones II Date: Wed, 23 Oct 2024 06:51:09 -0400 Subject: [PATCH 2/3] We actually want PostBuild.sh from #32 --- PostBuild.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/PostBuild.sh b/PostBuild.sh index f40dd46..af24ca2 100755 --- a/PostBuild.sh +++ b/PostBuild.sh @@ -278,6 +278,32 @@ function ConfigureNetworking { chroot "${CHROOTMNT}" systemctl enable NetworkManager } +# EL9 is more annoying about SysV-isms +function ConfigureRcLocalGenerator { + local GENERATOR_DIR="${CHROOTMNT}/etc/systemd/system-generators" + local GENERATOR_FIL="${GENERATOR_DIR}/systemd-rc-local-generator" + + # Ensure systemd file is present + if [[ ! -f ${GENERATOR_FIL} ]] + then + printf "Creating %s... " "${GENERATOR_DIR}" + install -Z "system_u:object_r:etc_t:s0" -dDm 0755 -o root -g root \ + "${GENERATOR_DIR}" || err_exit "Failed creating ${GENERATOR_DIR}" + echo "Success!" + + printf "Creating %s... " "${GENERATOR_FIL}" + install -bDm 0600 -o root -g root /dev/null "${GENERATOR_FIL}" || \ + err_exit "Failed creating ${GENERATOR_FIL}" + echo "Success!" + + printf "Setting SELinux label on %s... " "${GENERATOR_FIL}" + chcon -u system_u -r object_r -t etc_t "${GENERATOR_FIL}" || \ + err_exit "Failed creating ${GENERATOR_FIL}" + echo "Success!" + fi +} + + # Firewalld config function FirewalldSetup { err_exit "Setting up baseline firewall rules..." NONE @@ -661,6 +687,9 @@ CreateFstab # Set /tmp as a tmpfs SetupTmpfs +# Ensure no systemd-rc-local-generator log-spamming +ConfigureRcLocalGenerator + # Configure logging ConfigureLogging From 9e7c38d0a3aa3066920e9b65a9d9797e84b0ac32 Mon Sep 17 00:00:00 2001 From: Thomas H Jones II Date: Wed, 23 Oct 2024 06:57:11 -0400 Subject: [PATCH 3/3] Still don't want init-scripts set up --- AWSutils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSutils.sh b/AWSutils.sh index 7f6beb2..8237d54 100755 --- a/AWSutils.sh +++ b/AWSutils.sh @@ -351,8 +351,8 @@ function InstallCfnBootstrap { err_exit "Failed making cfn-hup service executable" err_exit "Using alternatives to configure cfn-hup symlink and initscript..." NONE - chroot "${CHROOTMNT}" alternatives --verbose --install /opt/aws/bin/cfn-hup cfn-hup /usr/local/bin/cfn-hup 1 --initscript cfn-hup || \ - err_exit "Failed configuring cfn-hup symlink and initscript" + chroot "${CHROOTMNT}" alternatives --verbose --install /opt/aws/bin/cfn-hup cfn-hup /usr/local/bin/cfn-hup 1 || \ + err_exit "Failed configuring cfn-hup symlink" err_exit "Cleaning up install files..." NONE rm -rf "${CHROOTMNT}${TMPDIR}" || \