arc/network: fix user mac setting

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-06-26 20:55:02 +02:00
parent f2117fe5bb
commit db0c69520e
2 changed files with 10 additions and 12 deletions

View File

@ -416,8 +416,8 @@ function arcPatch() {
--nocancel --title "Arc Patch"\
--menu "Please choose an Option." 7 50 0 \
1 "Use Arc Patch (only for QC)" \
2 "Use random Serial/Mac" \
3 "Use my own Serial/Mac" \
2 "Use random SN/Mac" \
3 "Use my own SN/Mac" \
2>"${TMP_PATH}/resp"
resp=$(cat ${TMP_PATH}/resp)
[ -z "${resp}" ] && return 1
@ -431,8 +431,8 @@ function arcPatch() {
writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}"
elif [ ${resp} -eq 3 ]; then
while true; do
dialog --backtitle "$(backtitle)" --colors --title "Serial" \
--inputbox "Please enter a valid Serial " 0 0 "" \
dialog --backtitle "$(backtitle)" --colors --title "DSM SN" \
--inputbox "Please enter a valid SN!" 7 50 "" \
2>"${TMP_PATH}/resp"
[ $? -ne 0 ] && break 2
SN="$(cat ${TMP_PATH}/resp)"
@ -442,8 +442,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 "Serial looks invalid, continue?" 5 50
[ $? -eq 0 ] && break
done
writeConfigKey "arc.patch" "user" "${USER_CONFIG_FILE}"

View File

@ -17,24 +17,22 @@ function getnet() {
done
elif [ "${ARCPATCH}" == "user" ]; then
# User Mac
RET=1
for ETH in ${ETHX}; do
while true; do
MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')"
dialog --backtitle "$(backtitle)" --title "Mac Setting" \
--inputbox "Type a custom MAC for ${ETH}.\nEq. 001132123456" 0 0 "${MAC}"\
--inputbox "Type a custom MAC for ${ETH} (Eq. 001132123456)." 7 50 "${MAC}"\
2>"${TMP_PATH}/resp"
RET=$?
[ ${RET} -ne 0 ] && break
[ $? -ne 0 ] && break
MAC=$(cat "${TMP_PATH}/resp")
[ -z "${MAC}" ] && MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')"
MAC="$(echo "${MAC}" | sed "s/:\|-\| //g")"
if [ ${#MAC} -eq 12 ]; then
writeConfigKey "arc.${ETH}" "${MAC}" "${USER_CONFIG_FILE}"
continue
break
else
dialog --backtitle "$(backtitle)" --title "Mac Setting" --msgbox "Invalid MAC" 0 0
dialog --backtitle "$(backtitle)" --title "Mac Setting" --msgbox "Invalid MAC - Try again!" 5 50
fi
done
done