mirror of
https://github.com/AuxXxilium/arc.git
synced 2024-11-24 00:39:53 +07:00
tree: remove usage of syno api
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
7da081d887
commit
cc429e4ea5
@ -97,18 +97,13 @@ function arcModel() {
|
||||
# Loop menu
|
||||
RESTRICT=1
|
||||
PS="$(readConfigEntriesArray "platforms" "${P_FILE}" | sort)"
|
||||
MJ="$(python ${ARC_PATH}/include/functions.py getmodelsoffline -p "${PS[*]}")"
|
||||
if [[ -z "${MJ}" || "${MJ}" == "[]" ]]; then
|
||||
dialog --backtitle "$(backtitlep)" --title "Model" --title "Model" \
|
||||
--msgbox "Failed to get models, please try again!" 3 50
|
||||
return 1
|
||||
fi
|
||||
echo -n "" >"${TMP_PATH}/modellist"
|
||||
echo "${MJ}" | jq -c '.[]' | while read -r item; do
|
||||
name=$(echo "${item}" | jq -r '.name')
|
||||
arch=$(echo "${item}" | jq -r '.arch')
|
||||
echo "${name} ${arch}" >>"${TMP_PATH}/modellist"
|
||||
done
|
||||
while read -r P; do
|
||||
PM="$(readConfigEntriesArray "${P}" "${D_FILE}" | sort)"
|
||||
while read -r M; do
|
||||
echo "${M} ${P}" >>"${TMP_PATH}/modellist"
|
||||
done < <(echo "${PM}")
|
||||
done < <(echo "${PS}")
|
||||
if [ "${ARCMODE}" == "config" ]; then
|
||||
while true; do
|
||||
echo -n "" >"${TMP_PATH}/menu"
|
||||
@ -282,17 +277,14 @@ function arcVersion() {
|
||||
PAT_HASH=""
|
||||
URLVER=""
|
||||
while true; do
|
||||
PJ="$(python ${ARC_PATH}/include/functions.py getpats -m "${MODEL}" -r "${PRODUCTVER}")"
|
||||
PVS="$(echo "${PJ}" | jq -r '.[].release')"
|
||||
[ -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 ".[] | select(.release == \"${VERSION}\") | .mLink")
|
||||
if curl --head -skL -m 5 "${CHECK_URL}" | head -n 1 | grep -q "404\|403"; then
|
||||
continue
|
||||
else
|
||||
echo "${VERSION}" >>"${TMP_PATH}/versions"
|
||||
fi
|
||||
PVS="$(readConfigEntriesArray "${PLATFORM}.\"${MODEL}\"" "${D_FILE}" | sort -r)"
|
||||
echo -n "" >"${TMP_PATH}/versions"
|
||||
while read -r V; do
|
||||
if [ "${V:0:3}" != "${PRODUCTVER}" ]; then
|
||||
continue
|
||||
else
|
||||
echo "${V}" >>"${TMP_PATH}/versions"
|
||||
fi
|
||||
done < <(echo "${PVS}")
|
||||
DSMPVS="$(cat ${TMP_PATH}/versions)"
|
||||
dialog --backtitle "$(backtitlep)" --colors --title "DSM Version" \
|
||||
@ -301,10 +293,9 @@ function arcVersion() {
|
||||
RET=$?
|
||||
[ ${RET} -ne 0 ] && return
|
||||
PV=$(cat ${TMP_PATH}/resp)
|
||||
PAT_URL=$(echo "${PJ}" | jq -r ".[] | select(.release == \"${PV}\") | .mLink")
|
||||
PAT_HASH=$(echo "${PJ}" | jq -r ".[] | select(.release == \"${PV}\") | .mCheckSum")
|
||||
URLVER="$(echo "${PV}" | cut -d'.' -f1,2)"
|
||||
[ "${PRODUCTVER}" != "${URLVER}" ] && PRODUCTVER="${URLVER}"
|
||||
PAT_URL="$(readConfigKey "${PLATFORM}.\"${MODEL}\".\"${PV}\".url" "${D_FILE}")"
|
||||
PAT_HASH="$(readConfigKey "${PLATFORM}.\"${MODEL}\".\"${PV}\".hash" "${D_FILE}")"
|
||||
[ "${PRODUCTVER}" != "${PV:0:3}" ] && PRODUCTVER="${PV:0:3}"
|
||||
writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}"
|
||||
[ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ] && VALID="true" && break
|
||||
done
|
||||
@ -763,6 +754,7 @@ function make() {
|
||||
sleep 2
|
||||
return 1
|
||||
fi
|
||||
STEP="boot"
|
||||
if [ -f "${ORI_ZIMAGE_FILE}" ] && [ -f "${ORI_RDGZ_FILE}" ] && [ -f "${MOD_ZIMAGE_FILE}" ] && [ -f "${MOD_RDGZ_FILE}" ]; then
|
||||
MODELID=$(echo ${MODEL} | sed 's/d$/D/; s/rp$/RP/; s/rp+/RP+/')
|
||||
writeConfigKey "modelid" "${MODELID}" "${USER_CONFIG_FILE}"
|
||||
@ -810,35 +802,42 @@ function arcFinish() {
|
||||
###############################################################################
|
||||
# Calls boot.sh to boot into DSM Reinstall Mode
|
||||
function juniorboot() {
|
||||
if [ "${BUILDDONE}" == "false" ] && [ "${ARCMODE}" != "automated" ]; then
|
||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
|
||||
if [[ "${BUILDDONE}" == "false" && "${ARCMODE}" != "automated" ]] || [ "${MODEL}" != "${MODELID}" ]; then
|
||||
dialog --backtitle "$(backtitle)" --title "Alert" \
|
||||
--yesno "Config changed, you need to rebuild the Loader?" 0 0
|
||||
if [ $? -eq 0 ]; then
|
||||
arcSummary
|
||||
fi
|
||||
else
|
||||
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
|
||||
--infobox "Booting DSM Reinstall Mode...\nPlease stay patient!" 4 30
|
||||
sleep 3
|
||||
rebootTo junior
|
||||
fi
|
||||
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
|
||||
--infobox "Booting DSM Reinstall Mode...\nPlease stay patient!" 4 30
|
||||
sleep 3
|
||||
rebootTo junior
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Calls boot.sh to boot into DSM kernel/ramdisk
|
||||
function boot() {
|
||||
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
|
||||
if [ "${BUILDDONE}" == "false" ] && [ "${ARCMODE}" != "automated" ]; then
|
||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
|
||||
if [[ "${BUILDDONE}" == "false" && "${ARCMODE}" != "automated" ]] || [ "${MODEL}" != "${MODELID}" ]; then
|
||||
dialog --backtitle "$(backtitle)" --title "Alert" \
|
||||
--yesno "Config changed, you need to rebuild the Loader?" 0 0
|
||||
if [ $? -eq 0 ]; then
|
||||
arcSummary
|
||||
fi
|
||||
else
|
||||
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
|
||||
--infobox "Booting DSM...\nPlease stay patient!" 4 25
|
||||
sleep 2
|
||||
clear
|
||||
exec boot.sh
|
||||
fi
|
||||
dialog --backtitle "$(backtitle)" --title "Arc Boot" \
|
||||
--infobox "Booting DSM...\nPlease stay patient!" 4 25
|
||||
sleep 2
|
||||
clear
|
||||
exec boot.sh
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -1,4 +1 @@
|
||||
###############################################################################
|
||||
|
||||
# Update Offline Configs
|
||||
updateOffline
|
@ -41,6 +41,7 @@ S_FILE="${MODEL_CONFIG_PATH}/serials.yml"
|
||||
S_FILE_ARC="${MODEL_CONFIG_PATH}/arc_serials.yml"
|
||||
S_FILE_ENC="${MODEL_CONFIG_PATH}/arc_serials.enc"
|
||||
P_FILE="${MODEL_CONFIG_PATH}/platforms.yml"
|
||||
D_FILE="${MODEL_CONFIG_PATH}/data.yml"
|
||||
|
||||
EXTRACTOR_PATH="${PART3_PATH}/extractor"
|
||||
EXTRACTOR_BIN="syno_extract_system_patch"
|
@ -284,77 +284,5 @@ def getpats4mv(model, version):
|
||||
pats = {k: pats[k] for k in sorted(pats.keys(), reverse=True)}
|
||||
print(json.dumps(pats, indent=4))
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option("-m", "--model", type=str, required=True, help="The model of Syno.")
|
||||
@click.option("-r", "--release", type=str, required=True, help="The release version of Syno.")
|
||||
def getpats(model, release):
|
||||
"""
|
||||
Get all mLink, mCheckSum, and full release version for the specified model and release.
|
||||
"""
|
||||
import json
|
||||
|
||||
try:
|
||||
with open(os.path.join('/mnt/p3/configs/offline.json')) as file:
|
||||
data = json.load(file)
|
||||
|
||||
links = []
|
||||
for I in data["channel"]["item"]:
|
||||
if not I["title"].startswith("DSM"):
|
||||
continue
|
||||
if release not in I["title"]:
|
||||
continue
|
||||
for J in I["model"]:
|
||||
name = J["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+")
|
||||
if name == model:
|
||||
full_release = I["title"].split(" ")[1]
|
||||
links.append({ "release": full_release, "mLink": J["mLink"], "mCheckSum": J.get("mCheckSum", "N/A")})
|
||||
|
||||
if links:
|
||||
print(json.dumps(links, indent=4))
|
||||
else:
|
||||
print(f"No data found for model {model} and release {release}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
@cli.command()
|
||||
@click.option("-p", "--platforms", type=str, help="The platforms of Syno.")
|
||||
def getmodelsoffline(platforms=None):
|
||||
"""
|
||||
Get Syno Models from offline data.
|
||||
"""
|
||||
import json
|
||||
|
||||
if platforms is not None and platforms != "":
|
||||
PS = platforms.lower().replace(",", " ").split()
|
||||
else:
|
||||
PS = []
|
||||
|
||||
models = []
|
||||
try:
|
||||
with open(os.path.join('/mnt/p3/configs/offline.json')) as file:
|
||||
data = json.load(file)
|
||||
|
||||
for I in data["channel"]["item"]:
|
||||
if not I["title"].startswith("DSM"):
|
||||
continue
|
||||
for J in I["model"]:
|
||||
arch = J["mUnique"].split("_")[1]
|
||||
name = J["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+")
|
||||
if len(PS) > 0 and arch.lower() not in PS:
|
||||
continue
|
||||
if any(name == B["name"] for B in models):
|
||||
continue
|
||||
models.append({"name": name, "arch": arch})
|
||||
|
||||
models = sorted(models, key=lambda k: (k["arch"], k["name"]))
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
models.sort(key=lambda x: (x["arch"], x["name"]))
|
||||
print(json.dumps(models, indent=4))
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
@ -152,17 +152,31 @@ function getmapSelection() {
|
||||
REMAP1="*"
|
||||
fi
|
||||
# Ask for Portmap
|
||||
dialog --backtitle "$(backtitle)" --title "Sata Portmap" \
|
||||
--menu "Choose a Portmap for Sata!?\n* Recommended Option" 8 60 0 \
|
||||
1 "DiskIdxMap: Active Ports ${REMAP1}" \
|
||||
2 "DiskIdxMap: Max Ports ${REMAP2}" \
|
||||
3 "SataRemap: Remove empty Ports ${REMAP3}" \
|
||||
4 "AhciRemap: Remove empty Ports (new) ${REMAP4}" \
|
||||
5 "Set my own Portmap in Config" \
|
||||
2>"${TMP_PATH}/resp"
|
||||
[ $? -ne 0 ] && return 1
|
||||
resp=$(cat "${TMP_PATH}/resp")
|
||||
[ -z "${resp}" ] && return 1
|
||||
if [ "${STEP}" == "storagemap" ]; then
|
||||
dialog --backtitle "$(backtitlep)" --title "Sata Portmap" \
|
||||
--menu "Choose a Portmap for Sata!?\n* Recommended Option" 8 60 0 \
|
||||
1 "DiskIdxMap: Active Ports ${REMAP1}" \
|
||||
2 "DiskIdxMap: Max Ports ${REMAP2}" \
|
||||
3 "SataRemap: Remove empty Ports ${REMAP3}" \
|
||||
4 "AhciRemap: Remove empty Ports (new) ${REMAP4}" \
|
||||
5 "Set my own Portmap in Config" \
|
||||
2>"${TMP_PATH}/resp"
|
||||
[ $? -ne 0 ] && return 1
|
||||
resp=$(cat "${TMP_PATH}/resp")
|
||||
[ -z "${resp}" ] && return 1
|
||||
else
|
||||
dialog --backtitle "$(backtitle)" --title "Sata Portmap" \
|
||||
--menu "Choose a Portmap for Sata!?\n* Recommended Option" 8 60 0 \
|
||||
1 "DiskIdxMap: Active Ports ${REMAP1}" \
|
||||
2 "DiskIdxMap: Max Ports ${REMAP2}" \
|
||||
3 "SataRemap: Remove empty Ports ${REMAP3}" \
|
||||
4 "AhciRemap: Remove empty Ports (new) ${REMAP4}" \
|
||||
5 "Set my own Portmap in Config" \
|
||||
2>"${TMP_PATH}/resp"
|
||||
[ $? -ne 0 ] && return 1
|
||||
resp=$(cat "${TMP_PATH}/resp")
|
||||
[ -z "${resp}" ] && return 1
|
||||
fi
|
||||
if [ ${resp} -eq 1 ]; then
|
||||
writeConfigKey "arc.remap" "acports" "${USER_CONFIG_FILE}"
|
||||
elif [ ${resp} -eq 2 ]; then
|
||||
|
@ -433,9 +433,9 @@ function updateLKMs() {
|
||||
function updateOffline() {
|
||||
local ARCOFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
|
||||
if [ "${ARCOFFLINE}" != "true" ]; then
|
||||
[ -f "${MODEL_CONFIG_PATH}/offline.json" ] && cp -f "${MODEL_CONFIG_PATH}/offline.json" "${MODEL_CONFIG_PATH}/offline.json.bak"
|
||||
curl -skL "https://autoupdate.synology.com/os/v2" -o "${MODEL_CONFIG_PATH}/offline.json"
|
||||
[ ! -f "${MODEL_CONFIG_PATH}/offline.json" ] && cp -f "${MODEL_CONFIG_PATH}/offline.json.bak" "${MODEL_CONFIG_PATH}/offline.json"
|
||||
[ -f "${MODEL_CONFIG_PATH}/data.yml" ] && cp -f "${MODEL_CONFIG_PATH}/data.yml" "${MODEL_CONFIG_PATH}/data.yml.bak"
|
||||
curl -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/refs/heads/main/data.yml" -o "${MODEL_CONFIG_PATH}/data.yml"
|
||||
[ ! -f "${MODEL_CONFIG_PATH}/data.yml" ] && cp -f "${MODEL_CONFIG_PATH}/data.yml.bak" "${MODEL_CONFIG_PATH}/data.yml"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
@ -244,8 +244,8 @@ function getOffline() {
|
||||
local DEST_PATH="${1}"
|
||||
|
||||
[ ! -d "${DEST_PATH}" ] && mkdir -p "${DEST_PATH}"
|
||||
rm -f "${DEST_PATH}/offline.json"
|
||||
if curl -skL "https://autoupdate.synology.com/os/v2" -o "${DEST_PATH}/offline.json"; then
|
||||
rm -f "${DEST_PATH}/data.yml"
|
||||
if curl -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/refs/heads/main/data.yml" -o "${DEST_PATH}/data.yml"; then
|
||||
echo "Getting Offline end"
|
||||
else
|
||||
echo "Failed to get Offline"
|
||||
|
Loading…
Reference in New Issue
Block a user