tree: reformate part 3

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-05-09 16:52:47 +02:00
parent 828d1c2ad7
commit 9698a8757c
8 changed files with 202 additions and 137 deletions

View File

@ -1039,7 +1039,7 @@ function updateMenu() {
# Show Storagemenu to user # Show Storagemenu to user
function storageMenu() { function storageMenu() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")" DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")"
# Get Portmap for Loader # Get 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
@ -1076,7 +1076,7 @@ function sysinfo() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${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}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"
@ -1305,7 +1305,7 @@ function fullsysinfo() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${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}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"

View File

@ -38,6 +38,7 @@ if [ "${OFFLINE}" = "false" ]; then
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}" writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
else else
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}" 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" \ dialog --backtitle "$(backtitle)" --title "Offline Mode" \
--msgbox "Can't connect to Github.\nSwitch to Offline Mode!" 0 0 --msgbox "Can't connect to Github.\nSwitch to Offline Mode!" 0 0
fi fi
@ -50,12 +51,12 @@ KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
# Get DSM Data from Config # Get DSM Data from Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")" MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
if [ -n "${MODEL}" ]; then if [ -n "${MODEL}" ]; then
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")" DT="$(readConfigKey "platforms.${PLATFORM}.dt" "${P_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
fi fi
# Get Arc Data from Config # Get Arc Data from Config
@ -109,7 +110,7 @@ function backtitle() {
IPCON="(IP)" IPCON="(IP)"
fi fi
BACKTITLE="${ARC_TITLE} | " BACKTITLE="${ARC_TITLE} | "
BACKTITLE+="${MODEL}(${PLATFORM}) | " BACKTITLE+="${MODEL} | "
BACKTITLE+="${PRODUCTVER} | " BACKTITLE+="${PRODUCTVER} | "
BACKTITLE+="${IPCON} | " BACKTITLE+="${IPCON} | "
BACKTITLE+="Patch: ${ARCPATCH} | " BACKTITLE+="Patch: ${ARCPATCH} | "
@ -122,95 +123,110 @@ function backtitle() {
############################################################################### ###############################################################################
# Model Selection # Model Selection
function arcModel() { function arcModel() {
dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \
--infobox "Reading Models..." 0 0
# Loop menu # Loop menu
RESTRICT=1 RESTRICT=1
FLGBETA=0 PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)"
dialog --backtitle "$(backtitle)" --title "Model" --aspect 18 \ if [ "${OFFLINE}" = "true" ]; then
--infobox "Reading Models..." 3 20 MJ="$(python include/functions.py getmodelsoffline -p "${PS[*]}")"
PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)" else
MJ="$(python include/functions.py getmodels -p "${PS[*]}")" MJ="$(python include/functions.py getmodels -p "${PS[*]}")"
if [[ -z "${MJ}" || "${MJ}" = "[]" ]]; then fi
dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \ if [[ -z "${MJ}" || "${MJ}" = "[]" ]]; then
--msgbox "Failed to get models, please try again!" 0 0 dialog --backtitle "$(backtitle)" --title "Model" --title "Model" \
return 1 --msgbox "Failed to get models, please try again!" 0 0
fi return 1
echo -n "" >"${TMP_PATH}/modellist" fi
echo "${MJ}" | jq -c '.[]' | while read -r item; do echo -n "" >"${TMP_PATH}/modellist"
name=$(echo "$item" | jq -r '.name') echo "${MJ}" | jq -c '.[]' | while read -r item; do
arch=$(echo "$item" | jq -r '.arch') name=$(echo "$item" | jq -r '.name')
echo "${name} ${arch}" >>"${TMP_PATH}/modellist" arch=$(echo "$item" | jq -r '.arch')
done echo "${name} ${arch}" >>"${TMP_PATH}/modellist"
while true; do done
echo -n "" >"${TMP_PATH}/menu" while true; do
while read -r M A; do echo -n "" >"${TMP_PATH}/menu"
DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")" while read -r M A; do
FLAGS="$(readConfigArray "platforms.${A}.flags" "${P_FILE}")" COMPATIBLE=1
ARCCONF="$(readConfigKey "${M}.serial" "${S_FILE}" 2>/dev/null)" DT="$(readConfigKey "platforms.${A}.dt" "${P_FILE}")"
ARC="" FLAGS="$(readConfigArray "platforms.${A}.flags" "${P_FILE}")"
[ -n "${ARCCONF}" ] && ARC="x" ARCCONF="$(readConfigKey "${M}.serial" "${S_FILE}" 2>/dev/null)"
CPU="Intel" ARC=""
[[ "${A}" = "r1000" || "${A}" = "v1000" || "${A}" = "epyc7002" ]] && CPU="AMD" [ -n "${ARCCONF}" ] && ARC="x"
IGPUS="" CPU="Intel"
[[ "${A}" = "apollolake" || "${A}" = "geminilake" || "${A}" = "epyc7002" ]] && IGPUS="x" [[ "${A}" = "r1000" || "${A}" = "v1000" || "${A}" = "epyc7002" ]] && CPU="AMD"
HBAS="x" IGPUS=""
[ "${DT}" = "true" ] && HBAS="" [[ "${A}" = "apollolake" || "${A}" = "geminilake" || "${A}" = "epyc7002" ]] && IGPUS="x"
[ "${M}" = "SA6400" ] && HBAS="x" HBAS="x"
USBS="" [ "${DT}" = "true" ] && HBAS=""
[ "${DT}" = "false" ] && USBS="x" [ "${M}" = "SA6400" ] && HBAS="x"
M_2_CACHE="x" USBS=""
[[ "${M}" = "DS220+" || "${M}" = "DS224+" || "${M}" = "DS918+" || "${M}" = "DS1019+" || "${M}" = "DS1621xs+" || "${M}" = "RS1619xs+" ]] && M_2_CACHE="" [ "${DT}" = "false" ] && USBS="x"
M_2_STORAGE="x" M_2_CACHE="x"
[ "${DT}" = "false" ] && M_2_STORAGE="" [[ "${M}" = "DS918+" || "${M}" = "DS1019+" || "${M}" = "DS1621xs+" || "${M}" = "RS1619xs+" ]] && M_2_CACHE="+"
[[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_STORAGE="" [[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_CACHE=""
# Check id model is compatible with CPU M_2_STORAGE="x"
COMPATIBLE=1 [ "${DT}" = "false" ] && M_2_STORAGE="+"
if [ ${RESTRICT} -eq 1 ]; then [[ "${M}" = "DS220+" || "${M}" = "DS224+" ]] && M_2_STORAGE=""
for F in "${FLAGS}"; do if ! grep -q "^flags.*${F}.*" /proc/cpuinfo; then [ "${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 COMPATIBLE=0
break 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 fi
done
if [ "${DT}" = "true" ] && [ "${EXTERNALCONTROLLER}" = "true" ] && [ ! "${A}" = "epyc7002" ]; then
COMPATIBLE=0
fi fi
[ "${DT}" = "true" ] && DTS="x" || DTS="" if [ ${SATACONTROLLER} -eq 0 ] && [ "${EXTERNALCONTROLLER}" = "false" ] && [ ! "${A}" = "epyc7002" ]; then
[ ${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" COMPATIBLE=0
done <<<$(cat "${TMP_PATH}/modellist") fi
dialog --backtitle "$(backtitle)" --colors \ if [ -z "$(grep -w "${M}" "${S_FILE}")" ]; then
--cancel-label "Show all" --help-button --help-label "Exit" \ COMPATIBLE=0
--extra-button --extra-label "Info" \ fi
--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 \ else
--file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" [ -z "$(grep -w "${M}" "${S_FILE}")" ] && BETA="x" || BETA=""
RET=$? fi
case ${RET} in [ ${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"
0) # ok-button done <<<$(cat "${TMP_PATH}/modellist")
resp=$(cat ${TMP_PATH}/resp) dialog --backtitle "$(backtitle)" --colors \
[ -z "${resp}" ] && return 1 --cancel-label "Show all" --help-button --help-label "Exit" \
break --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 \
1) # cancel-button -> Show all Models --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp"
RESTRICT=0 RET=$?
;; case ${RET} in
2) # help-button -> Exit 0) # ok-button
return 0 resp=$(cat ${TMP_PATH}/resp)
break [ -z "${resp}" ] && return 1
;; break
3) # extra-button -> Platform Info ;;
dialog --textbox "./informations/${A}.yml" 15 80 1) # cancel-button -> Show all Models
;; RESTRICT=0
255) # ESC -> Exit ;;
return 1 2) # help-button -> Exit
break return 0
;; break
esac ;;
done 3) # extra-button -> Platform Info
# read model config for dt and aes 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 if [ "${MODEL}" != "${resp}" ]; then
MODEL="${resp}"
PRODUCTVER="" PRODUCTVER=""
PLATFORM="$(grep -w "${resp}" "${TMP_PATH}/modellist" | awk '{print $2}' | head -n 1)"
MODEL="${resp}"
writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}" writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}"
writeConfigKey "productver" "" "${USER_CONFIG_FILE}" writeConfigKey "productver" "" "${USER_CONFIG_FILE}"
writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}"
@ -221,6 +237,7 @@ function arcModel() {
writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" writeConfigKey "arc.sn" "" "${USER_CONFIG_FILE}"
writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" writeConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}"
writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}" writeConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}"
writeConfigKey "platform" "${PLATFORM}" "${USER_CONFIG_FILE}"
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}"
@ -248,7 +265,9 @@ function arcVersion() {
# Select Build for DSM # Select Build for DSM
ITEMS="$(readConfigEntriesArray "platforms.${PLATFORM}.productvers" "${P_FILE}" | sort -r)" ITEMS="$(readConfigEntriesArray "platforms.${PLATFORM}.productvers" "${P_FILE}" | sort -r)"
dialog --clear --no-items --nocancel --backtitle "$(backtitle)" \ 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) resp=$(cat ${TMP_PATH}/resp)
[ -z "${resp}" ] && return 1 [ -z "${resp}" ] && return 1
if [ "${PRODUCTVER}" != "${resp}" ]; then if [ "${PRODUCTVER}" != "${resp}" ]; then
@ -274,13 +293,21 @@ function arcVersion() {
KVERP="${KVER}" KVERP="${KVER}"
fi fi
dialog --backtitle "$(backtitle)" --title "Arc Config" \ dialog --backtitle "$(backtitle)" --title "Arc Config" \
--infobox "Reconfiguring Synoinfo and Modules" 3 40 --infobox "Reconfiguring Addons, Modules and Synoinfo" 3 50
# Reset synoinfo # Reset Synoinfo
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
while IFS=': ' read -r KEY VALUE; do while IFS=': ' read -r KEY VALUE; do
writeConfigKey "synoinfo.\"${KEY}\"" "${VALUE}" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo.\"${KEY}\"" "${VALUE}" "${USER_CONFIG_FILE}"
done <<<$(readModelMap "${MODEL}" "synoinfo") done <<<$(readConfigMap "platforms.${PLATFORM}.synoinfo" "${WORK_PATH}/platforms.yml")
# Reset modules # 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}" writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
while read -r ID DESC; do while read -r ID DESC; do
writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}"
@ -304,13 +331,13 @@ function arcVersion() {
function arcPatch() { function arcPatch() {
# Read Model Values # Read Model Values
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" 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)" ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)"
if [ "${CUSTOM}" = "true" ]; then if [ "${CUSTOM}" = "true" ]; then
ARCPATCHPRE="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ARCPATCHPRE="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
[ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false" [ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false"
if [[ "${ARCPATCH}" = "true" && "${ARCPATCHPRE}" = "true" ]]; then 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.sn" "${SN}" "${USER_CONFIG_FILE}"
writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}"
else else
@ -481,7 +508,7 @@ function premake() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${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 # Read Config for Arc Settings
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
# 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
@ -510,7 +537,7 @@ function arcSummary() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${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}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")" ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"
@ -584,28 +611,19 @@ function arcSummary() {
############################################################################### ###############################################################################
# Building Loader Online # Building Loader Online
function make() { function make() {
dialog --backtitle "$(backtitle)" --title "Model" --aspect 18 \
--infobox "Reading Models..." 3 20
# Read Model Config # Read Model Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${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}")" OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
# Cleanup # Cleanup
if [ -d "${UNTAR_PAT_PATH}" ]; then if [ -d "${UNTAR_PAT_PATH}" ]; then
rm -rf "${UNTAR_PAT_PATH}" rm -rf "${UNTAR_PAT_PATH}"
fi fi
mkdir -p "${UNTAR_PAT_PATH}" 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 # Check for offline Mode
if [ "${OFFLINE}" = "true" ]; then if [ "${OFFLINE}" = "true" ]; then
offlinemake offlinemake

View File

@ -41,7 +41,6 @@ fi
# Read model/system variables # Read model/system variables
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
MACSYS="$(readConfigKey "arc.macsys" "${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 -e "MEM: \033[1;37m${RAM}\033[0m"
echo 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 if ! readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q nvmesystem; then
HASATA=0 HASATA=0
for D in $(lsblk -dpno NAME); do 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}")" KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")"
DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")" DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")"
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${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}")" KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
declare -A CMDLINE declare -A CMDLINE
# Build Cmdline # Build Cmdline
MODELID="$(readModelKey ${MODEL} "id")" CMDLINE['syno_hw_version']="${MODEL}"
CMDLINE['syno_hw_version']="${MODELID:-${MODEL}}"
[ -z "${VID}" ] && VID="0x46f4" # Sanity check [ -z "${VID}" ] && VID="0x46f4" # Sanity check
[ -z "${PID}" ] && PID="0x0001" # Sanity check [ -z "${PID}" ] && PID="0x0001" # Sanity check
CMDLINE['vid']="${VID}" CMDLINE['vid']="${VID}"

View File

@ -4,7 +4,7 @@
# 1 - Path of Key # 1 - Path of Key
# 2 - Path of yaml config file # 2 - Path of yaml config file
function deleteConfigKey() { 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 # 2 - Value
# 3 - Path of yaml config file # 3 - Path of yaml config file
function writeConfigKey() { 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 # 2 - Path of yaml config file
# Return Value # Return Value
function readConfigKey() { function readConfigKey() {
RESULT=$(yq eval '.'${1}' | explode(.)' "${2}") RESULT=$(yq eval '.'${1}' | explode(.)' "${2}" 2>/dev/null)
[ "${RESULT}" == "null" ] && echo "" || echo ${RESULT} [ "${RESULT}" == "null" ] && echo "" || echo ${RESULT}
} }
@ -41,7 +41,7 @@ function initConfigKey() {
# 2 - Path of yaml config file # 2 - Path of yaml config file
# Returns map of values # Returns map of values
function readConfigMap() { 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 # 2 - Path of yaml config file
# Returns array/map of values # Returns array/map of values
function readConfigArray() { 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 # 2 - Path of yaml config file
# Returns array of values # Returns array of values
function readConfigEntriesArray() { 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
}

View File

@ -14,7 +14,7 @@ WORK_PATH = os.path.abspath(os.path.dirname(__file__))
@click.group() @click.group()
def cli(): def cli():
""" """
The CLI is a commands to RR. The CLI is a commands to Arc.
""" """
pass 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 = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4,)
qr.add_data(data) qr.add_data(data)
qr.make(fit=True) 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") img = img.convert("RGBA")
pixels = img.load() pixels = img.load()
for i in range(img.size[0]): 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"])) models = sorted(models, key=lambda k: (k["arch"], k["name"]))
print(json.dumps(models, indent=4)) 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__": if __name__ == "__main__":
cli() cli()

View File

@ -120,18 +120,15 @@ function getmap() {
writeConfigKey "device.harddrives" "${HARDDRIVES}" "${USER_CONFIG_FILE}" writeConfigKey "device.harddrives" "${HARDDRIVES}" "${USER_CONFIG_FILE}"
# Check for Sata Boot # Check for Sata Boot
LASTDRIVE=0 LASTDRIVE=0
while read -r LINE; do while read -r D; do
if [[ "${BUS}" != "usb" && ${LINE} -eq 0 ]]; then if [[ "${BUS}" != "usb" && ${D} -eq 0 ]]; then
MAXDISKS="$(readModelKey "${MODEL}" "disks")" MAXDISKS=${DRIVES}
if [ ${MAXDISKS} -lt ${DRIVES} ]; then echo -n "${D}>${MAXDISKS}:">>"${TMP_PATH}/remap"
MAXDISKS=${DRIVES} elif [ ! ${D} = ${LASTDRIVE} ]; then
fi echo -n "${D}>${LASTDRIVE}:">>"${TMP_PATH}/remap"
echo -n "${LINE}>${MAXDISKS}:">>"${TMP_PATH}/remap"
elif [ ! ${LINE} = ${LASTDRIVE} ]; then
echo -n "${LINE}>${LASTDRIVE}:">>"${TMP_PATH}/remap"
LASTDRIVE=$((${LASTDRIVE} + 1)) LASTDRIVE=$((${LASTDRIVE} + 1))
elif [ ${LINE} = ${LASTDRIVE} ]; then elif [ ${D} = ${LASTDRIVE} ]; then
LASTDRIVE=$((${LINE} + 1)) LASTDRIVE=$((${D} + 1))
fi fi
done <<<$(cat "${TMP_PATH}/ports") done <<<$(cat "${TMP_PATH}/ports")
} }

View File

@ -16,6 +16,7 @@ getModules "files/p3/modules"
getConfigs "files/p3/configs" getConfigs "files/p3/configs"
getPatches "files/p3/patches" getPatches "files/p3/patches"
getTheme "files/p1/boot/grub" getTheme "files/p1/boot/grub"
getOffline "files/p3/configs"
IMAGE_FILE="arc.img" IMAGE_FILE="arc.img"
gzip -dc "files/initrd/opt/arc/grub.img.gz" >"${IMAGE_FILE}" gzip -dc "files/initrd/opt/arc/grub.img.gz" >"${IMAGE_FILE}"

View File

@ -210,12 +210,12 @@ function getBuildroot() {
TAG=$(curl -s "https://api.github.com/repos/AuxXxilium/arc-buildroot/releases" | jq -r ".[0].tag_name") TAG=$(curl -s "https://api.github.com/repos/AuxXxilium/arc-buildroot/releases" | jq -r ".[0].tag_name")
fi fi
[ ! -d "${DEST_PATH}" ] && mkdir -p "${DEST_PATH}" [ ! -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") 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}" echo "TAG=${TAG}; Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1 [ ${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") 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}" echo "TAG=${TAG}; Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1 [ ${STATUS} -ne 200 ] && exit 1
@ -223,6 +223,21 @@ function getBuildroot() {
echo "Getting Buildroot end" 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 # repack initrd
# $1 initrd file # $1 initrd file
# $2 plugin path # $2 plugin path