Compare commits

...

7 Commits

Author SHA1 Message Date
henrygd
7282044f80 improve memo deps for default area chart 2025-07-29 20:53:44 -04:00
henrygd
d77c37c0b0 winget upgrade: make sure service is stopped before updating package 2025-07-29 18:37:34 -04:00
Sven van Ginkel
e362cbbca5 Move copy button (#1010)
Thank you!
2025-07-28 19:20:37 -04:00
evrial
118544926b [Fix] OpenWrt agent install script (#1005)
* Update install-agent.sh

* Update install-agent.sh

* Update install-agent.sh
2025-07-28 14:56:31 -04:00
henrygd
d4bb0a0a30 fix: consolidate OpenWRT environment variables into single procd_set_param call 2025-07-27 18:51:26 -04:00
henrygd
fe5e35d1a9 agent install script: improve openwrt compatibility 2025-07-27 18:44:36 -04:00
henrygd
60a6ae2caa add winget token for goreleaser action 2025-07-25 20:13:31 -04:00
6 changed files with 82 additions and 41 deletions

View File

@@ -3,7 +3,7 @@ name: Make release and binaries
on:
push:
tags:
- 'v*'
- "v*"
permissions:
contents: write
@@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.22.1'
go-version: "^1.22.1"
- name: GoReleaser beszel
uses: goreleaser/goreleaser-action@v6
@@ -40,3 +40,4 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }}
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}

View File

@@ -188,6 +188,7 @@ winget:
publisher_support_url: "https://github.com/henrygd/beszel/issues"
short_description: "Agent for Beszel, a lightweight server monitoring platform."
skip_upload: auto
token: "{{ .Env.WINGET_TOKEN }}"
description: |
Beszel is a lightweight server monitoring platform that includes Docker
statistics, historical data, and alert functions. It has a friendly web

View File

@@ -87,5 +87,5 @@ export default function AreaChartDefault({
</ChartContainer>
</div>
)
}, [chartData.systemStats.length, yAxisWidth, maxToggled])
}, [chartData.systemStats.at(-1), yAxisWidth, maxToggled])
}

View File

@@ -174,17 +174,11 @@ export default function SystemsTable() {
invertSorting: false,
Icon: ServerIcon,
cell: (info) => (
<span className="flex gap-0.5 items-center text-base md:ps-1 md:pe-5">
<span className="flex gap-2 items-center md:ps-1 md:pe-5">
<IndicatorDot system={info.row.original} />
<Button
data-nolink
variant={"ghost"}
className="text-primary/90 h-7 px-1.5 gap-1.5"
onClick={() => copyToClipboard(info.getValue() as string)}
>
<span className="font-medium text-sm">
{info.getValue() as string}
<CopyIcon className="size-2.5" />
</Button>
</span>
</span>
),
header: sortableHeader,
@@ -721,6 +715,10 @@ const ActionsButton = memo(({ system }: { system: SystemRecord }) => {
</>
)}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => copyToClipboard(name)}>
<CopyIcon className="me-2.5 size-4" />
<Trans>Copy name</Trans>
</DropdownMenuItem>
<DropdownMenuItem onClick={() => copyToClipboard(host)}>
<CopyIcon className="me-2.5 size-4" />
<Trans>Copy host</Trans>

View File

@@ -5,7 +5,7 @@ is_alpine() {
}
is_openwrt() {
cat /etc/os-release | grep -q "OpenWrt"
grep -qi "OpenWrt" /etc/os-release
}
# If SELinux is enabled, set the context of the binary
@@ -227,8 +227,8 @@ if [ "$UNINSTALL" = true ]; then
rm -f /var/log/beszel-agent.log /var/log/beszel-agent.err
elif is_openwrt; then
echo "Stopping and disabling the agent service..."
service beszel-agent stop
service beszel-agent disable
/etc/init.d/beszel-agent stop
/etc/init.d/beszel-agent disable
echo "Removing the OpenWRT service files..."
rm -f /etc/init.d/beszel-agent
@@ -288,13 +288,13 @@ package_installed() {
}
# Check for package manager and install necessary packages if not installed
if is_alpine; then
if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then
if package_installed apk; then
if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then
apk update
apk add tar curl coreutils shadow
fi
elif is_openwrt; then
if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then
elif package_installed opkg; then
if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then
opkg update
opkg install tar curl coreutils
fi
@@ -335,11 +335,10 @@ else
fi
# Create a dedicated user for the service if it doesn't exist
echo "Creating a dedicated user for the Beszel Agent service..."
if is_alpine; then
if ! id -u beszel >/dev/null 2>&1; then
echo "Creating a dedicated group for the Beszel Agent service..."
addgroup beszel
echo "Creating a dedicated user for the Beszel Agent service..."
adduser -S -D -H -s /sbin/nologin -G beszel beszel
fi
# Add the user to the docker group to allow access to the Docker socket if group docker exists
@@ -347,10 +346,37 @@ if is_alpine; then
echo "Adding beszel to docker group"
usermod -aG docker beszel
fi
elif is_openwrt; then
# Create beszel group first if it doesn't exist (check /etc/group directly)
if ! grep -q "^beszel:" /etc/group >/dev/null 2>&1; then
echo "beszel:x:999:" >> /etc/group
fi
# Create beszel user if it doesn't exist (double-check to prevent duplicates)
if ! id -u beszel >/dev/null 2>&1 && ! grep -q "^beszel:" /etc/passwd >/dev/null 2>&1; then
echo "beszel:x:999:999::/nonexistent:/bin/false" >> /etc/passwd
fi
# Add the user to the docker group if docker group exists and user is not already in it
if grep -q "^docker:" /etc/group >/dev/null 2>&1; then
echo "Adding beszel to docker group"
# Check if beszel is already in docker group
if ! grep "^docker:" /etc/group | grep -q "beszel"; then
# Add beszel to docker group by modifying /etc/group
# Handle both cases: group with existing members and group without members
if grep "^docker:" /etc/group | grep -q ":.*:.*$"; then
# Group has existing members, append with comma
sed -i 's/^docker:\([^:]*:[^:]*:\)\(.*\)$/docker:\1\2,beszel/' /etc/group
else
# Group has no members, just append
sed -i 's/^docker:\([^:]*:[^:]*:\)$/docker:\1beszel/' /etc/group
fi
fi
fi
else
if ! id -u beszel >/dev/null 2>&1; then
echo "Creating a dedicated user for the Beszel Agent service..."
useradd --system --home-dir /nonexistent --shell /bin/false beszel
fi
# Add the user to the docker group to allow access to the Docker socket if group docker exists
@@ -546,10 +572,7 @@ start_service() {
procd_set_param command /opt/beszel-agent/beszel-agent
procd_set_param user beszel
procd_set_param pidfile /var/run/beszel-agent.pid
procd_set_param env PORT="$PORT"
procd_set_param env KEY="$KEY"
procd_set_param env TOKEN="$TOKEN"
procd_set_param env HUB_URL="$HUB_URL"
procd_set_param env PORT="$PORT" KEY="$KEY" TOKEN="$TOKEN" HUB_URL="$HUB_URL"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
@@ -573,10 +596,10 @@ EOF
# Enable the service
chmod +x /etc/init.d/beszel-agent
service beszel-agent enable
/etc/init.d/beszel-agent enable
# Start the service
service beszel-agent restart
/etc/init.d/beszel-agent restart
# Auto-update service for OpenWRT using a crontab job
if [ "$AUTO_UPDATE_FLAG" = "true" ]; then
@@ -604,9 +627,9 @@ EOF
esac
# Check service status
if ! service beszel-agent running >/dev/null 2>&1; then
if ! /etc/init.d/beszel-agent running >/dev/null 2>&1; then
echo "Error: The Beszel Agent service is not running."
service beszel-agent status
/etc/init.d/beszel-agent status
exit 1
fi

View File

@@ -217,13 +217,6 @@ function Update-ServicePath {
throw "NSSM is not available in PATH and no valid NSSMPath was provided"
}
# Stop the service
Write-Host "Stopping beszel-agent service..."
& $nssmCommand stop beszel-agent
if ($LASTEXITCODE -ne 0) {
Write-Host "Warning: Failed to stop service, continuing anyway..." -ForegroundColor Yellow
}
# Update the application path
& $nssmCommand set beszel-agent Application $NewAgentPath
if ($LASTEXITCODE -ne 0) {
@@ -233,7 +226,25 @@ function Update-ServicePath {
Write-Host "Service path updated to: $NewAgentPath"
# Start the service
Start-BeszelAgentService -NSSMPath $nssmCommand
}
# Function to start and monitor the service
function Start-BeszelAgentService {
param (
[string]$NSSMPath = ""
)
Write-Host "Starting beszel-agent service..."
# Determine the NSSM executable to use
$nssmCommand = "nssm"
if ($NSSMPath -and (Test-Path $NSSMPath)) {
$nssmCommand = $NSSMPath
} elseif (-not (Test-CommandExists "nssm")) {
throw "NSSM is not available in PATH and no valid NSSMPath was provided"
}
& $nssmCommand start beszel-agent
$startResult = $LASTEXITCODE
@@ -255,7 +266,7 @@ function Update-ServicePath {
if ($serviceStatus -eq "SERVICE_RUNNING") {
$serviceStarted = $true
Write-Host "Success! The beszel-agent service is now running with the updated path." -ForegroundColor Green
Write-Host "Success! The beszel-agent service is now running." -ForegroundColor Green
}
elseif ($serviceStatus -like "*PENDING*") {
Write-Host "Service is still starting (status: $serviceStatus)... waiting" -ForegroundColor Yellow
@@ -273,7 +284,7 @@ function Update-ServicePath {
}
} else {
# NSSM start command was successful
Write-Host "Success! The beszel-agent service is running with the updated path." -ForegroundColor Green
Write-Host "Success! The beszel-agent service is running properly." -ForegroundColor Green
}
}
@@ -287,7 +298,6 @@ $isAdmin = Test-Admin
try {
Write-Host "Beszel Agent Upgrade Script" -ForegroundColor Cyan
Write-Host "===========================" -ForegroundColor Cyan
Write-Host ""
# First: Check if service exists (doesn't require admin)
$existingService = Get-Service -Name "beszel-agent" -ErrorAction SilentlyContinue
@@ -312,6 +322,13 @@ try {
Write-Host "Retrieving current service configuration..."
$currentConfig = Get-ServiceConfiguration -NSSMPath $nssmPath
# Stop the service before upgrade
Write-Host "Stopping beszel-agent service..."
& $nssmPath stop beszel-agent
if ($LASTEXITCODE -ne 0) {
Write-Host "Warning: Failed to stop service, continuing anyway..." -ForegroundColor Yellow
}
# Upgrade the agent (doesn't require admin)
Write-Host "Upgrading beszel-agent..."
$newAgentPath = $null
@@ -340,7 +357,8 @@ try {
# Check if the path has changed
if ($currentConfig.CurrentPath -eq $newAgentPath) {
Write-Host "Agent path has not changed. Service update not needed." -ForegroundColor Green
Write-Host "Agent path has not changed. Restarting service..." -ForegroundColor Green
Start-BeszelAgentService -NSSMPath $nssmPath
Write-Host "Upgrade completed successfully!" -ForegroundColor Green
exit 0
}