Created
July 28, 2025 07:48
-
-
Save ChrisTX/62337d4f32a8e999fd0a3c9dc3161550 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #shellcheck disable=SC2034 | |
| COMMAND="${1}" | |
| KERNEL_VERSION="${2}" | |
| BOOT_DIR_ABS="${3}" | |
| KERNEL_IMAGE="${4}" | |
| if [[ ${KERNEL_INSTALL_LAYOUT} != "arch" ]]; then | |
| exit 0 | |
| fi | |
| KERNEL_SUFFIX=$(echo "$KERNEL_VERSION" | sed -n "s/^.*[0-9]\(-\?[a-zA-Z]*\)$/\1/p") | |
| KERNEL_PACKAGE_NAME="linux${KERNEL_SUFFIX}" | |
| KERNEL_INSTALL_ROOT="/boot" | |
| if [[ ${COMMAND} == add ]]; then | |
| mkdir -p "${KERNEL_INSTALL_ROOT}" || exit 1 | |
| [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo "Installing kernel image for ${KERNEL_PACKAGE_NAME}..." | |
| install -m 0644 "${KERNEL_IMAGE}" "${KERNEL_INSTALL_ROOT}/vmlinuz-${KERNEL_PACKAGE_NAME}" || exit 1 | |
| INITRD="${KERNEL_INSTALL_STAGING_AREA}/initrd" | |
| if [[ -f ${INITRD} ]]; then | |
| [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo "Installing initramfs image for ${KERNEL_PACKAGE_NAME}..." | |
| install -m 0644 "${INITRD}" "${KERNEL_INSTALL_ROOT}/initramfs-${KERNEL_PACKAGE_NAME}.img" || exit 1 | |
| fi | |
| elif [[ ${COMMAND} == remove ]]; then | |
| [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo "Removing kernel and initramfs image for ${KERNEL_PACKAGE_NAME}..." | |
| rm -f \ | |
| "${KERNEL_INSTALL_ROOT}/vmlinuz-${KERNEL_PACKAGE_NAME}" \ | |
| "${KERNEL_INSTALL_ROOT}/initramfs-${KERNEL_PACKAGE_NAME}.img" || exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment