feat: support custom display name (close #189)

This commit is contained in:
ttionya
2025-03-16 14:34:59 +08:00
parent 8eb664e44f
commit 8cdf803e34
4 changed files with 31 additions and 5 deletions
+8
View File
@@ -314,6 +314,14 @@ Here is timezone list at [wikipedia](https://en.wikipedia.org/wiki/List_of_tz_da
Default: `UTC`
#### DISPLAY_NAME
A custom name to identify your vaultwarden instance in notifications and logs.
This doesn't affect functionality, it only affects the display in the notification title and partial log output.
Default: `vaultwarden`
#### DATA_DIR
This folder stores the data of vaultwarden.
+8
View File
@@ -312,6 +312,14 @@ Rclone 全局参数,详见 [flags](https://rclone.org/flags/)。
默认值:`UTC`
#### DISPLAY_NAME
用于在通知和日志中标识 vaultwarden 实例的自定义名称。
这不会影响功能,仅影响通知标题和部分日志输出中的显示。
默认值:`vaultwarden`
#### DATA_DIR
指定存放 vaultwarden 数据的目录。
+4 -2
View File
@@ -12,6 +12,7 @@ fi
# mail test
if [[ "$1" == "mail" ]]; then
export_env_file
init_env_display
init_env_mail
MAIL_SMTP_ENABLE="TRUE"
@@ -21,7 +22,7 @@ if [[ "$1" == "mail" ]]; then
MAIL_TO="$2"
fi
send_mail "vaultwarden Backup Test" "Your SMTP configuration looks correct."
send_mail "${DISPLAY_NAME} Backup Test" "Your SMTP configuration looks correct."
exit 0
fi
@@ -29,11 +30,12 @@ fi
# ping test
if [[ "$1" == "ping" ]]; then
export_env_file
init_env_display
init_env_ping
PING_DEBUG="TRUE"
send_ping "$2" "vaultwarden Backup Test" "Your PING configuration looks correct."
send_ping "$2" "${DISPLAY_NAME} Backup Test" "Your PING configuration looks correct."
exit 0
fi
+11 -3
View File
@@ -163,9 +163,9 @@ function send_ping() {
# notification content
########################################
function send_notification() {
local SUBJECT_START="vaultwarden Backup Start"
local SUBJECT_SUCCESS="vaultwarden Backup Success"
local SUBJECT_FAILURE="vaultwarden Backup Failed"
local SUBJECT_START="${DISPLAY_NAME} Backup Start"
local SUBJECT_SUCCESS="${DISPLAY_NAME} Backup Success"
local SUBJECT_FAILURE="${DISPLAY_NAME} Backup Failed"
case "$1" in
start)
@@ -301,6 +301,7 @@ function init_env() {
init_env_dir
init_env_db
init_env_display
init_env_ping
init_env_mail
@@ -413,6 +414,7 @@ function init_env() {
color yellow "MAIL_WHEN_FAILURE: ${MAIL_WHEN_FAILURE}"
fi
color yellow "TIMEZONE: ${TIMEZONE}"
color yellow "DISPLAY_NAME: ${DISPLAY_NAME}"
color yellow "========================================"
}
@@ -512,6 +514,12 @@ function init_env_db() {
fi
}
function init_env_display() {
# DISPLAY_NAME
get_env DISPLAY_NAME
DISPLAY_NAME="${DISPLAY_NAME:-"vaultwarden"}"
}
function init_env_ping() {
# PING_URL
get_env PING_URL