chore(install-agent): formatting + rm unused variable

This commit is contained in:
Henry Dollman
2025-01-18 18:09:02 -05:00
parent 4789f48ad0
commit ee6a456b66

View File

@@ -1,6 +1,5 @@
#!/bin/sh #!/bin/sh
# Move is_alpine function to the top of the file
is_alpine() { is_alpine() {
[ -f /etc/alpine-release ] [ -f /etc/alpine-release ]
} }
@@ -9,7 +8,6 @@ is_openwrt() {
cat /etc/os-release | grep -q "OpenWrt" cat /etc/os-release | grep -q "OpenWrt"
} }
version=0.0.1
# Define default values # Define default values
PORT=45876 PORT=45876
UNINSTALL=false UNINSTALL=false
@@ -133,12 +131,12 @@ if [ "$UNINSTALL" = true ]; then
systemctl daemon-reload systemctl daemon-reload
fi fi
echo "Removing the Beszel Agent directory..." echo "Removing the Beszel Agent directory..."
rm -rf /opt/beszel-agent rm -rf /opt/beszel-agent
echo "Removing the dedicated user for the agent service..." echo "Removing the dedicated user for the agent service..."
killall beszel-agent 2>/dev/null killall beszel-agent 2>/dev/null
if is_alpine || is_openwrt; then if is_alpine || is_openwrt; then
deluser beszel 2>/dev/null deluser beszel 2>/dev/null
else else
userdel beszel 2>/dev/null userdel beszel 2>/dev/null
@@ -174,10 +172,10 @@ if is_alpine; then
apk add tar curl coreutils shadow apk add tar curl coreutils shadow
fi fi
elif is_openwrt; then elif is_openwrt; then
if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then
opkg update opkg update
opkg install tar curl coreutils opkg install tar curl coreutils
fi fi
elif package_installed apt-get; then elif package_installed apt-get; then
if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then
apt-get update apt-get update
@@ -407,36 +405,36 @@ update() {
EOF EOF
# Enable the service # Enable the service
chmod +x /etc/init.d/beszel-agent chmod +x /etc/init.d/beszel-agent
service beszel-agent enable service beszel-agent enable
# Start the service # Start the service
service beszel-agent restart service beszel-agent restart
# Auto-update service for OpenWRT using a crontab job # Auto-update service for OpenWRT using a crontab job
printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): " printf "\nWould you like to enable automatic daily updates for beszel-agent? (y/n): "
read AUTO_UPDATE read AUTO_UPDATE
case "$AUTO_UPDATE" in case "$AUTO_UPDATE" in
[Yy]*) [Yy]*)
echo "Setting up daily automatic updates for beszel-agent..." echo "Setting up daily automatic updates for beszel-agent..."
cat >/etc/crontabs/beszel <<EOF cat >/etc/crontabs/beszel <<EOF
0 0 * * * /etc/init.d/beszel-agent update 0 0 * * * /etc/init.d/beszel-agent update
EOF EOF
/etc/init.d/cron restart /etc/init.d/cron restart
printf "\nAutomatic daily updates have been enabled.\n" printf "\nAutomatic daily updates have been enabled.\n"
;; ;;
esac esac
# Check service status # Check service status
if ! service beszel-agent running >/dev/null 2>&1; then if ! service beszel-agent running >/dev/null 2>&1; then
echo "Error: The Beszel Agent service is not running." echo "Error: The Beszel Agent service is not running."
service beszel-agent status service beszel-agent status
exit 1 exit 1
fi fi
else else
# Original systemd service installation code # Original systemd service installation code