Skip to content

Commit a719aba

Browse files
committed
chore: add install verification script
1 parent 6139290 commit a719aba

File tree

2 files changed

+181
-46
lines changed

2 files changed

+181
-46
lines changed

plugin/docs/migration/progress.md

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,98 @@
11
# Plugin Migration to Slackware Package: Progress Report
22

3+
## Overview
4+
This document tracks our progress in migrating the Unraid plugin to a native Slackware package.
5+
36
## Completed Tasks
7+
8+
### Package Structure and Slackware Integration
49
- Created standard Slackware package description file (`slack-desc`) for the dynamix.unraid.net package
10+
- Implemented proper Slackware init system integration:
11+
- Modified `rc.unraid-api` script to include standard start/stop/restart/status functions
12+
- Created proper init system symlinks in `doinst.sh` for runlevel 3 (startup) and 0/6 (shutdown)
13+
- Added boot-time node modules dependency restoration to the `start()` function
14+
- Moved environment setup from setup_api.sh to rc.unraid-api to ensure it's available at boot
15+
- The service will now properly start on boot if pre-installed in the OS
16+
17+
### Installation Scripts
518
- Added `doinst.sh` script to handle post-installation tasks like creating symlinks and starting services
6-
- Removed Node.js symlinking from both the doinst.sh script and plugin file as this will be handled by the build-txz script
7-
- Moved all setup and cleanup scripts from the plugin file to the doinst.sh script
819
- Implemented support for both install and remove operations in doinst.sh using Slackware's installation mode parameter
920
- Modularized the installation logic into separate scripts for better maintainability:
1021
- `setup_api.sh`: Handles API setup, symlinks, and service startup
1122
- `file_patches.sh`: Manages file patches and system configurations
1223
- `cleanup.sh`: Performs uninstallation and cleanup operations
13-
- File restoration scripts have been successfully migrated from the plugin's inline code to the modular cleanup.sh script, with improved organization using functions
24+
- Improved doinst.sh script maintainability:
25+
- Added SCRIPTS_DIR variable to centralize script paths
26+
- Replaced all hardcoded script paths with the variable reference
27+
28+
### Cleanup and Removal Operations
29+
- File restoration scripts have been successfully migrated from the plugin's inline code to the modular cleanup.sh script
1430
- Enhanced cleanup.sh to handle both installation and removal scenarios with a mode parameter ('restore' or 'cleanup')
1531
- Updated doinst.sh to call cleanup.sh with the appropriate mode for both installation and removal operations
16-
- Ensured POSIX shell compatibility by replacing Bash-specific array syntax with POSIX-compliant for loops
17-
- These changes follow Slackware packaging conventions for proper integration with the OS
18-
- Removed the now-redundant file restoration block from the plugin file
19-
- Removed redundant cleanup commands from the plugin XML file as they've been properly migrated to the Slackware package scripts
20-
- Simplified the plugin XML file by removing all cleanup code, as these operations are now entirely handled by the Slackware package system via removepkg
21-
- Simplified the unsupported OS handling code to just display a warning message and exit gracefully rather than performing complex cleanup operations
32+
- Simplified the plugin XML file by removing all cleanup code, as these operations are now entirely handled by the Slackware package system
2233
- Updated the removal script to rely on the Slackware package system instead of manually running cleanup operations
2334
- Consolidated all cleanup scripts into a single robust shell script:
2435
- Merged functionality from the PHP `cleanup_operations.php` script into the shell-based `cleanup.sh`
25-
- Removed dependency on PHP for cleanup operations, making the process more compatible with native Slackware tooling
36+
- Removed dependency on PHP for cleanup operations, making it more compatible with native Slackware tooling
2637
- Created a unified script that handles both file restoration (during installation) and full cleanup (during removal)
27-
- Added a mode parameter to control which operations are performed
28-
- Completely removed the legacy PHP cleanup script (cleanup_operations.php)
29-
- Eliminated duplicate cleanup scripts by:
30-
- Removing the redundant script at install/scripts/cleanup.sh
31-
- Standardizing on the version at usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
32-
- Ensuring all script references point to the canonical script location
33-
- Improved doinst.sh script maintainability:
34-
- Added SCRIPTS_DIR variable to centralize script paths
35-
- Replaced all hardcoded script paths with the variable reference
36-
- Makes future path changes easier to implement by only requiring a single edit
37-
- Eliminated duplicate setup_api.sh scripts by:
38-
- Removing the redundant script at install/scripts/setup_api.sh
39-
- Standardizing on the version at usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
40-
- Following the same pattern used for cleanup.sh consolidation
38+
39+
### Node.js and Dependencies Management
40+
- Removed Node.js symlinking from both the doinst.sh script and plugin file as this will be handled by the build-txz script
41+
- Implemented vendor archive handling in the rc.unraid-api script:
42+
- Proper path definitions for the vendor archive
43+
- Comprehensive dependency restoration function that checks file existence and disk space
44+
- Archive creation function for backing up node_modules
45+
- Command-line interface for both restoration and archiving operations
46+
- Automatic restoration during service startup if node_modules are missing
47+
48+
### Script Consolidation
49+
- Eliminated duplicate cleanup scripts by standardizing on the version at usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
50+
- Eliminated duplicate setup_api.sh scripts by standardizing on the version at usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
51+
52+
### POSIX Compatibility
53+
- Ensured POSIX shell compatibility by replacing Bash-specific array syntax with POSIX-compliant for loops
54+
- Fixed POSIX shell compatibility in verify_install.sh:
55+
- Replaced Bash-specific array syntax with POSIX-compliant string lists
56+
- Maintained identical functionality while ensuring /bin/sh compatibility
57+
- Eliminated SC3030 shellcheck warnings about undefined arrays in POSIX sh
58+
- Removed unused check_file() function to fix SC2317 unreachable command warning
59+
60+
### Verification and TAG Handling
61+
- Created post-installation verification script:
62+
- Checks for existence of critical files and directories
63+
- Verifies executable permissions on important scripts
64+
- Validates init script symlinks for proper startup/shutdown
65+
- Provides color-coded output for easy readability
66+
- Integrated with doinst.sh to run automatically after installation
67+
- Added TAG handling from plugin XML file to the Slackware package
68+
69+
## Recent Decisions
70+
- Kept version compatibility check in the plugin file rather than the Slackware package:
71+
- Recognized that doinst.sh runs after files are already installed
72+
- Version checking needs to happen before installation to be effective
73+
- The PHP check in the plugin file is the best place for this validation
74+
- Removed TAG handling from doinst.sh and reverted to plugin file approach:
75+
- Discovered TAG isn't properly set in the Unraid environment within doinst.sh context
76+
- Reverted to using the plugin file for TAG handling to ensure proper functionality
77+
78+
## Removed Components
79+
- Removed redundant build-slackware-package.sh script:
80+
- Eliminated duplicate functionality as we now use build-txz.ts for package creation
81+
- Simplified build tooling to use a single TypeScript-based build process
82+
- Removed makepkg-usage.md documentation:
83+
- Determined that direct makepkg usage documentation is unnecessary
84+
- Package creation is now fully handled by the build-txz.ts script
4185

4286
## Next Steps
87+
- Document complete migration process with testing results
4388
- Review and ensure all file permissions are set correctly
4489
- Test package installation and removal
4590
- Verify that all services start correctly after installation
46-
- Ensure proper dependency handling
47-
- Convert PHP version compatibility check to a shell script
48-
- Implement vendor archive handling in the package structure
49-
- Create complete SlackBuild script with proper:
50-
- Build process
51-
- File permissions
52-
- Directory structure
53-
- Add TAG handling from plugin XML file
54-
- Create post-installation verification to ensure all files are properly installed
55-
- Document complete migration process with testing results
56-
57-
## Recently Completed
58-
- Implemented proper Slackware init system integration:
59-
- Modified `rc.unraid-api` script to include standard start/stop/restart/status functions
60-
- Added boot-time node modules dependency restoration to the `start()` function
61-
- Removed service startup from `setup_api.sh` as it's now handled by the init system
62-
- Created proper init system symlinks in `doinst.sh` for runlevel 3 (startup) and 0/6 (shutdown)
63-
- Moved environment setup from setup_api.sh to rc.unraid-api to ensure it's available at boot
64-
- The service will now properly start on boot if pre-installed in the OS
65-
- Node modules will be automatically restored from the vendor archive if missing at boot
6691

67-
## Notes
92+
## Implementation Notes
6893
- Disk space verification checks are not needed in the native package since it will be pre-installed in Unraid
6994
- Gzip availability checks are unnecessary for the native package
7095
- DNS resolution checks are unnecessary and should be removed from the plugin file
71-
- Plugin staging conflict check is outdated and no longer needed
96+
- Plugin staging conflict check is outdated and no longer needed
97+
- Full SlackBuild script is not necessary since we're not compiling code; direct use of `makepkg` is simpler
98+
- Version compatibility checks should remain in the plugin file since they need to run before installation
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/sh
2+
# Post-installation verification script
3+
# Checks that critical files are installed correctly
4+
5+
# Exit on errors
6+
set -e
7+
8+
# Define color codes for output
9+
GREEN='\033[0;32m'
10+
RED='\033[0;31m'
11+
YELLOW='\033[0;33m'
12+
NC='\033[0m' # No Color
13+
14+
echo "Performing installation verification..."
15+
16+
# Define critical files to check (POSIX-compliant, no arrays)
17+
CRITICAL_FILES="/usr/local/bin/unraid-api
18+
/etc/rc.d/rc.unraid-api
19+
/usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log
20+
/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
21+
/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh
22+
/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh"
23+
24+
# Define critical directories to check (POSIX-compliant, no arrays)
25+
CRITICAL_DIRS="/usr/local/unraid-api
26+
/var/log/unraid-api
27+
/usr/local/emhttp/plugins/dynamix.my.servers
28+
/usr/local/emhttp/plugins/dynamix.unraid.net"
29+
30+
# Function to check if file exists and is executable
31+
check_executable() {
32+
if [ -x "$1" ]; then
33+
printf '%s✓%s Executable file %s exists and is executable\n' "$GREEN" "$NC" "$1"
34+
return 0
35+
elif [ -f "$1" ]; then
36+
printf '%s⚠%s File %s exists but is not executable\n' "$YELLOW" "$NC" "$1"
37+
return 1
38+
else
39+
printf '%s✗%s Executable file %s is missing\n' "$RED" "$NC" "$1"
40+
return 2
41+
fi
42+
}
43+
44+
# Function to check if directory exists
45+
check_dir() {
46+
if [ -d "$1" ]; then
47+
printf '%s✓%s Directory %s exists\n' "$GREEN" "$NC" "$1"
48+
return 0
49+
else
50+
printf '%s✗%s Directory %s is missing\n' "$RED" "$NC" "$1"
51+
return 1
52+
fi
53+
}
54+
55+
# Check executable files
56+
echo "Checking executable files..."
57+
EXEC_ERRORS=0
58+
for file in $CRITICAL_FILES; do
59+
if ! check_executable "$file"; then
60+
EXEC_ERRORS=$((EXEC_ERRORS + 1))
61+
fi
62+
done
63+
64+
# Check directories
65+
echo "Checking directories..."
66+
DIR_ERRORS=0
67+
for dir in $CRITICAL_DIRS; do
68+
if ! check_dir "$dir"; then
69+
DIR_ERRORS=$((DIR_ERRORS + 1))
70+
fi
71+
done
72+
73+
# Check init script symlinks
74+
echo "Checking init script symlinks..."
75+
if [ -L "/etc/rc.d/rc3.d/S99unraid-api" ]; then
76+
printf '%s✓%s Init script symlink for startup exists\n' "$GREEN" "$NC"
77+
else
78+
printf '%s✗%s Init script symlink for startup is missing\n' "$RED" "$NC"
79+
EXEC_ERRORS=$((EXEC_ERRORS + 1))
80+
fi
81+
82+
if [ -L "/etc/rc.d/rc0.d/K01unraid-api" ] && [ -L "/etc/rc.d/rc6.d/K01unraid-api" ]; then
83+
printf '%s✓%s Init script symlinks for shutdown exist\n' "$GREEN" "$NC"
84+
else
85+
printf '%s✗%s Init script symlinks for shutdown are missing\n' "$RED" "$NC"
86+
EXEC_ERRORS=$((EXEC_ERRORS + 1))
87+
fi
88+
89+
# Check if unraid-api is in path
90+
if command -v unraid-api >/dev/null 2>&1; then
91+
printf '%s✓%s unraid-api is in PATH\n' "$GREEN" "$NC"
92+
else
93+
printf '%s⚠%s unraid-api is not in PATH\n' "$YELLOW" "$NC"
94+
fi
95+
96+
# Summary
97+
echo ""
98+
echo "Verification summary:"
99+
if [ $EXEC_ERRORS -eq 0 ] && [ $DIR_ERRORS -eq 0 ]; then
100+
printf '%sAll critical files and directories are present.%s\n' "$GREEN" "$NC"
101+
echo "Installation verification passed."
102+
exit 0
103+
else
104+
printf '%sFound %d file errors and %d directory errors.%s\n' "$RED" "$EXEC_ERRORS" "$DIR_ERRORS" "$NC"
105+
echo "Installation verification completed with issues."
106+
# We don't exit with error as this is just a verification script
107+
exit 0
108+
fi

0 commit comments

Comments
 (0)