mirror of
https://github.com/unraid/api.git
synced 2026-05-25 11:39:52 -05:00
build: fix doinst.sh compatibility with installpkg --root (#1446)
- Isolate plugin concerns into `.plg` plugin & api file modifiers instead of the api's slackware package. ## Summary by CodeRabbit * **New Features** * Installation process modularized into package installation, post-install setup with verification, and service startup with cleanup. * Added logging and error detection during installation, including symlink verification. * Created required log directory to support service dependencies. * Integrated nginx service with reload capability triggered by configuration changes. * Added automatic patching of nginx configuration and hosts file to improve security and iframe compatibility. * Enhanced file modification system to handle side effects and trigger nginx reloads as needed. * **Refactor** * Restructured installation scripts for clarity; setup scripts now separate steps. * Removed legacy installation logic and deprecated related scripts. * Enabled hard link addition during package creation. * Simplified installation scripts by removing conditional branching and detailed logging. * Streamlined API environment setup by removing redundant post-install steps. * Updated dependency injection to explicitly provide nginx service token. * Improved patch application error reporting with file path details. * **Chores** * Disabled legacy scripts to streamline installation. * Removed `.gitignore` to track previously ignored files. * Updated tests to include new dependencies and relaxed logger assertions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210661184127051
This commit is contained in:
@@ -210,7 +210,7 @@ exit 0
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<!-- install all the things -->
|
||||
<!-- install api package and all necessary files -->
|
||||
<FILE Run="/bin/bash" Method="install">
|
||||
<INLINE>
|
||||
TAG="&tag;"
|
||||
@@ -242,17 +242,69 @@ if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up any old node_modules archives (on the boot drive) that don't match our current version
|
||||
#
|
||||
# Must run after package installation because it provides an update api config file,
|
||||
# which determines the current API version and vendor archive to keep.
|
||||
/etc/rc.d/rc.unraid-api cleanup-dependencies
|
||||
|
||||
if [[ -n "$TAG" && "$TAG" != "" ]]; then
|
||||
printf -v sedcmd 's@^\*\*Unraid Connect\*\*@**Unraid Connect (%s)**@' "$TAG"
|
||||
sed -i "${sedcmd}" "/usr/local/emhttp/plugins/dynamix.unraid.net/README.md"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<!-- port of the old doinst.sh script -->
|
||||
<FILE Run="/bin/bash" Method="install">
|
||||
<INLINE>
|
||||
<![CDATA[
|
||||
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")"
|
||||
|
||||
echo "Starting Unraid Connect installation..."
|
||||
|
||||
# Move settings on flash drive
|
||||
CFG_OLD=/boot/config/plugins/Unraid.net
|
||||
CFG_NEW=/boot/config/plugins/dynamix.my.servers
|
||||
[ -d "$CFG_OLD" ] && [ ! -d "$CFG_NEW" ] && mv "$CFG_OLD" "$CFG_NEW"
|
||||
|
||||
# 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"
|
||||
else
|
||||
echo "ERROR: setup_api.sh not found or not executable" >> "$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 at $(date)" >> "$LOGFILE"
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<!-- start the unraid api service -->
|
||||
<FILE Run="/bin/bash" Method="install">
|
||||
<INLINE>
|
||||
<![CDATA[
|
||||
# Clean up any old node_modules archives (on the boot drive) that don't match our current version
|
||||
#
|
||||
# Must run after package installation because the package provides an update api config file,
|
||||
# which determines the current API version and vendor archive to keep.
|
||||
/etc/rc.d/rc.unraid-api cleanup-dependencies
|
||||
|
||||
echo "Starting Unraid API service"
|
||||
/etc/rc.d/rc.unraid-api plugins add unraid-api-plugin-connect -b --no-restart
|
||||
/etc/rc.d/rc.unraid-api start
|
||||
@@ -260,9 +312,8 @@ echo "Starting Unraid API service"
|
||||
echo "Unraid API service started"
|
||||
echo "✅ Installation is complete, it is safe to close this window"
|
||||
echo
|
||||
|
||||
exit 0
|
||||
]]>
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user