migration/deno-v4 #1
84
install.sh
84
install.sh
@@ -213,8 +213,24 @@ echo "Download URL: $DOWNLOAD_URL"
|
||||
echo ""
|
||||
|
||||
# Check if installation directory exists
|
||||
SERVICE_WAS_RUNNING=0
|
||||
OLD_NODE_INSTALL=0
|
||||
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
# Check if this is an old Node.js-based installation
|
||||
if [ -f "$INSTALL_DIR/package.json" ] || [ -d "$INSTALL_DIR/node_modules" ]; then
|
||||
OLD_NODE_INSTALL=1
|
||||
echo "Detected old Node.js-based NUPST installation (v3.x or earlier)"
|
||||
echo "This installer will migrate to the new Deno-based binary version (v4.0+)"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ $AUTO_YES -eq 0 ] && [ $INTERACTIVE -eq 1 ]; then
|
||||
if [ $OLD_NODE_INSTALL -eq 1 ]; then
|
||||
echo "This will replace your Node.js installation with a pre-compiled binary."
|
||||
echo "Your configuration in /etc/nupst/config.json will be preserved."
|
||||
echo ""
|
||||
fi
|
||||
echo "Installation directory already exists: $INSTALL_DIR"
|
||||
echo "Do you want to update/reinstall? (Y/n): "
|
||||
read -r update_confirm
|
||||
@@ -226,6 +242,28 @@ if [ -d "$INSTALL_DIR" ]; then
|
||||
fi
|
||||
|
||||
echo "Updating existing installation at $INSTALL_DIR..."
|
||||
|
||||
# Check if service is running and stop it
|
||||
if systemctl is-active --quiet nupst 2>/dev/null; then
|
||||
echo "Stopping NUPST service..."
|
||||
systemctl stop nupst
|
||||
SERVICE_WAS_RUNNING=1
|
||||
fi
|
||||
|
||||
# Clean up old Node.js installation files
|
||||
if [ $OLD_NODE_INSTALL -eq 1 ]; then
|
||||
echo "Cleaning up old Node.js installation files..."
|
||||
rm -rf "$INSTALL_DIR/node_modules" 2>/dev/null || true
|
||||
rm -rf "$INSTALL_DIR/vendor" 2>/dev/null || true
|
||||
rm -rf "$INSTALL_DIR/dist_ts" 2>/dev/null || true
|
||||
rm -f "$INSTALL_DIR/package.json" 2>/dev/null || true
|
||||
rm -f "$INSTALL_DIR/package-lock.json" 2>/dev/null || true
|
||||
rm -f "$INSTALL_DIR/pnpm-lock.yaml" 2>/dev/null || true
|
||||
rm -f "$INSTALL_DIR/tsconfig.json" 2>/dev/null || true
|
||||
rm -f "$INSTALL_DIR/setup.sh" 2>/dev/null || true
|
||||
rm -rf "$INSTALL_DIR/bin" 2>/dev/null || true
|
||||
echo "Old installation files removed."
|
||||
fi
|
||||
else
|
||||
if [ $AUTO_YES -eq 0 ] && [ $INTERACTIVE -eq 1 ]; then
|
||||
echo "NUPST will be installed to: $INSTALL_DIR"
|
||||
@@ -301,18 +339,54 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Restart service if it was running before update
|
||||
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
||||
echo "Restarting NUPST service..."
|
||||
systemctl start nupst
|
||||
echo "Service restarted successfully."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "================================================"
|
||||
echo " NUPST Installation Complete!"
|
||||
echo "================================================"
|
||||
echo ""
|
||||
|
||||
if [ $OLD_NODE_INSTALL -eq 1 ]; then
|
||||
echo "Migration from v3.x to v4.0 successful!"
|
||||
echo ""
|
||||
echo "What changed:"
|
||||
echo " • Node.js runtime removed (now a self-contained binary)"
|
||||
echo " • Faster startup and lower memory usage"
|
||||
echo " • CLI commands now use subcommand structure"
|
||||
echo " (old commands still work with deprecation warnings)"
|
||||
echo ""
|
||||
echo "Migration guide: https://code.foss.global/serve.zone/nupst/src/branch/main/MIGRATION.md"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Installation details:"
|
||||
echo " Binary location: $BINARY_PATH"
|
||||
echo " Symlink location: $BIN_DIR/nupst"
|
||||
echo " Version: $VERSION"
|
||||
echo ""
|
||||
echo "Get started:"
|
||||
echo " nupst --version"
|
||||
echo " nupst help"
|
||||
echo " nupst ups add # Add a UPS device"
|
||||
echo " nupst service enable # Enable systemd service"
|
||||
|
||||
# Check if configuration exists
|
||||
if [ -f "/etc/nupst/config.json" ]; then
|
||||
echo "Configuration: /etc/nupst/config.json (preserved)"
|
||||
echo ""
|
||||
echo "Your existing configuration has been preserved."
|
||||
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
||||
echo "The service has been restarted with your current settings."
|
||||
else
|
||||
echo "Start the service with: sudo nupst service start"
|
||||
fi
|
||||
else
|
||||
echo "Get started:"
|
||||
echo " nupst --version"
|
||||
echo " nupst help"
|
||||
echo " nupst ups add # Add a UPS device"
|
||||
echo " nupst service enable # Enable systemd service"
|
||||
fi
|
||||
echo ""
|
||||
|
Reference in New Issue
Block a user