Skip to content

Commit

Permalink
Merge pull request #2163 from AuxXxilium/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AuxXxilium authored Jun 27, 2024
2 parents 28b6908 + 6adb83f commit 0148ed7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
3 changes: 1 addition & 2 deletions files/initrd/opt/arc/arc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function editUserConfig() {
[ $? -ne 0 ] && return 1
mv -f "${TMP_PATH}/userconfig" "${USER_CONFIG_FILE}"
ERRORS=$(yq eval "${USER_CONFIG_FILE}" 2>&1)
[ $? -eq 0 ] && continue || break
[ $? -eq 0 ] && break || continue
dialog --backtitle "$(backtitle)" --title "Invalid YAML format" --msgbox "${ERRORS}" 0 0
done
OLDMODEL="${MODEL}"
Expand Down Expand Up @@ -1118,7 +1118,6 @@ function sysinfo() {
TEXT+="\n\Zb$(lspci -s ${NETBUS} -nnk | awk '{$1=""}1' | awk '{$1=$1};1')\Zn\n"
done
# Print Config Informations
TEXT+="\n"
TEXT+="\n\Z4> Arc: ${ARC_VERSION}\Zn"
TEXT+="\n Subversion: \ZbAddons ${ADDONSVERSION} | Configs ${CONFIGSVERSION} | LKM ${LKMVERSION} | Modules ${MODULESVERSION} | Patches ${PATCHESVERSION}\Zn"
TEXT+="\n\Z4>> Loader\Zn"
Expand Down
26 changes: 9 additions & 17 deletions files/initrd/opt/arc/arc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,10 @@ function arcVersion() {
KVERP="${KVER}"
fi
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
cp -f "${ARC_PATH}/include/modulelist" "${USER_UP_PATH}/modulelist"
echo -e "\n\n# Arc Modules" >>"${USER_UP_PATH}/modulelist"
KOLIST=""
for I in $(lsmod | awk -F' ' '{print $1}' | grep -v 'Module'); do
KOLIST+="$(getdepends "${PLATFORM}" "${KVERP}" "${I}") ${I} "
done
KOLIST=($(echo ${KOLIST} | tr ' ' '\n' | sort -u))
# Rewrite modules
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
while read -r ID DESC; do
writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}"
for MOD in ${KOLIST[@]}; do
[ "${MOD}" == "${ID}" ] && echo "N ${ID}.ko" >>"${USER_UP_PATH}/modulelist"
done
done < <(getAllModules "${PLATFORM}" "${KVERP}")
# Check for Only Version
if [ "${ONLYVERSION}" == "true" ]; then
Expand Down Expand Up @@ -443,7 +435,7 @@ function arcPatch() {
fi
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \
--yesno "Serial looks invalid, continue?" 5 50
--yesno "SN looks invalid, continue?" 5 50
[ $? -eq 0 ] && break
done
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
Expand All @@ -452,8 +444,8 @@ function arcPatch() {
dialog --clear --backtitle "$(backtitle)" \
--nocancel --title "Non Arc Patch Model" \
--menu "Please choose an Option." 8 50 0 \
1 "Use random Serial/Mac" \
2 "Use my Serial/Mac" \
1 "Use random SN/Mac" \
2 "Use my SN/Mac" \
2>"${TMP_PATH}/resp"
resp=$(cat ${TMP_PATH}/resp)
[ -z "${resp}" ] && return 1
Expand All @@ -463,8 +455,8 @@ function arcPatch() {
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 "" \
dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \
--inputbox "Please enter a SN " 7 50 "" \
2>"${TMP_PATH}/resp"
[ $? -ne 0 ] && break 2
SN="$(cat ${TMP_PATH}/resp)"
Expand All @@ -474,8 +466,8 @@ function arcPatch() {
break
fi
# At present, the SN rules are not complete, and many SNs are not truly invalid, so not provide tips now.
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
--yesno "Serial looks invalid, continue?" 0 0
dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \
--yesno "SN looks invalid, continue?" 5 50
[ $? -eq 0 ] && break
done
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"
Expand Down
8 changes: 3 additions & 5 deletions files/initrd/opt/arc/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,15 @@ if [ "${ARCPATCH}" == "true" ]; then
NICPORTS="$(readConfigKey "${MODEL}.ports" "${S_FILE}" 2>/dev/null)"
[ -z "${NICPORTS}" ] && NICPORTS=1
else
NICPORTS=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
NICPORTS="$(echo ${ETHX} | wc -w)"
fi
for ETH in ${ETHX}; do
MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
ETHN=$((${ETHN} + 1))
if [ ${ETHN} -le ${NICPORTS} ]; then
CMDLINE['mac${ETHN}']="${MAC}"
fi
[ ${ETHN} -le ${NICPORTS} ] && CMDLINE['mac${ETHN}']="${MAC}"
done
CMDLINE['netif_num']="${NICPORTS}"
[ ${ETHN} -le ${NICPORTS} ] && CMDLINE['netif_num']="${ETHN}" || CMDLINE['netif_num']="${NICPORTS}"

# Read user network settings
while IFS=': ' read -r KEY VALUE; do
Expand Down
6 changes: 3 additions & 3 deletions files/initrd/opt/arc/include/network.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Get Network Config for Loader
function getnet() {
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
NICPORTS="$(readConfigKey "${MODEL}.ports" "${S_FILE}" 2>/dev/null)"
if [ "${ARCPATCH}" == "true" ]; then
ETHN="${#ETHX}"
ETHN="$(echo ${ETHX} | wc -w)"
MACS=($(generateMacAddress "${MODEL}" ${ETHN} true))
for I in $(seq 1 ${ETHN}); do
writeConfigKey "arc.eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}"
done
elif [ "${ARCPATCH}" == "false" ]; then
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
ETHN="$(echo ${ETHX} | wc -w)"
MACS=($(generateMacAddress "${MODEL}" ${ETHN} false))
for I in $(seq 1 ${ETHN}); do
writeConfigKey "arc.eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}"
Expand Down
2 changes: 1 addition & 1 deletion files/initrd/opt/arc/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ for ETH in ${ETHX}; do
[ "${ETH::3}" = "eth" ] && ethtool -s ${ETH} wol g 2>/dev/null || true
initConfigKey "arc.${ETH}" "${MACR}" "${USER_CONFIG_FILE}"
done
ETHN="${#ETHX}"
ETHN="$(echo ${ETHX} | wc -w)"
writeConfigKey "device.nic" "${ETHN}" "${USER_CONFIG_FILE}"
# No network devices
echo
Expand Down

0 comments on commit 0148ed7

Please sign in to comment.