Applicable Products
- Any QNAP NAS running QTS or QuTS hero that supports custom
autorun.sh scripts
Scenario
- You refer to Running Your Own Application at Startup and created an
autorun.sh script under /tmp/config with executable permissions (-rwxr-xr-x). - The autorun feature is enabled in Control Panel > Hardware.
- After rebooting, the expected actions do not occur. It is unclear whether:
autorun.sh was never triggered, orautorun.sh ran, but some commands failed due to timing or environment differences.
- Running the same script manually via SSH works as expected, which makes the root cause harder to identify.
Solution
The most direct way to confirm that autorun.sh runs at boot is to add a buzzer command and a log entry at the beginning of the script.
- If you hear a beep after boot,
autorun.sh was triggered. - If you hear a beep but the main functionality does not work, commands later in the script may be failing because a required network interface, filesystem, or service is not ready.
Prerequisitesautorun.sh is stored at /tmp/config/autorun.sh.- The file is executable:
-rwxr-xr-x. - The autorun feature is enabled in Control Panel > Hardware.
To implement this, first reduce autorun.sh to a minimal observable version:
#!/bin/bash
# Minimal execution proof
echo "autorun.sh started at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
Buzzer commands
- Short beep:
hal_app --se_buzzer enc_id=0,mode=0 - Long beep:
hal_app --se_buzzer enc_id=0,mode=1
Recommended usage:
- Place two short beeps at the very start: indicates that
autorun.sh has started and two short beeps at the end of autorun.sh .
#!/bin/bash
echo "autorun.sh started at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
hal_app --se_buzzer enc_id=0,mode=0
# Your actual configuration below
sleep 5
# ... your commands here ...
echo "autorun.sh completed at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
hal_app --se_buzzer enc_id=0,mode=0
Interpreting the results
Note: QNAP NAS systems emit beep sounds at specific points during normal boot:
- Power-on beep: Single short beep when power is applied (very early in boot, before autorun.sh runs)
- System-starting beep Single short beep when the operating system starts loading (before autorun.sh runs)
- System-ready beep: Usually a long beep after the OS has initialized and services are starting (after autorun.sh runs )
In order to distinguish autorun.sh beeps from the system boot beeps, you may add a differenet beep combinations in your autorun.sh during debug stage.
Besides, you can also view /tmp/autorun.log to check whether autorun.sh is executed.
Warnings
autorun.sh runs with elevated privileges during boot. Ensure that the syntax is correct to avoid system instability.- The buzzer confirms that the script was triggered, but does not guarantee that every command inside it succeeded.
Further Reading
适用产品
- Any QNAP NAS running QTS or QuTS hero that supports custom
autorun.sh scripts
场景
- 您参考了在启动时运行您自己的应用程序并在
/tmp/config下创建了一个具有可执行权限的autorun.sh脚本(-rwxr-xr-x)。 - 在控制台 > 硬件中启用了自动运行功能。
- 重启后,预期的操作没有发生。目前不清楚:
autorun.sh从未被触发,或者autorun.sh运行了,但由于时间或环境差异,一些命令失败。
- 通过 SSH 手动运行相同的脚本可以正常工作,这使得根本原因更难识别。
解决方案
确认autorun.sh在启动时运行的较直接方法是在脚本开头添加蜂鸣器命令和日志条目。
- 如果启动后听到蜂鸣声,说明
autorun.sh被触发。 - 如果听到蜂鸣声但主要功能不工作,可能是因为脚本中的后续命令失败,原因是所需的网络接口、文件系统或服务尚未准备好。
先决条件autorun.sh存储在/tmp/config/autorun.sh。- 文件是可执行的:
-rwxr-xr-x。 - 在控制台 > 硬件中启用了自动运行功能。
要实现这一点,首先将autorun.sh简化为一个可观察的较小版本:
#!/bin/bash
# 较小执行证明
echo "autorun.sh started at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
蜂鸣器命令
- 短鸣:
hal_app --se_buzzer enc_id=0,mode=0 - 长鸣:
hal_app --se_buzzer enc_id=0,mode=1
推荐用法:
- 在开始时放置两个短鸣:表示
autorun.sh已启动,并在autorun.sh结束时放置两个短鸣。
#!/bin/bash
echo "autorun.sh started at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
hal_app --se_buzzer enc_id=0,mode=0
# 您的实际配置如下
sleep 5
# ... 您的命令在这里 ...
echo "autorun.sh completed at $(date)" >> /tmp/autorun.log
hal_app --se_buzzer enc_id=0,mode=0
hal_app --se_buzzer enc_id=0,mode=0
结果解释
注意:QNAP NAS 系统在正常启动的特定点会发出蜂鸣声:
- 开机蜂鸣:通电时发出单短鸣(启动初期,在 autorun.sh 运行之前)
- 系统启动蜂鸣 单短鸣当操作系统开始加载时(在 autorun.sh 运行之前)
- 系统准备就绪蜂鸣:通常在操作系统初始化并开始启动服务后发出长鸣(在 autorun.sh 运行之后)
为了区分 autorun.sh 的蜂鸣与系统启动蜂鸣,您可以在调试阶段在 autorun.sh 中添加不同的蜂鸣组合。
此外,您还可以查看/tmp/autorun.log 以检查autorun.sh是否执行。
警告
autorun.sh在启动时以提升的权限运行。确保语法正确以避免系统不稳定。- 蜂鸣器确认脚本已触发,但不保证其中的每个命令都成功执行。
进一步阅读