formatting

This commit is contained in:
Ing 2025-12-16 13:11:13 +08:00
parent f8c4589f84
commit d5dcb28318
11 changed files with 1806 additions and 1637 deletions

View File

@ -176,23 +176,6 @@ jobs:
echo "TAG=${TAG}" >> $GITHUB_ENV
case "${{ env.size }}" in
2GB)
echo "2GB"
;;
4GB)
echo "4GB"
resizeImg rr/rr.img +2048M
;;
8GB)
echo "8GB"
resizeImg rr/rr.img +6144M
;;
*)
echo "unknown size"
;;
esac
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" rr/rr.img
@ -254,6 +237,26 @@ jobs:
echo "Of course, you can also modify the settings yourself."
} >README.txt
case "${{ env.size }}" in
2GB)
echo "2GB"
gzip -dc "files/initrd/opt/rr/grub.img.gz" > rr/rr_2GB.img
repackImg rr/rr.img rr/rr_2GB.img
rm -f rr/rr.img
mv -f rr/rr_2GB.img rr/rr.img
;;
4GB)
echo "4GB"
;;
8GB)
echo "8GB"
resizeImg rr/rr.img +4096M
;;
*)
echo "unknown size"
;;
esac
case "${{ env.format }}" in
ova)
echo "OVA"

View File

@ -32,14 +32,14 @@ WTITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEA
DATE="$(date)"
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
printf "\033[1;31m%*s\033[0m\n" "$(((${#WTITLE} + ${COLUMNS}) / 2))" "${WTITLE}"
printf "\033[1;31m%*s\033[0m\n" "$(((${#WTITLE} + COLUMNS) / 2))" "${WTITLE}"
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"
BTITLE="Boot Type:"
BTITLE+="$([ ${EFI} -eq 1 ] && echo " [UEFI]" || echo " [BIOS]")"
BTITLE+="$([ "${BUS}" = "usb" ] && echo " [${BUS^^} flashdisk]" || echo " [${BUS^^} DoM]")"
printf "\033[1;33m%*s\033[0m\n" $(((${#BTITLE} + ${COLUMNS}) / 2)) "${BTITLE}"
printf "\033[1;33m%*s\033[0m\n" $(((${#BTITLE} + COLUMNS) / 2)) "${BTITLE}"
if [ -f "${PART1_PATH}/.upgraded" ]; then
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
@ -378,7 +378,7 @@ else
COUNT=0
BOOTIPWAIT="$(readConfigKey "bootipwait" "${USER_CONFIG_FILE}")"
BOOTIPWAIT=${BOOTIPWAIT:-10}
while [ ${COUNT} -lt $((${BOOTIPWAIT} + 32)) ]; do
while [ ${COUNT} -lt $((BOOTIPWAIT + 32)) ]; do
MSG=""
for N in ${ETHX}; do
if [ "1" = "$(cat "/sys/class/net/${N}/carrier" 2>/dev/null)" ]; then

View File

@ -48,7 +48,7 @@ function mergeConfigModules() {
XF=$(mktemp 2>/dev/null)
XF=${XF:-/tmp/tmp.XXXXXXXXXX}
echo -en "${ML}" | yq -p p -o y >"${XF}"
deleteConfigKey "modules.\"RRORG\"" "${XF}"
deleteConfigKey 'modules."RRORG"' "${XF}"
yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${2}" "${XF}" 2>/dev/null
rm -f "${XF}"
}

View File

@ -32,7 +32,7 @@ TITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEAS
DATE="$(date)"
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
printf "\033[1;31m%*s\033[0m\n" "$(((${#TITLE} + ${COLUMNS}) / 2))" "${TITLE}"
printf "\033[1;31m%*s\033[0m\n" "$(((${#TITLE} + COLUMNS) / 2))" "${TITLE}"
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"

View File

@ -430,8 +430,8 @@ function reconfiguringV() {
writeConfigKey "kver" "${KVER}" "${USER_CONFIG_FILE}"
writeConfigKey "kpre" "${KPRE}" "${USER_CONFIG_FILE}"
# Check kernel
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] &&
[ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] \
&& [ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
:
else
KERNEL='official'
@ -530,8 +530,8 @@ function setConfigFromDSM() {
writeConfigKey "kver" "${KVER}" "${USER_CONFIG_FILE}"
writeConfigKey "kpre" "${KPRE}" "${USER_CONFIG_FILE}"
# Check kernel
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] &&
[ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] \
&& [ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
:
else
KERNEL='official'
@ -1372,11 +1372,11 @@ function extractPatFiles() {
RET=$?
fi
if [ ${RET} -ne 0 ] ||
[ ! -f "${EXT_PATH}/grub_cksum.syno" ] ||
[ ! -f "${EXT_PATH}/GRUB_VER" ] ||
[ ! -f "${EXT_PATH}/zImage" ] ||
[ ! -f "${EXT_PATH}/rd.gz" ]; then
if [ ${RET} -ne 0 ] \
|| [ ! -f "${EXT_PATH}/grub_cksum.syno" ] \
|| [ ! -f "${EXT_PATH}/GRUB_VER" ] \
|| [ ! -f "${EXT_PATH}/zImage" ] \
|| [ ! -f "${EXT_PATH}/rd.gz" ]; then
printf "%s\n%s: %d\n" "$(TEXT "pat Invalid, try again!")" "$(TEXT "Error")" "${RET}" >"${LOG_FILE}"
return 1
fi
@ -1674,7 +1674,7 @@ function showDisksInfo() {
else
MSG+="$(printf "%02d" "${P}") "
fi
NUMPORTS=$((${NUMPORTS} + 1))
NUMPORTS=$((NUMPORTS + 1))
done
MSG+="\n"
done
@ -1685,7 +1685,7 @@ function showDisksInfo() {
PORTNUM=$(lsscsi -bS 2>/dev/null | awk '$3 != "0"' | grep -v - | grep "\[${PORT}:" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(lspci -d ::107 2>/dev/null | wc -l)" -gt 0 ] && MSG+="\nSAS:\n"
for PCI in $(lspci -d ::107 2>/dev/null | awk '{print $1}'); do
@ -1694,7 +1694,7 @@ function showDisksInfo() {
PORTNUM=$(lsscsi -bS 2>/dev/null | awk '$3 != "0"' | grep -v - | grep "\[${PORT}:" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(lspci -d ::100 2>/dev/null | wc -l)" -gt 0 ] && MSG+="\nSCSI:\n"
for PCI in $(lspci -d ::100 2>/dev/null | awk '{print $1}'); do
@ -1702,7 +1702,7 @@ function showDisksInfo() {
PORTNUM=$(ls -l /sys/block/* 2>/dev/null | grep "${PCI}" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(lspci -d ::101 2>/dev/null | wc -l)" -gt 0 ] && MSG+="\nIDE:\n"
for PCI in $(lspci -d ::101 2>/dev/null | awk '{print $1}'); do
@ -1710,7 +1710,7 @@ function showDisksInfo() {
PORTNUM=$(ls -l /sys/block/* 2>/dev/null | grep "${PCI}" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(ls -l /sys/class/scsi_host 2>/dev/null | grep usb | wc -l)" -gt 0 ] && MSG+="\nUSB:\n"
for PCI in $(lspci -d ::c03 2>/dev/null | awk '{print $1}'); do
@ -1719,7 +1719,7 @@ function showDisksInfo() {
PORTNUM=$(lsscsi -bS 2>/dev/null | awk '$3 != "0"' | grep -v - | grep "\[${PORT}:" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(ls -l /sys/block/mmc* 2>/dev/null | wc -l)" -gt 0 ] && MSG+="\nMMC:\n"
for PCI in $(lspci -d ::805 2>/dev/null | awk '{print $1}'); do
@ -1727,7 +1727,7 @@ function showDisksInfo() {
PORTNUM=$(ls -l /sys/block/mmc* 2>/dev/null | grep "${PCI}" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
[ "$(lspci -d ::108 2>/dev/null | wc -l)" -gt 0 ] && MSG+="\nNVME:\n"
for PCI in $(lspci -d ::108 2>/dev/null | awk '{print $1}'); do
@ -1736,7 +1736,7 @@ function showDisksInfo() {
PORTNUM=$(lsscsi -bS 2>/dev/null | awk '$3 != "0"' | grep -v - | grep "\[N:${PORT}:" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
done
if [ "$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep 'vmbus:acpi' | wc -l)" -gt 0 ]; then
MSG+="\nVMBUS:\n"
@ -1744,7 +1744,7 @@ function showDisksInfo() {
PORTNUM=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep 'vmbus:acpi' | wc -l)
[ ${PORTNUM} -eq 0 ] || {
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
NUMPORTS=$((NUMPORTS + PORTNUM))
}
fi
MSG+="\n"
@ -1891,9 +1891,9 @@ function allowDSMDowngrade() {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Removing ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(TEXT "Remove VERSION file for DSM system partition(md0) completed.")" ||
MSG="$(TEXT "Remove VERSION file for DSM system partition(md0) failed.")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(TEXT "Remove VERSION file for DSM system partition(md0) completed.")" \
|| MSG="$(TEXT "Remove VERSION file for DSM system partition(md0) failed.")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -1988,9 +1988,9 @@ function resetDSMPassword() {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Resetting ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(printf "$(TEXT "Reset password for user '%s' completed.")" "${USER}")" ||
MSG="$(printf "$(TEXT "Reset password for user '%s' failed.")" "${USER}")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(printf "$(TEXT "Reset password for user '%s' completed.")" "${USER}")" \
|| MSG="$(printf "$(TEXT "Reset password for user '%s' failed.")" "${USER}")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2033,9 +2033,9 @@ function addNewDSMUser() {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Adding ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(printf "$(TEXT "Add new user '%s' completed.")" "${username}")" ||
MSG="$(printf "$(TEXT "Add new user '%s' failed.")" "${username}")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(printf "$(TEXT "Add new user '%s' completed.")" "${username}")" \
|| MSG="$(printf "$(TEXT "Add new user '%s' failed.")" "${username}")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2071,9 +2071,9 @@ function forceEnableDSMTelnetSSH() {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Enabling ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(TEXT "Force enable Telnet&SSH of DSM system completed.")" ||
MSG="$(TEXT "Force enable Telnet&SSH of DSM system failed.")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(TEXT "Force enable Telnet&SSH of DSM system completed.")" \
|| MSG="$(TEXT "Force enable Telnet&SSH of DSM system failed.")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2110,9 +2110,9 @@ function removeBlockIPDB {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Removing ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(TEXT "Removing the blocked ip database completed.")" ||
MSG="$(TEXT "Removing the blocked ip database failed.")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(TEXT "Removing the blocked ip database completed.")" \
|| MSG="$(TEXT "Removing the blocked ip database failed.")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2145,9 +2145,9 @@ function disablescheduledTasks {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Enabling ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(TEXT "Disable all scheduled tasks of DSM completed.")" ||
MSG="$(TEXT "Disable all scheduled tasks of DSM failed.")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(TEXT "Disable all scheduled tasks of DSM completed.")" \
|| MSG="$(TEXT "Disable all scheduled tasks of DSM failed.")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2203,9 +2203,9 @@ function initDSMNetwork {
rm -rf "${TMP_PATH}/mdX"
) 2>&1 | DIALOG --title "$(TEXT "Advanced")" \
--progressbox "$(TEXT "Recovering ...")" 20 100
[ -f "${TMP_PATH}/isOk" ] &&
MSG="$(TEXT "Initialize DSM network settings completed.")" ||
MSG="$(TEXT "Initialize DSM network settings failed.")"
[ -f "${TMP_PATH}/isOk" ] \
&& MSG="$(TEXT "Initialize DSM network settings completed.")" \
|| MSG="$(TEXT "Initialize DSM network settings failed.")"
DIALOG --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0
return 0
@ -2399,9 +2399,9 @@ function tryRecoveryDSM() {
PS="$(readConfigEntriesArray "platforms" "${WORK_PATH}/platforms.yml" | sort)"
VS="$(readConfigEntriesArray "platforms.${R_PLATFORM}.productvers" "${WORK_PATH}/platforms.yml" | sort -r)"
if [ -n "${R_PLATFORM}" ] && arrayExistItem "${R_PLATFORM}" ${PS} &&
[ -n "${R_PRODUCTVER}" ] && arrayExistItem "${R_PRODUCTVER}" ${VS} &&
[ -n "${R_BUILDNUM}" ] && [ -n "${R_SMALLNUM}" ]; then
if [ -n "${R_PLATFORM}" ] && arrayExistItem "${R_PLATFORM}" ${PS} \
&& [ -n "${R_PRODUCTVER}" ] && arrayExistItem "${R_PRODUCTVER}" ${VS} \
&& [ -n "${R_BUILDNUM}" ] && [ -n "${R_SMALLNUM}" ]; then
cp -rf "${TMP_PATH}/mdX/usr/rr/backup/p1/"* "${PART1_PATH}"
if [ -d "${TMP_PATH}/mdX/usr/rr/backup/p3" ]; then
cp -rf "${TMP_PATH}/mdX/usr/rr/backup/p3/"* "${PART3_PATH}"
@ -3202,8 +3202,8 @@ function advancedMenu() {
m)
rm -f "${TMP_PATH}/menu"
{
echo "1 \"Native SATA Disk(SYNO)\""
echo "2 \"Fake SATA DOM(Redpill)\""
echo '1 "Native SATA Disk(SYNO)"'
echo '2 "Fake SATA DOM(Redpill)"'
} >"${TMP_PATH}/menu"
DIALOG --title "$(TEXT "Advanced")" \
--default-item "${SATADOM}" --menu "$(TEXT "Choose a mode(Only supported for kernel version 4)")" 0 0 0 --file "${TMP_PATH}/menu" \
@ -3238,9 +3238,9 @@ function advancedMenu() {
j)
AU=$(readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q "blockupdate" && echo "false" || echo "true")
if [ "${AU}" = "true" ]; then
writeConfigKey "addons.\"blockupdate\"" "" "${USER_CONFIG_FILE}"
writeConfigKey 'addons."blockupdate"' "" "${USER_CONFIG_FILE}"
else
deleteConfigKey "addons.\"blockupdate\"" "${USER_CONFIG_FILE}"
deleteConfigKey 'addons."blockupdate"' "${USER_CONFIG_FILE}"
fi
touch "${PART1_PATH}/.build"
NEXT="j"
@ -3289,9 +3289,9 @@ function advancedMenu() {
n)
rm -f "${TMP_PATH}/menu"
{
echo "5 \"Reboot after 5 seconds\""
echo "0 \"No reboot\""
echo "-1 \"Restart immediately\""
echo '5 "Reboot after 5 seconds"'
echo '0 "No reboot"'
echo '-1 "Restart immediately"'
} >"${TMP_PATH}/menu"
DIALOG --title "$(TEXT "Advanced")" \
--default-item "${KERNELPANIC}" --menu "$(TEXT "Choose a time(seconds)")" 0 0 0 --file "${TMP_PATH}/menu" \
@ -3662,8 +3662,8 @@ function updateRR() {
fi
FSNEW=$(du -sm "${TMP_PATH}/update/${VALUE}" 2>/dev/null | awk '{print $1}')
FSOLD=$(du -sm "/${VALUE}" 2>/dev/null | awk '{print $1}')
SIZENEW=$((${SIZENEW} + ${FSNEW:-0}))
SIZEOLD=$((${SIZEOLD} + ${FSOLD:-0}))
SIZENEW=$((SIZENEW + ${FSNEW:-0}))
SIZEOLD=$((SIZEOLD + ${FSOLD:-0}))
done <<<"$(readConfigMap "replace" "${TMP_PATH}/update/update-list.yml")"
SIZESPL=$(df -m "${PART3_PATH}" 2>/dev/null | awk 'NR==2 {print $4}')
@ -4090,8 +4090,8 @@ else
fi
echo "u \"$(TEXT "Parse pat")\""
if [ -n "${PRODUCTVER}" ]; then
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] &&
[ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
if [ -f "${CKS_PATH}/bzImage-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.gz" ] \
&& [ -f "${CKS_PATH}/modules-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}.tgz" ]; then
echo "s \"$(TEXT "Kernel:") \Z4${KERNEL}\Zn\""
fi
echo "a \"$(TEXT "Addons menu")\""

View File

@ -59,8 +59,8 @@ mkdir -p "${RAMDISK_PATH}"
# Check if DSM buildnumber changed
. "${RAMDISK_PATH}/etc/VERSION"
if [ -n "${PRODUCTVER}" ] && [ -n "${BUILDNUM}" ] && [ -n "${SMALLNUM}" ] &&
([ ! "${PRODUCTVER}" = "${majorversion:-0}.${minorversion:-0}" ] || [ ! "${BUILDNUM}" = "${buildnumber:-0}" ] || [ ! "${SMALLNUM}" = "${smallfixnumber:-0}" ]); then
if [ -n "${PRODUCTVER}" ] && [ -n "${BUILDNUM}" ] && [ -n "${SMALLNUM}" ] \
&& ([ ! "${PRODUCTVER}" = "${majorversion:-0}.${minorversion:-0}" ] || [ ! "${BUILDNUM}" = "${buildnumber:-0}" ] || [ ! "${SMALLNUM}" = "${smallfixnumber:-0}" ]); then
OLDVER="${PRODUCTVER}(${BUILDNUM}$([ ${SMALLNUM:-0} -ne 0 ] && echo "u${SMALLNUM}"))"
NEWVER="${majorversion}.${minorversion}(${buildnumber}$([ ${smallfixnumber:-0} -ne 0 ] && echo "u${smallfixnumber}"))"
echo -e "\033[A\n\033[1;32mBuild number changed from \033[1;31m${OLDVER}\033[1;32m to \033[1;31m${NEWVER}\033[0m"
@ -144,7 +144,7 @@ echo "Create addons.sh" >"${LOG_FILE}"
{
echo "#!/bin/sh"
echo 'echo "addons.sh called with params ${@}"'
echo "export LOADERLABEL=\"RR\""
echo 'export LOADERLABEL="RR"'
echo "export LOADERRELEASE=\"${RR_RELEASE}\""
echo "export LOADERVERSION=\"${RR_VERSION}\""
echo "export PLATFORM=\"${PLATFORM}\""
@ -213,7 +213,7 @@ echo "Modify files" >"${LOG_FILE}"
# backup current loader configs
mkdir -p "${RAMDISK_PATH}/usr/rr"
{
echo "LOADERLABEL=\"RR\""
echo 'LOADERLABEL="RR"'
echo "LOADERRELEASE=\"${RR_RELEASE}\""
echo "LOADERVERSION=\"${RR_VERSION}\""
} >"${RAMDISK_PATH}/usr/rr/VERSION"

View File

@ -11,6 +11,7 @@ from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
from openpyxl import Workbook
@click.group()
def cli():
"""
@ -21,8 +22,12 @@ def cli():
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
@click.option(
"-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile."
)
@click.option(
"-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile."
)
def getmodels(workpath, jsonpath, xlsxpath):
models = {}
platforms_yml = os.path.join(workpath, "opt", "rr", "platforms.yml")
@ -37,7 +42,11 @@ def getmodels(workpath, jsonpath, xlsxpath):
productvers[V] = f"{kpre}-{kver}" if kpre else kver
models[P] = {"productvers": productvers, "models": []}
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]))
adapter = HTTPAdapter(
max_retries=Retry(
total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]
)
)
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
@ -45,11 +54,13 @@ def getmodels(workpath, jsonpath, xlsxpath):
try:
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
#url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
# url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
p = re.compile(r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL)
p = re.compile(
r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL
)
data = p.findall(req.text)
except Exception as e:
click.echo(f"Error: {e}")
@ -80,22 +91,30 @@ def getmodels(workpath, jsonpath, xlsxpath):
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
@click.option(
"-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile."
)
@click.option(
"-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile."
)
def getpats(workpath, jsonpath, xlsxpath):
def __fullversion(ver):
arr = ver.split('-')
a, b, c = (arr[0].split('.') + ['0', '0', '0'])[:3]
d = arr[1] if len(arr) > 1 else '00000'
e = arr[2] if len(arr) > 2 else '0'
return f'{a}.{b}.{c}-{d}-{e}'
arr = ver.split("-")
a, b, c = (arr[0].split(".") + ["0", "0", "0"])[:3]
d = arr[1] if len(arr) > 1 else "00000"
e = arr[2] if len(arr) > 2 else "0"
return f"{a}.{b}.{c}-{d}-{e}"
platforms_yml = os.path.join(workpath, "opt", "rr", "platforms.yml")
with open(platforms_yml, "r") as f:
data = yaml.safe_load(f)
platforms = data.get("platforms", [])
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]))
adapter = HTTPAdapter(
max_retries=Retry(
total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]
)
)
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
@ -103,11 +122,13 @@ def getpats(workpath, jsonpath, xlsxpath):
try:
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
#url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
# url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
p = re.compile(r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL)
p = re.compile(
r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL
)
data = p.findall(req.text)
except Exception as e:
click.echo(f"Error: {e}")
@ -128,62 +149,94 @@ def getpats(workpath, jsonpath, xlsxpath):
pats = {}
for M in models:
pats[M] = {}
version = '7'
version = "7"
urlInfo = "https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
urlSteps = "https://www.synology.com/api/support/findUpgradeSteps?"
#urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
#urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
# urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
# urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
major = f"&major={version.split('.')[0]}" if len(version.split('.')) > 0 else ""
minor = f"&minor={version.split('.')[1]}" if len(version.split('.')) > 1 else ""
major = f"&major={version.split('.')[0]}" if len(version.split(".")) > 0 else ""
minor = f"&minor={version.split('.')[1]}" if len(version.split(".")) > 1 else ""
try:
req = session.get(f"{urlInfo}&product={M.replace('+', '%2B')}{major}{minor}", timeout=10, verify=False)
req = session.get(
f"{urlInfo}&product={M.replace('+', '%2B')}{major}{minor}",
timeout=10,
verify=False,
)
req.encoding = "utf-8"
data = json.loads(req.text)
except Exception as e:
click.echo(f"Error: {e}")
continue
build_ver = data['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = data['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = data['info']['system']['detail'][0]['items'][0]['nano']
build_ver = data["info"]["system"]["detail"][0]["items"][0]["build_ver"]
build_num = data["info"]["system"]["detail"][0]["items"][0]["build_num"]
buildnano = data["info"]["system"]["detail"][0]["items"][0]["nano"]
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
if V not in pats[M]:
pats[M][V] = {
'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': data['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
"url": data["info"]["system"]["detail"][0]["items"][0]["files"][0][
"url"
].split("?")[0],
"sum": data["info"]["system"]["detail"][0]["items"][0]["files"][0].get(
"checksum", "0" * 32
),
}
from_ver = min(I['build'] for I in data['info']['pubVers'])
from_ver = min(I["build"] for I in data["info"]["pubVers"])
for I in data['info']['productVers']:
if not I['version'].startswith(version):
for I in data["info"]["productVers"]:
if not I["version"].startswith(version):
continue
if not major or not minor:
majorTmp = f"&major={I['version'].split('.')[0]}" if len(I['version'].split('.')) > 0 else ""
minorTmp = f"&minor={I['version'].split('.')[1]}" if len(I['version'].split('.')) > 1 else ""
majorTmp = (
f"&major={I['version'].split('.')[0]}"
if len(I["version"].split(".")) > 0
else ""
)
minorTmp = (
f"&minor={I['version'].split('.')[1]}"
if len(I["version"].split(".")) > 1
else ""
)
try:
reqTmp = session.get(f"{urlInfo}&product={M.replace('+', '%2B')}{majorTmp}{minorTmp}", timeout=10, verify=False)
reqTmp = session.get(
f"{urlInfo}&product={M.replace('+', '%2B')}{majorTmp}{minorTmp}",
timeout=10,
verify=False,
)
reqTmp.encoding = "utf-8"
dataTmp = json.loads(reqTmp.text)
except Exception as e:
click.echo(f"Error: {e}")
continue
build_ver = dataTmp['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = dataTmp['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = dataTmp['info']['system']['detail'][0]['items'][0]['nano']
build_ver = dataTmp["info"]["system"]["detail"][0]["items"][0][
"build_ver"
]
build_num = dataTmp["info"]["system"]["detail"][0]["items"][0][
"build_num"
]
buildnano = dataTmp["info"]["system"]["detail"][0]["items"][0]["nano"]
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
if V not in pats[M]:
pats[M][V] = {
'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
"url": dataTmp["info"]["system"]["detail"][0]["items"][0][
"files"
][0]["url"].split("?")[0],
"sum": dataTmp["info"]["system"]["detail"][0]["items"][0][
"files"
][0].get("checksum", "0" * 32),
}
for J in I['versions']:
to_ver = J['build']
for J in I["versions"]:
to_ver = J["build"]
try:
reqSteps = session.get(f"{urlSteps}&product={M.replace('+', '%2B')}&from_ver={from_ver}&to_ver={to_ver}", timeout=10, verify=False)
reqSteps = session.get(
f"{urlSteps}&product={M.replace('+', '%2B')}&from_ver={from_ver}&to_ver={to_ver}",
timeout=10,
verify=False,
)
if reqSteps.status_code != 200:
continue
reqSteps.encoding = "utf-8"
@ -192,17 +245,28 @@ def getpats(workpath, jsonpath, xlsxpath):
click.echo(f"Error: {e}")
continue
for S in dataSteps['upgrade_steps']:
if not S.get('full_patch') or not S['build_ver'].startswith(version):
for S in dataSteps["upgrade_steps"]:
if not S.get("full_patch") or not S["build_ver"].startswith(
version
):
continue
V = __fullversion(f"{S['build_ver']}-{S['build_num']}-{S['nano']}")
if V not in pats[M]:
reqPat = session.head(S['files'][0]['url'].split('?')[0].replace("global.synologydownload.com", "global.download.synology.com"), timeout=10, verify=False)
reqPat = session.head(
S["files"][0]["url"]
.split("?")[0]
.replace(
"global.synologydownload.com",
"global.download.synology.com",
),
timeout=10,
verify=False,
)
if reqPat.status_code == 403:
continue
pats[M][V] = {
'url': S['files'][0]['url'].split('?')[0],
'sum': S['files'][0].get('checksum', '0' * 32)
"url": S["files"][0]["url"].split("?")[0],
"sum": S["files"][0].get("checksum", "0" * 32),
}
if jsonpath:
@ -220,8 +284,12 @@ def getpats(workpath, jsonpath, xlsxpath):
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
@click.option(
"-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile."
)
@click.option(
"-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile."
)
def getaddons(workpath, jsonpath, xlsxpath):
AS = glob.glob(os.path.join(workpath, "mnt", "p3", "addons", "*", "manifest.yml"))
AS.sort()
@ -231,7 +299,9 @@ def getaddons(workpath, jsonpath, xlsxpath):
A_data = yaml.safe_load(file)
A_name = A_data.get("name", "")
A_system = A_data.get("system", False)
A_description = A_data.get("description", {"en_US": "Unknown", "zh_CN": "Unknown"})
A_description = A_data.get(
"description", {"en_US": "Unknown", "zh_CN": "Unknown"}
)
addons[A_name] = {"system": A_system, "description": A_description}
if jsonpath:
with open(jsonpath, "w") as f:
@ -241,14 +311,25 @@ def getaddons(workpath, jsonpath, xlsxpath):
ws = wb.active
ws.append(["Name", "system", "en_US", "zh_CN"])
for k1, v1 in addons.items():
ws.append([k1, v1.get("system", False), v1.get("description").get("en_US", ""), v1.get("description").get("zh_CN", "")])
ws.append(
[
k1,
v1.get("system", False),
v1.get("description").get("en_US", ""),
v1.get("description").get("zh_CN", ""),
]
)
wb.save(xlsxpath)
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
@click.option(
"-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile."
)
@click.option(
"-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile."
)
def getmodules(workpath, jsonpath, xlsxpath):
MS = glob.glob(os.path.join(workpath, "mnt", "p3", "modules", "*.tgz"))
MS.sort()

View File

@ -318,6 +318,91 @@ function repackInitrd() {
sudo rm -rf "${RDXZ_PATH}"
}
function repackImg() {
local INPUT_FILE="${1}"
local OUTPUT_FILE="${2}"
[ -z "${INPUT_FILE}" ] && exit 1
[ -z "${OUTPUT_FILE}" ] || [ ! -f "${OUTPUT_FILE}" ] && exit 1
OUTPUT_FILE="$(realpath "${OUTPUT_FILE}")"
if [ -d "${INPUT_FILE}" ]; then
_umount() {
for i in {1..3}; do
sudo mount | grep -q "/tmp/mnt/p${i}" || continue
sudo umount "/tmp/mnt/p${i}"
rm -rf "/tmp/mnt/p${i}"
done
}
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" "${OUTPUT_FILE}"
for i in {1..3}; do
[ ! -d "${INPUT_FILE}/mnt/p${i}" ] && continue
rm -rf "/tmp/mnt/p${i}" 2>/dev/null
mkdir -p "/tmp/mnt/p${i}"
sudo mount "${LOOPX}p${i}" "/tmp/mnt/p${i}" || {
echo "Mount failed"
_umount
break
}
sudo cp -rf "${INPUT_FILE}/mnt/p${i}/". "/tmp/mnt/p${i}" || {
echo "Copy failed"
_umount
break
}
sudo sync
_umount
done
sudo losetup --detach "${LOOPX}"
elif [ -f "${INPUT_FILE}" ]; then
_umount() {
for i in {1..3}; do
sudo mount | grep -q "/tmp/i/mnt/p${i}" || continue
sudo umount "/tmp/i/mnt/p${i}"
rm -rf "/tmp/i/mnt/p${i}"
done
for i in {1..3}; do
sudo mount | grep -q "/tmp/x/mnt/p${i}" || continue
sudo umount "/tmp/x/mnt/p${i}"
rm -rf "/tmp/x/mnt/p${i}"
done
}
LOOPI=$(sudo losetup -f)
sudo losetup -P "${LOOPI}" "${INPUT_FILE}"
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" "${OUTPUT_FILE}"
for i in {1..3}; do
rm -rf "/tmp/i/mnt/p${i}" 2>/dev/null
mkdir -p "/tmp/i/mnt/p${i}"
rm -rf "/tmp/x/mnt/p${i}" 2>/dev/null
mkdir -p "/tmp/x/mnt/p${i}"
sudo mount "${LOOPI}p${i}" "/tmp/i/mnt/p${i}" || {
echo "Mount failed"
_umount
break
}
sudo mount "${LOOPX}p${i}" "/tmp/x/mnt/p${i}" || {
echo "Mount failed"
_umount
break
}
sudo cp -rf "/tmp/i/mnt/p${i}/". "/tmp/x/mnt/p${i}" || {
echo "Copy failed"
_umount
break
}
sudo sync
_umount
done
sudo losetup --detach "${LOOPX}"
sudo losetup --detach "${LOOPI}"
else
exit 1
fi
}
# resizeimg
# $1 input file
# $2 changsize MB eg: +50M -50M

View File

@ -182,16 +182,16 @@ if [ "${STATUS:-0}" -ne 0 ] || [ -z "${BLDISK}" ]; then
fi
[ -n "${IMG}" ] || rm -f "${IMG_PATH}"
case "${BLTYPE}" in
usb)
usb)
ARGS+="-device nec-usb-xhci,id=usb-bus0,multifunction=on -drive file=$(pvesm path ${BLDISK}),media=disk,format=raw,if=none,id=usb1 -device usb-storage,bus=usb-bus0.0,port=1,drive=usb1,bootindex=999,removable=on "
;;
nvme)
nvme)
ARGS+="-drive file=$(pvesm path ${BLDISK}),media=disk,format=raw,if=none,id=nvme1 -device nvme,drive=nvme1,serial=nvme001 "
;;
sata)
sata)
qm set ${VMID} --sata$((SATAIDX++)) "${BLDISK}"
;;
*)
*)
echo "Setting bootloader disk failed"
qm destroy ${VMID} --purge
exit 1