Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8bfbf0be3 | |||
3e6b883b38 | |||
47ef918128 | |||
5951638967 | |||
b06e2b2273 | |||
cc1cfe894c |
21
changelog.md
21
changelog.md
@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-03-26 - 2.6.2 - fix(setup/readme)
|
||||
Improve force update instructions and dependency installation process in setup.sh and readme.md
|
||||
|
||||
- Clarify force update commands with explicit paths in readme.md
|
||||
- Remove existing node_modules before installing dependencies in setup.sh
|
||||
- Switch from 'npm ci --only=production' to 'npm install --omit=dev' with updated error instructions
|
||||
|
||||
## 2025-03-26 - 2.6.1 - fix(setup)
|
||||
Update setup.sh to temporarily add vendor Node.js binary to PATH for dependency installation, log Node and npm versions, and restore the original PATH afterwards.
|
||||
|
||||
- Temporarily prepend vendor Node.js binary directory to PATH to ensure proper npm execution.
|
||||
- Log Node.js and npm versions for debugging purposes.
|
||||
- Restore the original PATH after installing dependencies.
|
||||
|
||||
## 2025-03-26 - 2.6.0 - feat(setup)
|
||||
Add --force update flag to setup script and update installation instructions
|
||||
|
||||
- Implemented --force option in setup.sh to force-update Node.js binary and dependencies
|
||||
- Updated readme.md to document the --force flag and revised update steps
|
||||
- Modified ts/cli.ts update command to pass the --force flag to setup.sh
|
||||
|
||||
## 2025-03-26 - 2.5.2 - fix(installer)
|
||||
Improve Node.js binary detection, dependency management, and SNMPv3 fallback logic
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@serve.zone/nupst",
|
||||
"version": "2.5.2",
|
||||
"version": "2.6.2",
|
||||
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
15
readme.md
15
readme.md
@ -227,8 +227,19 @@ sudo nupst update
|
||||
This will:
|
||||
1. Pull the latest changes from the git repository
|
||||
2. Run the installation scripts
|
||||
3. Refresh the systemd service configuration
|
||||
4. Restart the service if it was running
|
||||
3. Force-update Node.js and all dependencies, even if they already exist
|
||||
4. Refresh the systemd service configuration
|
||||
5. Restart the service if it was running
|
||||
|
||||
You can also manually run the setup script with the force flag to update Node.js and dependencies without updating the application code:
|
||||
|
||||
```bash
|
||||
# If you're in the nupst directory:
|
||||
bash ./setup.sh --force
|
||||
|
||||
# If you're in another directory, specify the full path:
|
||||
bash /opt/nupst/setup.sh --force
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
|
52
setup.sh
52
setup.sh
@ -2,6 +2,22 @@
|
||||
|
||||
# NUPST Setup Script
|
||||
# Downloads the appropriate Node.js binary for the current platform
|
||||
# and installs production dependencies
|
||||
|
||||
# Parse command line arguments
|
||||
FORCE_UPDATE=0
|
||||
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--force|-f)
|
||||
FORCE_UPDATE=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# Unknown option
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Find the directory where this script is located
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
@ -74,8 +90,9 @@ case "$OS" in
|
||||
esac
|
||||
|
||||
# Check if we already have the Node.js binary
|
||||
if [ -f "$SCRIPT_DIR/vendor/$NODE_DIR/bin/node" ]; then
|
||||
if [ -f "$SCRIPT_DIR/vendor/$NODE_DIR/bin/node" ] && [ $FORCE_UPDATE -eq 0 ]; then
|
||||
echo "Node.js binary already exists for $OS-$ARCH. Skipping download."
|
||||
echo "Use --force or -f to force update Node.js."
|
||||
else
|
||||
echo "Downloading Node.js v$NODE_VERSION for $OS-$ARCH..."
|
||||
|
||||
@ -222,25 +239,34 @@ echo "dist_ts directory successfully downloaded from npm registry."
|
||||
# Make launcher script executable
|
||||
chmod +x "$SCRIPT_DIR/bin/nupst"
|
||||
|
||||
# Add our Node.js bin directory to the PATH temporarily
|
||||
NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin"
|
||||
OLD_PATH="$PATH"
|
||||
export PATH="$NODE_BIN_DIR:$PATH"
|
||||
|
||||
# Remove existing node_modules directory
|
||||
echo "Removing existing node_modules directory..."
|
||||
rm -rf "$SCRIPT_DIR/node_modules"
|
||||
|
||||
# Install production dependencies
|
||||
echo "Installing production dependencies..."
|
||||
"$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund
|
||||
echo "Using Node.js binary from: $NODE_BIN_DIR"
|
||||
echo "Node version: $(node --version)"
|
||||
echo "NPM version: $(npm --version)"
|
||||
|
||||
npm --prefix "$SCRIPT_DIR" install --omit=dev --no-audit --no-fund
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Warning: Failed to install dependencies with 'npm ci'. Trying 'npm install'..."
|
||||
"$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" install --only=production --no-audit --no-fund
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to install dependencies. NUPST may not function correctly."
|
||||
echo "You can try to install dependencies manually by running:"
|
||||
echo "cd $SCRIPT_DIR && npm install --only=production"
|
||||
else
|
||||
echo "Dependencies installed successfully with 'npm install'."
|
||||
fi
|
||||
echo "Error: Failed to install dependencies. NUPST may not function correctly."
|
||||
echo "You can try to install dependencies manually by running:"
|
||||
echo "cd $SCRIPT_DIR && npm install --omit=dev"
|
||||
else
|
||||
echo "Dependencies installed successfully with 'npm ci'."
|
||||
echo "Dependencies installed successfully."
|
||||
fi
|
||||
|
||||
# Restore the original PATH
|
||||
export PATH="$OLD_PATH"
|
||||
|
||||
echo "NUPST setup completed successfully."
|
||||
echo "You can now run NUPST using: $SCRIPT_DIR/bin/nupst"
|
||||
echo "To install NUPST globally, run: sudo ln -s $SCRIPT_DIR/bin/nupst /usr/local/bin/nupst"
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '2.5.2',
|
||||
version: '2.6.2',
|
||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||
}
|
||||
|
@ -418,9 +418,9 @@ Options:
|
||||
console.log('│ Running install.sh to update NUPST...');
|
||||
execSync(`cd ${installDir} && bash ./install.sh`, { stdio: 'pipe' });
|
||||
|
||||
// 3. Run the setup.sh script
|
||||
console.log('│ Running setup.sh to update dependencies...');
|
||||
execSync(`cd ${installDir} && bash ./setup.sh`, { stdio: 'pipe' });
|
||||
// 3. Run the setup.sh script with force flag to update Node.js and dependencies
|
||||
console.log('│ Running setup.sh to update Node.js and dependencies...');
|
||||
execSync(`cd ${installDir} && bash ./setup.sh --force`, { stdio: 'pipe' });
|
||||
|
||||
// 4. Refresh the systemd service
|
||||
console.log('│ Refreshing systemd service...');
|
||||
|
Reference in New Issue
Block a user