diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 137b6de1f..d64d7346f 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -174,37 +174,40 @@ function modulesMenu() { BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; 6) - TEXT="" - TEXT+="This function is experimental and dangerous. If you don't know much, please exit.\n" - TEXT+="The imported .ko of this function will be implanted into the corresponding arch's modules package, which will affect all models of the arch.\n" - TEXT+="This program will not determine the availability of imported modules or even make type judgments, as please double check if it is correct.\n" - TEXT+="If you want to remove it, please go to the \"Update Menu\" -> \"Update Modules\" to forcibly update the modules. All imports will be reset.\n" - TEXT+="Do you want to continue?" - dialog --backtitle "$(backtitle)" --title "Add external Module" \ - --yesno "${TEXT}" 0 0 - [ $? -ne 0 ] && return 1 - dialog --backtitle "$(backtitle)" --aspect 18 --colors --inputbox "Please enter the complete URL to download.\n" 0 0 \ - 2>"${TMP_PATH}/resp" - URL=$(cat "${TMP_PATH}/resp") - [ -z "${URL}" ] && return 1 - clear - echo "Downloading ${URL}" - STATUS=$(curl -kLJO -w "%{http_code}" "${URL}" --progress-bar) - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - dialog --backtitle "$(backtitle)" --title "Add external Module" --aspect 18 \ - --msgbox "ERROR: Check internet, URL or cache disk space" 0 0 - return 1 - fi - KONAME=$(basename "$URL") - if [ -n "${KONAME}" ] && [ "${KONAME##*.}" = "ko" ]; then - addToModules "${PLATFORM}" "${KVERP}" "${TMP_UP_PATH}/${USER_FILE}" - dialog --backtitle "$(backtitle)" --title "Add external Module" --aspect 18 \ - --msgbox "Module ${KONAME} added to ${PLATFORM}-${KVER}" 0 0 - rm -f "${KONAME}" - else - dialog --backtitle "$(backtitle)" --title "Add external Module" --aspect 18 \ - --msgbox "File format not recognized!" 0 0 - fi + MSG="" + MSG+="This function is experimental and dangerous. If you don't know much, please exit.\n" + MSG+="The imported .ko of this function will be implanted into the corresponding arch's modules package, which will affect all models of the arch.\n" + MSG+="This program will not determine the availability of imported modules or even make type judgments, as please double check if it is correct.\n" + MSG+="If you want to remove it, please go to the \"Update Menu\" -> \"Update Modules\" to forcibly update the modules. All imports will be reset.\n" + MSG+="Do you want to continue?" + dialog --backtitle "$(backtitle)" --title "External Modules" \ + --yesno "${MSG}" 0 0 + [ $? -ne 0 ] && return + TMP_UP_PATH=${TMP_PATH}/users + USER_FILE="" + rm -rf ${TMP_UP_PATH} + mkdir -p ${TMP_UP_PATH} + dialog --backtitle "$(backtitle)" --title "External Modules" \ + --ok-label "Proceed" --msgbox "Please upload the *.ko file to /tmp/users.\n- Use SFTP at ${IPCON}:22 User: root PW: arc\n- Use Webclient at http://${IPCON}:7304" 7 50 + for F in $(ls "${TMP_UP_PATH}" 2>/dev/null); do + USER_FILE="${F}" + if [ -n "${USER_FILE}" ] && [ "${USER_FILE##*.}" = "ko" ]; then + KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")" + # Modify KVER for Epyc7002 + if [ "${PLATFORM}" = "epyc7002" ]; then + KVERP="${PRODUCTVER}-${KVER}" + else + KVERP="${KVER}" + fi + addToModules "${PLATFORM}" "${KVERP}" "${TMP_UP_PATH}/${USER_FILE}" + dialog --backtitle "$(backtitle)" --title "External Modules" \ + --msgbox "Module: ${USER_FILE}\nadded to ${PLATFORM}-${KVERP}" 7 50 + rm -f "${TMP_UP_PATH}/${USER_FILE}" + else + dialog --backtitle "$(backtitle)" --title "External Modules" \ + --msgbox "Not a valid file, please try again!" 7 50 + fi + done writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" ;; diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 6caa3949e..2382d2cbb 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -123,141 +123,143 @@ function backtitle() { ############################################################################### # Model Selection function arcModel() { - dialog --backtitle "$(backtitle)" --title "DSM Model" \ - --infobox "Reading Models..." 3 25 - # Loop menu - RESTRICT=1 - 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[*]}")" - 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="" - BETA="" - [ -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 + if [ "${CUSTOM}" = "false" ]; then + dialog --backtitle "$(backtitle)" --title "DSM Model" \ + --infobox "Reading Models..." 3 25 + # Loop menu + RESTRICT=1 + 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[*]}")" + 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="" + BETA="" + [ -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" ] && [ ! "${A}" = "epyc7002" ]; then COMPATIBLE=0 - break fi - done - if [ "${DT}" = "true" ] && [ "${EXTERNALCONTROLLER}" = "true" ] && [ ! "${A}" = "epyc7002" ]; then - COMPATIBLE=0 + if [ "${SATACONTROLLER}" = "0" ] && [ "${EXTERNALCONTROLLER}" = "false" ] && [ ! "${A}" = "epyc7002" ]; then + COMPATIBLE=0 + fi + [ -z "$(grep -w "${M}" "${S_FILE}")" ] && COMPATIBLE=0 + else + [ -z "$(grep -w "${M}" "${S_FILE}")" ] && BETA="x" || BETA="" fi - if [ "${SATACONTROLLER}" = "0" ] && [ "${EXTERNALCONTROLLER}" = "false" ] && [ ! "${A}" = "epyc7002" ]; then - COMPATIBLE=0 + [ -z "$(grep -w "${A}" "${P_FILE}")" ] && COMPATIBLE=0 + if [ -n "${ARC_KEY}" ]; then + [ ${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" + else + [ ${COMPATIBLE} -eq 1 ] && echo -e "${M} \"\t$(printf "\Zb%-8s\Zn \Zb%-15s\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}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}" "${BETA}")\" ">>"${TMP_PATH}/menu" fi - [ -z "$(grep -w "${M}" "${S_FILE}")" ] && COMPATIBLE=0 - else - [ -z "$(grep -w "${M}" "${S_FILE}")" ] && BETA="x" || BETA="" - fi - [ -z "$(grep -w "${A}" "${P_FILE}")" ] && COMPATIBLE=0 + done <<<$(cat "${TMP_PATH}/modellist") if [ -n "${ARC_KEY}" ]; then - [ ${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" + dialog --backtitle "$(backtitle)" --title "Arc DSM Model" --colors \ + --cancel-label "Show all" --help-button --help-label "Exit" \ + --extra-button --extra-label "Info" \ + --menu "Supported Models for Loader (x = supported / + = need Addons) | Beta Models can have faulty Values.\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" else - [ ${COMPATIBLE} -eq 1 ] && echo -e "${M} \"\t$(printf "\Zb%-8s\Zn \Zb%-15s\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}" "${IGPUS}" "${HBAS}" "${M_2_CACHE}" "${M_2_STORAGE}" "${USBS}" "${BETA}")\" ">>"${TMP_PATH}/menu" + dialog --backtitle "$(backtitle)" --title "DSM Model" --colors \ + --cancel-label "Show all" --help-button --help-label "Exit" \ + --extra-button --extra-label "Info" \ + --menu "Supported Models for Loader (x = supported / + = need Addons) | Beta Models can have faulty Values.\n$(printf "\Zb%-16s\Zn \Zb%-8s\Zn \Zb%-15s\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" "iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Beta")" 0 120 0 \ + --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" fi - done <<<$(cat "${TMP_PATH}/modellist") - if [ -n "${ARC_KEY}" ]; then - dialog --backtitle "$(backtitle)" --title "Arc DSM Model" --colors \ - --cancel-label "Show all" --help-button --help-label "Exit" \ - --extra-button --extra-label "Info" \ - --menu "Supported Models for Loader (x = supported / + = need Addons) | Beta Models can have faulty Values.\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" - else - dialog --backtitle "$(backtitle)" --title "DSM Model" --colors \ - --cancel-label "Show all" --help-button --help-label "Exit" \ - --extra-button --extra-label "Info" \ - --menu "Supported Models for Loader (x = supported / + = need Addons) | Beta Models can have faulty Values.\n$(printf "\Zb%-16s\Zn \Zb%-8s\Zn \Zb%-15s\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" "iGPU" "HBA" "M.2 Cache" "M.2 Volume" "USB Mount" "Beta")" 0 120 0 \ - --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" - fi - RET=$? - case ${RET} in - 0) # ok-button - resp=$(cat ${TMP_PATH}/resp) - [ -z "${resp}" ] && return 1 - break - ;; - 1) # cancel-button -> Show all Models - [ ${RESTRICT} -eq 1 ] && RESTRICT=0 || RESTRICT=1 - ;; - 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 + RET=$? + case ${RET} in + 0) # ok-button + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 + break + ;; + 1) # cancel-button -> Show all Models + [ ${RESTRICT} -eq 1 ] && RESTRICT=0 || RESTRICT=1 + ;; + 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 + fi # Reset Model Config if changed if [ "${MODEL}" != "${resp}" ]; then - PRODUCTVER="" - PLATFORM="$(grep -w "${resp}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" - MODEL="${resp}" - MODELID="$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/')" + if [ "${CUSTOM}" = "false" ]; then + PRODUCTVER="" + MODEL="${resp}" + writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" + writeConfigKey "productver" "" "${USER_CONFIG_FILE}" + else + MODEL="${readConfigKey "model" "${USER_CONFIG_FILE}"}" + fi + PLATFORM="$(grep -w "${MODEL}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)" + MODELID="$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/; s/XS+/xs+/')" writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" writeConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.remap" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" - writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}" writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}" - writeConfigKey "productver" "" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" - if [ "${OFFLINE}" = "false" ]; then - getLogo "${MODEL}" - fi 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 @@ -639,7 +641,7 @@ function make() { PAT_URL=$(echo ${PAT_DATA} | jq -r '.info.system.detail[0].items[0].files[0].url') PAT_HASH=$(echo ${PAT_DATA} | jq -r '.info.system.detail[0].items[0].files[0].checksum') PAT_URL=${PAT_URL%%\?*} - if [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ]; then + if [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && [ echo ${PAT_URL} | grep "https://" ]; then break fi fi @@ -878,7 +880,7 @@ function boot() { if grep -q "automated_arc" /proc/cmdline; then # Check for Custom Build if [ "${CUSTOM}" = "true" ]; then - arcVersion + arcModel else make fi