Compare commits

...

6 Commits

Author SHA1 Message Date
Ing
8feb56926e fix w 2024-06-24 01:04:08 +08:00
Ing
cdaf827489 fix something 2024-06-24 00:43:10 +08:00
Ing
f28428b140 disable "Fast reboot" of kexec 2024-06-24 00:17:28 +08:00
Ing
271509eb46 fix small screen dialog --form error 2024-06-23 20:39:52 +08:00
Ing
cf1d15adb9 fix makeqr error 2024-06-22 20:10:04 +08:00
Ing
3857652388 fix addNewDSMUser 2024-06-22 20:09:43 +08:00
4 changed files with 74 additions and 63 deletions

View File

@ -247,12 +247,12 @@ else
done
BOOTWAIT="$(readConfigKey "bootwait" "${USER_CONFIG_FILE}")"
[ -z "${BOOTWAIT}" ] && BOOTWAIT=10
w -h 2>/dev/null | grep -v tty1 | awk '{print $1" "$2" "$3}' >WB
busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WB
MSG=""
while test ${BOOTWAIT} -ge 0; do
MSG="$(printf "\033[1;33m$(TEXT "%2ds (Changing access(ssh/web) status will interrupt boot)")\033[0m" "${BOOTWAIT}")"
echo -en "\r${MSG}"
w -h 2>/dev/null | grep -v tty1 | awk '{print $1" "$2" "$3}' >WC
busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WC
if ! diff WB WC >/dev/null 2>&1; then
echo -en "\r\033[1;33m$(TEXT "access(ssh/web) status has changed and booting is interrupted.")\033[0m\n"
rm -f WB WC
@ -286,7 +286,7 @@ else
fi
kexec ${KEXECARGS} -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog
echo -e "\033[1;37m$(TEXT "Booting ...")\033[0m"
for T in $(w -h 2>/dev/null | awk '{print $2}'); do
for T in $(busybox w 2>/dev/null | grep -v 'TTY' | awk '{print $2}'); do
[ -w "/dev/${T}" ] && echo -e "\n\033[1;43m$(TEXT "[This interface will not be operational. Please wait a few minutes.\nFind DSM via http://find.synology.com/ or Synology Assistant and connect.]")\033[0m\n" >"/dev/${T}" 2>/dev/null || true
done
@ -294,6 +294,6 @@ else
rm -rf "${PART1_PATH}/logs" >/dev/null 2>&1 || true
KERNELWAY="$(readConfigKey "kernelway" "${USER_CONFIG_FILE}")"
[ "${KERNELWAY}" = "kexec" ] && kexec -i -a -e || poweroff
[ "${KERNELWAY}" = "kexec" ] && kexec -a -e || poweroff
exit 0
fi

View File

View File

@ -42,55 +42,59 @@ def makeqr(data, file, location, output):
"""
Generate a QRCode.
"""
import fcntl, struct
import qrcode
from PIL import Image
try:
import fcntl, struct
import qrcode
from PIL import Image
FBIOGET_VSCREENINFO = 0x4600
FBIOPUT_VSCREENINFO = 0x4601
FBIOGET_FSCREENINFO = 0x4602
FBDEV = "/dev/fb0"
if data is not None:
qr = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4,)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="purple", back_color="white")
img = img.convert("RGBA")
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if pixels[i, j] == (255, 255, 255, 255):
pixels[i, j] = (255, 255, 255, 0)
FBIOGET_VSCREENINFO = 0x4600
FBIOPUT_VSCREENINFO = 0x4601
FBIOGET_FSCREENINFO = 0x4602
FBDEV = "/dev/fb0"
if data is not None:
qr = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4,)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="purple", back_color="white")
img = img.convert("RGBA")
pixels = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
if pixels[i, j] == (255, 255, 255, 255):
pixels[i, j] = (255, 255, 255, 0)
if os.path.exists(os.path.join(WORK_PATH, "logo.png")):
icon = Image.open(os.path.join(WORK_PATH, "logo.png"))
icon = icon.convert("RGBA")
img.paste(icon.resize((int(img.size[0] / 5), int(img.size[1] / 5))), (int((img.size[0] - int(img.size[0] / 5)) / 2), int((img.size[1] - int(img.size[1] / 5)) / 2),),)
if os.path.exists(os.path.join(WORK_PATH, "logo.png")):
icon = Image.open(os.path.join(WORK_PATH, "logo.png"))
icon = icon.convert("RGBA")
img.paste(icon.resize((int(img.size[0] / 5), int(img.size[1] / 5))), (int((img.size[0] - int(img.size[0] / 5)) / 2), int((img.size[1] - int(img.size[1] / 5)) / 2),),)
if file is not None:
img = Image.open(file)
# img = img.convert("RGBA")
# pixels = img.load()
# for i in range(img.size[0]):
# for j in range(img.size[1]):
# if pixels[i, j] == (255, 255, 255, 255):
# pixels[i, j] = (255, 255, 255, 0)
if file is not None:
img = Image.open(file)
# img = img.convert("RGBA")
# pixels = img.load()
# for i in range(img.size[0]):
# for j in range(img.size[1]):
# if pixels[i, j] == (255, 255, 255, 255):
# pixels[i, j] = (255, 255, 255, 0)
(xres, yres) = (1920, 1080)
with open(FBDEV, "rb") as fb:
vi = fcntl.ioctl(fb, FBIOGET_VSCREENINFO, bytes(160))
res = struct.unpack("I" * 40, vi)
if res[0] != 0 and res[1] != 0:
(xres, yres) = (res[0], res[1])
xqr, yqr = (int(xres / 8), int(xres / 8))
img = img.resize((xqr, yqr))
(xres, yres) = (1920, 1080)
with open(FBDEV, "rb") as fb:
vi = fcntl.ioctl(fb, FBIOGET_VSCREENINFO, bytes(160))
res = struct.unpack("I" * 40, vi)
if res[0] != 0 and res[1] != 0:
(xres, yres) = (res[0], res[1])
xqr, yqr = (int(xres / 8), int(xres / 8))
img = img.resize((xqr, yqr))
alpha = Image.new("RGBA", (xres, yres), (0, 0, 0, 0))
if int(location) not in range(0, 8):
location = 0
loc = (img.size[0] * int(location), alpha.size[1] - img.size[1])
alpha.paste(img, loc)
alpha.save(output)
alpha = Image.new("RGBA", (xres, yres), (0, 0, 0, 0))
if int(location) not in range(0, 8):
location = 0
loc = (img.size[0] * int(location), alpha.size[1] - img.size[1])
alpha.paste(img, loc)
alpha.save(output)
except:
pass
@cli.command()
@ -101,12 +105,12 @@ def getmodels(platforms=None):
"""
import json, requests, urllib3
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
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount('http://', adapter)
session.mount('https://', adapter)
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if platforms is not None and platforms != "":
@ -142,8 +146,9 @@ def getmodels(platforms=None):
try:
import re
from bs4 import BeautifulSoup
#url="https://kb.synology.com/en-us/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
url="https://kb.synology.cn/zh-cn/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
# url="https://kb.synology.com/en-us/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
url = "https://kb.synology.cn/zh-cn/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
bs = BeautifulSoup(req.text, "html.parser")

View File

@ -863,7 +863,9 @@ function cmdlineMenu() {
MSG+="$(TEXT " * \Z4consoleblank=300\Zn\n Set the console to auto turnoff display 300 seconds after no activity (measured in seconds).\n")"
MSG+="$(TEXT "\nEnter the parameter name and value you need to add.\n")"
LINENUM=$(($(echo -e "${MSG}" | wc -l) + 10))
RET=0
while true; do
[ ${RET} -eq 255 ] && MSG="$(TEXT "Commonly used cmdlines:\n")"
DIALOG --title "$(TEXT "Cmdline")" \
--form "${MSG}" ${LINENUM:-16} 100 2 "Name:" 1 1 "" 1 10 85 0 "Value:" 2 1 "" 2 10 85 0 \
2>"${TMP_PATH}/resp"
@ -875,7 +877,7 @@ function cmdlineMenu() {
if [ -z "${NAME//\"/}" ]; then
DIALOG --title "$(TEXT "Cmdline")" \
--yesno "$(TEXT "Invalid parameter name, retry?")" 0 0
[ $? -eq 0 ] && break
[ $? -eq 0 ] && continue || break
fi
writeConfigKey "cmdline.\"${NAME//\"/}\"" "${VALUE}" "${USER_CONFIG_FILE}"
break
@ -884,7 +886,7 @@ function cmdlineMenu() {
break
;;
255) # ESC
break
# break
;;
esac
done
@ -935,7 +937,7 @@ function cmdlineMenu() {
if [ -z "${sn}" -o -z "${mac1}" ]; then
DIALOG --title "$(TEXT "Cmdline")" \
--yesno "$(TEXT "Invalid SN/MAC, retry?")" 0 0
[ $? -eq 0 ] && break
[ $? -eq 0 ] && continue || break
fi
SN="${sn}"
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
@ -997,7 +999,9 @@ function synoinfoMenu() {
MSG+="$(TEXT " * \Z4max_sys_raid_disks=12\Zn\n Maximum number of system partition(md0) raid disks.\n")"
MSG+="$(TEXT "\nEnter the parameter name and value you need to add.\n")"
LINENUM=$(($(echo -e "${MSG}" | wc -l) + 10))
RET=0
while true; do
[ ${RET} -eq 255 ] && MSG="$(TEXT "Commonly used synoinfo:\n")"
DIALOG --title "$(TEXT "Synoinfo")" \
--form "${MSG}" ${LINENUM:-16} 100 2 "Name:" 1 1 "" 1 10 85 0 "Value:" 2 1 "" 2 10 85 0 \
2>"${TMP_PATH}/resp"
@ -1009,7 +1013,7 @@ function synoinfoMenu() {
if [ -z "${NAME//\"/}" ]; then
DIALOG --title "$(TEXT "Synoinfo")" \
--yesno "$(TEXT "Invalid parameter name, retry?")" 0 0
[ $? -eq 0 ] && break
[ $? -eq 0 ] && continue || break
fi
writeConfigKey "synoinfo.\"${NAME//\"/}\"" "${VALUE}" "${USER_CONFIG_FILE}"
touch ${PART1_PATH}/.build
@ -1019,7 +1023,7 @@ function synoinfoMenu() {
break
;;
255) # ESC
break
# break
;;
esac
done
@ -1552,7 +1556,7 @@ function setWirelessAccount() {
if [ -z "${SSID}" -o -z "${PSK}" ]; then
DIALOG --title "$(TEXT "Advanced")" \
--yesno "$(TEXT "Invalid SSID/PSK, retry?")" 0 0
[ $? -eq 0 ] && break
[ $? -eq 0 ] && continue || break
fi
(
rm -f ${PART1_PATH}/wpa_supplicant.conf
@ -1924,7 +1928,7 @@ function addNewDSMUser() {
(
ONBOOTUP=""
ONBOOTUP="${ONBOOTUP}if synouser --enum local | grep -q ^${username}\$; then synouser --setpw ${username} ${password}; else synouser --add ${username} ${password} rr 0 user@rr.com 1; fi\n"
ONBOOTUP="${ONBOOTUP}synogroup --member administrators ${username}\n"
ONBOOTUP="${ONBOOTUP}synogroup --memberadd administrators ${username}\n"
ONBOOTUP="${ONBOOTUP}echo \"DELETE FROM task WHERE task_name LIKE ''RRONBOOTUPRR_ADDUSER'';\" | sqlite3 /usr/syno/etc/esynoscheduler/esynoscheduler.db\n"
mkdir -p "${TMP_PATH}/mdX"
@ -2860,8 +2864,10 @@ function updateRR() {
mkdir -p "${TMP_PATH}/update/$(dirname "${VALUE}")"
mv -f "${TMP_PATH}/update/$(basename "${KEY}")" "${TMP_PATH}/update/${VALUE}"
fi
SIZENEW=$((${SIZENEW} + $(du -sm "${TMP_PATH}/update/${VALUE}" 2>/dev/null | awk '{print $1}')))
SIZEOLD=$((${SIZEOLD} + $(du -sm "${VALUE}" 2>/dev/null | awk '{print $1}')))
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}))
done <<<$(readConfigMap "replace" "${TMP_PATH}/update/update-list.yml")
SIZESPL=$(df -m ${PART3_PATH} 2>/dev/null | awk 'NR==2 {print $4}')