mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-25 06:56:17 +01:00
Compare commits
2 Commits
1153-syste
...
45816e7de6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45816e7de6 | ||
|
|
2a6946906e |
@@ -40,11 +40,12 @@ func (o *openRCRestarter) Restart() error {
|
|||||||
type openWRTRestarter struct{ cmd string }
|
type openWRTRestarter struct{ cmd string }
|
||||||
|
|
||||||
func (w *openWRTRestarter) Restart() error {
|
func (w *openWRTRestarter) Restart() error {
|
||||||
if err := exec.Command(w.cmd, "running", "beszel-agent").Run(); err != nil {
|
// https://openwrt.org/docs/guide-user/base-system/managing_services?s[]=service
|
||||||
|
if err := exec.Command("/etc/init.d/beszel-agent", "running").Run(); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ghupdate.ColorPrint(ghupdate.ColorYellow, "Restarting beszel-agent via procd…")
|
ghupdate.ColorPrint(ghupdate.ColorYellow, "Restarting beszel-agent via procd…")
|
||||||
return exec.Command(w.cmd, "restart", "beszel-agent").Run()
|
return exec.Command("/etc/init.d/beszel-agent", "restart").Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
type freeBSDRestarter struct{ cmd string }
|
type freeBSDRestarter struct{ cmd string }
|
||||||
@@ -64,11 +65,13 @@ func detectRestarter() restarter {
|
|||||||
if path, err := exec.LookPath("rc-service"); err == nil {
|
if path, err := exec.LookPath("rc-service"); err == nil {
|
||||||
return &openRCRestarter{cmd: path}
|
return &openRCRestarter{cmd: path}
|
||||||
}
|
}
|
||||||
|
if path, err := exec.LookPath("procd"); err == nil {
|
||||||
|
return &openWRTRestarter{cmd: path}
|
||||||
|
}
|
||||||
if path, err := exec.LookPath("service"); err == nil {
|
if path, err := exec.LookPath("service"); err == nil {
|
||||||
if runtime.GOOS == "freebsd" {
|
if runtime.GOOS == "freebsd" {
|
||||||
return &freeBSDRestarter{cmd: path}
|
return &freeBSDRestarter{cmd: path}
|
||||||
}
|
}
|
||||||
return &openWRTRestarter{cmd: path}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ case "$1" in
|
|||||||
printf " -u : Uninstall Beszel Agent\n"
|
printf " -u : Uninstall Beszel Agent\n"
|
||||||
printf " --auto-update [VALUE] : Control automatic daily updates\n"
|
printf " --auto-update [VALUE] : Control automatic daily updates\n"
|
||||||
printf " VALUE can be true (enable) or false (disable). If not specified, will prompt.\n"
|
printf " VALUE can be true (enable) or false (disable). If not specified, will prompt.\n"
|
||||||
printf " --china-mirrors [URL] : Use GitHub proxy to resolve network timeout issues in mainland China\n"
|
printf " --mirror [URL] : Use GitHub proxy to resolve network timeout issues in mainland China\n"
|
||||||
printf " URL: optional custom proxy URL (default: https://gh.beszel.dev)\n"
|
printf " URL: optional custom proxy URL (default: https://gh.beszel.dev)\n"
|
||||||
printf " -h, --help : Display this help message\n"
|
printf " -h, --help : Display this help message\n"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -293,7 +293,7 @@ while [ $# -gt 0 ]; do
|
|||||||
-u)
|
-u)
|
||||||
UNINSTALL=true
|
UNINSTALL=true
|
||||||
;;
|
;;
|
||||||
--china-mirrors*)
|
--mirror* | --china-mirrors*)
|
||||||
# Check if there's a value after the = sign
|
# Check if there's a value after the = sign
|
||||||
if echo "$1" | grep -q "="; then
|
if echo "$1" | grep -q "="; then
|
||||||
# Extract the value after =
|
# Extract the value after =
|
||||||
@@ -301,19 +301,23 @@ while [ $# -gt 0 ]; do
|
|||||||
if [ -n "$CUSTOM_PROXY" ]; then
|
if [ -n "$CUSTOM_PROXY" ]; then
|
||||||
GITHUB_PROXY_URL="$CUSTOM_PROXY"
|
GITHUB_PROXY_URL="$CUSTOM_PROXY"
|
||||||
GITHUB_URL="$(ensure_trailing_slash "$CUSTOM_PROXY")https://github.com"
|
GITHUB_URL="$(ensure_trailing_slash "$CUSTOM_PROXY")https://github.com"
|
||||||
|
GITHUB_API_URL="$(ensure_trailing_slash "$CUSTOM_PROXY")https://api.github.com"
|
||||||
else
|
else
|
||||||
GITHUB_PROXY_URL="https://gh.beszel.dev"
|
GITHUB_PROXY_URL="https://gh.beszel.dev"
|
||||||
GITHUB_URL="$GITHUB_PROXY_URL"
|
GITHUB_URL="$GITHUB_PROXY_URL"
|
||||||
|
GITHUB_API_URL="$GITHUB_PROXY_URL"
|
||||||
fi
|
fi
|
||||||
elif [ "$2" != "" ] && ! echo "$2" | grep -q '^-'; then
|
elif [ "$2" != "" ] && ! echo "$2" | grep -q '^-'; then
|
||||||
# use custom proxy URL provided as next argument
|
# use custom proxy URL provided as next argument
|
||||||
GITHUB_PROXY_URL="$2"
|
GITHUB_PROXY_URL="$2"
|
||||||
GITHUB_URL="$(ensure_trailing_slash "$2")https://github.com"
|
GITHUB_URL="$(ensure_trailing_slash "$2")https://github.com"
|
||||||
|
GITHUB_API_URL="$(ensure_trailing_slash "$2")https://api.github.com"
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
# No value specified, use default
|
# No value specified, use default
|
||||||
GITHUB_PROXY_URL="https://gh.beszel.dev"
|
GITHUB_PROXY_URL="https://gh.beszel.dev"
|
||||||
GITHUB_URL="$GITHUB_PROXY_URL"
|
GITHUB_URL="$GITHUB_PROXY_URL"
|
||||||
|
GITHUB_API_URL="$GITHUB_PROXY_URL"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--auto-update*)
|
--auto-update*)
|
||||||
@@ -452,18 +456,6 @@ if [ "$UNINSTALL" = true ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Confirm the use of GitHub mirrors for downloads
|
|
||||||
if [ -n "$GITHUB_PROXY_URL" ]; then
|
|
||||||
printf "\nConfirm use of GitHub mirror (%s) for downloading beszel-agent?\nThis helps to install properly in mainland China. (Y/n): " "$GITHUB_PROXY_URL"
|
|
||||||
read USE_MIRROR
|
|
||||||
USE_MIRROR=${USE_MIRROR:-Y}
|
|
||||||
if [ "$USE_MIRROR" = "Y" ] || [ "$USE_MIRROR" = "y" ]; then
|
|
||||||
echo "Using GitHub Mirror ($GITHUB_PROXY_URL) for downloads..."
|
|
||||||
else
|
|
||||||
GITHUB_URL="https://github.com"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if a package is installed
|
# Check if a package is installed
|
||||||
package_installed() {
|
package_installed() {
|
||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
@@ -608,7 +600,12 @@ FILE_NAME="beszel-agent_${OS}_${ARCH}.tar.gz"
|
|||||||
|
|
||||||
# Determine version to install
|
# Determine version to install
|
||||||
if [ "$VERSION" = "latest" ]; then
|
if [ "$VERSION" = "latest" ]; then
|
||||||
INSTALL_VERSION=$(curl -s "$GITHUB_API_URL""/repos/henrygd/beszel/releases/latest" | grep -o '"tag_name": "v[^"]*"' | cut -d'"' -f4 | tr -d 'v')
|
API_RELEASE_URL="$GITHUB_API_URL/repos/henrygd/beszel/releases/latest"
|
||||||
|
# gh.beszel.dev mirror needs api=true for api.github.com
|
||||||
|
if echo "$GITHUB_API_URL" | grep -qE "^https://gh\.beszel\.dev/?$"; then
|
||||||
|
API_RELEASE_URL="$API_RELEASE_URL?api=true"
|
||||||
|
fi
|
||||||
|
INSTALL_VERSION=$(curl -s "$API_RELEASE_URL" | grep -o '"tag_name"\s*:\s*"v[^"]*"' | cut -d'"' -f4 | tr -d 'v')
|
||||||
if [ -z "$INSTALL_VERSION" ]; then
|
if [ -z "$INSTALL_VERSION" ]; then
|
||||||
echo "Failed to get latest version"
|
echo "Failed to get latest version"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user