diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index f721f6211..180b8af70 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -413,4 +413,60 @@ function extractDSMFiles() { else return 1 fi +} + +############################################################################### +# Livepatch +function livepatch() { + FAIL=0 + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" + if [ "${OFFLINE}" = "false" ]; then + # Looking for Update + if [ ${FAIL} -eq 1 ]; then + # Update Configs + updateConfigs + # Update Patches + updatePatches + # Patch zImage + if ! ${ARC_PATH}/zimage-patch.sh; then + FAIL=1 + else + ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" + writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + # Patch Ramdisk + if ! ${ARC_PATH}/ramdisk-patch.sh; then + FAIL=1 + else + RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" + writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" + FAIL=0 + fi + fi + fi + if [ ${FAIL} -eq 1 ]; then + echo + echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 + sleep 5 + exit 1 + else + echo "DSM Image patched - Ready!" + fi } \ No newline at end of file diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 7d889a478..e0125d607 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -344,60 +344,4 @@ function updateLKMs() { ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update LKMs" \ --progressbox "Updating LKMs..." 20 70 return 0 -} - -############################################################################### -# Livepatch -function livepatch() { - FAIL=0 - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" - if [ "${OFFLINE}" = "false" ]; then - # Looking for Update - if [ ${FAIL} -eq 1 ]; then - # Update Configs - updateConfigs - # Update Patches - updatePatches - # Patch zImage - if ! ${ARC_PATH}/zimage-patch.sh; then - FAIL=1 - else - ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')" - writeConfigKey "zimage-hash" "${ZIMAGE_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - # Patch Ramdisk - if ! ${ARC_PATH}/ramdisk-patch.sh; then - FAIL=1 - else - RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')" - writeConfigKey "ramdisk-hash" "${RAMDISK_HASH_CUR}" "${USER_CONFIG_FILE}" - FAIL=0 - fi - fi - fi - if [ ${FAIL} -eq 1 ]; then - echo - echo -e "Patching DSM Files failed! Please stay patient for Update." 0 0 - sleep 5 - exit 1 - else - echo "DSM Image patched - Ready!" - fi } \ No newline at end of file