mirror of
https://github.com/unraid/api.git
synced 2025-12-31 21:49:57 -06:00
feat: always start the API and run npm link from script path
This commit is contained in:
@@ -840,6 +840,7 @@ if [[ "$webguiManifestTs" -gt "$plgManifestTs" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the API (previously in rc.d script)
|
# Install the API (previously in rc.d script)
|
||||||
|
echo "Extracting and installing the Unraid API"
|
||||||
|
|
||||||
flash="/boot/config/plugins/dynamix.my.servers"
|
flash="/boot/config/plugins/dynamix.my.servers"
|
||||||
[[ ! -d "${flash}" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1
|
[[ ! -d "${flash}" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1
|
||||||
@@ -850,7 +851,7 @@ source "${flash}/env"
|
|||||||
api_base_directory="/usr/local/unraid-api"
|
api_base_directory="/usr/local/unraid-api"
|
||||||
unraid_binary_path="/usr/local/bin/unraid-api"
|
unraid_binary_path="/usr/local/bin/unraid-api"
|
||||||
# Ensure installation tgz exists
|
# Ensure installation tgz exists
|
||||||
[[ ! -f "${flash}/unraid-api.tgz" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1
|
[[ ! -f "${flash}/unraid-api.tgz" ]] && echo "Missing unraid-api.tgz" && exit 1
|
||||||
# Stop old process
|
# Stop old process
|
||||||
[[ -f "${unraid_binary_path}" ]] && ${unraid_binary_path} stop
|
[[ -f "${unraid_binary_path}" ]] && ${unraid_binary_path} stop
|
||||||
# Install unraid-api
|
# Install unraid-api
|
||||||
@@ -868,19 +869,11 @@ else
|
|||||||
# not fatal, previous version of unraid.min.js should still exist in /usr/local/emhttp/webGui/webComps
|
# not fatal, previous version of unraid.min.js should still exist in /usr/local/emhttp/webGui/webComps
|
||||||
echo "Note: ${flash}/webComps/unraid.min.js is missing"
|
echo "Note: ${flash}/webComps/unraid.min.js is missing"
|
||||||
fi
|
fi
|
||||||
cd "${api_base_directory}" && npm link --force
|
npm link "${api_base_directory}" --force
|
||||||
# bail if expected file does not exist
|
# bail if expected file does not exist
|
||||||
[[ ! -f "${api_base_directory}/package.json" ]] && echo "unraid-api install failed" && exit 1
|
[[ ! -f "${api_base_directory}/package.json" ]] && echo "unraid-api install failed" && exit 1
|
||||||
# if nginx is running, start the api. if not, it will be started by rc.nginx
|
|
||||||
if /etc/rc.d/rc.nginx status &>/dev/null; then
|
${unraid_binary_path} start
|
||||||
# Start new process
|
|
||||||
${unraid_binary_path} start
|
|
||||||
# Note: do not run another unraid-api command until you see "UNRAID API started successfully!" in syslog
|
|
||||||
sleep 3
|
|
||||||
echo "unraid-api installed and started"
|
|
||||||
else
|
|
||||||
echo "unraid-api installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# start background process to start flash backup
|
# start background process to start flash backup
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user