Compare commits
2 Commits
dda02fa792
...
72c22465ab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c22465ab | ||
|
|
afb5df27c1 |
@ -82,8 +82,27 @@ function uninstall() {
|
|||||||
rm -f "$SERVICE_PATH"
|
rm -f "$SERVICE_PATH"
|
||||||
rm -rf "$INSTALL_PATH"
|
rm -rf "$INSTALL_PATH"
|
||||||
rm -f "/usr/local/bin/update_jellystat"
|
rm -f "/usr/local/bin/update_jellystat"
|
||||||
|
rm -f "$HOME/.jellystat"
|
||||||
msg_ok "${APP} has been uninstalled"
|
msg_ok "${APP} has been uninstalled"
|
||||||
msg_warn "PostgreSQL database was NOT removed. Remove manually if needed."
|
|
||||||
|
# Ask about PostgreSQL database removal
|
||||||
|
echo ""
|
||||||
|
echo -n "${TAB}Also remove PostgreSQL database 'jellystat'? (y/N): "
|
||||||
|
read -r db_prompt
|
||||||
|
if [[ "${db_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
|
if command -v psql &>/dev/null; then
|
||||||
|
msg_info "Removing PostgreSQL database and user"
|
||||||
|
sudo -u postgres psql -c "DROP DATABASE IF EXISTS jellystat;" &>/dev/null || true
|
||||||
|
sudo -u postgres psql -c "DROP USER IF EXISTS jellystat;" &>/dev/null || true
|
||||||
|
msg_ok "Removed PostgreSQL database 'jellystat' and user 'jellystat'"
|
||||||
|
else
|
||||||
|
msg_warn "PostgreSQL not found - database may have been removed already"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
msg_warn "PostgreSQL database was NOT removed. Remove manually if needed:"
|
||||||
|
echo -e "${TAB} sudo -u postgres psql -c \"DROP DATABASE jellystat;\""
|
||||||
|
echo -e "${TAB} sudo -u postgres psql -c \"DROP USER jellystat;\""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@ -251,76 +270,12 @@ EOF
|
|||||||
systemctl enable --now jellystat &>/dev/null
|
systemctl enable --now jellystat &>/dev/null
|
||||||
msg_ok "Created and started service"
|
msg_ok "Created and started service"
|
||||||
|
|
||||||
# Create update script
|
# Create update script (simple wrapper that calls this addon with type=update)
|
||||||
msg_info "Creating update script"
|
msg_info "Creating update script"
|
||||||
cat <<'UPDATEEOF' >/usr/local/bin/update_jellystat
|
cat <<'UPDATEEOF' >/usr/local/bin/update_jellystat
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Jellystat Update Script
|
# Jellystat Update Script
|
||||||
# Auto-generated by community-scripts addon installer
|
type=update bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/tools/addon/jellystat.sh)"
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
APP="Jellystat"
|
|
||||||
INSTALL_PATH="/opt/jellystat"
|
|
||||||
CONFIG_PATH="/opt/jellystat/.env"
|
|
||||||
|
|
||||||
# Colors
|
|
||||||
YW='\033[33m'
|
|
||||||
GN='\033[1;92m'
|
|
||||||
RD='\033[01;31m'
|
|
||||||
BL='\033[36m'
|
|
||||||
CL='\033[m'
|
|
||||||
CM="${GN}✔️${CL}"
|
|
||||||
INFO="${BL}ℹ️${CL}"
|
|
||||||
|
|
||||||
msg_info() { echo -e "${INFO} ${YW}${1}...${CL}"; }
|
|
||||||
msg_ok() { echo -e "${CM} ${GN}${1}${CL}"; }
|
|
||||||
|
|
||||||
echo -e "${BL}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
|
||||||
echo -e "${GN} Jellystat Update Script${CL}"
|
|
||||||
echo -e "${BL}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Source tools.func for check_for_gh_release and fetch_and_deploy_gh_release
|
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/tools.func) 2>/dev/null || {
|
|
||||||
echo -e "${RD}Failed to load tools.func${CL}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if check_for_gh_release "jellystat" "CyferShepard/Jellystat"; then
|
|
||||||
msg_info "Stopping service"
|
|
||||||
systemctl stop jellystat.service &>/dev/null || true
|
|
||||||
msg_ok "Stopped service"
|
|
||||||
|
|
||||||
msg_info "Backing up configuration"
|
|
||||||
cp "$CONFIG_PATH" /tmp/jellystat.env.bak 2>/dev/null || true
|
|
||||||
msg_ok "Backed up configuration"
|
|
||||||
|
|
||||||
fetch_and_deploy_gh_release "jellystat" "CyferShepard/Jellystat" "tarball" "latest" "$INSTALL_PATH"
|
|
||||||
|
|
||||||
msg_info "Restoring configuration"
|
|
||||||
cp /tmp/jellystat.env.bak "$CONFIG_PATH" 2>/dev/null || true
|
|
||||||
rm -f /tmp/jellystat.env.bak
|
|
||||||
msg_ok "Restored configuration"
|
|
||||||
|
|
||||||
msg_info "Installing dependencies"
|
|
||||||
cd "$INSTALL_PATH"
|
|
||||||
npm install &>/dev/null
|
|
||||||
msg_ok "Installed dependencies"
|
|
||||||
|
|
||||||
msg_info "Building ${APP}"
|
|
||||||
npm run build &>/dev/null
|
|
||||||
msg_ok "Built ${APP}"
|
|
||||||
|
|
||||||
msg_info "Starting service"
|
|
||||||
systemctl start jellystat.service &>/dev/null
|
|
||||||
msg_ok "Started service"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
msg_ok "${APP} updated successfully!"
|
|
||||||
else
|
|
||||||
msg_ok "${APP} is already up-to-date"
|
|
||||||
fi
|
|
||||||
UPDATEEOF
|
UPDATEEOF
|
||||||
chmod +x /usr/local/bin/update_jellystat
|
chmod +x /usr/local/bin/update_jellystat
|
||||||
msg_ok "Created update script (/usr/local/bin/update_jellystat)"
|
msg_ok "Created update script (/usr/local/bin/update_jellystat)"
|
||||||
@ -349,6 +304,19 @@ EOF
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# MAIN
|
# MAIN
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Handle type=update (called from update script)
|
||||||
|
if [[ "${type:-}" == "update" ]]; then
|
||||||
|
header_info
|
||||||
|
if [[ -d "$INSTALL_PATH" && -f "$INSTALL_PATH/package.json" ]]; then
|
||||||
|
update
|
||||||
|
else
|
||||||
|
msg_error "${APP} is not installed. Nothing to update."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
header_info
|
header_info
|
||||||
|
|
||||||
IP=$(get_ip)
|
IP=$(get_ip)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user