如何在启动后使用busybox自动运行程序?

AJ *_* GS 6 startup busybox buildroot autostart

我正在使用带有 busybox 的嵌入式 Linux。我想自动运行名为“myApplication”的应用程序(启动后运行级别 5,所有服务均已启动)。

到目前为止我所做的:

  • 我在 /etc/init.d/ 下创建了一个名为 S90myscript 的脚本
  • 然后我将这一行添加到 inittab 中:

::sysinit:/etc/init.d/S90myscript

该脚本包含以下内容:

! /bin/sh
### BEGIN INIT INFO
# Provides: myApplication
# Should-Start: $all
# Required-Start: $remote_fs $network $local_fs
# Required-Stop: $remote_fs
# Default-Start: 5
# Default-Stop: 0 6
# Short-Description: start myprogram at boot time
### END INIT INFO
#

set -e

. /lib/lsb/init-functions
PATH=/root:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin
PROGRAMNAME="myApplication"
case "$1" in
start)
$PROGRAMNAME
;;
stop)
skill $PROGRAMNAME
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?符号链接?难道是我做错了什么?

先感谢您

AJ *_* GS 5

找到了解决方案。

  1. 我放置myApplication在/usr/sbin/
  2. 创建了一个名为 myApp 的符号链接到位于的脚本/etc/init.d/S99myAppScript (请注意,没有 .sh,我必须sudo chmod 755在该脚本上运行)
  3. 在命令之前的rcS文件末尾添加了以下行:/etc/init.d/done

    myApp &
    
    Run Code Online (Sandbox Code Playgroud)

重新启动系统后,myApplication 将自动运行。