mirror of
https://github.com/RROrg/rr.git
synced 2025-12-19 02:30:00 +08:00
formatting
This commit is contained in:
parent
f8c4589f84
commit
d5dcb28318
37
.github/workflows/issues.yml
vendored
37
.github/workflows/issues.yml
vendored
@ -176,23 +176,6 @@ jobs:
|
|||||||
|
|
||||||
echo "TAG=${TAG}" >> $GITHUB_ENV
|
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)
|
LOOPX=$(sudo losetup -f)
|
||||||
sudo losetup -P "${LOOPX}" rr/rr.img
|
sudo losetup -P "${LOOPX}" rr/rr.img
|
||||||
|
|
||||||
@ -254,6 +237,26 @@ jobs:
|
|||||||
echo "Of course, you can also modify the settings yourself."
|
echo "Of course, you can also modify the settings yourself."
|
||||||
} >README.txt
|
} >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
|
case "${{ env.format }}" in
|
||||||
ova)
|
ova)
|
||||||
echo "OVA"
|
echo "OVA"
|
||||||
|
|||||||
@ -32,14 +32,14 @@ WTITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEA
|
|||||||
DATE="$(date)"
|
DATE="$(date)"
|
||||||
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
||||||
printf "\033[1;44m%*s\033[A\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;44m%*s\033[A\n" "${COLUMNS}" ""
|
||||||
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"
|
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"
|
||||||
|
|
||||||
BTITLE="Boot Type:"
|
BTITLE="Boot Type:"
|
||||||
BTITLE+="$([ ${EFI} -eq 1 ] && echo " [UEFI]" || echo " [BIOS]")"
|
BTITLE+="$([ ${EFI} -eq 1 ] && echo " [UEFI]" || echo " [BIOS]")"
|
||||||
BTITLE+="$([ "${BUS}" = "usb" ] && echo " [${BUS^^} flashdisk]" || echo " [${BUS^^} DoM]")"
|
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
|
if [ -f "${PART1_PATH}/.upgraded" ]; then
|
||||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||||
@ -378,7 +378,7 @@ else
|
|||||||
COUNT=0
|
COUNT=0
|
||||||
BOOTIPWAIT="$(readConfigKey "bootipwait" "${USER_CONFIG_FILE}")"
|
BOOTIPWAIT="$(readConfigKey "bootipwait" "${USER_CONFIG_FILE}")"
|
||||||
BOOTIPWAIT=${BOOTIPWAIT:-10}
|
BOOTIPWAIT=${BOOTIPWAIT:-10}
|
||||||
while [ ${COUNT} -lt $((${BOOTIPWAIT} + 32)) ]; do
|
while [ ${COUNT} -lt $((BOOTIPWAIT + 32)) ]; do
|
||||||
MSG=""
|
MSG=""
|
||||||
for N in ${ETHX}; do
|
for N in ${ETHX}; do
|
||||||
if [ "1" = "$(cat "/sys/class/net/${N}/carrier" 2>/dev/null)" ]; then
|
if [ "1" = "$(cat "/sys/class/net/${N}/carrier" 2>/dev/null)" ]; then
|
||||||
|
|||||||
@ -23,10 +23,10 @@ trap 'flock -u 911; rm -f "${TMP_PATH}/helper.lock"' EXIT INT TERM HUP
|
|||||||
|
|
||||||
{
|
{
|
||||||
printf "$(TEXT "Closing this window or press 'ctrl + c' to exit the assistance.")\n"
|
printf "$(TEXT "Closing this window or press 'ctrl + c' to exit the assistance.")\n"
|
||||||
printf "$(TEXT "Please give the following link to the helper. (Click to open and copy)")\n"
|
printf "$(TEXT "Please give the following link to the helper. (Click to open and copy)")\n"
|
||||||
printf " 👇\n"
|
printf " 👇\n"
|
||||||
sshx -q --name "RR-Helper" 2>&1
|
sshx -q --name "RR-Helper" 2>&1
|
||||||
[ $? -ne 0 ] && while true; do sleep 1; done
|
[ $? -ne 0 ] && while true; do sleep 1; done
|
||||||
} | dialog --colors --aspect 50 --title "$(TEXT "Online Assistance")" --progressbox "$(TEXT "Notice: Please keep this window open.")" 20 100 2>&1
|
} | dialog --colors --aspect 50 --title "$(TEXT "Online Assistance")" --progressbox "$(TEXT "Notice: Please keep this window open.")" 20 100 2>&1
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|||||||
@ -48,7 +48,7 @@ function mergeConfigModules() {
|
|||||||
XF=$(mktemp 2>/dev/null)
|
XF=$(mktemp 2>/dev/null)
|
||||||
XF=${XF:-/tmp/tmp.XXXXXXXXXX}
|
XF=${XF:-/tmp/tmp.XXXXXXXXXX}
|
||||||
echo -en "${ML}" | yq -p p -o y >"${XF}"
|
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
|
yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${2}" "${XF}" 2>/dev/null
|
||||||
rm -f "${XF}"
|
rm -f "${XF}"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,12 +114,12 @@ function generateSerial() {
|
|||||||
|
|
||||||
SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}"
|
SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}"
|
||||||
case "${SUFFIX:-"alpha"}" in
|
case "${SUFFIX:-"alpha"}" in
|
||||||
numeric)
|
numeric)
|
||||||
SERIAL+="$(random)"
|
SERIAL+="$(random)"
|
||||||
;;
|
;;
|
||||||
alpha)
|
alpha)
|
||||||
SERIAL+="$(genRandomLetter)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomLetter)"
|
SERIAL+="$(genRandomLetter)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomLetter)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "${SERIAL}"
|
echo "${SERIAL}"
|
||||||
}
|
}
|
||||||
@ -167,16 +167,16 @@ function validateSerial() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
case "${SUFFIX:-"alpha"}" in
|
case "${SUFFIX:-"alpha"}" in
|
||||||
numeric)
|
numeric)
|
||||||
if ! echo "${S}" | grep -q "^[0-9]\{6\}$"; then
|
if ! echo "${S}" | grep -q "^[0-9]\{6\}$"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
alpha)
|
alpha)
|
||||||
if ! echo "${S}" | grep -q "^[A-Z][0-9][0-9][0-9][0-9][A-Z]$"; then
|
if ! echo "${S}" | grep -q "^[A-Z][0-9][0-9][0-9][0-9][A-Z]$"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ TITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEAS
|
|||||||
DATE="$(date)"
|
DATE="$(date)"
|
||||||
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
||||||
printf "\033[1;44m%*s\033[A\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;44m%*s\033[A\n" "${COLUMNS}" ""
|
||||||
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"
|
printf "\033[1;32m%*s\033[0m\n" "${COLUMNS}" "${DATE}"
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -59,8 +59,8 @@ mkdir -p "${RAMDISK_PATH}"
|
|||||||
# Check if DSM buildnumber changed
|
# Check if DSM buildnumber changed
|
||||||
. "${RAMDISK_PATH}/etc/VERSION"
|
. "${RAMDISK_PATH}/etc/VERSION"
|
||||||
|
|
||||||
if [ -n "${PRODUCTVER}" ] && [ -n "${BUILDNUM}" ] && [ -n "${SMALLNUM}" ] &&
|
if [ -n "${PRODUCTVER}" ] && [ -n "${BUILDNUM}" ] && [ -n "${SMALLNUM}" ] \
|
||||||
([ ! "${PRODUCTVER}" = "${majorversion:-0}.${minorversion:-0}" ] || [ ! "${BUILDNUM}" = "${buildnumber:-0}" ] || [ ! "${SMALLNUM}" = "${smallfixnumber:-0}" ]); then
|
&& ([ ! "${PRODUCTVER}" = "${majorversion:-0}.${minorversion:-0}" ] || [ ! "${BUILDNUM}" = "${buildnumber:-0}" ] || [ ! "${SMALLNUM}" = "${smallfixnumber:-0}" ]); then
|
||||||
OLDVER="${PRODUCTVER}(${BUILDNUM}$([ ${SMALLNUM:-0} -ne 0 ] && echo "u${SMALLNUM}"))"
|
OLDVER="${PRODUCTVER}(${BUILDNUM}$([ ${SMALLNUM:-0} -ne 0 ] && echo "u${SMALLNUM}"))"
|
||||||
NEWVER="${majorversion}.${minorversion}(${buildnumber}$([ ${smallfixnumber:-0} -ne 0 ] && echo "u${smallfixnumber}"))"
|
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"
|
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 "#!/bin/sh"
|
||||||
echo 'echo "addons.sh called with params ${@}"'
|
echo 'echo "addons.sh called with params ${@}"'
|
||||||
echo "export LOADERLABEL=\"RR\""
|
echo 'export LOADERLABEL="RR"'
|
||||||
echo "export LOADERRELEASE=\"${RR_RELEASE}\""
|
echo "export LOADERRELEASE=\"${RR_RELEASE}\""
|
||||||
echo "export LOADERVERSION=\"${RR_VERSION}\""
|
echo "export LOADERVERSION=\"${RR_VERSION}\""
|
||||||
echo "export PLATFORM=\"${PLATFORM}\""
|
echo "export PLATFORM=\"${PLATFORM}\""
|
||||||
@ -213,7 +213,7 @@ echo "Modify files" >"${LOG_FILE}"
|
|||||||
# backup current loader configs
|
# backup current loader configs
|
||||||
mkdir -p "${RAMDISK_PATH}/usr/rr"
|
mkdir -p "${RAMDISK_PATH}/usr/rr"
|
||||||
{
|
{
|
||||||
echo "LOADERLABEL=\"RR\""
|
echo 'LOADERLABEL="RR"'
|
||||||
echo "LOADERRELEASE=\"${RR_RELEASE}\""
|
echo "LOADERRELEASE=\"${RR_RELEASE}\""
|
||||||
echo "LOADERVERSION=\"${RR_VERSION}\""
|
echo "LOADERVERSION=\"${RR_VERSION}\""
|
||||||
} >"${RAMDISK_PATH}/usr/rr/VERSION"
|
} >"${RAMDISK_PATH}/usr/rr/VERSION"
|
||||||
|
|||||||
183
scripts/func.py
183
scripts/func.py
@ -11,6 +11,7 @@ from requests.adapters import HTTPAdapter
|
|||||||
from requests.packages.urllib3.util.retry import Retry # type: ignore
|
from requests.packages.urllib3.util.retry import Retry # type: ignore
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def cli():
|
def cli():
|
||||||
"""
|
"""
|
||||||
@ -21,8 +22,12 @@ def cli():
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
|
@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(
|
||||||
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
|
"-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):
|
def getmodels(workpath, jsonpath, xlsxpath):
|
||||||
models = {}
|
models = {}
|
||||||
platforms_yml = os.path.join(workpath, "opt", "rr", "platforms.yml")
|
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
|
productvers[V] = f"{kpre}-{kver}" if kpre else kver
|
||||||
models[P] = {"productvers": productvers, "models": []}
|
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 = requests.Session()
|
||||||
session.mount("http://", adapter)
|
session.mount("http://", adapter)
|
||||||
session.mount("https://", adapter)
|
session.mount("https://", adapter)
|
||||||
@ -45,11 +54,13 @@ def getmodels(workpath, jsonpath, xlsxpath):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
|
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 = session.get(url, timeout=10, verify=False)
|
||||||
req.encoding = "utf-8"
|
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)
|
data = p.findall(req.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}")
|
click.echo(f"Error: {e}")
|
||||||
@ -80,22 +91,30 @@ def getmodels(workpath, jsonpath, xlsxpath):
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
|
@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(
|
||||||
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
|
"-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 getpats(workpath, jsonpath, xlsxpath):
|
||||||
def __fullversion(ver):
|
def __fullversion(ver):
|
||||||
arr = ver.split('-')
|
arr = ver.split("-")
|
||||||
a, b, c = (arr[0].split('.') + ['0', '0', '0'])[:3]
|
a, b, c = (arr[0].split(".") + ["0", "0", "0"])[:3]
|
||||||
d = arr[1] if len(arr) > 1 else '00000'
|
d = arr[1] if len(arr) > 1 else "00000"
|
||||||
e = arr[2] if len(arr) > 2 else '0'
|
e = arr[2] if len(arr) > 2 else "0"
|
||||||
return f'{a}.{b}.{c}-{d}-{e}'
|
return f"{a}.{b}.{c}-{d}-{e}"
|
||||||
|
|
||||||
platforms_yml = os.path.join(workpath, "opt", "rr", "platforms.yml")
|
platforms_yml = os.path.join(workpath, "opt", "rr", "platforms.yml")
|
||||||
with open(platforms_yml, "r") as f:
|
with open(platforms_yml, "r") as f:
|
||||||
data = yaml.safe_load(f)
|
data = yaml.safe_load(f)
|
||||||
platforms = data.get("platforms", [])
|
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 = requests.Session()
|
||||||
session.mount("http://", adapter)
|
session.mount("http://", adapter)
|
||||||
session.mount("https://", adapter)
|
session.mount("https://", adapter)
|
||||||
@ -103,11 +122,13 @@ def getpats(workpath, jsonpath, xlsxpath):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
|
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 = session.get(url, timeout=10, verify=False)
|
||||||
req.encoding = "utf-8"
|
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)
|
data = p.findall(req.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}")
|
click.echo(f"Error: {e}")
|
||||||
@ -128,62 +149,94 @@ def getpats(workpath, jsonpath, xlsxpath):
|
|||||||
pats = {}
|
pats = {}
|
||||||
for M in models:
|
for M in models:
|
||||||
pats[M] = {}
|
pats[M] = {}
|
||||||
version = '7'
|
version = "7"
|
||||||
urlInfo = "https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
|
urlInfo = "https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
|
||||||
urlSteps = "https://www.synology.com/api/support/findUpgradeSteps?"
|
urlSteps = "https://www.synology.com/api/support/findUpgradeSteps?"
|
||||||
#urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
|
# urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
|
||||||
#urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
|
# urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
|
||||||
|
|
||||||
major = f"&major={version.split('.')[0]}" if len(version.split('.')) > 0 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 ""
|
minor = f"&minor={version.split('.')[1]}" if len(version.split(".")) > 1 else ""
|
||||||
try:
|
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"
|
req.encoding = "utf-8"
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}")
|
click.echo(f"Error: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
build_ver = data['info']['system']['detail'][0]['items'][0]['build_ver']
|
build_ver = data["info"]["system"]["detail"][0]["items"][0]["build_ver"]
|
||||||
build_num = data['info']['system']['detail'][0]['items'][0]['build_num']
|
build_num = data["info"]["system"]["detail"][0]["items"][0]["build_num"]
|
||||||
buildnano = data['info']['system']['detail'][0]['items'][0]['nano']
|
buildnano = data["info"]["system"]["detail"][0]["items"][0]["nano"]
|
||||||
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
|
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
|
||||||
if V not in pats[M]:
|
if V not in pats[M]:
|
||||||
pats[M][V] = {
|
pats[M][V] = {
|
||||||
'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
|
"url": data["info"]["system"]["detail"][0]["items"][0]["files"][0][
|
||||||
'sum': data['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
|
"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']:
|
for I in data["info"]["productVers"]:
|
||||||
if not I['version'].startswith(version):
|
if not I["version"].startswith(version):
|
||||||
continue
|
continue
|
||||||
if not major or not minor:
|
if not major or not minor:
|
||||||
majorTmp = f"&major={I['version'].split('.')[0]}" if len(I['version'].split('.')) > 0 else ""
|
majorTmp = (
|
||||||
minorTmp = f"&minor={I['version'].split('.')[1]}" if len(I['version'].split('.')) > 1 else ""
|
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:
|
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"
|
reqTmp.encoding = "utf-8"
|
||||||
dataTmp = json.loads(reqTmp.text)
|
dataTmp = json.loads(reqTmp.text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}")
|
click.echo(f"Error: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
build_ver = dataTmp['info']['system']['detail'][0]['items'][0]['build_ver']
|
build_ver = dataTmp["info"]["system"]["detail"][0]["items"][0][
|
||||||
build_num = dataTmp['info']['system']['detail'][0]['items'][0]['build_num']
|
"build_ver"
|
||||||
buildnano = dataTmp['info']['system']['detail'][0]['items'][0]['nano']
|
]
|
||||||
|
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}")
|
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
|
||||||
if V not in pats[M]:
|
if V not in pats[M]:
|
||||||
pats[M][V] = {
|
pats[M][V] = {
|
||||||
'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
|
"url": dataTmp["info"]["system"]["detail"][0]["items"][0][
|
||||||
'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0].get('checksum', '0' * 32)
|
"files"
|
||||||
|
][0]["url"].split("?")[0],
|
||||||
|
"sum": dataTmp["info"]["system"]["detail"][0]["items"][0][
|
||||||
|
"files"
|
||||||
|
][0].get("checksum", "0" * 32),
|
||||||
}
|
}
|
||||||
|
|
||||||
for J in I['versions']:
|
for J in I["versions"]:
|
||||||
to_ver = J['build']
|
to_ver = J["build"]
|
||||||
try:
|
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:
|
if reqSteps.status_code != 200:
|
||||||
continue
|
continue
|
||||||
reqSteps.encoding = "utf-8"
|
reqSteps.encoding = "utf-8"
|
||||||
@ -192,17 +245,28 @@ def getpats(workpath, jsonpath, xlsxpath):
|
|||||||
click.echo(f"Error: {e}")
|
click.echo(f"Error: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for S in dataSteps['upgrade_steps']:
|
for S in dataSteps["upgrade_steps"]:
|
||||||
if not S.get('full_patch') or not S['build_ver'].startswith(version):
|
if not S.get("full_patch") or not S["build_ver"].startswith(
|
||||||
|
version
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
V = __fullversion(f"{S['build_ver']}-{S['build_num']}-{S['nano']}")
|
V = __fullversion(f"{S['build_ver']}-{S['build_num']}-{S['nano']}")
|
||||||
if V not in pats[M]:
|
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:
|
if reqPat.status_code == 403:
|
||||||
continue
|
continue
|
||||||
pats[M][V] = {
|
pats[M][V] = {
|
||||||
'url': S['files'][0]['url'].split('?')[0],
|
"url": S["files"][0]["url"].split("?")[0],
|
||||||
'sum': S['files'][0].get('checksum', '0' * 32)
|
"sum": S["files"][0].get("checksum", "0" * 32),
|
||||||
}
|
}
|
||||||
|
|
||||||
if jsonpath:
|
if jsonpath:
|
||||||
@ -220,8 +284,12 @@ def getpats(workpath, jsonpath, xlsxpath):
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
|
@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(
|
||||||
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
|
"-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):
|
def getaddons(workpath, jsonpath, xlsxpath):
|
||||||
AS = glob.glob(os.path.join(workpath, "mnt", "p3", "addons", "*", "manifest.yml"))
|
AS = glob.glob(os.path.join(workpath, "mnt", "p3", "addons", "*", "manifest.yml"))
|
||||||
AS.sort()
|
AS.sort()
|
||||||
@ -231,7 +299,9 @@ def getaddons(workpath, jsonpath, xlsxpath):
|
|||||||
A_data = yaml.safe_load(file)
|
A_data = yaml.safe_load(file)
|
||||||
A_name = A_data.get("name", "")
|
A_name = A_data.get("name", "")
|
||||||
A_system = A_data.get("system", False)
|
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}
|
addons[A_name] = {"system": A_system, "description": A_description}
|
||||||
if jsonpath:
|
if jsonpath:
|
||||||
with open(jsonpath, "w") as f:
|
with open(jsonpath, "w") as f:
|
||||||
@ -241,14 +311,25 @@ def getaddons(workpath, jsonpath, xlsxpath):
|
|||||||
ws = wb.active
|
ws = wb.active
|
||||||
ws.append(["Name", "system", "en_US", "zh_CN"])
|
ws.append(["Name", "system", "en_US", "zh_CN"])
|
||||||
for k1, v1 in addons.items():
|
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)
|
wb.save(xlsxpath)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of RR.")
|
@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(
|
||||||
@click.option("-x", "--xlsxpath", type=str, required=False, help="The output path of xlsxfile.")
|
"-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):
|
def getmodules(workpath, jsonpath, xlsxpath):
|
||||||
MS = glob.glob(os.path.join(workpath, "mnt", "p3", "modules", "*.tgz"))
|
MS = glob.glob(os.path.join(workpath, "mnt", "p3", "modules", "*.tgz"))
|
||||||
MS.sort()
|
MS.sort()
|
||||||
|
|||||||
135
scripts/func.sh
135
scripts/func.sh
@ -259,14 +259,14 @@ function unpackInitrd() {
|
|||||||
INITRD_FORMAT=$(file -b --mime-type "${INITRD_FILE}")
|
INITRD_FORMAT=$(file -b --mime-type "${INITRD_FILE}")
|
||||||
|
|
||||||
case "${INITRD_FORMAT}" in
|
case "${INITRD_FORMAT}" in
|
||||||
*'x-cpio'*) (cd "${OUTPUT_PATH}" && sudo cpio -idm <"${INITRD_FILE}") >/dev/null 2>&1 ;;
|
*'x-cpio'*) (cd "${OUTPUT_PATH}" && sudo cpio -idm <"${INITRD_FILE}") >/dev/null 2>&1 ;;
|
||||||
*'x-xz'*) (cd "${OUTPUT_PATH}" && xz -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-xz'*) (cd "${OUTPUT_PATH}" && xz -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-lz4'*) (cd "${OUTPUT_PATH}" && lz4 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-lz4'*) (cd "${OUTPUT_PATH}" && lz4 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-lzma'*) (cd "${OUTPUT_PATH}" && lzma -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-lzma'*) (cd "${OUTPUT_PATH}" && lzma -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-bzip2'*) (cd "${OUTPUT_PATH}" && bzip2 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-bzip2'*) (cd "${OUTPUT_PATH}" && bzip2 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'gzip'*) (cd "${OUTPUT_PATH}" && gzip -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'gzip'*) (cd "${OUTPUT_PATH}" && gzip -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'zstd'*) (cd "${OUTPUT_PATH}" && zstd -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'zstd'*) (cd "${OUTPUT_PATH}" && zstd -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,32 +292,117 @@ function repackInitrd() {
|
|||||||
INITRD_FORMAT=$(file -b --mime-type "${INITRD_FILE}")
|
INITRD_FORMAT=$(file -b --mime-type "${INITRD_FILE}")
|
||||||
|
|
||||||
case "${INITRD_FORMAT}" in
|
case "${INITRD_FORMAT}" in
|
||||||
*'x-cpio'*) (cd "${RDXZ_PATH}" && sudo cpio -idm <"${INITRD_FILE}") >/dev/null 2>&1 ;;
|
*'x-cpio'*) (cd "${RDXZ_PATH}" && sudo cpio -idm <"${INITRD_FILE}") >/dev/null 2>&1 ;;
|
||||||
*'x-xz'*) (cd "${RDXZ_PATH}" && xz -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-xz'*) (cd "${RDXZ_PATH}" && xz -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-lz4'*) (cd "${RDXZ_PATH}" && lz4 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-lz4'*) (cd "${RDXZ_PATH}" && lz4 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-lzma'*) (cd "${RDXZ_PATH}" && lzma -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-lzma'*) (cd "${RDXZ_PATH}" && lzma -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'x-bzip2'*) (cd "${RDXZ_PATH}" && bzip2 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'x-bzip2'*) (cd "${RDXZ_PATH}" && bzip2 -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'gzip'*) (cd "${RDXZ_PATH}" && gzip -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'gzip'*) (cd "${RDXZ_PATH}" && gzip -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*'zstd'*) (cd "${RDXZ_PATH}" && zstd -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
*'zstd'*) (cd "${RDXZ_PATH}" && zstd -dc "${INITRD_FILE}" | sudo cpio -idm) >/dev/null 2>&1 ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sudo cp -rf "${PLUGIN_PATH}/"* "${RDXZ_PATH}/"
|
sudo cp -rf "${PLUGIN_PATH}/"* "${RDXZ_PATH}/"
|
||||||
[ -f "${OUTPUT_PATH}" ] && rm -rf "${OUTPUT_PATH}"
|
[ -f "${OUTPUT_PATH}" ] && rm -rf "${OUTPUT_PATH}"
|
||||||
# shellcheck disable=SC2024
|
# shellcheck disable=SC2024
|
||||||
case "${INITRD_FORMAT}" in
|
case "${INITRD_FORMAT}" in
|
||||||
*'x-cpio'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'x-cpio'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'x-xz'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | xz -9 -C crc32 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'x-xz'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | xz -9 -C crc32 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'x-lz4'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | lz4 -9 -l -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'x-lz4'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | lz4 -9 -l -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'x-lzma'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | lzma -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'x-lzma'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | lzma -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'x-bzip2'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | bzip2 -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'x-bzip2'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | bzip2 -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'gzip'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | gzip -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'gzip'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | gzip -9 -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*'zstd'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | zstd -19 -T0 -f -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
*'zstd'*) (cd "${RDXZ_PATH}" && sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | zstd -19 -T0 -f -c - >"${OUTPUT_PATH}") >/dev/null 2>&1 ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
sudo rm -rf "${RDXZ_PATH}"
|
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
|
# resizeimg
|
||||||
# $1 input file
|
# $1 input file
|
||||||
# $2 changsize MB eg: +50M -50M
|
# $2 changsize MB eg: +50M -50M
|
||||||
@ -365,7 +450,7 @@ function createvmx() {
|
|||||||
# Convert raw image to VMDK
|
# Convert raw image to VMDK
|
||||||
rm -rf "VMX_${VMNAME}"
|
rm -rf "VMX_${VMNAME}"
|
||||||
mkdir -p "VMX_${VMNAME}"
|
mkdir -p "VMX_${VMNAME}"
|
||||||
qemu-img convert -O vmdk -o 'adapter_type=lsilogic,subformat=monolithicSparse,compat6' "${BLIMAGE}" "VMX_${VMNAME}/${VMNAME}-disk1.vmdk" # 'adapter_type=lsilogic,subformat=streamOptimized,compat6'
|
qemu-img convert -O vmdk -o 'adapter_type=lsilogic,subformat=monolithicSparse,compat6' "${BLIMAGE}" "VMX_${VMNAME}/${VMNAME}-disk1.vmdk" # 'adapter_type=lsilogic,subformat=streamOptimized,compat6'
|
||||||
qemu-img create -f vmdk "VMX_${VMNAME}/${VMNAME}-disk2.vmdk" "32G"
|
qemu-img create -f vmdk "VMX_${VMNAME}/${VMNAME}-disk2.vmdk" "32G"
|
||||||
|
|
||||||
# Create VM configuration
|
# Create VM configuration
|
||||||
|
|||||||
122
scripts/pve.sh
122
scripts/pve.sh
@ -40,53 +40,53 @@ fi
|
|||||||
eval set -- "$ARGS"
|
eval set -- "$ARGS"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--onboot)
|
--onboot)
|
||||||
ONBOOT="$2"
|
ONBOOT="$2"
|
||||||
echo "$ONBOOT" | grep -qvE '^(0|1)$' && ONBOOT=1
|
echo "$ONBOOT" | grep -qvE '^(0|1)$' && ONBOOT=1
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--efi)
|
--efi)
|
||||||
EFI="$2"
|
EFI="$2"
|
||||||
echo "$EFI" | grep -qvE '^(0|1)$' && EFI=1
|
echo "$EFI" | grep -qvE '^(0|1)$' && EFI=1
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--bltype)
|
--bltype)
|
||||||
BLTYPE="$2"
|
BLTYPE="$2"
|
||||||
echo "$BLTYPE" | grep -qvE '^(sata|usb|nvme)$' && BLTYPE="sata"
|
echo "$BLTYPE" | grep -qvE '^(sata|usb|nvme)$' && BLTYPE="sata"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--storage)
|
--storage)
|
||||||
STORAGE="$2"
|
STORAGE="$2"
|
||||||
[ -n "${STORAGE}" ] && pvesm status -content images | grep -qw "^${STORAGE}" || STORAGE=""
|
[ -n "${STORAGE}" ] && pvesm status -content images | grep -qw "^${STORAGE}" || STORAGE=""
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--v9ppath)
|
--v9ppath)
|
||||||
V9PPATH="$2"
|
V9PPATH="$2"
|
||||||
[ -d "${V9PPATH}" ] && V9PPATH="$(realpath "${V9PPATH}")" || V9PPATH=""
|
[ -d "${V9PPATH}" ] && V9PPATH="$(realpath "${V9PPATH}")" || V9PPATH=""
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--vfsdirid)
|
--vfsdirid)
|
||||||
VFSDIRID="$2"
|
VFSDIRID="$2"
|
||||||
[ -n "${VFSDIRID}" ] && pvesh ls /cluster/mapping/dir | grep -qw "${VFSDIRID}" || VFSDIRID=""
|
[ -n "${VFSDIRID}" ] && pvesh ls /cluster/mapping/dir | grep -qw "${VFSDIRID}" || VFSDIRID=""
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--tag)
|
--tag)
|
||||||
TAG="$(echo "$2" | sed 's/^[v|V]//g')"
|
TAG="$(echo "$2" | sed 's/^[v|V]//g')"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--img)
|
--img)
|
||||||
IMG="$2"
|
IMG="$2"
|
||||||
[ -f "${IMG}" ] && IMG="$(realpath "${IMG}")" || IMG=""
|
[ -f "${IMG}" ] && IMG="$(realpath "${IMG}")" || IMG=""
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -182,20 +182,20 @@ if [ "${STATUS:-0}" -ne 0 ] || [ -z "${BLDISK}" ]; then
|
|||||||
fi
|
fi
|
||||||
[ -n "${IMG}" ] || rm -f "${IMG_PATH}"
|
[ -n "${IMG}" ] || rm -f "${IMG_PATH}"
|
||||||
case "${BLTYPE}" in
|
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 "
|
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 "
|
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}"
|
qm set ${VMID} --sata$((SATAIDX++)) "${BLDISK}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Setting bootloader disk failed"
|
echo "Setting bootloader disk failed"
|
||||||
qm destroy ${VMID} --purge
|
qm destroy ${VMID} --purge
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
X86_VENDOR=$(awk -F: '/vendor_id/ {gsub(/^[ \t]+/, "", $2); print $2; exit}' /proc/cpuinfo)
|
X86_VENDOR=$(awk -F: '/vendor_id/ {gsub(/^[ \t]+/, "", $2); print $2; exit}' /proc/cpuinfo)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user