Skip to content

Commit cdd4141

Browse files
author
Pulse
committed
fix(pulse): Update Pulse scripts for v4 Go rewrite
- Remove v3 detection logic since latest release is now v4+ - Use universal package and built-in installer - Update script preserves data directory during updates - Simplified scripts since v3 is no longer the latest
1 parent d9cefc3 commit cdd4141

File tree

2 files changed

+60
-51
lines changed

2 files changed

+60
-51
lines changed

ct/pulse.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,45 @@ function update_script() {
3131
msg_error "No ${APP} Installation Found!"
3232
exit
3333
fi
34-
RELEASE=$(curl -fsSL https://api.github.com/repos/rcourtman/Pulse/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
34+
35+
# Get latest release info
36+
RELEASE_INFO=$(curl -s https://api.github.com/repos/rcourtman/Pulse/releases/latest)
37+
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
38+
RELEASE="${LATEST_VERSION#v}"
39+
3540
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
3641
msg_info "Stopping ${APP}"
3742
systemctl stop pulse
3843
msg_ok "Stopped ${APP}"
3944

40-
msg_info "Updating Pulse"
45+
msg_info "Updating Pulse to ${LATEST_VERSION}"
4146
temp_file=$(mktemp)
42-
mkdir -p /opt/pulse
47+
48+
# Backup config if it exists
49+
if [ -d /opt/pulse/data ]; then
50+
cp -r /opt/pulse/data /tmp/pulse-data-backup
51+
fi
52+
53+
# Download and extract
4354
rm -rf /opt/pulse/*
44-
curl -fsSL "https://github.com/rcourtman/Pulse/releases/download/v${RELEASE}/pulse-v${RELEASE}.tar.gz" -o "$temp_file"
45-
tar zxf "$temp_file" --strip-components=1 -C /opt/pulse
55+
curl -fsSL "https://github.com/rcourtman/Pulse/releases/download/${LATEST_VERSION}/pulse-${LATEST_VERSION}.tar.gz" -o "$temp_file"
56+
tar -xzf "$temp_file" -C /opt/pulse
57+
58+
# Restore config
59+
if [ -d /tmp/pulse-data-backup ]; then
60+
cp -r /tmp/pulse-data-backup /opt/pulse/data
61+
rm -rf /tmp/pulse-data-backup
62+
fi
63+
64+
# Run installer to update service if needed
65+
cd /opt/pulse
66+
if [ -f install.sh ]; then
67+
bash install.sh --update
68+
fi
69+
70+
rm -f "$temp_file"
4671
echo "${RELEASE}" >/opt/${APP}_version.txt
47-
msg_ok "Updated Pulse to ${RELEASE}"
48-
49-
msg_info "Setting permissions for /opt/pulse..."
50-
chown -R pulse:pulse "/opt/pulse"
51-
find "/opt/pulse" -type d -exec chmod 755 {} \;
52-
find "/opt/pulse" -type f -exec chmod 644 {} \;
53-
msg_ok "Set permissions."
72+
msg_ok "Updated Pulse to ${LATEST_VERSION}"
5473

5574
msg_info "Starting ${APP}"
5675
systemctl start pulse

install/pulse-install.sh

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,54 +28,44 @@ else
2828
exit 1
2929
fi
3030

31-
NODE_VERSION="20" setup_nodejs
31+
# Get latest release info
32+
msg_info "Checking for latest Pulse release"
33+
RELEASE_INFO=$(curl -s https://api.github.com/repos/rcourtman/Pulse/releases/latest)
34+
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
3235

33-
msg_info "Setup Pulse"
34-
RELEASE=$(curl -fsSL https://api.github.com/repos/rcourtman/Pulse/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
35-
temp_file=$(mktemp)
36-
mkdir -p /opt/pulse
37-
curl -fsSL "https://github.com/rcourtman/Pulse/releases/download/v${RELEASE}/pulse-v${RELEASE}.tar.gz" -o "$temp_file"
38-
tar zxf "$temp_file" --strip-components=1 -C /opt/pulse
39-
touch /opt/pulse/.env
40-
chown pulse:pulse /opt/pulse/.env
41-
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
42-
msg_ok "Installed Pulse"
36+
if [ -z "$LATEST_VERSION" ]; then
37+
msg_error "Failed to get latest release info"
38+
exit 1
39+
fi
40+
41+
msg_ok "Latest version: $LATEST_VERSION"
4342

44-
msg_info "Setting permissions for /opt/pulse..."
45-
chown -R pulse:pulse "/opt/pulse"
46-
find "/opt/pulse" -type d -exec chmod 755 {} \;
47-
find "/opt/pulse" -type f -exec chmod 644 {} \;
48-
msg_ok "Set permissions."
43+
# Install Pulse v4 (Go version)
44+
msg_info "Installing Pulse"
45+
mkdir -p /opt/pulse
46+
cd /opt/pulse
4947

50-
msg_info "Creating Service"
51-
cat <<EOF >/etc/systemd/system/pulse.service
52-
[Unit]
53-
Description=Pulse Monitoring Application
54-
After=network.target
48+
# Download universal package
49+
temp_file=$(mktemp)
50+
curl -fsSL "https://github.com/rcourtman/Pulse/releases/download/${LATEST_VERSION}/pulse-${LATEST_VERSION}.tar.gz" -o "$temp_file"
51+
tar -xzf "$temp_file"
52+
rm -f "$temp_file"
5553

56-
[Service]
57-
Type=simple
58-
User=pulse
59-
Group=pulse
60-
WorkingDirectory=/opt/pulse
61-
EnvironmentFile=/opt/pulse/.env
62-
ExecStart=/usr/bin/npm run start
63-
Restart=on-failure
64-
RestartSec=5
65-
StandardOutput=journal
66-
StandardError=journal
54+
# Set version file for update script compatibility
55+
echo "${LATEST_VERSION#v}" >/opt/${APPLICATION}_version.txt
6756

68-
[Install]
69-
WantedBy=multi-user.target
70-
EOF
71-
systemctl enable -q --now pulse
72-
msg_ok "Created Service"
57+
# Run the installer
58+
if [ -f install.sh ]; then
59+
bash install.sh
60+
else
61+
msg_error "Installer not found in package"
62+
exit 1
63+
fi
7364

7465
motd_ssh
7566
customize
7667

7768
msg_info "Cleaning up"
78-
rm -f "$temp_file"
7969
$STD apt-get -y autoremove
8070
$STD apt-get -y autoclean
81-
msg_ok "Cleaned"
71+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)