improve: handle both pulse and pulse-backend service names gracefully

- ProxmoxVE community script uses pulse-backend.service
- Our install script now detects and preserves existing service name
- Removed pulse-backend.service from pre-v4 detection (it's used by v4 too)
- Install script stops the correct service during upgrades
- New installs use 'pulse', existing use whatever they have

This ensures compatibility with all deployment methods without breaking changes.
This commit is contained in:
Pulse Monitor
2025-08-20 15:57:19 +00:00
parent 129907737e
commit d775916217
2 changed files with 27 additions and 8 deletions
+25 -3
View File
@@ -19,6 +19,17 @@ SERVICE_NAME="pulse"
GITHUB_REPO="rcourtman/Pulse"
REQUIRED_GO_VERSION="1.21"
# Detect existing service name (pulse or pulse-backend)
detect_service_name() {
if systemctl list-unit-files --no-legend | grep -q "^pulse-backend.service"; then
echo "pulse-backend"
elif systemctl list-unit-files --no-legend | grep -q "^pulse.service"; then
echo "pulse"
else
echo "pulse" # Default for new installations
fi
}
# Functions
print_header() {
echo -e "${BLUE}=================================================${NC}"
@@ -219,10 +230,13 @@ download_pulse() {
exit 1
fi
# Detect existing service name
EXISTING_SERVICE=$(detect_service_name)
# Stop service if running (for updates)
if systemctl is-active --quiet $SERVICE_NAME; then
print_info "Stopping existing Pulse service..."
systemctl stop $SERVICE_NAME
if systemctl is-active --quiet $EXISTING_SERVICE; then
print_info "Stopping existing Pulse service ($EXISTING_SERVICE)..."
systemctl stop $EXISTING_SERVICE
fi
# Extract to temporary directory first
@@ -277,6 +291,14 @@ setup_directories() {
install_systemd_service() {
print_info "Installing systemd service..."
# Use existing service name if found, otherwise use default
EXISTING_SERVICE=$(detect_service_name)
if [[ "$EXISTING_SERVICE" == "pulse-backend" ]] && [[ -f "/etc/systemd/system/pulse-backend.service" ]]; then
# Keep using pulse-backend for compatibility (ProxmoxVE)
SERVICE_NAME="pulse-backend"
print_info "Using existing service name: pulse-backend"
fi
cat > /etc/systemd/system/$SERVICE_NAME.service << EOF
[Unit]
Description=Pulse Monitoring Server
+2 -5
View File
@@ -689,11 +689,8 @@ func isPreV4Installation() bool {
return true
}
// Check for old service names
cmd := exec.Command("systemctl", "list-unit-files", "--no-legend", "pulse-backend.service")
if output, err := cmd.Output(); err == nil && len(output) > 0 {
return true
}
// Note: pulse-backend.service is used by both v4 and pre-v4, so we can't use it as an indicator
// Only check for Node.js artifacts which are exclusive to pre-v4
// Check for Node.js artifacts
nodeArtifacts := []string{