Skip to content

Commit

Permalink
Merge pull request #6169 from AuxXxilium/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AuxXxilium authored Feb 9, 2025
2 parents 22f135f + 8e3536d commit 3234b12
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 42 deletions.
10 changes: 6 additions & 4 deletions files/initrd/opt/arc/arc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ elif [ "${ARCMODE}" = "config" ]; then
# Main Section
0) genHardwareID; NEXT="0" ;;
1) arcModel; NEXT="2" ;;
2) arcSummary; NEXT="3" ;;
2) arcSummary; NEXT="4" ;;
3) rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true
arcSummary;
NEXT="3"
NEXT="4"
;;
4) boot; NEXT="3" ;;
4) boot; NEXT="4" ;;
# Info Section
a) sysinfo; NEXT="a" ;;
A) networkdiag; NEXT="A" ;;
Expand Down Expand Up @@ -353,7 +353,9 @@ elif [ "${ARCMODE}" = "config" ]; then
done
clear
else
echo "Unknown Mode: ${ARCMODE} - Exiting..."
echo "Unknown Mode: ${ARCMODE} - Rebooting to Config Mode"
sleep 3
rebootTo config
fi

# Inform user
Expand Down
26 changes: 8 additions & 18 deletions files/initrd/opt/arc/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rm -rf "${PART1_PATH}/logs" >/dev/null 2>&1 || true
# Get Loader Disk Bus
[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!"
BUS=$(getBus "${LOADER_DISK}")
EFI=$([ -d /sys/firmware/efi ] && echo 1 || echo 0)
[ -d /sys/firmware/efi ] && EFI="1" || EFI="0"

# Print Title centralized
clear
Expand Down Expand Up @@ -64,7 +64,7 @@ ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"

# Build Sanity Check
[ "${BUILDDONE}" = "false" ] && die "Loader build not completed!"
[[ -z "${MODELID}" || "${MODELID}" != "${MODEL}" ]] && die "Loader build not completed! Model mismatch!"
[[ -z "${MODELID}" || "${MODELID}" != "${MODEL}" ]] && die "Loader build not completed! Model mismatch! -> Rebuild loader!"

# HardwareID Check
if [ "${ARCPATCH}" = "true" ] || [ -n "${ARCCONF}" ]; then
Expand Down Expand Up @@ -153,7 +153,7 @@ ETHM=${ETHM:-${ETHN}}
NIC=0
for N in ${ETHX}; do
MAC=$(readConfigKey "${N}" "${USER_CONFIG_FILE}" 2>/dev/null)
MAC=${MAC:-$(cat /sys/class/net/${N}/address 2>/dev/null | tr '[:upper:]' '[:lower:]')}
[ -z ${MAC} ] && MAC="$(cat /sys/class/net/${N}/address 2>/dev/null)"
CMDLINE["mac$((++NIC))"]="${MAC}"
[ ${NIC} -ge ${ETHM} ] && break
done
Expand Down Expand Up @@ -276,7 +276,6 @@ for KEY in "${!CMDLINE[@]}"; do
[ -n "${VALUE}" ] && CMDLINE_LINE+="=${VALUE}"
done
CMDLINE_LINE=$(echo "${CMDLINE_LINE}" | sed 's/^ //') # Remove leading space
echo "${CMDLINE_LINE}" >"${PART1_PATH}/cmdline.yml"

# Boot
DIRECTBOOT="$(readConfigKey "directboot" "${USER_CONFIG_FILE}")"
Expand All @@ -301,7 +300,7 @@ elif [ "${DIRECTBOOT}" = "false" ]; then
fi

[ ! -f /var/run/dhcpcd/pid ] && /etc/init.d/S09dhcpcd restart >/dev/null 2>&1 && sleep 3 || true
checkNIC
checkNIC || true
echo

DSMLOGO="$(readConfigKey "bootscreen.dsmlogo" "${USER_CONFIG_FILE}")"
Expand All @@ -322,22 +321,13 @@ elif [ "${DIRECTBOOT}" = "false" ]; then
fi
done

# # Unload all network interfaces
# for D in $(realpath /sys/class/net/*/device/driver); do rmmod -f "$(basename ${D})" 2>/dev/null || true; done

# Unload all graphics drivers
# for D in $(lsmod | grep -E '^(nouveau|amdgpu|radeon|i915)' | awk '{print $1}'); do rmmod -f "${D}" 2>/dev/null || true; done
# for I in $(find /sys/devices -name uevent -exec bash -c 'cat {} 2>/dev/null | grep -Eq "PCI_CLASS=0?30[0|1|2]00" && dirname {}' \;); do
# [ -e ${I}/reset ] && cat ${I}/vendor >/dev/null | grep -iq 0x10de && echo 1 >${I}/reset || true # Proc open nvidia driver when booting
# done

echo -e "\033[1;37mLoading DSM Kernel...\033[0m"
KEXECARGS="-a"
if [ $(echo "${KVER:-4}" | cut -d'.' -f1) -lt 4 ] && [ ${EFI} -eq 1 ]; then
echo -e "\033[1;33mWarning, running kexec with --noefi param, strange things will happen!!\033[0m"
KEXECARGS="kexecboot"
if [ ${EFI} -eq 0 ]; then
KEXECARGS+=" --noefi"
fi
kexec ${KEXECARGS} -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE} kexecboot" >"${LOG_FILE}" 2>&1 || dieLog

kexec -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE} ${KEXECARGS}" >"${PART1_PATH}/cmdline.yml" || die "Failed to load DSM Kernel!"

echo -e "\033[1;37mBooting DSM...\033[0m"
[ "${KERNELLOAD}" = "kexec" ] && kexec -e || poweroff
Expand Down
4 changes: 3 additions & 1 deletion files/initrd/opt/arc/evo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ elif [ "${ARCMODE}" = "config" ]; then
esac
done
else
echo "Unknown Mode: ${ARCMODE} - Exiting..."
echo "Unknown Mode: ${ARCMODE} - Rebooting to Config Mode"
sleep 3
rebootTo config
fi

# Inform user
Expand Down
4 changes: 0 additions & 4 deletions files/initrd/opt/arc/include/addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,10 @@ function installAddon() {
fi
local ADDON="${1}"
mkdir -p "${TMP_PATH}/${ADDON}"
local HAS_FILES=0
# First check generic files
if [ -f "${ADDONS_PATH}/${ADDON}/all.tgz" ]; then
tar -zxf "${ADDONS_PATH}/${ADDON}/all.tgz" -C "${TMP_PATH}/${ADDON}"
HAS_FILES=1
fi
# If has files to copy, copy it, else return error
[ ${HAS_FILES} -ne 1 ] && return 1
cp -f "${TMP_PATH}/${ADDON}/install.sh" "${RAMDISK_PATH}/addons/${ADDON}.sh" 2>"${LOG_FILE}"
chmod +x "${RAMDISK_PATH}/addons/${ADDON}.sh"
[ -d ${TMP_PATH}/${ADDON}/root ] && (cp -rnf "${TMP_PATH}/${ADDON}/root/"* "${RAMDISK_PATH}/" 2>"${LOG_FILE}")
Expand Down
10 changes: 5 additions & 5 deletions files/initrd/opt/arc/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ arc_mode || die "No bootmode found!"
[ -f "${USER_CONFIG_FILE}" ] && sed -i "s/'/\"/g" "${USER_CONFIG_FILE}" >/dev/null 2>&1 || true

BUS=$(getBus "${LOADER_DISK}")
EFI=$([ -d /sys/firmware/efi ] && echo 1 || echo 0)
[ -d /sys/firmware/efi ] && EFI="1" || EFI="0"

# Print Title centralized
clear
Expand Down Expand Up @@ -131,15 +131,15 @@ elif ! echo "${BUSLIST}" | grep -wq "${BUS}"; then
die "$(printf "The boot disk does not support the current %s, only %s are supported." "${BUS}" "${BUSLIST// /\/}")"
fi

# Save variables to user config file
writeConfigKey "vid" "${VID}" "${USER_CONFIG_FILE}"
writeConfigKey "pid" "${PID}" "${USER_CONFIG_FILE}"

# Inform user and check bus
echo -e "Loader Disk: \033[1;34m${LOADER_DISK}\033[0m"
echo -e "Loader Disk Type: \033[1;34m${BUS}\033[0m"
echo

# Save variables to user config file
writeConfigKey "vid" "${VID}" "${USER_CONFIG_FILE}"
writeConfigKey "pid" "${PID}" "${USER_CONFIG_FILE}"

# Decide if boot automatically
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
if [ "${ARCMODE}" = "config" ]; then
Expand Down
21 changes: 17 additions & 4 deletions files/initrd/opt/arc/ramdisk-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ RD_COMPRESSED="$(readConfigKey "rd-compressed" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
BUILDNUM="$(readConfigKey "buildnum" "${USER_CONFIG_FILE}")"
SMALLNUM="$(readConfigKey "smallnum" "${USER_CONFIG_FILE}")"
ARCBRANCH="$(readConfigKey "arc.branch" "${USER_CONFIG_FILE}")"
# Read new PAT Info from Config
PAT_URL="$(readConfigKey "paturl" "${USER_CONFIG_FILE}")"
PAT_HASH="$(readConfigKey "pathash" "${USER_CONFIG_FILE}")"
Expand Down Expand Up @@ -117,6 +116,16 @@ for PATCH in "${PATCHES[@]}"; do
done
done

# Add serial number to synoinfo.conf, to help to recovery a installed DSM
echo "Set synoinfo SN" >"${LOG_FILE}"
_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1
_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc.defaults/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1
for KEY in "${!SYNOINFO[@]}"; do
echo "Set synoinfo ${KEY}" >>"${LOG_FILE}"
_set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1
_set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc.defaults/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1
done

# Patch /sbin/init.post
grep -v -e '^[\t ]*#' -e '^$' "${PATCH_PATH}/config-manipulators.sh" >"${TMP_PATH}/rp.txt"
sed -e "/@@@CONFIG-MANIPULATORS-TOOLS@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post"
Expand Down Expand Up @@ -152,7 +161,7 @@ mkdir -p "${RAMDISK_PATH}/addons"
echo "export LOADERLABEL=\"ARC\""
echo "export LOADERVERSION=\"${ARC_VERSION}\""
echo "export LOADERBUILD=\"${ARC_BUILD}\""
echo "export LOADERBRANCH=\"${ARCBRANCH}\""
echo "export LOADERBRANCH=\"${ARC_BRANCH}\""
echo "export PLATFORM=\"${PLATFORM}\""
echo "export MODEL=\"${MODEL}\""
echo "export MODELID=\"${MODELID}\""
Expand All @@ -171,11 +180,13 @@ if [ "${PLATFORM}" = "epyc7002" ]; then
fi

# System Addons
for ADDON in revert misc eudev disks localrss notify wol mountloader; do
for ADDON in "revert" "misc" "eudev" "disks" "localrss" "notify" "wol"; do
PARAMS=""
if [ "${ADDON}" = "disks" ]; then
HDDSORT="$(readConfigKey "hddsort" "${USER_CONFIG_FILE}")"
PARAMS="${HDDSORT}"
if [ -n "${HDDSORT}" ]; then
PARAMS="${HDDSORT}"
fi
[ -f "${USER_UP_PATH}/${MODEL}.dts" ] && cp -f "${USER_UP_PATH}/${MODEL}.dts" "${RAMDISK_PATH}/addons/model.dts"
fi
installAddon "${ADDON}" "${PLATFORM}" || exit 1
Expand All @@ -193,6 +204,8 @@ done
echo "inetd" >>"${RAMDISK_PATH}/addons/addons.sh"

echo "Modify files" >"${LOG_FILE}"
# Remove function from scripts
[ "2" = "${BUILDNUM:0:1}" ] && sed -i 's/function //g' $(find "${RAMDISK_PATH}/addons/" -type f -name "*.sh")

# Build modules dependencies
# ${ARC_PATH}/depmod -a -b ${RAMDISK_PATH} 2>/dev/null
Expand Down
12 changes: 6 additions & 6 deletions files/p1/boot/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
menuentry 'Arc DSM Mode' ${menuentry_id_option} boot {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline}
linux /bzImage-arc ${ARC_CMDLINE}
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand All @@ -119,7 +119,7 @@ if [ -e /automated ]; then
menuentry 'Arc Automated Mode' ${menuentry_id_option} automated {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} automated_arc
linux /bzImage-arc ${ARC_CMDLINE} automated_arc
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand All @@ -133,7 +133,7 @@ fi
menuentry 'Arc Config Mode' ${menuentry_id_option} config {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} force_arc
linux /bzImage-arc ${ARC_CMDLINE} force_arc
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand All @@ -147,7 +147,7 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
menuentry 'Arc Update Mode' ${menuentry_id_option} update {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} update_arc
linux /bzImage-arc ${ARC_CMDLINE} update_arc
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand All @@ -159,7 +159,7 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
menuentry 'DSM Recovery Mode' ${menuentry_id_option} recovery {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} recovery
linux /bzImage-arc ${ARC_CMDLINE} recovery
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand All @@ -171,7 +171,7 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
menuentry 'DSM Reinstall Mode' ${menuentry_id_option} junior {
gfxmode
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} force_junior
linux /bzImage-arc ${ARC_CMDLINE} force_junior
echo "Loading Arc Initramfs..."
if [ -e /initrd-user ]; then
initrd /initrd-arc /initrd-user
Expand Down

0 comments on commit 3234b12

Please sign in to comment.