Skip to content

Commit 2a102fc

Browse files
committed
feat: attempt to start unraid-api with background task
1 parent e695481 commit 2a102fc

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

plugin/plugins/dynamix.unraid.net.plg

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,21 @@ npm link "${api_base_directory}" --force
873873
# bail if expected file does not exist
874874
[[ ! -f "${api_base_directory}/package.json" ]] && echo "unraid-api install failed" && exit 1
875875
876-
${unraid_binary_path} start
877-
878-
# start background process to start flash backup
879-
echo
880-
if [ -f /var/local/emhttp/var.ini ]; then
881-
# the system has fully booted, emhttpd and nginx are running
882-
echo "Starting flash backup (if enabled)"
883-
echo "/etc/rc.d/rc.flash_backup start" | at -M now &>/dev/null
884-
# else
885-
# the system is booting, emhttpd will install the api and start rc.flash_backup. rc.nginx will start the api.
886-
# nothing to do here
887-
fi
876+
# Start a background process to wait for /var/local/emhttp/var.ini
877+
( timeout=30 elapsed=0
878+
while (( elapsed < timeout )); do
879+
if [ -f /var/local/emhttp/var.ini ]; then
880+
logger "Starting flash backup (if enabled)"
881+
echo "/etc/rc.d/rc.flash_backup start" | at -M now &>/dev/null
882+
logger "Starting Unraid API"
883+
${unraid_binary_path} start
884+
exit 0
885+
fi
886+
sleep 1
887+
(( elapsed++ ))
888+
done
889+
echo "Timeout waiting for /var/local/emhttp/var.ini"
890+
) &
888891
889892
echo
890893
echo "✅ Installation is complete, it is safe to close this window"

0 commit comments

Comments
 (0)