diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 812b8ee1..c8600da5 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1039,7 +1039,7 @@ function updateMenu() { # Show Storagemenu to user function storageMenu() { MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" # Get Portmap for Loader getmap if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then @@ -1076,7 +1076,7 @@ function sysinfo() { MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" @@ -1305,7 +1305,7 @@ function fullsysinfo() { MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index f2eee8b0..24d8ffdc 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -38,6 +38,7 @@ if [ "${OFFLINE}" = "false" ]; then writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}" else writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}" + cp -f "${PART3_PATH}/configs/offline.json" "${ARC_PATH}/include/offline.json" dialog --backtitle "$(backtitle)" --title "Offline Mode" \ --msgbox "Can't connect to Github.\nSwitch to Offline Mode!" 0 0 fi @@ -50,12 +51,12 @@ KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" # Get DSM Data from Config MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" if [ -n "${MODEL}" ]; then PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${PLATFORM}.dt" "${P_FILE}")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" fi # Get Arc Data from Config @@ -109,7 +110,7 @@ function backtitle() { IPCON="(IP)" fi BACKTITLE="${ARC_TITLE} | " - BACKTITLE+="${MODEL}(${PLATFORM}) | " + BACKTITLE+="${MODEL} | " BACKTITLE+="${PRODUCTVER} | " BACKTITLE+="${IPCON} | " BACKTITLE+="Patch: ${ARCPATCH} | " @@ -122,95 +123,110 @@ function backtitle() { ############################################################################### # Model Selection function arcModel() { + dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \ + --infobox "Reading Models..." 0 0 # Loop menu RESTRICT=1 - FLGBETA=0 - dialog --backtitle "$(backtitle)" --title "Model" --aspect 18 \ - --infobox "Reading Models..." 3 20 - PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)" + PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)" + if [ "${OFFLINE}" = "true" ]; then + MJ="$(python include/functions.py getmodelsoffline -p "${PS[*]}")" + else MJ="$(python include/functions.py getmodels -p "${PS[*]}")" - if [[ -z "${MJ}" || "${MJ}" = "[]" ]]; then - dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \ - --msgbox "Failed to get models, please try again!" 0 0 - return 1 - fi - echo -n "" >"${TMP_PATH}/modellist" - echo "${MJ}" | jq -c '.[]' | while read -r item; do - name=$(echo "$item" | jq -r '.name') - arch=$(echo "$item" | jq -r '.arch') - echo "${name} ${arch}" >>"${TMP_PATH}/modellist" - done - while true; do - echo -n "" >"${TMP_PATH}/menu" - while read -r M A; do - DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" - FLAGS="$(readConfigArray "platforms.${A}.flags" "${P_FILE}")" - ARCCONF="$(readConfigKey "${M}.serial" "${S_FILE}" 2>/dev/null)" - ARC="" - [ -n "${ARCCONF}" ] && ARC="x" - CPU="Intel" - [[ "${A}" = "r1000" || "${A}" = "v1000" || "${A}" = "epyc7002" ]] && CPU="AMD" - IGPUS="" - [[ "${A}" = "apollolake" || "${A}" = "geminilake" || "${A}" = "epyc7002" ]] && IGPUS="x" - HBAS="x" - [ "${DT}" = "true" ] && HBAS="" - [ "${M}" = "SA6400" ] && HBAS="x" - USBS="" - [ "${DT}" = "false" ] && USBS="x" - M_2_CACHE="x" - [[ "${M}" = "DS220+" || "${M}" = "DS224+" || "${M}" = "DS918+" || "${M}" = "DS1019+" || "${M}" = "DS1621xs+" || "${M}" = "RS1619xs+" ]] && M_2_CACHE="" - M_2_STORAGE="x" - [ "${DT}" = "false" ] && M_2_STORAGE="" - [[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_STORAGE="" - # Check id model is compatible with CPU - COMPATIBLE=1 - if [ ${RESTRICT} -eq 1 ]; then - for F in "${FLAGS}"; do if ! grep -q "^flags.*${F}.*" /proc/cpuinfo; then + fi + if [[ -z "${MJ}" || "${MJ}" = "[]" ]]; then + dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \ + --msgbox "Failed to get models, please try again!" 0 0 + return 1 + fi + echo -n "" >"${TMP_PATH}/modellist" + echo "${MJ}" | jq -c '.[]' | while read -r item; do + name=$(echo "$item" | jq -r '.name') + arch=$(echo "$item" | jq -r '.arch') + echo "${name} ${arch}" >>"${TMP_PATH}/modellist" + done + while true; do + echo -n "" >"${TMP_PATH}/menu" + while read -r M A; do + COMPATIBLE=1 + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" + FLAGS="$(readConfigArray "platforms.${A}.flags" "${P_FILE}")" + ARCCONF="$(readConfigKey "${M}.serial" "${S_FILE}" 2>/dev/null)" + ARC="" + [ -n "${ARCCONF}" ] && ARC="x" + CPU="Intel" + [[ "${A}" = "r1000" || "${A}" = "v1000" || "${A}" = "epyc7002" ]] && CPU="AMD" + IGPUS="" + [[ "${A}" = "apollolake" || "${A}" = "geminilake" || "${A}" = "epyc7002" ]] && IGPUS="x" + HBAS="x" + [ "${DT}" = "true" ] && HBAS="" + [ "${M}" = "SA6400" ] && HBAS="x" + USBS="" + [ "${DT}" = "false" ] && USBS="x" + M_2_CACHE="x" + [[ "${M}" = "DS918+" || "${M}" = "DS1019+" || "${M}" = "DS1621xs+" || "${M}" = "RS1619xs+" ]] && M_2_CACHE="+" + [[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_CACHE="" + M_2_STORAGE="x" + [ "${DT}" = "false" ] && M_2_STORAGE="+" + [[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_STORAGE="" + [ "${DT}" = "true" ] && DTS="x" || DTS="" + # Check id model is compatible with CPU + if [ ${RESTRICT} -eq 1 ]; then + for F in "${FLAGS}"; do + if ! grep -q "^flags.*${F}.*" /proc/cpuinfo; then COMPATIBLE=0 break - fi; done - if [ "${DT}" = "true" ] && [[ "${EXTERNALCONTROLLER}" = "true" && ! "${M}" = "SA6400" ]]; then - COMPATIBLE=0 - fi - if [[ ${SATACONTROLLER} -eq 0 && "${EXTERNALCONTROLLER}" = "false" && ! "${M}" = "SA6400" ]]; then - COMPATIBLE=0 fi + done + if [ "${DT}" = "true" ] && [ "${EXTERNALCONTROLLER}" = "true" ] && [ ! "${A}" = "epyc7002" ]; then + COMPATIBLE=0 fi - [ "${DT}" = "true" ] && DTS="x" || DTS="" - [ ${COMPATIBLE} -eq 1 ] && echo "${ID} \"$(printf "\Zb%-8s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn" "${CPU}" "${PLATFORM}" "${DTS}" "${ARC}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}")\" ">>"${TMP_PATH}/menu" - done <<<$(cat "${TMP_PATH}/modellist") - dialog --backtitle "$(backtitle)" --colors \ - --cancel-label "Show all" --help-button --help-label "Exit" \ - --extra-button --extra-label "Info" \ - --menu "Choose Model for Loader (This Chart indicates the original Values, without Addons.)\n $(printf "\Zb%-10s\Zn\Zb%-8s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn" "Model" "CPU" "Platform" "DT" "Arc" "iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount")" 0 115 0 \ - --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" - RET=$? - case ${RET} in - 0) # ok-button - resp=$(cat ${TMP_PATH}/resp) - [ -z "${resp}" ] && return 1 - break - ;; - 1) # cancel-button -> Show all Models - RESTRICT=0 - ;; - 2) # help-button -> Exit - return 0 - break - ;; - 3) # extra-button -> Platform Info - dialog --textbox "./informations/${A}.yml" 15 80 - ;; - 255) # ESC -> Exit - return 1 - break - ;; - esac - done - # read model config for dt and aes + if [ ${SATACONTROLLER} -eq 0 ] && [ "${EXTERNALCONTROLLER}" = "false" ] && [ ! "${A}" = "epyc7002" ]; then + COMPATIBLE=0 + fi + if [ -z "$(grep -w "${M}" "${S_FILE}")" ]; then + COMPATIBLE=0 + fi + else + [ -z "$(grep -w "${M}" "${S_FILE}")" ] && BETA="x" || BETA="" + fi + [ ${COMPATIBLE} -eq 1 ] && echo -e "${M} \"\t$(printf "\Zb%-8s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "${CPU}" "${A}" "${DTS}" "${ARC}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}" "${BETA}")\" ">>"${TMP_PATH}/menu" + done <<<$(cat "${TMP_PATH}/modellist") + dialog --backtitle "$(backtitle)" --colors \ + --cancel-label "Show all" --help-button --help-label "Exit" \ + --extra-button --extra-label "Info" \ + --menu "Choose Model for Loader (x = supported / + = need Addons)\n$(printf "\Zb%-16s\Zn \Zb%-8s\Zn \Zb%-15s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-5s\Zn \Zb%-10s\Zn \Zb%-12s\Zn \Zb%-10s\Zn \Zb%-10s\Zn" "Model" "CPU" "Platform" "DT" "Arc" "iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Beta")" 0 120 0 \ + --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" + RET=$? + case ${RET} in + 0) # ok-button + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 + break + ;; + 1) # cancel-button -> Show all Models + RESTRICT=0 + ;; + 2) # help-button -> Exit + return 0 + break + ;; + 3) # extra-button -> Platform Info + resp=$(cat ${TMP_PATH}/resp) + PLATFORM="$(grep -w "${resp}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" + dialog --backtitle "$(backtitle)" --colors \ + --title "Platform Info" --textbox "./informations/${PLATFORM}.yml" 15 80 + ;; + 255) # ESC -> Exit + return 1 + break + ;; + esac + done + # Reset Model Config if changed if [ "${MODEL}" != "${resp}" ]; then - MODEL="${resp}" PRODUCTVER="" + PLATFORM="$(grep -w "${resp}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" + MODEL="${resp}" writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" writeConfigKey "productver" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" @@ -221,6 +237,7 @@ function arcModel() { writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" + writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" @@ -248,7 +265,9 @@ function arcVersion() { # Select Build for DSM ITEMS="$(readConfigEntriesArray "platforms.${PLATFORM}.productvers" "${P_FILE}" | sort -r)" dialog --clear --no-items --nocancel --backtitle "$(backtitle)" \ - --menu "Choose a Version" 7 30 0 ${ITEMS} 2>"${TMP_PATH}/resp" + --no-items --menu "DSM Version" 7 30 0 ${ITEMS} \ + 2>"${TMP_PATH}/resp" + [ $? -ne 0 ] && return 0 resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ "${PRODUCTVER}" != "${resp}" ]; then @@ -274,13 +293,21 @@ function arcVersion() { KVERP="${KVER}" fi dialog --backtitle "$(backtitle)" --title "Arc Config" \ - --infobox "Reconfiguring Synoinfo and Modules" 3 40 - # Reset synoinfo + --infobox "Reconfiguring Addons, Modules and Synoinfo" 3 50 + # 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 + done <<<$(readConfigMap "platforms.${PLATFORM}.synoinfo" "${WORK_PATH}/platforms.yml") + # Reset Addons + writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" + while IFS=': ' read -r ADDON PARAM; do + [ -z "${ADDON}" ] && continue + if ! checkAddonExist "${ADDON}" "${PLATFORM}" "${KVERP}"; then + deleteConfigKey "addons.\"${ADDON}\"" "${USER_CONFIG_FILE}" + fi + done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") + # Reset Modules writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" while read -r ID DESC; do writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" @@ -304,13 +331,13 @@ function arcVersion() { function arcPatch() { # Read Model Values MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)" if [ "${CUSTOM}" = "true" ]; then ARCPATCHPRE="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" [ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false" if [[ "${ARCPATCH}" = "true" && "${ARCPATCHPRE}" = "true" ]]; then - SN="$(readModelKey "${MODEL}" "arc.serial")" + SN="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)" writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}" writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" else @@ -481,7 +508,7 @@ function premake() { MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" # 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 @@ -510,7 +537,7 @@ function arcSummary() { MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" @@ -584,28 +611,19 @@ function arcSummary() { ############################################################################### # Building Loader Online function make() { + dialog --backtitle "$(backtitle)" --title "Model" --aspect 18 \ + --infobox "Reading Models..." 3 20 # Read Model Config MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" + DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" 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}" - if [ "${CUSTOM}" = "false" ]; then - # Check if all addon exists - while IFS=': ' read -r ADDON PARAM; do - [ -z "${ADDON}" ] && continue - if ! checkAddonExist "${ADDON}" "${PLATFORM}"; then - dialog --backtitle "$(backtitle)" --title "Error" --aspect 18 \ - --msgbox "Addon ${ADDON} not found!" 0 0 - return 1 - fi - done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") - fi # Check for offline Mode if [ "${OFFLINE}" = "true" ]; then offlinemake diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index cc288290..f59bdc84 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -41,7 +41,6 @@ fi # Read model/system variables PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" -MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" @@ -62,11 +61,6 @@ echo -e "CPU: \033[1;37m${CPU}\033[0m" echo -e "MEM: \033[1;37m${RAM}\033[0m" echo -if [[ ! -f "${MODEL_CONFIG_PATH}/${MODEL}.yml" || -z "$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}]")" ]]; then - echo -e "\033[1;33m*** The current version of Arc does not support booting ${MODEL}-${PRODUCTVER}, please rebuild. ***\033[0m" - exit 1 -fi - if ! readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q nvmesystem; then HASATA=0 for D in $(lsblk -dpno NAME); do @@ -86,14 +80,13 @@ SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")" DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")" EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" -DT="$(readModelKey "${MODEL}" "dt")" +DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" declare -A CMDLINE # Build Cmdline -MODELID="$(readModelKey ${MODEL} "id")" -CMDLINE['syno_hw_version']="${MODELID:-${MODEL}}" +CMDLINE['syno_hw_version']="${MODEL}" [ -z "${VID}" ] && VID="0x46f4" # Sanity check [ -z "${PID}" ] && PID="0x0001" # Sanity check CMDLINE['vid']="${VID}" diff --git a/files/initrd/opt/arc/include/configFile.sh b/files/initrd/opt/arc/include/configFile.sh index 8a6713d1..866ba3ed 100755 --- a/files/initrd/opt/arc/include/configFile.sh +++ b/files/initrd/opt/arc/include/configFile.sh @@ -4,7 +4,7 @@ # 1 - Path of Key # 2 - Path of yaml config file function deleteConfigKey() { - yq eval 'del(.'${1}')' --inplace "${2}" + yq eval 'del(.'${1}')' --inplace "${2}" 2>/dev/null } ############################################################################### @@ -13,7 +13,7 @@ function deleteConfigKey() { # 2 - Value # 3 - Path of yaml config file function writeConfigKey() { - [ "${2}" = "{}" ] && yq eval '.'${1}' = {}' --inplace "${3}" || yq eval '.'${1}' = "'"${2}"'"' --inplace "${3}" + [ "${2}" = "{}" ] && yq eval '.'${1}' = {}' --inplace "${3}" 2>/dev/null || yq eval '.'${1}' = "'"${2}"'"' --inplace "${3}" 2>/dev/null } ############################################################################### @@ -22,7 +22,7 @@ function writeConfigKey() { # 2 - Path of yaml config file # Return Value function readConfigKey() { - RESULT=$(yq eval '.'${1}' | explode(.)' "${2}") + RESULT=$(yq eval '.'${1}' | explode(.)' "${2}" 2>/dev/null) [ "${RESULT}" == "null" ] && echo "" || echo ${RESULT} } @@ -41,7 +41,7 @@ function initConfigKey() { # 2 - Path of yaml config file # Returns map of values function readConfigMap() { - yq eval '.'${1}' | explode(.) | to_entries | map([.key, .value] | join(": ")) | .[]' "${2}" + yq eval '.'${1}' | explode(.) | to_entries | map([.key, .value] | join(": ")) | .[]' "${2}" 2>/dev/null } ############################################################################### @@ -50,7 +50,7 @@ function readConfigMap() { # 2 - Path of yaml config file # Returns array/map of values function readConfigArray() { - yq eval '.'${1}'[]' "${2}" + yq eval '.'${1}'[]' "${2}" 2>/dev/null } ############################################################################### @@ -59,5 +59,13 @@ function readConfigArray() { # 2 - Path of yaml config file # Returns array of values function readConfigEntriesArray() { - yq eval '.'${1}' | explode(.) | to_entries | map([.key])[] | .[]' "${2}" + yq eval '.'${1}' | explode(.) | to_entries | map([.key])[] | .[]' "${2}" 2>/dev/null } + +############################################################################### +# Check yaml config file +# 1 - Path of yaml config file +# Returns error information +function checkConfigFile() { + yq eval "${1}" 2>&1 +} \ No newline at end of file diff --git a/files/initrd/opt/arc/include/functions.py b/files/initrd/opt/arc/include/functions.py index 45a22916..8ee991ff 100755 --- a/files/initrd/opt/arc/include/functions.py +++ b/files/initrd/opt/arc/include/functions.py @@ -14,7 +14,7 @@ WORK_PATH = os.path.abspath(os.path.dirname(__file__)) @click.group() def cli(): """ - The CLI is a commands to RR. + The CLI is a commands to Arc. """ pass @@ -54,7 +54,7 @@ def makeqr(data, file, location, output): qr = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4,) qr.add_data(data) qr.make(fit=True) - img = qr.make_image(fill_color="purple", back_color="white") + img = qr.make_image(fill_color="grey", back_color="black") img = img.convert("RGBA") pixels = img.load() for i in range(img.size[0]): @@ -127,6 +127,39 @@ def getmodels(platforms=None): models = sorted(models, key=lambda k: (k["arch"], k["name"])) print(json.dumps(models, indent=4)) +@cli.command() +@click.option("-p", "--platforms", type=str, help="The platforms of Syno.") +def getmodelsoffline(platforms=None): + """ + Get Syno Models. + """ + import re, json + import requests + import fcntl, struct + + if platforms is not None and platforms != "": + PS = platforms.lower().replace(",", " ").split() + else: + PS = [] + + models = [] + with open(os.path.join(WORK_PATH, "offline.json")) as user_file: + data = json.load(user_file) + + for I in data["channel"]["item"]: + if not I["title"].startswith("DSM"): + continue + for J in I["model"]: + arch = J["mUnique"].split("_")[1] + name = J["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+") + if len(PS) > 0 and arch.lower() not in PS: + continue + if any(name == B["name"] for B in models): + continue + models.append({"name": name, "arch": arch}) + + models = sorted(models, key=lambda k: (k["arch"], k["name"])) + print(json.dumps(models, indent=4)) if __name__ == "__main__": cli() \ No newline at end of file diff --git a/files/initrd/opt/arc/include/storage.sh b/files/initrd/opt/arc/include/storage.sh index 2c9f1d27..fdebc034 100755 --- a/files/initrd/opt/arc/include/storage.sh +++ b/files/initrd/opt/arc/include/storage.sh @@ -120,18 +120,15 @@ function getmap() { writeConfigKey "device.harddrives" "${HARDDRIVES}" "${USER_CONFIG_FILE}" # Check for Sata Boot LASTDRIVE=0 - while read -r LINE; do - if [[ "${BUS}" != "usb" && ${LINE} -eq 0 ]]; then - MAXDISKS="$(readModelKey "${MODEL}" "disks")" - if [ ${MAXDISKS} -lt ${DRIVES} ]; then - MAXDISKS=${DRIVES} - fi - echo -n "${LINE}>${MAXDISKS}:">>"${TMP_PATH}/remap" - elif [ ! ${LINE} = ${LASTDRIVE} ]; then - echo -n "${LINE}>${LASTDRIVE}:">>"${TMP_PATH}/remap" + while read -r D; do + if [[ "${BUS}" != "usb" && ${D} -eq 0 ]]; then + MAXDISKS=${DRIVES} + echo -n "${D}>${MAXDISKS}:">>"${TMP_PATH}/remap" + elif [ ! ${D} = ${LASTDRIVE} ]; then + echo -n "${D}>${LASTDRIVE}:">>"${TMP_PATH}/remap" LASTDRIVE=$((${LASTDRIVE} + 1)) - elif [ ${LINE} = ${LASTDRIVE} ]; then - LASTDRIVE=$((${LINE} + 1)) + elif [ ${D} = ${LASTDRIVE} ]; then + LASTDRIVE=$((${D} + 1)) fi done <<<$(cat "${TMP_PATH}/ports") } diff --git a/img-gen.sh b/img-gen.sh index 7c6fe204..b86931da 100755 --- a/img-gen.sh +++ b/img-gen.sh @@ -16,6 +16,7 @@ getModules "files/p3/modules" getConfigs "files/p3/configs" getPatches "files/p3/patches" getTheme "files/p1/boot/grub" +getOffline "files/p3/configs" IMAGE_FILE="arc.img" gzip -dc "files/initrd/opt/arc/grub.img.gz" >"${IMAGE_FILE}" diff --git a/scripts/func.sh b/scripts/func.sh index 5176cb7b..1a80d5ee 100755 --- a/scripts/func.sh +++ b/scripts/func.sh @@ -210,12 +210,12 @@ function getBuildroot() { TAG=$(curl -s "https://api.github.com/repos/AuxXxilium/arc-buildroot/releases" | jq -r ".[0].tag_name") fi [ ! -d "${DEST_PATH}" ] && mkdir -p "${DEST_PATH}" - rm -rf "${DEST_PATH}/bzImage-arc" + rm -f "${DEST_PATH}/bzImage-arc" STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-buildroot/releases/download/${TAG}/bzImage" -o "${DEST_PATH}/bzImage-arc") echo "TAG=${TAG}; Status=${STATUS}" [ ${STATUS} -ne 200 ] && exit 1 - rm -rf "${DEST_PATH}/initrd-arc" + rm -f "${DEST_PATH}/initrd-arc" STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-buildroot/releases/download/${TAG}/rootfs.cpio.xz" -o "${DEST_PATH}/initrd-arc") echo "TAG=${TAG}; Status=${STATUS}" [ ${STATUS} -ne 200 ] && exit 1 @@ -223,6 +223,21 @@ function getBuildroot() { echo "Getting Buildroot end" } +# Get latest Offline +# $1 path +function getOffline() { + echo "Getting Offline begin" + local DEST_PATH="${1:-configs}" + + [ ! -d "${DEST_PATH}" ] && mkdir -p "${DEST_PATH}" + rm -f "${DEST_PATH}/offline.json" + STATUS=$(curl -w "%{http_code}" -L "https://autoupdate.synology.com/os/v2" -o "${DEST_PATH}/offline.json") + echo "Status=${STATUS}" + [ ${STATUS} -ne 200 ] && exit 1 + + echo "Getting Offline end" +} + # repack initrd # $1 initrd file # $2 plugin path