Files
api/plugin/source/dynamix.unraid.net/install/doinst.sh
Eli Bosley 4f63b4cf3b feat: native slackware package (#1381)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added detailed versioning for plugin packages incorporating
architecture and build identifiers.
- Simplified and improved install/uninstall scripts with backup and
dynamic package detection.
- Introduced comprehensive setup, verification, patching, and cleanup
scripts for the Unraid API environment.
- Enhanced service control with explicit start, stop, restart, and
status commands.
- Added robust dependency management scripts for restoring and archiving
Node.js modules.
- Implemented vendor archive metadata storage and dynamic handling
during build and runtime.
- Added new CLI options and environment schemas for consistent build
configuration.
- Introduced new shutdown scripts to gracefully stop flash-backup and
unraid-api services.
- Added utility scripts for API version detection and vendor archive
configuration.
- Added a new package description file detailing Unraid API features and
homepage link.

- **Bug Fixes**
- Improved validation and error reporting for missing manifests,
dependencies, and configuration files.
  - Enhanced fallback logic for locating and creating vendor archives.
- Fixed iframe compatibility in UI by updating HTML and Firefox
preference files.

- **Chores**
- Updated .gitignore with generated file patterns for Node.js binaries
and archives.
  - Removed obsolete internal documentation and legacy cleanup scripts.
- Refined Docker Compose and CI workflows to pass precise API versioning
and manage build artifacts.
- Centralized common environment validation and CLI option definitions
across build tools.
- Cleaned up plugin manifest by removing Node.js and PNPM-related
entities and legacy logic.
- Improved logging and error handling in build and installation scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-08 22:54:10 -04:00

110 lines
4.0 KiB
Bash

#!/bin/sh
set -eu
# Main installation script for dynamix.unraid.net package
# This script calls specialized external scripts to handle different aspects of installation
# Get the install mode (passed as the first argument by the installpkg script)
INSTALL_MODE="${1:-install}"
# Use absolute paths for script directory to avoid path resolution issues
SCRIPTS_DIR="/usr/local/share/dynamix.unraid.net/install/scripts"
# Log file for debugging
LOGFILE="/var/log/unraid-api/dynamix-unraid-install.log"
mkdir -p "$(dirname "$LOGFILE")"
date > "$LOGFILE"
echo "Starting installation with mode: $INSTALL_MODE" >> "$LOGFILE"
echo "Script directory: $SCRIPTS_DIR" >> "$LOGFILE"
# Make sure scripts are executable
if [ -d "$SCRIPTS_DIR" ]; then
chmod +x "$SCRIPTS_DIR"/*.sh
echo "Made scripts executable" >> "$LOGFILE"
else
echo "ERROR: Scripts directory not found: $SCRIPTS_DIR" >> "$LOGFILE"
# Create directory structure if it doesn't exist yet
mkdir -p "$SCRIPTS_DIR"
fi
# Process based on installation mode
if [ "$INSTALL_MODE" = "install" ] || [ "$INSTALL_MODE" = "upgrade" ]; then
echo "Starting Unraid Connect installation..."
# Apply file patches and system configurations
if [ -x "$SCRIPTS_DIR/file_patches.sh" ]; then
echo "Applying system patches and configurations..."
echo "Running file_patches.sh" >> "$LOGFILE"
# Capture output and add to log file
patches_output=$("$SCRIPTS_DIR/file_patches.sh")
echo "$patches_output" >> "$LOGFILE"
else
echo "ERROR: file_patches.sh not found or not executable" >> "$LOGFILE"
fi
# Setup the API (but don't start it yet)
if [ -x "$SCRIPTS_DIR/setup_api.sh" ]; then
echo "Setting up Unraid API..."
echo "Running setup_api.sh" >> "$LOGFILE"
# Capture output and add to log file
setup_output=$("$SCRIPTS_DIR/setup_api.sh")
echo "$setup_output" >> "$LOGFILE"
# Verify symlinks were created
if [ -L "/usr/local/bin/unraid-api" ]; then
echo "Symlink created successfully" >> "$LOGFILE"
else
echo "ERROR: Symlink not created, attempting to create manually" >> "$LOGFILE"
# Create the symlink manually as fallback
if [ -f "/usr/local/unraid-api/dist/cli.js" ]; then
ln -sf "/usr/local/unraid-api/dist/cli.js" "/usr/local/bin/unraid-api"
ln -sf "/usr/local/bin/unraid-api" "/usr/local/sbin/unraid-api"
ln -sf "/usr/local/bin/unraid-api" "/usr/bin/unraid-api"
echo "Manually created symlinks" >> "$LOGFILE"
else
echo "ERROR: Source file for symlink not found" >> "$LOGFILE"
fi
fi
else
echo "ERROR: setup_api.sh not found or not executable" >> "$LOGFILE"
fi
# Make the rc script executable
if [ -f /etc/rc.d/rc.unraid-api ]; then
chmod 755 /etc/rc.d/rc.unraid-api
echo "Made rc.unraid-api executable" >> "$LOGFILE"
# Start the service
/etc/rc.d/rc.unraid-api start
# Verify the service started successfully
if ! /etc/rc.d/rc.unraid-api status | grep -q "online"; then
echo "⚠️ Warning: Unraid API service failed to start" | tee -a "$LOGFILE"
echo "Check $LOGFILE for details"
else
echo "Unraid API service started successfully" >> "$LOGFILE"
fi
else
echo "ERROR: rc.unraid-api not found" >> "$LOGFILE"
fi
# Run post-installation verification
if [ -x "$SCRIPTS_DIR/verify_install.sh" ]; then
echo "Running post-installation verification..."
echo "Running verify_install.sh" >> "$LOGFILE"
# Capture output and add to log file
verify_output=$("$SCRIPTS_DIR/verify_install.sh")
echo "$verify_output" >> "$LOGFILE"
else
echo "ERROR: verify_install.sh not found or not executable" >> "$LOGFILE"
fi
echo "Installation completed successfully."
echo "Installation completed at $(date)" >> "$LOGFILE"
elif [ "$INSTALL_MODE" = "remove" ]; then
echo "Starting Unraid Connect removal..."
echo "Starting removal" >> "$LOGFILE"
echo "Removal completed successfully."
echo "Removal completed at $(date)" >> "$LOGFILE"
fi