tree: fixes

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-08-06 21:01:04 +02:00
parent 498da3d502
commit 63d2573f2c
6 changed files with 58 additions and 51 deletions

View File

@ -1722,7 +1722,7 @@ function formatDisks() {
[[ "${KNAME}" = "${LOADER_DISK}" || "${PKNAME}" = "${LOADER_DISK}" ]] && continue
[ -z "${SIZE}" ] && SIZE="Unknown"
printf "\"%s\" \"%-6s %-4s\" \"off\"\n" "${KNAME}" "${SIZE}" "${TYPE}" >>"${TMP_PATH}/opts"
done < <(lsblk -pno KNAME,SIZE,TYPE,PKNAME)
done < <(lsblk -Jpno KNAME,SIZE,TYPE,PKNAME 2>/dev/null | sed 's|null|"N/A"|g' | jq -r '.blockdevices[] | "\(.kname) \(.id) \(.size) \(.type) \(.pkname)"' 2>/dev/null)
if [ ! -f "${TMP_PATH}/opts" ]; then
dialog --backtitle "$(backtitle)" --title "Format Disks" \
--msgbox "No disk found!" 0 0
@ -1823,7 +1823,7 @@ function cloneLoader() {
[[ "${KNAME}" = "${LOADER_DISK}" || "${PKNAME}" = "${LOADER_DISK}" ]] && continue
[ -z "${SIZE}" ] && SIZE="Unknown"
printf "\"%s\" \"%-6s %-4s\" \"off\"\n" "${KNAME}" "${SIZE}" "${TYPE}" >>"${TMP_PATH}/opts"
done < <(lsblk -dpno KNAME,SIZE,TYPE,PKNAME | sort)
done < <(lsblk -Jpno KNAME,SIZE,TYPE,PKNAME 2>/dev/null | sed 's|null|"N/A"|g' | jq -r '.blockdevices[] | "\(.kname) \(.id) \(.size) \(.type) \(.pkname)"' 2>/dev/null)
if [ ! -f "${TMP_PATH}/opts" ]; then
dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \
--msgbox "No disk found!" 0 0
@ -2101,9 +2101,7 @@ function rebootMenu() {
echo -e "network \"Arc: Restart Network Service\"" >>"${TMP_PATH}/opts"
echo -e "recovery \"DSM: Recovery Mode\"" >>"${TMP_PATH}/opts"
echo -e "junior \"DSM: Reinstall Mode\"" >>"${TMP_PATH}/opts"
if efibootmgr 2>/dev/null | grep -q "^Boot0000"; then
echo -e "bios \"System: BIOS/UEFI\"" >>"${TMP_PATH}/opts"
fi
echo -e "bios \"System: BIOS/UEFI\"" >>"${TMP_PATH}/opts"
echo -e "poweroff \"System: Shutdown\"" >>"${TMP_PATH}/opts"
echo -e "shell \"System: Shell Cmdline\"" >>"${TMP_PATH}/opts"
dialog --backtitle "$(backtitle)" --title "Power Menu" \
@ -2114,20 +2112,18 @@ function rebootMenu() {
[ -z "${resp}" ] && return
REDEST=${resp}
dialog --backtitle "$(backtitle)" --title "Power Menu" \
--infobox "${REDEST} selected ...!" 0 0
if [ "${REDEST}" == "bios" ]; then
efibootmgr -n 0000 >/dev/null 2>&1
reboot
exit 0
elif [ "${REDEST}" == "poweroff" ]; then
--infobox "${REDEST} selected ...!" 5 30
if [ "${REDEST}" == "poweroff" ]; then
poweroff
exit 0
elif [ "${REDEST}" == "shell" ]; then
clear
exit 0
elif [ "${REDEST}" == "init" ]; then
clear
init.sh
elif [ "${REDEST}" == "network" ]; then
clear
/etc/init.d/S41dhcpcd restart
arc.sh
else

View File

@ -65,6 +65,8 @@ BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
# Get Keymap and Timezone Config
ntpCheck
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
# Check for Dynamic Mode
dynCheck

View File

@ -134,6 +134,9 @@ function bootDSM () {
CMDLINE['loglevel']="15"
CMDLINE['log_buf_len']="32M"
CMDLINE['panic']="${KERNELPANIC:-0}"
CMDLINE['pcie_aspm']="off"
CMDLINE['nox2apic']=""
CMDLINE['nomodeset']=""
CMDLINE['modprobe.blacklist']="${MODBLACKLIST}"
[ $(cat /proc/cpuinfo | grep Intel | wc -l) -gt 0 ] && CMDLINE["intel_pstate"]="disable"

View File

@ -93,7 +93,7 @@ function generateSerial() {
SUFFIX="$(readConfigKey "${1}.suffix" "${S_FILE}" 2>/dev/null)"
fi
SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}"
local SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}"
case "${SUFFIX:-"alpha"}" in
numeric)
SERIAL+="$(random)"
@ -124,7 +124,7 @@ function generateMacAddress() {
MACSUF="$(printf '%02x%02x%02x' $((${RANDOM} % 256)) $((${RANDOM} % 256)) $((${RANDOM} % 256)))"
fi
NUM=${2:-1}
MACS=""
local MACS=""
for I in $(seq 1 ${NUM}); do
MACS+="$(printf '%06x%06x' $((0x${MACPRE:-"001132"})) $(($((0x${MACSUF})) + ${I})))"
[ ${I} -lt ${NUM} ] && MACS+=" "
@ -221,25 +221,25 @@ function _set_conf_kv() {
# sort netif name
# @1 -mac1,mac2,mac3...
function _sort_netif() {
ETHLIST=""
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
local ETHLIST=""
local ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
for ETH in ${ETHX}; do
MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
ETHBUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)"
local MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
local ETHBUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)"
ETHLIST="${ETHLIST}${ETHBUS} ${MAC} ${ETH}\n"
done
ETHLISTTMPM=""
ETHLISTTMPB="$(echo -e "${ETHLIST}" | sort)"
local ETHLISTTMPM=""
local ETHLISTTMPB="$(echo -e "${ETHLIST}" | sort)"
if [ -n "${1}" ]; then
MACS="$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')"
local MACS="$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')"
for MACX in ${MACS}; do
ETHLISTTMPM="${ETHLISTTMPM}$(echo -e "${ETHLISTTMPB}" | grep "${MACX}")\n"
ETHLISTTMPB="$(echo -e "${ETHLISTTMPB}" | grep -v "${MACX}")\n"
done
fi
ETHLIST="$(echo -e "${ETHLISTTMPM}${ETHLISTTMPB}" | grep -v '^$')"
ETHSEQ="$(echo -e "${ETHLIST}" | awk '{print $3}' | sed 's/eth//g')"
ETHNUM="$(echo -e "${ETHLIST}" | wc -l)"
local ETHLIST="$(echo -e "${ETHLISTTMPM}${ETHLISTTMPB}" | grep -v '^$')"
local ETHSEQ="$(echo -e "${ETHLIST}" | awk '{print $3}' | sed 's/eth//g')"
local ETHNUM="$(echo -e "${ETHLIST}" | wc -l)"
# sort
if [ ! "${ETHSEQ}" = "$(seq 0 $((${ETHNUM:0} - 1)))" ]; then
/etc/init.d/S41dhcpcd stop >/dev/null 2>&1
@ -262,15 +262,12 @@ function _sort_netif() {
# get bus of disk
# 1 - device path
function getBus() {
BUS=""
# xvd
[ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep "${1} " | grep -q "xen" && echo "xen")
# usb/ata(sata/ide)/scsi
[ -z "${BUS}" ] && BUS=$(udevadm info --query property --name "${1}" 2>/dev/null | grep ID_BUS | cut -d= -f2 | sed 's/ata/sata/')
# usb/sata(sata/ide)/nvme
[ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,TRAN 2>/dev/null | grep "${1} " | awk '{print $2}') #Spaces are intentional
# usb/scsi(sata/ide)/virtio(scsi/virtio)/mmc/nvme
[ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep "${1} " | awk '{print $2}' | awk -F':' '{print $(NF-1)}' | sed 's/_host//') # Spaces are intentional
local BUS=""
# usb/ata(ide)/sata/sas/virtio/mmc/nvme
[ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,TRAN 2>/dev/null | grep "${1} " | awk '{print $2}' | sed 's/^ata$/ide/') #Spaces are intentional
# usb/scsi(ide/sata/sas)/virtio/mmc/nvme/vmbus/xen(xvd)
[ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep "${1} " | awk '{print $2}' | awk -F':' '{print $(NF-1)}' | sed 's/_host//' | sed 's/^.*xen.*$/xen/') # Spaces are intentional
[ -z "${BUS}" ] && BUS="unknown"
echo "${BUS}"
return 0
}
@ -279,7 +276,7 @@ function getBus() {
# get IP
# 1 - ethN
function getIP() {
IP=""
local IP=""
MACR="$(cat /sys/class/net/${1}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")"
if [ -n "${IPR}" ]; then
@ -302,7 +299,7 @@ function getIP() {
# get logo of model
# 1 - model
function getLogo() {
MODEL="${1}"
local MODEL="${1}"
rm -f "${PART3_PATH}/logo.png"
STATUS=$(curl -skL -m 10 -w "%{http_code}" "https://www.synology.com/api/products/getPhoto?product=${MODEL/+/%2B}&type=img_s&sort=0" -o "${PART3_PATH}/logo.png")
if [ $? -ne 0 -o ${STATUS:-0} -ne 200 -o ! -f "${PART3_PATH}/logo.png" ]; then
@ -318,7 +315,7 @@ function getLogo() {
###############################################################################
# Find and mount the DSM root filesystem
function findDSMRoot() {
DSMROOTS=""
local DSMROOTS=""
[ -z "${DSMROOTS}" ] && DSMROOTS="$(mdadm --detail --scan 2>/dev/null | grep -E "name=SynologyNAS:0|name=DiskStation:0|name=SynologyNVR:0|name=BeeStation:0" | awk '{print $2}' | uniq)"
[ -z "${DSMROOTS}" ] && DSMROOTS="$(lsblk -pno KNAME,PARTN,FSTYPE,FSVER,LABEL | grep -E "sd[a-z]{1,2}1" | grep -w "linux_raid_member" | grep "0.9" | awk '{print $1}')"
echo "${DSMROOTS}"
@ -382,7 +379,7 @@ function delCmdline() {
# Rebooting
# (based on pocopico's TCRP code)
function rebootTo() {
MODES="config recovery junior automated update"
local MODES="config recovery junior automated update bios memtest"
[ -z "${1}" ] && exit 1
if ! echo "${MODES}" | grep -qw "${1}"; then exit 1; fi
[ ! -f "${USER_GRUBENVFILE}" ] && grub-editenv ${USER_GRUBENVFILE} create
@ -527,17 +524,17 @@ function livepatch() {
###############################################################################
# Check NTP and Keyboard Layout
function ntpCheck() {
LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
local LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
local KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
if [ "${OFFLINE}" == "false" ]; then
# Timezone
if [ "${ARCNIC}" == "auto" ]; then
REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
local REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
local TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
else
REGION="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
local REGION="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
local TIMEZONE="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
fi
writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}"

View File

@ -127,12 +127,12 @@ echo
VID="0x46f4"
PID="0x0001"
BUSLIST="usb sata scsi nvme mmc xen"
BUSLIST="usb sata scsi nvme mmc ide vmbus xen"
if [ "${BUS}" == "usb" ]; then
VID="0x$(udevadm info --query property --name "${LOADER_DISK}" | grep ID_VENDOR_ID | cut -d= -f2)"
PID="0x$(udevadm info --query property --name "${LOADER_DISK}" | grep ID_MODEL_ID | cut -d= -f2)"
elif ! echo "${BUSLIST}" | grep -wq "${BUS}"; then
die "Loader Disk (${BUS}) is not USB or SATA/SCSI/NVME/eMMC"
die "Loader Disk isn't USB or SATA/SCSI/NVME/MMC/IDE/VMBUS/XEN"
fi
# Inform user and check bus

View File

@ -10,6 +10,11 @@ insmod linux
insmod gzio
insmod fat
insmod ext2
insmod ata
insmod btrfs
insmod ntfs
insmod part_msdos
insmod part_gpt
set default="boot"
set timeout="5"
@ -78,7 +83,7 @@ set menu_color_normal=white/black
set menu_color_highlight=white/red
set color_normal=white/black
set ARC_CMDLINE="earlyprintk earlycon=uart8250,io,0x3f8,115200n8 console=ttyS0,115200n8 root=/dev/ram rootwait net.ifnames=0 pcie_aspm=off nox2apic nomodeset"
set ARC_CMDLINE="earlyprintk earlycon=uart8250,io,0x3f8,115200n8 console=ttyS0,115200n8 root=/dev/ram rootwait net.ifnames=0 panic=0 pcie_aspm=off nox2apic nomodeset"
search --set=root --label "ARC3"
if [ -e /automated ]; then
@ -151,6 +156,15 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
}
fi
menuentry 'Enter BIOS Setup' --id bios {
fwsetup
}
menuentry 'Start Memtest86+' --id memtest {
echo "Loading memtest86+..."
linux ${prefix}/memtest
}
if [ ${vesa_mode} = 1 ]; then
menuentry 'Change Vesa to Text Output' --id videomode {
set vesa_mode=0
@ -164,9 +178,4 @@ else
reboot
configfile ${prefix}/grub.cfg
}
fi
menuentry 'Start Memtest86+' --id memtest {
echo "Loading memtest86+..."
linux ${prefix}/memtest
}
fi