arc: add new functions

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium
2024-06-21 15:32:43 +02:00
parent 0eaeae5b20
commit e507b66033
2 changed files with 76 additions and 21 deletions

View File

@@ -1927,6 +1927,77 @@ function arcNIC () {
return
}
###############################################################################
# Reboot Menu
function rebootMenu() {
rm -f "${TMP_PATH}/opts" >/dev/null
touch "${TMP_PATH}/opts"
# Selectable Reboot Options
echo -e "config \"Config Mode\"" >>"${TMP_PATH}/opts"
echo -e "update \"Automated Update Mode\"" >>"${TMP_PATH}/opts"
echo -e "recovery \"Recovery Mode\"" >>"${TMP_PATH}/opts"
echo -e "junior \"Reinstall Mode\"" >>"${TMP_PATH}/opts"
echo -e "bios \"BIOS/UEFI\"" >>"${TMP_PATH}/opts"
echo -e "poweroff \"Shutdown\"" >>"${TMP_PATH}/opts"
echo -e "shell \"Exit to Shell Cmdline\"" >>"${TMP_PATH}/opts"
dialog --backtitle "$(backtitle)" --title "DSM Frequency Scaling" \
--menu "Choose a Destination" 0 0 0 --file "${TMP_PATH}/opts" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(cat ${TMP_PATH}/resp)
[ -z "${resp}" ] && return
REDEST=${resp}
dialog --backtitle "$(backtitle)" --title "Reboot" \
--infobox "Reboot to ${REDEST}!" 0 0
if [ "${REDEST}" == "bios" ]; then
efibootmgr -n 0000
reboot
exit 0
elif [ "${REDEST}" == "poweroff" ]; then
poweroff
exit 0
elif [ "${REDEST}" == "shell" ]; then
break 2
else
rebootTo ${REDEST}
exit 0
fi
return
}
###############################################################################
# Reset DSM Network
function resetDSMNetwork {
MSG=""
MSG+="This option will clear all customized settings of the network card and restore them to the default state.\n"
MSG+="Warning:\nThis operation is irreversible. Please backup important data. Do you want to continue?"
dialog --backtitle "$(backtitle)" --title "Reset DSM Network" \
--yesno "${MSG}" 0 0
[ $? -ne 0 ] && return
DSMROOTS="$(findDSMRoot)"
if [ -z "${DSMROOTS}" ]; then
dialog --backtitle "$(backtitle)" --title "Reset DSM Network" \
--msgbox "No DSM system partition(md0) found!\nPlease insert all disks before continuing." 0 0
return
fi
(
mkdir -p "${TMP_PATH}/mdX"
for I in ${DSMROOTS}; do
mount -t ext4 "${I}" "${TMP_PATH}/mdX"
[ $? -ne 0 ] && continue
rm -f "${TMP_PATH}/mdX/etc/sysconfig/network-scripts/ifcfg-bond"* "${TMP_PATH}/mdX/etc/sysconfig/network-scripts/ifcfg-eth"*
sync
umount "${TMP_PATH}/mdX"
done
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | dialog --backtitle "$(backtitle)" --title "Reset DSM Network" \
--progressbox "Resetting ..." 20 100
MSG="The network settings have been resetted."
dialog --backtitle "$(backtitle)" --title "Reset DSM Network" \
--msgbox "${MSG}" 0 0
return
}
###############################################################################
# CPU Governor Menu
function governorMenu () {

View File

@@ -892,22 +892,6 @@ function juniorboot() {
exec reboot
}
###############################################################################
# Calls boot.sh to boot into DSM Recovery Mode
function recoveryboot() {
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
[ "${BUILDDONE}" == "false" ] && dialog --backtitle "$(backtitle)" --title "Alert" \
--yesno "Config changed, please build Loader first." 0 0
if [ $? -eq 0 ]; then
make
fi
grub-editenv ${USER_GRUBENVFILE} set next_entry="recovery"
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
--infobox "Booting DSM Recovery Mode...\nPlease stay patient!" 4 30
sleep 2
exec reboot
}
###############################################################################
# Calls boot.sh to boot into DSM kernel/ramdisk
function boot() {
@@ -986,8 +970,6 @@ else
echo "i \"Boot IP Waittime: \Z4${BOOTIPWAIT}\Zn \" " >>"${TMP_PATH}/menu"
fi
echo "q \"Directboot: \Z4${DIRECTBOOT}\Zn \" " >>"${TMP_PATH}/menu"
echo "J \"Boot DSM Reinstall Mode\" " >>"${TMP_PATH}/menu"
echo "I \"Boot DSM Recovery Mode\" " >>"${TMP_PATH}/menu"
fi
if [ "${DSMOPTS}" == "true" ]; then
echo "7 \"\Z1Hide DSM Options\Zn \" " >>"${TMP_PATH}/menu"
@@ -1002,7 +984,7 @@ else
echo "s \"Allow Downgrade \" " >>"${TMP_PATH}/menu"
echo "t \"Change User Password \" " >>"${TMP_PATH}/menu"
echo "N \"Add new User\" " >>"${TMP_PATH}/menu"
echo "T \"Force enable SSH in DSM \" " >>"${TMP_PATH}/menu"
echo "J \"Reset DSM Network Config \" " >>"${TMP_PATH}/menu"
if [ "${PLATFORM}" == "epyc7002" ]; then
echo "K \"Kernel: \Z4${KERNEL}\Zn \" " >>"${TMP_PATH}/menu"
fi
@@ -1015,6 +997,7 @@ else
echo "o \"Switch MacSys: \Z4${MACSYS}\Zn \" " >>"${TMP_PATH}/menu"
echo "W \"RD Compression: \Z4${RD_COMPRESSED}\Zn \" " >>"${TMP_PATH}/menu"
echo "X \"Sata DOM: \Z4${SATADOM}\Zn \" " >>"${TMP_PATH}/menu"
echo "T \"Force enable SSH in DSM \" " >>"${TMP_PATH}/menu"
fi
fi
if [ "${DEVOPTS}" == "true" ]; then
@@ -1043,6 +1026,7 @@ else
if [ "${OFFLINE}" == "false" ]; then
echo "z \"Update Loader\" " >>"${TMP_PATH}/menu"
fi
echo "I \"Reboot \" " >>"${TMP_PATH}/menu"
echo "V \"Credits \" " >>"${TMP_PATH}/menu"
dialog --clear --default-item ${NEXT} --backtitle "$(backtitle)" --colors \
@@ -1097,8 +1081,6 @@ else
writeConfigKey "arc.directboot" "${DIRECTBOOT}" "${USER_CONFIG_FILE}"
NEXT="q"
;;
J) juniorboot; NEXT="J" ;;
I) recoveryboot; NEXT="I" ;;
# DSM Section
7) [ "${DSMOPTS}" == "true" ] && DSMOPTS='false' || DSMOPTS='true'
DSMOPTS="${DSMOPTS}"
@@ -1109,6 +1091,7 @@ else
s) downgradeMenu; NEXT="s" ;;
t) resetPassword; NEXT="t" ;;
N) addNewDSMUser; NEXT="N" ;;
J) resetDSMNetwork; NEXT="J" ;;
K) [ "${KERNEL}" == "official" ] && KERNEL='custom' || KERNEL='official'
writeConfigKey "arc.kernel" "${KERNEL}" "${USER_CONFIG_FILE}"
if [ "${ODP}" == "true" ]; then
@@ -1214,6 +1197,7 @@ else
;;
y) keymapMenu; NEXT="y" ;;
z) updateMenu; NEXT="z" ;;
I) rebootMenu; NEXT="I" ;;
V) credits; NEXT="V" ;;
esac
done