From e8b864b51572c8dbffa70709c17cbf9adb949289 Mon Sep 17 00:00:00 2001 From: Daniel Hiller Date: Sun, 16 Mar 2025 05:22:42 +0100 Subject: [PATCH] agent installer script: option to skip auto update question --- supplemental/scripts/install-agent.sh | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/supplemental/scripts/install-agent.sh b/supplemental/scripts/install-agent.sh index 92e7da7..7b0c737 100755 --- a/supplemental/scripts/install-agent.sh +++ b/supplemental/scripts/install-agent.sh @@ -27,6 +27,7 @@ GITHUB_URL="https://github.com" GITHUB_API_URL="https://api.github.com" # not blocked in China currently GITHUB_PROXY_URL="" KEY="" +AUTO_UPDATE_FLAG="false" # default to not auto-enable updates # Check for help flag case "$1" in @@ -39,6 +40,7 @@ case "$1" in printf " -u : Uninstall Beszel Agent\n" printf " --china-mirrors [URL] : Use GitHub proxy (gh.beszel.dev) to resolve network timeout issues in mainland China\n" printf " optional: specify a custom proxy URL, e.g., \"https://ghfast.top\"\n" + printf " --auto-update : Enable automatic daily updates for the Beszel Agent\n" printf " -h, --help : Display this help message\n" exit 0 ;; @@ -95,6 +97,9 @@ while [ $# -gt 0 ]; do GITHUB_URL="$GITHUB_PROXY_URL" fi ;; + --auto-update) + AUTO_UPDATE_FLAG="true" + ;; *) echo "Invalid option: $1" >&2 exit 1 @@ -348,8 +353,12 @@ EOF fi # Auto-update service for Alpine - printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " - read AUTO_UPDATE + if [ "$AUTO_UPDATE_FLAG" = "true" ]; then + AUTO_UPDATE="y" + else + printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " + read AUTO_UPDATE + fi case "$AUTO_UPDATE" in [Yy]*) echo "Setting up daily automatic updates for beszel-agent..." @@ -432,8 +441,12 @@ EOF service beszel-agent restart # Auto-update service for OpenWRT using a crontab job - printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " - read AUTO_UPDATE + if [ "$AUTO_UPDATE_FLAG" = "true" ]; then + AUTO_UPDATE="y" + else + printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " + read AUTO_UPDATE + fi case "$AUTO_UPDATE" in [Yy]*) echo "Setting up daily automatic updates for beszel-agent..." @@ -499,8 +512,12 @@ EOF systemctl start beszel-agent.service # Prompt for auto-update setup - printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " - read AUTO_UPDATE + if [ "$AUTO_UPDATE_FLAG" = "true" ]; then + AUTO_UPDATE="y" + else + printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " + read AUTO_UPDATE + fi case "$AUTO_UPDATE" in [Yy]*) echo "Setting up daily automatic updates for beszel-agent..."