初始化脚本.sh:

初始化脚本.sh:

我有一个想要在启动时运行的脚本。

这是一个非常简单的脚本,它插入几个内核模块并启动vino-server

初始化脚本.sh:

#!/bin/bash
sudo rmmod nvhost_vi

# Insert the camera modules
sudo modprobe videobuf2-dma-contig
sudo modprobe adv7280
sudo modprobe tegra_camera

# Start the VNC server
cd /usr/lib/vino
./vino-server &

我已经在目录中添加了符号链接/etc/rc2.d,我确保已将执行权限应用于该脚本。

如果我重新启动系统,我会注意到(检查dmesg)该脚本直到启动后大约 260 秒才运行 - 而不是在预期的启动过程中运行。

发生这种情况有什么原因吗?此版本的 Ubuntu (14.04.5 LTS) 在 ARM 核心的 NVIDIA Jetson TK1 主板上运行。

美中不足的是,我有一个完全相同的设置(来自相同的部署映像)不会出现此行为。同一 rc2.d 目录中的相同脚本会在启动时运行(启动后 13 秒)。

答案1

您的帖子没有解释/etc/rc2.d文件夹内的链接如何命名。如果您想注册自定义启动脚本,您应该将其放在目录中/etc/init.d,然后使用更新-rc.d

$ sudo cp /home/user/mod_and_vnc /etc/init.d/
$ sudo update-rc.d mod_and_vnc defaults

$ ls -la /etc/rc*.d/*mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc0.d/K20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc1.d/K20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc2.d/S20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc3.d/S20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc4.d/S20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc5.d/S20mod_and_vnc -> ../init.d/mod_and_vnc
lrwxrwxrwx 1 root root 21 Jul 19 15:11 /etc/rc6.d/K20mod_and_vnc -> ../init.d/mod_and_vnc

相关内容