mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-08-27 01:41:58 +00:00
Defer QNAP autorun until encrypted volume unlocks (Fixes #1422)
QNAP's autorun.sh fires well before encrypted data volumes are unlocked, so the previous one-line entry that invoked start-pulse-agent.sh on the encrypted volume failed immediately — the wrapper did not exist yet, and the agent never started after reboot. Replace the entry with a backgrounded waiter that polls for the wrapper (every 2 s, up to 30 min) and execs it once the volume comes up. On unencrypted volumes the loop exits on the first check, so behaviour is unchanged. A timeout message is logged to /var/log/pulse-agent.log if the volume never unlocks within the window. The block is uninstall-safe: no internal blank lines, so the existing sed marker-to-blank-line range still removes it cleanly.
This commit is contained in:
parent
7e4d4e07bf
commit
9fe622b885
1 changed files with 18 additions and 2 deletions
|
|
@ -1705,7 +1705,22 @@ EOF
|
|||
cat >> "$AUTORUN_PATH" <<AUTORUNEOF
|
||||
|
||||
${AUTORUN_MARKER}
|
||||
${WRAPPER_SCRIPT} >> /var/log/${AGENT_NAME}.log 2>&1 &
|
||||
(
|
||||
_pulse_wrapper="${WRAPPER_SCRIPT}"
|
||||
_pulse_log="/var/log/${AGENT_NAME}.log"
|
||||
_pulse_waited=0
|
||||
_pulse_wait_max=1800
|
||||
while [ ! -x "\$_pulse_wrapper" ] && [ "\$_pulse_waited" -lt "\$_pulse_wait_max" ]; do
|
||||
sleep 2
|
||||
_pulse_waited=\$((_pulse_waited + 2))
|
||||
done
|
||||
if [ -x "\$_pulse_wrapper" ]; then
|
||||
[ "\$_pulse_waited" -gt 0 ] && echo "\$(date '+%Y-%m-%d %H:%M:%S') [pulse-agent-autorun] data volume available after \${_pulse_waited}s" >> "\$_pulse_log"
|
||||
"\$_pulse_wrapper" >> "\$_pulse_log" 2>&1
|
||||
else
|
||||
echo "\$(date '+%Y-%m-%d %H:%M:%S') [pulse-agent-autorun] timed out after \${_pulse_wait_max}s waiting for \$_pulse_wrapper" >> "\$_pulse_log"
|
||||
fi
|
||||
) &
|
||||
|
||||
AUTORUNEOF
|
||||
chmod +x "$AUTORUN_PATH"
|
||||
|
|
@ -1726,7 +1741,8 @@ AUTORUNEOF
|
|||
if [[ "$AUTORUN_CONFIGURED" != true ]]; then
|
||||
log_warn "Could not configure autorun.sh automatically."
|
||||
log_warn "To persist across reboots, add the following to your QNAP autorun.sh:"
|
||||
log_warn " ${WRAPPER_SCRIPT} >> /var/log/${AGENT_NAME}.log 2>&1 &"
|
||||
log_warn " (w='${WRAPPER_SCRIPT}'; i=0; while [ ! -x \"\$w\" ] && [ \$i -lt 1800 ]; do sleep 2; i=\$((i+2)); done; [ -x \"\$w\" ] && \"\$w\" >> /var/log/${AGENT_NAME}.log 2>&1) &"
|
||||
log_warn "The waiter accommodates encrypted data volumes that unlock after autorun."
|
||||
log_warn "See: https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue