mirror of
https://github.com/AuxXxilium/arc.git
synced 2024-11-24 00:39:53 +07:00
arc: reduce code part 1
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
b55ed1f888
commit
408959e974
@ -244,21 +244,28 @@ function arcVersion() {
|
|||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||||
PLATFORM="$(readModelKey "${MODEL}" "platform")"
|
PLATFORM="$(readModelKey "${MODEL}" "platform")"
|
||||||
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
||||||
# Select Build for DSM
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
ITEMS="$(readConfigEntriesArray "productvers" "${MODEL_CONFIG_PATH}/${MODEL}.yml" | sort -r)"
|
# Select Build for DSM
|
||||||
dialog --clear --no-items --nocancel --backtitle "$(backtitle)" \
|
ITEMS="$(readConfigEntriesArray "productvers" "${MODEL_CONFIG_PATH}/${MODEL}.yml" | sort -r)"
|
||||||
--menu "Choose a Version" 7 30 0 ${ITEMS} 2>"${TMP_PATH}/resp"
|
dialog --clear --no-items --nocancel --backtitle "$(backtitle)" \
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
--menu "Choose a Version" 7 30 0 ${ITEMS} 2>"${TMP_PATH}/resp"
|
||||||
[ -z "${resp}" ] && return 1
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
if [ "${PRODUCTVER}" != "${resp}" ]; then
|
[ -z "${resp}" ] && return 1
|
||||||
PRODUCTVER="${resp}"
|
if [ "${PRODUCTVER}" != "${resp}" ]; then
|
||||||
writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}"
|
PRODUCTVER="${resp}"
|
||||||
|
writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}"
|
||||||
|
if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then
|
||||||
|
# Delete old files
|
||||||
|
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
||||||
|
else
|
||||||
if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then
|
if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then
|
||||||
# Delete old files
|
# Delete old files
|
||||||
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
|
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
|
||||||
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
|
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
|
||||||
# Modify KVER for Epyc7002
|
# Modify KVER for Epyc7002
|
||||||
if [ "${PLATFORM}" = "epyc7002" ]; then
|
if [ "${PLATFORM}" = "epyc7002" ]; then
|
||||||
@ -278,13 +285,17 @@ function arcVersion() {
|
|||||||
while read -r ID DESC; do
|
while read -r ID DESC; do
|
||||||
writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}"
|
writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}"
|
||||||
done <<<$(getAllModules "${PLATFORM}" "${KVERP}")
|
done <<<$(getAllModules "${PLATFORM}" "${KVERP}")
|
||||||
if [ "${ONLYVERSION}" != "true" ]; then
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
arcPatch
|
if [ "${ONLYVERSION}" != "true" ]; then
|
||||||
|
arcPatch
|
||||||
|
else
|
||||||
|
# Build isn't done
|
||||||
|
writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}"
|
||||||
|
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Build isn't done
|
arcPatch
|
||||||
writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}"
|
|
||||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,79 +306,93 @@ function arcPatch() {
|
|||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||||
DT="$(readModelKey "${MODEL}" "dt")"
|
DT="$(readModelKey "${MODEL}" "dt")"
|
||||||
ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)"
|
ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)"
|
||||||
if [ -n "${ARCCONF}" ]; then
|
if [ "${CUSTOM}" = "true" ]; then
|
||||||
dialog --clear --backtitle "$(backtitle)" \
|
ARCPATCHPRE="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
|
||||||
--nocancel --title "Arc Patch"\
|
[ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false"
|
||||||
--menu "Do you want to use Syno Services?" 7 50 0 \
|
if [[ "${ARCPATCH}" = "true" && "${ARCPATCHPRE}" = "true" ]]; then
|
||||||
1 "Yes - Install with Arc Patch" \
|
SN="$(readModelKey "${MODEL}" "arc.serial")"
|
||||||
2 "No - Install with random Serial/Mac" \
|
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
||||||
3 "No - Install with my Serial/Mac" \
|
|
||||||
2>"${TMP_PATH}/resp"
|
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
|
||||||
[ -z "${resp}" ] && return 1
|
|
||||||
if [ ${resp} -eq 1 ]; then
|
|
||||||
# Read Arc Patch from File
|
|
||||||
SN="$(readConfigKey "${MODEL}.serial" "${S_FILE}")"
|
|
||||||
writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}"
|
||||||
elif [ ${resp} -eq 2 ]; then
|
else
|
||||||
# Generate random Serial
|
|
||||||
SN="$(generateSerial "${MODEL}")"
|
SN="$(generateSerial "${MODEL}")"
|
||||||
|
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
||||||
elif [ ${resp} -eq 3 ]; then
|
|
||||||
while true; do
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
|
||||||
--inputbox "Please enter a valid Serial " 0 0 "" \
|
|
||||||
2>"${TMP_PATH}/resp"
|
|
||||||
[ $? -ne 0 ] && break 2
|
|
||||||
SN="$(cat ${TMP_PATH}/resp)"
|
|
||||||
if [ -z "${SN}" ]; then
|
|
||||||
return
|
|
||||||
elif [ $(validateSerial ${MODEL} ${SN}) -eq 1 ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
|
|
||||||
break
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
|
||||||
--yesno "Invalid Serial, continue?" 0 0
|
|
||||||
[ $? -eq 0 ] && break
|
|
||||||
done
|
|
||||||
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
|
|
||||||
fi
|
fi
|
||||||
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
else
|
||||||
elif [ -z "${ARCCONF}" ]; then
|
if [ -n "${ARCCONF}" ]; then
|
||||||
dialog --clear --backtitle "$(backtitle)" \
|
dialog --clear --backtitle "$(backtitle)" \
|
||||||
--nocancel --title "Non Arc Patch Model" \
|
--nocancel --title "Arc Patch"\
|
||||||
--menu "Please select an Option?" 8 50 0 \
|
--menu "Do you want to use Syno Services?" 7 50 0 \
|
||||||
1 "Install with random Serial/Mac" \
|
1 "Yes - Install with Arc Patch" \
|
||||||
2 "Install with my Serial/Mac" \
|
2 "No - Install with random Serial/Mac" \
|
||||||
2>"${TMP_PATH}/resp"
|
3 "No - Install with my Serial/Mac" \
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
2>"${TMP_PATH}/resp"
|
||||||
[ -z "${resp}" ] && return 1
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
if [ ${resp} -eq 1 ]; then
|
[ -z "${resp}" ] && return 1
|
||||||
# Generate random Serial
|
if [ ${resp} -eq 1 ]; then
|
||||||
SN="$(generateSerial "${MODEL}")"
|
# Read Arc Patch from File
|
||||||
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
SN="$(readConfigKey "${MODEL}.serial" "${S_FILE}")"
|
||||||
elif [ ${resp} -eq 2 ]; then
|
writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}"
|
||||||
while true; do
|
elif [ ${resp} -eq 2 ]; then
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
# Generate random Serial
|
||||||
--inputbox "Please enter a Serial Number " 0 0 "" \
|
SN="$(generateSerial "${MODEL}")"
|
||||||
2>"${TMP_PATH}/resp"
|
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
||||||
[ $? -ne 0 ] && break 2
|
elif [ ${resp} -eq 3 ]; then
|
||||||
SN="$(cat ${TMP_PATH}/resp)"
|
while true; do
|
||||||
if [ -z "${SN}" ]; then
|
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
||||||
return
|
--inputbox "Please enter a valid Serial " 0 0 "" \
|
||||||
elif [ $(validateSerial ${MODEL} ${SN}) -eq 1 ]; then
|
2>"${TMP_PATH}/resp"
|
||||||
|
[ $? -ne 0 ] && break 2
|
||||||
|
SN="$(cat ${TMP_PATH}/resp)"
|
||||||
|
if [ -z "${SN}" ]; then
|
||||||
|
return
|
||||||
|
elif [ $(validateSerial ${MODEL} ${SN}) -eq 1 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
|
||||||
break
|
break
|
||||||
fi
|
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
||||||
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
|
--yesno "Invalid Serial, continue?" 0 0
|
||||||
break
|
[ $? -eq 0 ] && break
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
done
|
||||||
--yesno "Invalid Serial, continue?" 0 0
|
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
|
||||||
[ $? -eq 0 ] && break
|
fi
|
||||||
done
|
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
|
elif [ -z "${ARCCONF}" ]; then
|
||||||
|
dialog --clear --backtitle "$(backtitle)" \
|
||||||
|
--nocancel --title "Non Arc Patch Model" \
|
||||||
|
--menu "Please select an Option?" 8 50 0 \
|
||||||
|
1 "Install with random Serial/Mac" \
|
||||||
|
2 "Install with my Serial/Mac" \
|
||||||
|
2>"${TMP_PATH}/resp"
|
||||||
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
|
[ -z "${resp}" ] && return 1
|
||||||
|
if [ ${resp} -eq 1 ]; then
|
||||||
|
# Generate random Serial
|
||||||
|
SN="$(generateSerial "${MODEL}")"
|
||||||
|
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
||||||
|
elif [ ${resp} -eq 2 ]; then
|
||||||
|
while true; do
|
||||||
|
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
||||||
|
--inputbox "Please enter a Serial Number " 0 0 "" \
|
||||||
|
2>"${TMP_PATH}/resp"
|
||||||
|
[ $? -ne 0 ] && break 2
|
||||||
|
SN="$(cat ${TMP_PATH}/resp)"
|
||||||
|
if [ -z "${SN}" ]; then
|
||||||
|
return
|
||||||
|
elif [ $(validateSerial ${MODEL} ${SN}) -eq 1 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
|
||||||
|
break
|
||||||
|
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
|
||||||
|
--yesno "Invalid Serial, continue?" 0 0
|
||||||
|
[ $? -eq 0 ] && break
|
||||||
|
done
|
||||||
|
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
|
||||||
|
fi
|
||||||
|
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
||||||
fi
|
fi
|
||||||
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
|
||||||
fi
|
fi
|
||||||
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
|
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
|
||||||
if [ "${ONLYPATCH}" = "true" ]; then
|
if [ "${ONLYPATCH}" = "true" ]; then
|
||||||
@ -385,53 +410,67 @@ function arcSettings() {
|
|||||||
dialog --backtitle "$(backtitle)" --colors --title "Network Config" \
|
dialog --backtitle "$(backtitle)" --colors --title "Network Config" \
|
||||||
--infobox "Network Config..." 3 30
|
--infobox "Network Config..." 3 30
|
||||||
sleep 2
|
sleep 2
|
||||||
getnet
|
if [ "${CUSTOM}" = "true" ]; then
|
||||||
|
autogetnet
|
||||||
|
else
|
||||||
|
getnet
|
||||||
|
fi
|
||||||
# Select Portmap for Loader
|
# Select Portmap for Loader
|
||||||
getmap
|
getmap
|
||||||
if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then
|
if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Storage Map" \
|
dialog --backtitle "$(backtitle)" --colors --title "Storage Map" \
|
||||||
--infobox "Storage Map..." 3 30
|
--infobox "Storage Map..." 3 30
|
||||||
sleep 2
|
sleep 2
|
||||||
getmapSelection
|
if [ "${CUSTOM}" = "true" ]; then
|
||||||
fi
|
autogetmapSelection
|
||||||
# Add Arc Addons
|
else
|
||||||
writeConfigKey "addons.cpuinfo" "" "${USER_CONFIG_FILE}"
|
getmapSelection
|
||||||
# Select Addons
|
|
||||||
addonSelection
|
|
||||||
# Check for DT and HBA/Raid Controller
|
|
||||||
if [ ! "${MODEL}" = "SA6400" ]; then
|
|
||||||
if [[ "${DT}" = "true" && "${EXTERNALCONTROLLER}" = "true" ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
|
||||||
--msgbox "WARN: You use a HBA/Raid Controller and selected a DT Model.\nThis is still an experimental Feature." 0 0
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Check for more then 8 Ethernet Ports
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
DEVICENIC="$(readConfigKey "device.nic" "${USER_CONFIG_FILE}")"
|
# Add Arc Addons
|
||||||
if [ ${DEVICENIC} -gt 8 ]; then
|
writeConfigKey "addons.cpuinfo" "" "${USER_CONFIG_FILE}"
|
||||||
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
# Select Addons
|
||||||
--msgbox "WARN: You have more then 8 Ethernet Ports.\nThere are only 8 supported by DSM." 0 0
|
addonSelection
|
||||||
fi
|
# Check for DT and HBA/Raid Controller
|
||||||
# Check for AES
|
if [ ! "${MODEL}" = "SA6400" ]; then
|
||||||
if ! grep -q "^flags.*aes.*" /proc/cpuinfo; then
|
if [[ "${DT}" = "true" && "${EXTERNALCONTROLLER}" = "true" ]]; then
|
||||||
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
||||||
--msgbox "WARN: Your CPU does not have AES Support for Hardwareencryption in DSM." 0 0
|
--msgbox "WARN: You use a HBA/Raid Controller and selected a DT Model.\nThis is still an experimental Feature." 0 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Check for more then 8 Ethernet Ports
|
||||||
|
DEVICENIC="$(readConfigKey "device.nic" "${USER_CONFIG_FILE}")"
|
||||||
|
if [ ${DEVICENIC} -gt 8 ]; then
|
||||||
|
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
||||||
|
--msgbox "WARN: You have more then 8 Ethernet Ports.\nThere are only 8 supported by DSM." 0 0
|
||||||
|
fi
|
||||||
|
# Check for AES
|
||||||
|
if ! grep -q "^flags.*aes.*" /proc/cpuinfo; then
|
||||||
|
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
|
||||||
|
--msgbox "WARN: Your CPU does not have AES Support for Hardwareencryption in DSM." 0 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Config is done
|
# Config is done
|
||||||
writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}"
|
||||||
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
|
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
|
||||||
# Ask for Build
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
dialog --clear --backtitle "$(backtitle)" \
|
# Ask for Build
|
||||||
--menu "Config done -> Build now?" 7 50 0 \
|
dialog --clear --backtitle "$(backtitle)" \
|
||||||
1 "Yes - Build Arc Loader now" \
|
--menu "Config done -> Build now?" 7 50 0 \
|
||||||
2 "No - I want to make changes" \
|
1 "Yes - Build Arc Loader now" \
|
||||||
2>"${TMP_PATH}/resp"
|
2 "No - I want to make changes" \
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
2>"${TMP_PATH}/resp"
|
||||||
[ -z "${resp}" ] && return 1
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
if [ ${resp} -eq 1 ]; then
|
[ -z "${resp}" ] && return 1
|
||||||
|
if [ ${resp} -eq 1 ]; then
|
||||||
|
premake
|
||||||
|
elif [ ${resp} -eq 2 ]; then
|
||||||
|
dialog --clear --no-items --backtitle "$(backtitle)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
premake
|
premake
|
||||||
elif [ ${resp} -eq 2 ]; then
|
|
||||||
dialog --clear --no-items --backtitle "$(backtitle)"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,11 +488,6 @@ function premake() {
|
|||||||
# Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation
|
# Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation
|
||||||
writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}"
|
writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}"
|
writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}"
|
||||||
# Optimized Synoinfo
|
|
||||||
writeConfigKey "synoinfo.support_trim" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_disk_hibernation" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_btrfs_dedupe" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_tiny_btrfs_dedupe" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
# eMMC Boot Support
|
# eMMC Boot Support
|
||||||
if [ "${EMMCBOOT}" = "true" ]; then
|
if [ "${EMMCBOOT}" = "true" ]; then
|
||||||
writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}"
|
writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}"
|
||||||
@ -462,8 +496,13 @@ function premake() {
|
|||||||
deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}"
|
deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}"
|
||||||
deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}"
|
deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}"
|
||||||
fi
|
fi
|
||||||
# Show Config Summary
|
if [ "${CUSTOM}" = "true" ]; then
|
||||||
arcSummary
|
# Build Loader
|
||||||
|
make
|
||||||
|
else
|
||||||
|
# Show Config Summary
|
||||||
|
arcSummary
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -557,15 +596,17 @@ function make() {
|
|||||||
rm -rf "${UNTAR_PAT_PATH}"
|
rm -rf "${UNTAR_PAT_PATH}"
|
||||||
fi
|
fi
|
||||||
mkdir -p "${UNTAR_PAT_PATH}"
|
mkdir -p "${UNTAR_PAT_PATH}"
|
||||||
# Check if all addon exists
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
while IFS=': ' read -r ADDON PARAM; do
|
# Check if all addon exists
|
||||||
[ -z "${ADDON}" ] && continue
|
while IFS=': ' read -r ADDON PARAM; do
|
||||||
if ! checkAddonExist "${ADDON}" "${PLATFORM}"; then
|
[ -z "${ADDON}" ] && continue
|
||||||
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
if ! checkAddonExist "${ADDON}" "${PLATFORM}"; then
|
||||||
--msgbox "Addon ${ADDON} not found!" 0 0
|
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
||||||
return 1
|
--msgbox "Addon ${ADDON} not found!" 0 0
|
||||||
fi
|
return 1
|
||||||
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
|
fi
|
||||||
|
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
|
||||||
|
fi
|
||||||
# Check for offline Mode
|
# Check for offline Mode
|
||||||
if [ "${OFFLINE}" = "true" ]; then
|
if [ "${OFFLINE}" = "true" ]; then
|
||||||
offlinemake
|
offlinemake
|
||||||
@ -608,22 +649,38 @@ function make() {
|
|||||||
idx=$((${idx} + 1))
|
idx=$((${idx} + 1))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
MSG="Failed to get PAT Data.\nPlease manually fill in the URL and Hash of PAT."
|
if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then
|
||||||
PAT_URL=""
|
MSG="Failed to get PAT Data.\nPlease manually fill in the URL and Hash of PAT."
|
||||||
PAT_HASH=""
|
PAT_URL=""
|
||||||
|
PAT_HASH=""
|
||||||
|
else
|
||||||
|
MSG="Successfully got PAT Data.\nPlease confirm or modify if needed."
|
||||||
|
fi
|
||||||
|
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" --default-button "OK" \
|
||||||
|
--form "${MSG}" 10 110 2 "URL" 1 1 "${PAT_URL}" 1 7 100 0 "HASH" 2 1 "${PAT_HASH}" 2 7 100 0 \
|
||||||
|
2>"${TMP_PATH}/resp"
|
||||||
|
RET=$?
|
||||||
|
[ ${RET} -eq 0 ] && break # ok-button
|
||||||
|
return 1 # 1 or 255 # cancel-button or ESC
|
||||||
|
PAT_URL="$(cat "${TMP_PATH}/resp" | sed -n '1p')"
|
||||||
|
PAT_HASH="$(cat "${TMP_PATH}/resp" | sed -n '2p')"
|
||||||
else
|
else
|
||||||
MSG="Successfully got PAT Data.\nPlease confirm or modify if needed."
|
if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then
|
||||||
|
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
||||||
|
--infobox "Could not get PAT Data..." 4 30
|
||||||
|
sleep 3
|
||||||
|
PAT_URL=""
|
||||||
|
PAT_HASH=""
|
||||||
|
break
|
||||||
|
else
|
||||||
|
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
||||||
|
--infobox "Successfully got PAT Data..." 4 30
|
||||||
|
sleep 3
|
||||||
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" --default-button "OK" \
|
|
||||||
--form "${MSG}" 10 110 2 "URL" 1 1 "${PAT_URL}" 1 7 100 0 "HASH" 2 1 "${PAT_HASH}" 2 7 100 0 \
|
|
||||||
2>"${TMP_PATH}/resp"
|
|
||||||
RET=$?
|
|
||||||
[ ${RET} -eq 0 ] && break # ok-button
|
|
||||||
return 1 # 1 or 255 # cancel-button or ESC
|
|
||||||
done
|
done
|
||||||
PAT_URL="$(cat "${TMP_PATH}/resp" | sed -n '1p')"
|
|
||||||
PAT_HASH="$(cat "${TMP_PATH}/resp" | sed -n '2p')"
|
|
||||||
if [[ "${PAT_HASH}" != "${PAT_HASH_CONF}" || ! -f "${ORI_ZIMAGE_FILE}" || ! -f "${ORI_RDGZ_FILE}" ]]; then
|
if [[ "${PAT_HASH}" != "${PAT_HASH_CONF}" || ! -f "${ORI_ZIMAGE_FILE}" || ! -f "${ORI_RDGZ_FILE}" ]]; then
|
||||||
writeConfigKey "arc.paturl" "${PAT_URL}" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.paturl" "${PAT_URL}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "arc.pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}"
|
||||||
@ -634,13 +691,15 @@ function make() {
|
|||||||
STATUS=$(curl --insecure -s -w "%{http_code}" -L "${DSM_URL}" -o "${DSM_FILE}")
|
STATUS=$(curl --insecure -s -w "%{http_code}" -L "${DSM_URL}" -o "${DSM_FILE}")
|
||||||
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
||||||
--msgbox "No DSM Image found!\nTry Syno Link." 0 0
|
--infobox "No DSM Image found!\nTry Syno Link." 0 0
|
||||||
|
sleep 3
|
||||||
# Grep PAT_URL
|
# Grep PAT_URL
|
||||||
PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat"
|
PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat"
|
||||||
STATUS=$(curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_FILE}" --progress-bar)
|
STATUS=$(curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_FILE}" --progress-bar)
|
||||||
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
||||||
--msgbox "No DSM Image found!\nExit." 0 0
|
--infobox "No DSM Image found!\nExit." 0 0
|
||||||
|
sleep 5
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Extract Files
|
# Extract Files
|
||||||
@ -672,7 +731,8 @@ function make() {
|
|||||||
tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1
|
tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1
|
||||||
elif [ ! -f "${UNTAR_PAT_PATH}/zImage" ]; then
|
elif [ ! -f "${UNTAR_PAT_PATH}/zImage" ]; then
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
||||||
--msgbox "ERROR: No DSM Image found!" 0 0
|
--infobox "ERROR: No DSM Image found!" 0 0
|
||||||
|
sleep 5
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Copy DSM Files to Locations if DSM Files not found
|
# Copy DSM Files to Locations if DSM Files not found
|
||||||
@ -693,22 +753,30 @@ function make() {
|
|||||||
# Build is done
|
# Build is done
|
||||||
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
|
||||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
||||||
# Ask for Boot
|
if grep -q "automated_arc" /proc/cmdline; then
|
||||||
dialog --clear --backtitle "$(backtitle)" \
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
--menu "Build done -> Boot now?" 8 50 0 \
|
rm -f "${PART3_PATH}/automated"
|
||||||
1 "Yes - Boot Arc Loader now" \
|
fi
|
||||||
2 "No - I want to make changes" \
|
|
||||||
2>"${TMP_PATH}/resp"
|
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
|
||||||
[ -z "${resp}" ] && return 1
|
|
||||||
if [ ${resp} -eq 1 ]; then
|
|
||||||
boot && exit 0
|
boot && exit 0
|
||||||
elif [ ${resp} -eq 2 ]; then
|
else
|
||||||
return 0
|
# Ask for Boot
|
||||||
|
dialog --clear --backtitle "$(backtitle)" \
|
||||||
|
--menu "Build done. Boot now?" 0 0 0 \
|
||||||
|
1 "Yes - Boot Arc Loader now" \
|
||||||
|
2 "No - I want to make changes" \
|
||||||
|
2>"${TMP_PATH}/resp"
|
||||||
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
|
[ -z "${resp}" ] && return 1
|
||||||
|
if [ ${resp} -eq 1 ]; then
|
||||||
|
boot && exit 0
|
||||||
|
elif [ ${resp} -eq 2 ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
||||||
--msgbox "Build failed!\nPlease check your Connection and Diskspace!" 0 0
|
--infobox "Build failed!\nPlease check your Connection and Diskspace!" 0 0
|
||||||
|
sleep 5
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -730,7 +798,8 @@ function offlinemake() {
|
|||||||
PAT_FILE=$(ls ${UPLOAD_PATH}/*.pat)
|
PAT_FILE=$(ls ${UPLOAD_PATH}/*.pat)
|
||||||
if [ ! -f "${PAT_FILE}" ]; then
|
if [ ! -f "${PAT_FILE}" ]; then
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Extraction" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "DSM Extraction" --aspect 18 \
|
||||||
--msgbox "No DSM Image found!\nExit." 0 0
|
--infobox "No DSM Image found!\nExit." 0 0
|
||||||
|
sleep 5
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
# Remove PAT Data for Offline
|
# Remove PAT Data for Offline
|
||||||
@ -782,22 +851,30 @@ function offlinemake() {
|
|||||||
# Build is done
|
# Build is done
|
||||||
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
|
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
|
||||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
||||||
# Ask for Boot
|
if grep -q "automated_arc" /proc/cmdline; then
|
||||||
dialog --clear --backtitle "$(backtitle)" \
|
if [ "${CUSTOM}" = "false" ]; then
|
||||||
--menu "Build done. Boot now?" 0 0 0 \
|
rm -f "${PART3_PATH}/automated"
|
||||||
1 "Yes - Boot Arc Loader now" \
|
fi
|
||||||
2 "No - I want to make changes" \
|
|
||||||
2>"${TMP_PATH}/resp"
|
|
||||||
resp=$(cat ${TMP_PATH}/resp)
|
|
||||||
[ -z "${resp}" ] && return 1
|
|
||||||
if [ ${resp} -eq 1 ]; then
|
|
||||||
boot && exit 0
|
boot && exit 0
|
||||||
elif [ ${resp} -eq 2 ]; then
|
else
|
||||||
return 0
|
# Ask for Boot
|
||||||
|
dialog --clear --backtitle "$(backtitle)" \
|
||||||
|
--menu "Build done. Boot now?" 0 0 0 \
|
||||||
|
1 "Yes - Boot Arc Loader now" \
|
||||||
|
2 "No - I want to make changes" \
|
||||||
|
2>"${TMP_PATH}/resp"
|
||||||
|
resp=$(cat ${TMP_PATH}/resp)
|
||||||
|
[ -z "${resp}" ] && return 1
|
||||||
|
if [ ${resp} -eq 1 ]; then
|
||||||
|
boot && exit 0
|
||||||
|
elif [ ${resp} -eq 2 ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \
|
||||||
--msgbox "Build failed!\nPlease check your Diskspace!" 0 0
|
--infobox "Build failed!\nPlease check your Diskspace!" 0 0
|
||||||
|
sleep 5
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -849,265 +926,14 @@ function boot() {
|
|||||||
exec reboot
|
exec reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Make Model Config
|
|
||||||
function arcAutomated() {
|
|
||||||
# read model config for dt and aes
|
|
||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
|
||||||
DT="$(readModelKey "${MODEL}" "dt")"
|
|
||||||
ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)"
|
|
||||||
ARCPATCHPRE="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
|
|
||||||
[ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false"
|
|
||||||
if [[ "${ARCPATCH}" = "true" && "${ARCPATCHPRE}" = "true" ]]; then
|
|
||||||
SN="$(readModelKey "${MODEL}" "arc.serial")"
|
|
||||||
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}"
|
|
||||||
else
|
|
||||||
SN="$(generateSerial "${MODEL}")"
|
|
||||||
writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
|
|
||||||
fi
|
|
||||||
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
|
|
||||||
PLATFORM="$(readModelKey "${MODEL}" "platform")"
|
|
||||||
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
|
||||||
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
|
|
||||||
# Modify KVER for Epyc7002
|
|
||||||
if [ "${PLATFORM}" = "epyc7002" ]; then
|
|
||||||
KVERP="${PRODUCTVER}-${KVER}"
|
|
||||||
else
|
|
||||||
KVERP="${KVER}"
|
|
||||||
fi
|
|
||||||
writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}"
|
|
||||||
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
|
|
||||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
|
||||||
if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then
|
|
||||||
# Delete old files
|
|
||||||
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
|
|
||||||
fi
|
|
||||||
dialog --backtitle "$(backtitle)" --title "Arc Config" \
|
|
||||||
--infobox "Reconfiguring Synoinfo and Modules" 3 40
|
|
||||||
# Reset synoinfo
|
|
||||||
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
|
|
||||||
while IFS=': ' read -r KEY VALUE; do
|
|
||||||
writeConfigKey "synoinfo.\"${KEY}\"" "${VALUE}" "${USER_CONFIG_FILE}"
|
|
||||||
done <<<$(readModelMap "${MODEL}" "synoinfo")
|
|
||||||
# Reset modules
|
|
||||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
|
||||||
while read -r ID DESC; do
|
|
||||||
writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}"
|
|
||||||
done <<<$(getAllModules "${PLATFORM}" "${KVERP}")
|
|
||||||
autoarcSettings
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Arc Settings Section
|
|
||||||
function autoarcSettings() {
|
|
||||||
# Get Network Config for Loader
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Network Config" \
|
|
||||||
--infobox "Network Config..." 3 30
|
|
||||||
sleep 2
|
|
||||||
autogetnet
|
|
||||||
# Select Portmap for Loader
|
|
||||||
getmap
|
|
||||||
if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Storage Map" \
|
|
||||||
--infobox "Storage Map..." 3 30
|
|
||||||
sleep 2
|
|
||||||
autogetmapSelection
|
|
||||||
fi
|
|
||||||
# Config is done
|
|
||||||
writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}"
|
|
||||||
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
|
|
||||||
autopremake
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Building Loader Online
|
|
||||||
function autopremake() {
|
|
||||||
# Read Model Config
|
|
||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
|
||||||
PLATFORM="$(readModelKey "${MODEL}" "platform")"
|
|
||||||
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
|
||||||
DT="$(readModelKey "${MODEL}" "dt")"
|
|
||||||
# Read Config for Arc Settings
|
|
||||||
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
|
|
||||||
# Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation
|
|
||||||
writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}"
|
|
||||||
# Optimized Synoinfo
|
|
||||||
writeConfigKey "synoinfo.support_trim" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_disk_hibernation" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_btrfs_dedupe" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "synoinfo.support_tiny_btrfs_dedupe" "yes" "${USER_CONFIG_FILE}"
|
|
||||||
# eMMC Boot Support
|
|
||||||
if [ "${EMMCBOOT}" = "true" ]; then
|
|
||||||
writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "modules.mmc_core" "" "${USER_CONFIG_FILE}"
|
|
||||||
else
|
|
||||||
deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}"
|
|
||||||
deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}"
|
|
||||||
fi
|
|
||||||
# Build Loader
|
|
||||||
automake
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Building Loader Online
|
|
||||||
function automake() {
|
|
||||||
# Read Model Config
|
|
||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
|
||||||
PLATFORM="$(readModelKey "${MODEL}" "platform")"
|
|
||||||
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
|
|
||||||
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
|
|
||||||
DT="$(readModelKey "${MODEL}" "dt")"
|
|
||||||
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
|
|
||||||
# Cleanup
|
|
||||||
if [ -d "${UNTAR_PAT_PATH}" ]; then
|
|
||||||
rm -rf "${UNTAR_PAT_PATH}"
|
|
||||||
fi
|
|
||||||
mkdir -p "${UNTAR_PAT_PATH}"
|
|
||||||
# Check if all addon exists
|
|
||||||
while IFS=': ' read -r ADDON PARAM; do
|
|
||||||
[ -z "${ADDON}" ] && continue
|
|
||||||
if ! checkAddonExist "${ADDON}" "${PLATFORM}"; then
|
|
||||||
deleteConfigKey "addons.${ADDON}" "${USER_CONFIG_FILE}"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
|
|
||||||
# Get PAT Data from Config
|
|
||||||
PAT_URL_CONF="$(readConfigKey "arc.paturl" "${USER_CONFIG_FILE}")"
|
|
||||||
PAT_HASH_CONF="$(readConfigKey "arc.pathash" "${USER_CONFIG_FILE}")"
|
|
||||||
if [[ -z "${PAT_URL_CONF}" || -z "${PAT_HASH_CONF}" ]]; then
|
|
||||||
PAT_URL_CONF="#"
|
|
||||||
PAT_HASH_CONF="#"
|
|
||||||
fi
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
|
||||||
--infobox "Get PAT Data from Syno..." 3 30
|
|
||||||
# Get PAT Data from Syno
|
|
||||||
idx=0
|
|
||||||
while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break
|
|
||||||
PAT_URL="$(curl -m 5 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].url')"
|
|
||||||
PAT_HASH="$(curl -m 5 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].checksum')"
|
|
||||||
PAT_URL=${PAT_URL%%\?*}
|
|
||||||
if [[ -n "${PAT_URL}" && -n "${PAT_HASH}" ]]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 3
|
|
||||||
idx=$((${idx} + 1))
|
|
||||||
done
|
|
||||||
if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
|
||||||
--infobox "Syno Connection failed,\ntry to get from Github..." 4 30
|
|
||||||
idx=0
|
|
||||||
while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break
|
|
||||||
PAT_URL="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER%%.*}.${PRODUCTVER##*.}/pat_url")"
|
|
||||||
PAT_HASH="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER%%.*}.${PRODUCTVER##*.}/pat_hash")"
|
|
||||||
PAT_URL=${PAT_URL%%\?*}
|
|
||||||
if [[ -n "${PAT_URL}" && -n "${PAT_HASH}" ]]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 3
|
|
||||||
idx=$((${idx} + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Data" --aspect 18 \
|
|
||||||
--infobox "No DSM Data found!\nExit." 0 0
|
|
||||||
sleep 5
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
|
||||||
--infobox "Get PAT Data sucessfull..." 3 30
|
|
||||||
fi
|
|
||||||
if [[ "${PAT_HASH}" != "${PAT_HASH_CONF}" || ! -f "${ORI_ZIMAGE_FILE}" || ! -f "${ORI_RDGZ_FILE}" ]]; then
|
|
||||||
writeConfigKey "arc.paturl" "${PAT_URL}" "${USER_CONFIG_FILE}"
|
|
||||||
writeConfigKey "arc.pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}"
|
|
||||||
# Check for existing Files
|
|
||||||
DSM_FILE="${UNTAR_PAT_PATH}/${PAT_HASH}.tar"
|
|
||||||
# Get new Files
|
|
||||||
DSM_URL="https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/files/${MODEL/+/%2B}/${PRODUCTVER}/${PAT_HASH}.tar"
|
|
||||||
STATUS=$(curl --insecure -s -w "%{http_code}" -L "${DSM_URL}" -o "${DSM_FILE}")
|
|
||||||
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
|
||||||
--infobox "No DSM Image found!\nTry Syno Link." 0 0
|
|
||||||
# Grep PAT_URL
|
|
||||||
PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat"
|
|
||||||
STATUS=$(curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_FILE}" --progress-bar)
|
|
||||||
if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
|
||||||
--infobox "No DSM Image found!\ Exit." 0 0
|
|
||||||
sleep 5
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Extract Files
|
|
||||||
header=$(od -bcN2 ${PAT_FILE} | head -1 | awk '{print $3}')
|
|
||||||
case ${header} in
|
|
||||||
105)
|
|
||||||
isencrypted="no"
|
|
||||||
;;
|
|
||||||
213)
|
|
||||||
isencrypted="no"
|
|
||||||
;;
|
|
||||||
255)
|
|
||||||
isencrypted="yes"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "Could not determine if pat file is encrypted or not, maybe corrupted, try again!"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ "${isencrypted}" = "yes" ]; then
|
|
||||||
# Uses the extractor to untar PAT file
|
|
||||||
LD_LIBRARY_PATH="${EXTRACTOR_PATH}" "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" "${PAT_FILE}" "${UNTAR_PAT_PATH}"
|
|
||||||
else
|
|
||||||
# Untar PAT file
|
|
||||||
tar -xf "${PAT_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1
|
|
||||||
fi
|
|
||||||
# Cleanup PAT Download
|
|
||||||
rm -f "${PAT_FILE}"
|
|
||||||
elif [ -f "${DSM_FILE}" ]; then
|
|
||||||
tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1
|
|
||||||
elif [ ! -f "${UNTAR_PAT_PATH}/zImage" ]; then
|
|
||||||
dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \
|
|
||||||
--infobox "ERROR: No DSM Image found!" 0 0
|
|
||||||
sleep 5
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \
|
|
||||||
--infobox "Image unpack sucessfull..." 3 30
|
|
||||||
# Copy DSM Files to Locations if DSM Files not found
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART1_PATH}"
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART1_PATH}"
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART2_PATH}"
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART2_PATH}"
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/zImage" "${ORI_ZIMAGE_FILE}"
|
|
||||||
cp -f "${UNTAR_PAT_PATH}/rd.gz" "${ORI_RDGZ_FILE}"
|
|
||||||
rm -rf "${UNTAR_PAT_PATH}"
|
|
||||||
fi
|
|
||||||
(
|
|
||||||
livepatch
|
|
||||||
sleep 3
|
|
||||||
) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Build Loader" \
|
|
||||||
--progressbox "Doing the Magic..." 20 70
|
|
||||||
if [[ -f "${ORI_ZIMAGE_FILE}" && -f "${ORI_RDGZ_FILE}" && -f "${MOD_ZIMAGE_FILE}" && -f "${MOD_RDGZ_FILE}" ]]; then
|
|
||||||
# Build is done
|
|
||||||
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
|
|
||||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
|
||||||
if [ "${CUSTOM}" = "false" ]; then
|
|
||||||
rm -f "${PART3_PATH}/automated"
|
|
||||||
fi
|
|
||||||
boot && exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Main loop
|
# Main loop
|
||||||
if grep -q "automated_arc" /proc/cmdline; then
|
if grep -q "automated_arc" /proc/cmdline; then
|
||||||
if [ "${CUSTOM}" = "true" ]; then
|
if [ "${CUSTOM}" = "true" ]; then
|
||||||
arcAutomated
|
arcVersion
|
||||||
else
|
else
|
||||||
automake
|
make
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
[ "${BUILDDONE}" = "true" ] && NEXT="3" || NEXT="1"
|
[ "${BUILDDONE}" = "true" ] && NEXT="3" || NEXT="1"
|
||||||
|
Loading…
Reference in New Issue
Block a user