Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3207

Merged
merged 5 commits into from
Aug 31, 2024
Merged

Dev #3207

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions files/initrd/opt/arc/arc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ function arcModel() {
writeConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}"
writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}"
writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}"
CHANGED="true"
elif [ "${MODEL}" != "${resp}" ]; then
PRODUCTVER=""
MODEL="${resp}"
Expand All @@ -241,11 +240,6 @@ function arcModel() {
writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}"
writeConfigKey "sn" "" "${USER_CONFIG_FILE}"
writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}"
CHANGED="true"
fi
if [ "${CHANGED}" == "true" ]; then
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true
rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true
fi
# Read Platform Data
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
Expand Down Expand Up @@ -293,20 +287,12 @@ function arcVersion() {
writeConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}"
writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}"
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
CHANGED="true"
fi
if [ "${CHANGED}" == "true" ]; then
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true
rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true
fi
dialog --backtitle "$(backtitle)" --title "DSM Version" \
--infobox "Reading DSM Build..." 3 25
PAT_URL=""
PAT_HASH=""
URLVER=""
# Cleanup
[ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}"
mkdir -p "${UNTAR_PAT_PATH}"
while true; do
PJ="$(python ${ARC_PATH}/include/functions.py getpats4mv -m "${MODEL}" -v "${PRODUCTVER}")"
if [[ -z "${PJ}" || "${PJ}" = "{}" ]]; then
Expand All @@ -317,9 +303,20 @@ function arcVersion() {
[ $? -eq 0 ] && continue # yes-button
return 1
else
PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join(" ")')"
PVS="$(echo "${PJ}" | jq -r 'keys | sort | reverse | join("\n")')"
[ -f "${TMP_PATH}/versions" ] && rm -f "${TMP_PATH}/versions" >/dev/null 2>&1 && touch "${TMP_PATH}/versions"
while IFS= read -r line; do
VERSION="${line}"
CHECK_URL=$(echo "${PJ}" | jq -r ".\"${VERSION}\".url")
if curl --head -skL -m 5 "${CHECK_URL}" | head -n 1 | grep -q "404\|403"; then
continue
else
echo "${VERSION}" >>"${TMP_PATH}/versions"
fi
done < <(echo "${PVS}")
DSMPVS="$(cat ${TMP_PATH}/versions)"
dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \
--no-items --menu "Choose a DSM Build" 0 0 0 ${PVS} \
--no-items --menu "Choose a DSM Build" 0 0 0 ${DSMPVS} \
2>${TMP_PATH}/resp
RET=$?
[ ${RET} -ne 0 ] && return
Expand All @@ -329,7 +326,7 @@ function arcVersion() {
URLVER="$(echo "${PV}" | cut -d'.' -f1,2)"
[ "${PRODUCTVER}" != "${URLVER}" ] && PRODUCTVER="${URLVER}"
writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}"
[ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && break
[ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && VALID="true" && break
fi
done
if [ -z "${PAT_URL}" ] || [ -z "${PAT_HASH}" ]; then
Expand All @@ -344,8 +341,8 @@ function arcVersion() {
return 1 # 1 or 255 # cancel-button or ESC
PAT_URL="$(cat "${TMP_PATH}/resp" | sed -n '1p')"
PAT_HASH="$(cat "${TMP_PATH}/resp" | sed -n '2p')"
[ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && VALID="true"
fi
VALID="true"
elif [ "${AUTOMATED}" == "true" ]; then
PAT_URL="$(readConfigKey "paturl" "${USER_CONFIG_FILE}")"
PAT_HASH="$(readConfigKey "pathash" "${USER_CONFIG_FILE}")"
Expand All @@ -355,19 +352,25 @@ function arcVersion() {
if [ "${OFFLINE}" == "false" ]; then
dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \
--infobox "Check PAT Data..." 3 40
URLCHECK="$(curl --head -skL -m 10 "${PAT_URL}" | head -n 1)"
if echo "${URLCHECK}" | grep -q 404; then
if curl --head -skL -m 10 "${PAT_URL}" | head -n 1 | grep -q 404; then
VALID="false"
else
VALID="true"
fi
fi
sleep 2
# Cleanup
mkdir -p "${USER_UP_PATH}"
DSM_FILE="${USER_UP_PATH}/${PAT_HASH}.tar"
if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ "${PAT_URL}" != "${PAT_URL_CONF}" ]; then
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true
rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true
rm -f "${USER_UP_PATH}/${PAT_HASH_CONF}.tar" >/dev/null 2>&1 || true
fi
if [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "false" ] && [ "${VALID}" == "true" ]; then
dialog --backtitle "$(backtitle)" --colors --title "DSM Version" \
--infobox "Try to get DSM Image..." 3 40
if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ "${PAT_URL}" != "${PAT_URL_CONF}" ] || [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then
if [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then
# Write new PAT Data to Config
writeConfigKey "paturl" "${PAT_URL}" "${USER_CONFIG_FILE}"
writeConfigKey "pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}"
Expand Down Expand Up @@ -398,7 +401,7 @@ function arcVersion() {
elif [ ! -f "${DSM_FILE}" ] && [ "${OFFLINE}" == "true" ] && [ "${AUTOMATED}" == "false" ]; then
PAT_FILE=$(ls ${USER_UP_PATH}/*.pat | head -n 1)
if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ]; then
rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" 2>/dev/null || true
rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true
VALID="true"
elif [ ! -f "${PAT_FILE}" ]; then
# Check for existing Files
Expand Down Expand Up @@ -433,6 +436,9 @@ function arcVersion() {
sleep 5
fi
fi
# Cleanup
[ -d "${UNTAR_PAT_PATH}" ] && rm -rf "${UNTAR_PAT_PATH}"
mkdir -p "${UNTAR_PAT_PATH}"
if [ -f "${DSM_FILE}" ] && [ "${VALID}" == "true" ]; then
tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" 2>/dev/null
VALID="true"
Expand Down Expand Up @@ -822,7 +828,7 @@ function make() {
###############################################################################
# Finish Building Loader
function arcFinish() {
rm -f "${LOG_FILE}" >/dev/null
rm -f "${LOG_FILE}" >/dev/null 2>&1 || true
writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}"
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
if [ "${AUTOMATED}" == "true" ]; then
Expand Down
32 changes: 16 additions & 16 deletions files/initrd/opt/arc/include/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ function upgradeLoader () {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/arc.img.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/arc.img.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
fi
Expand Down Expand Up @@ -155,14 +155,14 @@ function updateLoader() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
Expand Down Expand Up @@ -220,14 +220,14 @@ function updateAddons() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/addons.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/addons.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
Expand Down Expand Up @@ -291,14 +291,14 @@ function updatePatches() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/patches.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/patches.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
Expand Down Expand Up @@ -354,14 +354,14 @@ function updateCustom() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/custom.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/custom.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
Expand Down Expand Up @@ -417,14 +417,14 @@ function updateModules() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/modules.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/modules.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
curl --interface ${ARCNIC} -skL "${SHA}" -o "${TMP_PATH}/checksum.sha256"
Expand Down Expand Up @@ -495,13 +495,13 @@ function updateConfigs() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/configs.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/configs.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
fi
Expand Down Expand Up @@ -557,13 +557,13 @@ function updateLKMs() {
if [ "${ARCNIC}" == "auto" ]; then
curl -#kL "${URL}" -o "${TMP_PATH}/rp-lkms.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
else
curl --interface ${ARCNIC} -#kL "${URL}" -o "${TMP_PATH}/rp-lkms.zip" 2>&1 | while IFS= read -r -n1 char; do
[[ $char =~ [0-9] ]] && keep=1 ;
[[ $char == % ]] && echo "Download: $progress%" && progress="" && keep=0 ;
[[ $char == % ]] && echo "$progress%" && progress="" && keep=0 ;
[[ $keep == 1 ]] && progress="$progress$char" ;
done
fi
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 @@ -84,11 +84,11 @@ if grep -q "automated_arc" /proc/cmdline; then
else
writeConfigKey "automated" "false" "${USER_CONFIG_FILE}"
fi
[ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null 2>&1 || true
if [ -f "${PART1_PATH}/ARC-BRANCH" ]; then
ARCBRANCH=$(cat "${PART1_PATH}/ARC-BRANCH") && writeConfigKey "arc.branch" "${ARCBRANCH}" "${USER_CONFIG_FILE}"
rm -f "${PART1_PATH}/ARC-BRANCH" >/dev/null 2>&1 || true
fi
[ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" >/dev/null 2>&1 || true
# Check for compatibility
compatboot

Expand Down
9 changes: 4 additions & 5 deletions files/initrd/opt/arc/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fi

# Get Config Status
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"

# Get Keymap and Timezone Config
ntpCheck
Expand Down Expand Up @@ -65,19 +66,17 @@ function arcUpdate() {
# Ask for Boot
dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \
--infobox "Update successful!" 0 0
if [ "${CONFDONE}" == "true" ] && [ ! -f "${PART3_PATH}/automated" ]; then
echo "${ARC_VERSION}-${MODEL}-${PRODUCTVER}-custom" >"${PART3_PATH}/automated"
fi
boot
}

###############################################################################
# Calls boot.sh to boot into DSM kernel/ramdisk
function boot() {
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
if [ "${CONFDONE}" == "true" ]; then
BUILDDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
if [ "${BUILDDONE}" == "true" ]; then
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
--infobox "Rebooting to automated Build Mode...\nPlease stay patient!" 4 30
[ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-${PRODUCTVER}" >"${PART3_PATH}/automated"
sleep 3
rebootTo automated
else
Expand Down
22 changes: 11 additions & 11 deletions files/p1/boot/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ set color_normal=white/black
set ARC_CMDLINE="earlyprintk earlycon=uart8250,io,0x3f8,115200n8 console=ttyS0,115200n8 root=/dev/ram rootwait net.ifnames=0 panic=0 pcie_aspm=off"

search --set=root --label "ARC3"
if [ -e /automated ]; then
menuentry 'Arc Automated Mode' --id automated {
set_gfxpayload
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} automated_arc
echo "Loading Arc Initramfs..."
initrd /initrd-arc
echo "Booting..."
}
fi

if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
if [ "${default}" = "direct" ]; then
set timeout="1"
Expand All @@ -120,6 +109,17 @@ if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
}
fi

if [ -e /automated ]; then
menuentry 'Arc Automated Mode' --id automated {
set_gfxpayload
echo "Loading Arc Kernel..."
linux /bzImage-arc ${ARC_CMDLINE} ${arc_cmdline} automated_arc
echo "Loading Arc Initramfs..."
initrd /initrd-arc
echo "Booting..."
}
fi

menuentry 'Arc Config Mode' --id config {
set_gfxpayload
echo "Loading Arc Kernel..."
Expand Down