beszel-agent-update.service: avoid non-zero exit status and add logging (#397)

This commit is contained in:
Henry Dollman
2025-01-14 20:31:50 -05:00
parent 73427306d1
commit 5d88599c9a

View File

@@ -267,7 +267,7 @@ rm -rf "$TEMP_DIR"
# Modify service installation part, add Alpine check before systemd service creation # Modify service installation part, add Alpine check before systemd service creation
if is_alpine; then if is_alpine; then
echo "Creating OpenRC service for Alpine Linux..." echo "Creating OpenRC service for Alpine Linux..."
cat > /etc/init.d/beszel-agent <<EOF cat >/etc/init.d/beszel-agent <<EOF
#!/sbin/openrc-run #!/sbin/openrc-run
name="beszel-agent" name="beszel-agent"
@@ -317,7 +317,7 @@ EOF
[Yy]*) [Yy]*)
echo "Setting up daily automatic updates for beszel-agent..." echo "Setting up daily automatic updates for beszel-agent..."
cat > /etc/init.d/beszel-agent-update <<EOF cat >/etc/init.d/beszel-agent-update <<EOF
#!/sbin/openrc-run #!/sbin/openrc-run
name="beszel-agent-update" name="beszel-agent-update"
@@ -393,7 +393,7 @@ Wants=beszel-agent.service
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/bin/sh -c '/opt/beszel-agent/beszel-agent update | grep -q "Successfully updated" && systemctl restart beszel-agent' ExecStart=/bin/sh -c '/opt/beszel-agent/beszel-agent update | grep -q "Successfully updated" && (echo "Update found, restarting beszel-agent" && systemctl restart beszel-agent) || echo "No updates found"'
EOF EOF
# Create systemd timer for the daily update # Create systemd timer for the daily update