From 6bcf451e77b2d70b0fbe95f93f1ba314f00f4a2b Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Mon, 30 Dec 2024 20:45:45 +0100 Subject: [PATCH] tree: rework more Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 8 +++--- files/initrd/opt/arc/arc.sh | 32 ++++++++++------------- files/initrd/opt/arc/include/functions.sh | 8 +++--- files/initrd/opt/arc/include/network.sh | 4 +-- files/initrd/opt/arc/include/storage.sh | 16 ++++++------ files/initrd/opt/arc/init.sh | 22 ++++++++-------- 6 files changed, 43 insertions(+), 47 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 1ede0186..dbc91638 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -949,7 +949,7 @@ function updateMenu() { elif [ ${opts} -eq 3 ]; then ARC_BRANCH="dev" fi - writeConfigKey "arc.branch" "${ARC_BRANCH}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.branch" "\"${ARC_BRANCH}\"" "${USER_CONFIG_FILE}" ;; *) break @@ -1431,7 +1431,7 @@ function staticIPMenu() { echo "nameserver ${dnsname:-${gateway}}" >>/etc/resolv.conf fi fi - writeConfigKey "network.${MACR}" "${address}/${netmask}/${gateway}/${dnsname}" "${USER_CONFIG_FILE}" + writeConfigKey "network.${MACR}" "\"${address}/${netmask}/${gateway}/${dnsname}\"" "${USER_CONFIG_FILE}" IP="$(getIP)" [ -z "${IPCON}" ] && IPCON="${IP}" sleep 1 @@ -1686,7 +1686,7 @@ function loaderPorts() { 2>"${TMP_PATH}/resp" RET=$? case ${RET} in - 0) # ok-button + 0) HTTP=$(sed -n '1p' "${TMP_PATH}/resp" 2>/dev/null) DUFS=$(sed -n '2p' "${TMP_PATH}/resp" 2>/dev/null) TTYD=$(sed -n '3p' "${TMP_PATH}/resp" 2>/dev/null) @@ -2248,7 +2248,7 @@ function governorSelection () { resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return GOVERNOR=${resp} - writeConfigKey "governor" "${GOVERNOR}" "${USER_CONFIG_FILE}" + writeConfigKey "governor" "\"${GOVERNOR}\"" "${USER_CONFIG_FILE}" } ############################################################################### diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 8fa758f4..2cddbc9c 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -970,8 +970,7 @@ elif [ "${ARCMODE}" = "config" ]; then A) networkdiag; NEXT="A" ;; # System Section # Arc Section - 4) [ "${ARCOPTS}" = "true" ] && ARCOPTS='false' || ARCOPTS='true' - ARCOPTS="${ARCOPTS}" + 4) ARCOPTS=$([ "${ARCOPTS}" = "true" ] && echo 'false' || echo 'true') NEXT="4" ;; b) addonMenu; NEXT="b" ;; @@ -984,15 +983,14 @@ elif [ "${ARCMODE}" = "config" ]; then P) storagepanelMenu; NEXT="P" ;; Q) sequentialIOMenu; NEXT="Q" ;; # Boot Section - 6) [ "${BOOTOPTS}" = "true" ] && BOOTOPTS='false' || BOOTOPTS='true' - BOOTOPTS="${BOOTOPTS}" + 6) BOOTOPTS=$([ "${BOOTOPTS}" = "true" ] && echo 'false' || echo 'true') NEXT="6" ;; - m) [ "${KERNELLOAD}" = "kexec" ] && KERNELLOAD='power' || KERNELLOAD='kexec' - writeConfigKey "kernelload" "${KERNELLOAD}" "${USER_CONFIG_FILE}" + m) KERNELLOAD=$([ "${KERNELLOAD}" = "kexec" ] && echo 'power' || echo 'kexec') + writeConfigKey "kernelload" "\"${KERNELLOAD}"\" "${USER_CONFIG_FILE}" NEXT="m" ;; - E) [ "${EMMCBOOT}" = "true" ] && EMMCBOOT='false' || EMMCBOOT='true' + E) EMMCBOOT=$([ "${EMMCBOOT}" = "true" ] && echo 'false' || echo 'true') if [ "${EMMCBOOT}" = "false" ]; then writeConfigKey "emmcboot" "false" "${USER_CONFIG_FILE}" deleteConfigKey "synoinfo.disk_swap" "${USER_CONFIG_FILE}" @@ -1011,14 +1009,13 @@ elif [ "${ARCMODE}" = "config" ]; then NEXT="E" ;; i) bootipwaittime; NEXT="i" ;; - q) [ "${DIRECTBOOT}" = "false" ] && DIRECTBOOT='true' || DIRECTBOOT='false' + q) DIRECTBOOT=$([ "${DIRECTBOOT}" = "false" ] && echo 'true' || echo 'false') grub-editenv ${USER_GRUBENVFILE} create writeConfigKey "directboot" "${DIRECTBOOT}" "${USER_CONFIG_FILE}" NEXT="q" ;; # DSM Section - 7) [ "${DSMOPTS}" = "true" ] && DSMOPTS='false' || DSMOPTS='true' - DSMOPTS="${DSMOPTS}" + 7) DSMOPTS=$([ "${DSMOPTS}" = "true" ] && echo 'false' || echo 'true') NEXT="7" ;; j) cmdlineMenu; NEXT="j" ;; @@ -1031,7 +1028,7 @@ elif [ "${ARCMODE}" = "config" ]; then M) mountDSM; NEXT="M" ;; T) disablescheduledTasks; NEXT="T" ;; K) KERNEL=$([ "${KERNEL}" = "official" ] && echo 'custom' || echo 'official') - writeConfigKey "kernel" "${KERNEL}" "${USER_CONFIG_FILE}" + writeConfigKey "kernel" "\"${KERNEL}\"" "${USER_CONFIG_FILE}" dialog --backtitle "$(backtitle)" --title "Kernel" \ --infobox "Switching Kernel to ${KERNEL}! Stay patient..." 4 50 if [ "${ODP}" = "true" ]; then @@ -1050,19 +1047,19 @@ elif [ "${ARCMODE}" = "config" ]; then BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" NEXT="K" ;; - H) [ "${HDDSORT}" = "true" ] && HDDSORT='false' || HDDSORT='true' + H) HDDSORT=$([ "${HDDSORT}" = "true" ] && echo 'false' || echo 'true') writeConfigKey "hddsort" "${HDDSORT}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" NEXT="H" ;; - h) [ "${USBMOUNT}" = "true" ] && USBMOUNT='false' || USBMOUNT='true' + h) USBMOUNT=$([ "${USBMOUNT}" = "true" ] && echo 'false' || echo 'true') writeConfigKey "usbmount" "${USBMOUNT}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" NEXT="h" ;; - O) [ "${ODP}" = "false" ] && ODP='true' || ODP='false' + O) ODP=$([ "${ODP}" = "false" ] && echo 'true' || echo 'false') writeConfigKey "odp" "${ODP}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" @@ -1070,8 +1067,7 @@ elif [ "${ARCMODE}" = "config" ]; then ;; B) getbackup; NEXT="B" ;; # Loader Section - 8) [ "${LOADEROPTS}" = "true" ] && LOADEROPTS='false' || LOADEROPTS='true' - LOADEROPTS="${LOADEROPTS}" + 8) LOADEROPTS=$([ "${LOADEROPTS}" = "true" ] && echo 'false' || echo 'true') NEXT="8" ;; c) ARCOFFLINE=$([ "${ARCOFFLINE}" = "true" ] && echo 'false' || echo 'true') @@ -1090,8 +1086,8 @@ elif [ "${ARCMODE}" = "config" ]; then NEXT="W" ;; X) satadomMenu; NEXT="X" ;; - u) [ "${LKM}" = "prod" ] && LKM='dev' || LKM='prod' - writeConfigKey "lkm" "${LKM}" "${USER_CONFIG_FILE}" + u) LKM=$([ "${LKM}" = "prod" ] && echo 'dev' || echo 'prod') + writeConfigKey "lkm" "\"${LKM}\"" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" NEXT="u" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index 63679408..ec2b63ed 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -506,8 +506,8 @@ function onlineCheck() { fi [ -z "${KEYMAP}" ] && KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" if [ -n "${REGION}" ] && [ -n "${TIMEZONE}" ]; then - writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}" - writeConfigKey "time.timezone" "${TIMEZONE}" "${USER_CONFIG_FILE}" + writeConfigKey "time.region" "\"${REGION}\"" "${USER_CONFIG_FILE}" + writeConfigKey "time.timezone" "\"${TIMEZONE}\"" "${USER_CONFIG_FILE}" else REGION="$(readConfigKey "time.region" "${USER_CONFIG_FILE}")" TIMEZONE="$(readConfigKey "time.timezone" "${USER_CONFIG_FILE}")" @@ -517,11 +517,11 @@ function onlineCheck() { if [ -z "${LAYOUT}" ]; then [ -n "${KEYMAP}" ] && KEYMAP="$(echo ${KEYMAP} | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]' | tr -d '[:punct:]' | tr -d '[:digit:]')" if loadkeys "${KEYMAP:-us}" 2>/dev/null; then - writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}" + writeConfigKey "keymap" "\"${KEYMAP}\"" "${USER_CONFIG_FILE}" else KEYMAP="us" loadkeys "${KEYMAP}" 2>/dev/null - writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}" + writeConfigKey "keymap" "\"${KEYMAP}\"" "${USER_CONFIG_FILE}" fi fi NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)" diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index dade3462..eb884f2f 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -9,13 +9,13 @@ function getnet() { MACS=($(generateMacAddress "${MODEL}" "${ETHN}" "true")) for I in $(seq 1 ${ETHN}); do eval MAC${I}="${MACS[$((${I} - 1))]}" - writeConfigKey "eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}" + writeConfigKey "eth$((${I} - 1))" "\"${MACS[$((${I} - 1))]}\"" "${USER_CONFIG_FILE}" done elif [ "${ARCPATCH}" = "false" ]; then MACS=($(generateMacAddress "${MODEL}" "${ETHN}" "false")) for I in $(seq 1 ${ETHN}); do eval MAC${I}="${MACS[$((${I} - 1))]}" - writeConfigKey "eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}" + writeConfigKey "eth$((${I} - 1))" "\"${MACS[$((${I} - 1))]}\"" "${USER_CONFIG_FILE}" done elif [ "${ARCPATCH}" = "user" ]; then # User Mac diff --git a/files/initrd/opt/arc/include/storage.sh b/files/initrd/opt/arc/include/storage.sh index cf1df621..7a8a2504 100755 --- a/files/initrd/opt/arc/include/storage.sh +++ b/files/initrd/opt/arc/include/storage.sh @@ -176,24 +176,24 @@ function getmapSelection() { [ -z "${resp}" ] && return 1 fi if [ ${resp} -eq 1 ]; then - writeConfigKey "arc.remap" "acports" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"acports\"" "${USER_CONFIG_FILE}" elif [ ${resp} -eq 2 ]; then - writeConfigKey "arc.remap" "maxports" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"maxports\"" "${USER_CONFIG_FILE}" elif [ ${resp} -eq 3 ]; then - writeConfigKey "arc.remap" "remap" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"remap\"" "${USER_CONFIG_FILE}" elif [ ${resp} -eq 4 ]; then - writeConfigKey "arc.remap" "ahci" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"ahci\"" "${USER_CONFIG_FILE}" elif [ ${resp} -eq 5 ]; then - writeConfigKey "arc.remap" "user" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"user\"" "${USER_CONFIG_FILE}" fi else # Show recommended Option to user if [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" = "true" ] && [ "${MACHINE}" = "Native" ]; then - writeConfigKey "arc.remap" "maxports" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"maxports\"" "${USER_CONFIG_FILE}" elif [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" = "false" ]; then - writeConfigKey "arc.remap" "remap" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"remap\"" "${USER_CONFIG_FILE}" else - writeConfigKey "arc.remap" "acports" "${USER_CONFIG_FILE}" + writeConfigKey "arc.remap" "\"acports\"" "${USER_CONFIG_FILE}" fi fi # Check Remap for correct config diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index a6aa8c1e..d76e22fc 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -44,7 +44,7 @@ initConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.hardwareid" "" "${USER_CONFIG_FILE}" initConfigKey "arc.userid" "" "${USER_CONFIG_FILE}" -initConfigKey "arc.version" "${ARC_VERSION}" "${USER_CONFIG_FILE}" +initConfigKey "arc.version" "\"${ARC_VERSION}\"" "${USER_CONFIG_FILE}" initConfigKey "bootscreen" "{}" "${USER_CONFIG_FILE}" initConfigKey "bootscreen.dsminfo" "true" "${USER_CONFIG_FILE}" initConfigKey "bootscreen.systeminfo" "true" "${USER_CONFIG_FILE}" @@ -55,10 +55,10 @@ initConfigKey "bootipwait" "30" "${USER_CONFIG_FILE}" initConfigKey "device" "{}" "${USER_CONFIG_FILE}" initConfigKey "directboot" "false" "${USER_CONFIG_FILE}" initConfigKey "emmcboot" "false" "${USER_CONFIG_FILE}" -initConfigKey "governor" "performance" "${USER_CONFIG_FILE}" +initConfigKey "governor" "\"performance\"" "${USER_CONFIG_FILE}" initConfigKey "hddsort" "false" "${USER_CONFIG_FILE}" -initConfigKey "kernel" "official" "${USER_CONFIG_FILE}" -initConfigKey "kernelload" "power" "${USER_CONFIG_FILE}" +initConfigKey "kernel" "\"official\"" "${USER_CONFIG_FILE}" +initConfigKey "kernelload" "\"power\"" "${USER_CONFIG_FILE}" initConfigKey "kernelpanic" "5" "${USER_CONFIG_FILE}" initConfigKey "odp" "false" "${USER_CONFIG_FILE}" initConfigKey "pathash" "" "${USER_CONFIG_FILE}" @@ -85,17 +85,17 @@ initConfigKey "time" "{}" "${USER_CONFIG_FILE}" initConfigKey "usbmount" "false" "${USER_CONFIG_FILE}" initConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" if grep -q "automated_arc" /proc/cmdline; then - writeConfigKey "arc.mode" "automated" "${USER_CONFIG_FILE}" + writeConfigKey "arc.mode" "\"automated\"" "${USER_CONFIG_FILE}" elif grep -q "update_arc" /proc/cmdline; then - writeConfigKey "arc.mode" "update" "${USER_CONFIG_FILE}" + writeConfigKey "arc.mode" "\"update\"" "${USER_CONFIG_FILE}" elif grep -q "force_arc" /proc/cmdline; then - writeConfigKey "arc.mode" "config" "${USER_CONFIG_FILE}" + writeConfigKey "arc.mode" "\"config\"" "${USER_CONFIG_FILE}" else - writeConfigKey "arc.mode" "dsm" "${USER_CONFIG_FILE}" + writeConfigKey "arc.mode" "\"dsm\"" "${USER_CONFIG_FILE}" fi [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null 2>&1 || true if [ -n "${ARC_BRANCH}" ]; then - writeConfigKey "arc.branch" "${ARC_BRANCH}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.branch" "\"${ARC_BRANCH}\"" "${USER_CONFIG_FILE}" fi # Sort network interfaces if arrayExistItem "sortnetif:" $(readConfigMap "addons" "${USER_CONFIG_FILE}"); then @@ -121,7 +121,7 @@ ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true fi [ "${N::3}" = "eth" ] && ethtool -s "${N}" wol g 2>/dev/null || true # [ "${N::3}" = "eth" ] && ethtool -K ${N} rxhash off 2>/dev/null || true - initConfigKey "${N}" "${MACR}" "${USER_CONFIG_FILE}" + initConfigKey "${N}" "\"${MACR}\"" "${USER_CONFIG_FILE}" done ETHN=$(echo ${ETHX} | wc -w) writeConfigKey "device.nic" "${ETHN}" "${USER_CONFIG_FILE}" @@ -225,7 +225,7 @@ echo -e "Use \033[1;34mDisplay Output\033[0m or \033[1;34mhttp://${IPCON}:${TTYD # Check memory and load Arc RAM=$(awk '/MemTotal:/ {printf "%.0f", $2 / 1024}' /proc/meminfo 2>/dev/null) -if [ ${RAM} -le 3500 ]; then +if [ ${RAM} -le 1800 ]; then echo -e "\033[1;31mYou have less than 4GB of RAM, if errors occur in loader creation, please increase the amount of RAM.\033[0m\n\033[1;31mUse arc.sh to proceed. Not recommended!\033[0m" else exec arc.sh