mirror of
https://github.com/RROrg/rr.git
synced 2025-09-19 02:07:07 +08:00
Compare commits
2 Commits
6a6551d537
...
a78380f280
Author | SHA1 | Date | |
---|---|---|---|
|
a78380f280 | ||
|
4264d08471 |
@ -28,7 +28,7 @@ BUS=$(getBus "${LOADER_DISK}")
|
||||
clear
|
||||
COLUMNS=$(ttysize 2>/dev/null | awk '{print $1}')
|
||||
COLUMNS=${COLUMNS:-80}
|
||||
WTITLE="$(printf "$(TEXT "Welcome to %s")" "$([ -z "${RR_RELEASE}" ] && echo "${RR_TITLE}" || echo "${RR_TITLE}(${RR_RELEASE})")")"
|
||||
WTITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEASE})}")"
|
||||
DATE="$(date)"
|
||||
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
||||
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
|
||||
|
@ -38,7 +38,6 @@ function loaderIsConfigured() {
|
||||
[ ! -f "${MOD_RDGZ_FILE}" ] && return 1
|
||||
[ -z "$(readConfigKey "zimage-hash" "${USER_CONFIG_FILE}")" ] && return 1
|
||||
[ -z "$(readConfigKey "ramdisk-hash" "${USER_CONFIG_FILE}")" ] && return 1
|
||||
|
||||
return 0 # OK
|
||||
}
|
||||
|
||||
@ -485,3 +484,18 @@ function copyDSMFiles() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Send a webhook notification
|
||||
# 1 - webhook url
|
||||
# 2 - message (optional)
|
||||
function sendWebhook() {
|
||||
local URL="${1}"
|
||||
local MSGT="Notification from ${RR_TITLE}${RR_RELEASE:+(${RR_RELEASE})}"
|
||||
local MSGC="${2:-"test at $(date +'%Y-%m-%d %H:%M:%S')"}"
|
||||
|
||||
[ -z "${URL}" ] && return 1
|
||||
|
||||
curl -skL -X POST -H "Content-Type: application/json" -d "{\"title\":\"${MSGT}\", \"text\":\"${MSGC}\"}" "${URL}" >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ checkBootLoader || die "$(TEXT "The loader is corrupted, please rewrite it!")"
|
||||
clear
|
||||
COLUMNS=$(ttysize 2>/dev/null | awk '{print $1}')
|
||||
COLUMNS=${COLUMNS:-80}
|
||||
TITLE="$(printf "$(TEXT "Welcome to %s")" "$([ -z "${RR_RELEASE}" ] && echo "${RR_TITLE}" || echo "${RR_TITLE}(${RR_RELEASE})")")"
|
||||
TITLE="$(printf "$(TEXT "Welcome to %s")" "${RR_TITLE}${RR_RELEASE:+(${RR_RELEASE})}")"
|
||||
DATE="$(date)"
|
||||
printf "\033[1;44m%*s\n" "${COLUMNS}" ""
|
||||
printf "\033[1;44m%*s\033[A\n" "${COLUMNS}" ""
|
||||
@ -262,6 +262,15 @@ if [ "${DSMLOGO}" = "true" ] && [ -c "/dev/fb0" ] && [ ! "LOCALBUILD" = "${LOADE
|
||||
python3 "${WORK_PATH}/include/functions.py" makeqr -f "${WORK_PATH}/include/qhxg.png" -l "7" -o "${TMP_PATH}/qrcode_qhxg.png"
|
||||
[ -f "${TMP_PATH}/qrcode_qhxg.png" ] && echo | fbv -acufi "${TMP_PATH}/qrcode_qhxg.png" >/dev/null 2>&1 || true
|
||||
fi
|
||||
WEBHOOKURL="$(readConfigKey "webhookurl" "${USER_CONFIG_FILE}")"
|
||||
if [ -n "${WEBHOOKURL}" ] && [ ! -f "${TMP_PATH}/WebhookSent" ]; then
|
||||
DMI="$(dmesg 2>/dev/null | grep -i "DMI:" | head -1 | sed 's/\[.*\] DMI: //i')"
|
||||
IP="$(getIP)"
|
||||
echo "${IP}" | grep -q "^169\.254\." && IP=""
|
||||
[ -n "${IP}" ] && URL="http://${IP}:${TTYD:-7681}" || URL="http://rr:${TTYD:-7681}"
|
||||
sendWebhook "${WEBHOOKURL}" "{\"RR\":\"${RR_TITLE}${RR_RELEASE:+(${RR_RELEASE})}\", \"DATE\":\"$(date +'%Y-%m-%d %H:%M:%S')\", \"DMI\":\"${DMI}\", \"URL\":\"${URL}\"}"
|
||||
touch "${TMP_PATH}/WebhookSent"
|
||||
fi
|
||||
|
||||
# Check memory
|
||||
RAM="$(awk '/MemTotal:/ {printf "%.0f", $2 / 1024}' /proc/meminfo 2>/dev/null)"
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -87,7 +87,7 @@ function backtitle() {
|
||||
if [ "LOCALBUILD" = "${LOADER_DISK}" ]; then
|
||||
BACKTITLE="LOCAL "
|
||||
fi
|
||||
BACKTITLE+="$([ -z "${RR_RELEASE}" ] && echo "${RR_TITLE}" || echo "${RR_TITLE}(${RR_RELEASE})")"
|
||||
BACKTITLE+="${RR_TITLE}${RR_RELEASE:+(${RR_RELEASE})}"
|
||||
if [ -n "${MODEL}" ]; then
|
||||
BACKTITLE+=" ${MODEL}(${PLATFORM})"
|
||||
else
|
||||
@ -978,6 +978,7 @@ function cmdlineMenu() {
|
||||
MSG+="$(TEXT " * \Z4i915.max_vfs=7\Zn\n Set the maximum number of virtual functions (VFs) that can be created for Intel graphics hardware.\n")"
|
||||
MSG+="$(TEXT " * \Z4i915.modeset=0\Zn\n Disable the kernel mode setting (KMS) feature of the i915 driver.\n")"
|
||||
MSG+="$(TEXT " * \Z4apparmor.mode=complain\Zn\n Set the AppArmor security module to complain mode.\n")"
|
||||
MSG+="$(TEXT " * \Z4acpi_enforce_resources=lax\Zn\n Resolve the issue of some devices (such as fan controllers) not recognizing or using properly.\n")"
|
||||
MSG+="$(TEXT " * \Z4pci=nommconf\Zn\n Disable the use of Memory-Mapped Configuration for PCI devices(use this parameter cautiously).\n")"
|
||||
MSG+="$(TEXT " * \Z4consoleblank=300\Zn\n Set the console to auto turnoff display 300 seconds after no activity (measured in seconds).\n")"
|
||||
MSG+="$(TEXT "Please enter the parameter key and value you need to add.\n")"
|
||||
@ -2204,6 +2205,48 @@ function keymapMenu() {
|
||||
loadkeys "/usr/share/keymaps/i386/${LAYOUT}/${KEYMAP}.map.gz"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Bootloader notifications (Webhook)
|
||||
function notificationsMenu() {
|
||||
MSG=""
|
||||
MSG+="$(TEXT "Please enter the webhook url and content text.\n")"
|
||||
MSG+="$(TEXT "The webhook url must be a valid URL (Reference https://webhook-test.com/).\n")"
|
||||
MSG+="$(TEXT "The notify text is not currently supported, please ignore.\n")"
|
||||
WEBHOOKURL="$(readConfigKey "webhookurl" "${USER_CONFIG_FILE}")"
|
||||
# NOTIFYTEXT="$(readConfigKey "notifytext" "${USER_CONFIG_FILE}")"
|
||||
while true; do
|
||||
DIALOG --title "$(TEXT "Settings")" \
|
||||
--extra-button --extra-label "$(TEXT "Test")" \
|
||||
--form "${MSG}" 10 110 2 "webhookurl" 1 1 "${WEBHOOKURL}" 1 12 93 0 "notifytext" 2 1 "${NOTIFYTEXT}" 2 12 93 0 \
|
||||
2>"${TMP_PATH}/resp"
|
||||
RET=$?
|
||||
case ${RET} in
|
||||
0)
|
||||
# ok-button
|
||||
WEBHOOKURL="$(sed -n '1p' "${TMP_PATH}/resp" 2>/dev/null)"
|
||||
# NOTIFYTEXT="$(sed -n '2p' "${TMP_PATH}/resp" 2>/dev/null)"
|
||||
writeConfigKey "webhookurl" "${WEBHOOKURL}" "${USER_CONFIG_FILE}"
|
||||
# writeConfigKey "notifytext" "${NOTIFYTEXT}" "${USER_CONFIG_FILE}"
|
||||
break
|
||||
;;
|
||||
3)
|
||||
# extra-button
|
||||
WEBHOOKURL="$(sed -n '1p' "${TMP_PATH}/resp" 2>/dev/null)"
|
||||
# NOTIFYTEXT="$(sed -n '2p' "${TMP_PATH}/resp" 2>/dev/null)"
|
||||
sendWebhook "${WEBHOOKURL}"
|
||||
;;
|
||||
1)
|
||||
# cancel-button
|
||||
break
|
||||
;;
|
||||
255)
|
||||
# ESC
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Permits user edit the user config
|
||||
function editUserConfig() {
|
||||
@ -3277,6 +3320,7 @@ function settingsMenu() {
|
||||
echo "t \"$(TEXT "Choose a timezone")\""
|
||||
echo "k \"$(TEXT "Choose a keymap")\""
|
||||
echo "o \"$(TEXT "Show QR logo:") \Z4${DSMLOGO}\Zn\""
|
||||
echo "n \"$(TEXT "Bootloader notifications (Webhook)")\""
|
||||
echo "p \"$(TEXT "Custom patch script # Developer")\""
|
||||
echo "u \"$(TEXT "Edit user config file manually")\""
|
||||
echo "g \"$(TEXT "Edit grub.cfg file manually")\""
|
||||
@ -3322,6 +3366,10 @@ function settingsMenu() {
|
||||
writeConfigKey "dsmlogo" "${DSMLOGO}" "${USER_CONFIG_FILE}"
|
||||
NEXT="o"
|
||||
;;
|
||||
n)
|
||||
notificationsMenu
|
||||
NEXT="e"
|
||||
;;
|
||||
p)
|
||||
MSG=""
|
||||
MSG+="$(TEXT "This option provides information about custom patch scripts for the ramdisk.\n")"
|
||||
|
Loading…
x
Reference in New Issue
Block a user