如何使一个openwrt下的软件开机自启动
2024-10-15 09:49:09
条件有三:
1.需要在软件包的Makefile中添加宏定义Package/$(package-name)/preinst和Package/$(package-name)/prerm
define Package/hello/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Enabling rc.d symlink for hello"
/etc/init.d/hello enable
fi
exit
endef define Package/hello/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Removing rc.d symlink for hello"
/etc/init.d/hello disable
fi
exit
endef
2.需要一个启动脚本,并且需要有执行权限(曾尝试过直接将脚本放置在target/linux/$(chip-series)/base-files/etc/init.d目录下,但是openwrt启动后不会执行这个脚本,为什么,因为没有执行权限,那么直接修改此脚本的权限呢?不可行)
如何实施?
将启动脚本制作成一个此软件包的补丁,放到软件包的patches目录下,脚本内容如下:
#!/bin/sh /etc/rc.common
# "new(er)" style init script
# Look at /lib/functions/service.sh on a running system for explanations of what other SERVICE_
# options you can use, and when you might want them. START=
APP=hello
SERVICE_WRITE_PID=
SERVICE_DAEMONIZE= start() {
service_start /usr/bin/$APP
} stop() {
service_stop /usr/bin/$APP
}
3.脚本准备好了,那么此时需要安装脚本到要制作的根文件系统中
在软件包的Makefile中的宏定义Package/$(package-name)/install里加入以下类似代码:
$(INSTALL_DIR) $()/etc/init.d $(INSTALL_BIN) $(script-path) $()/etc/init.d
这样权限就有了
最新文章
- 【emWin】例程一:emWin系列教程简介
- AngularJS图片上传功能的实现
- Matlab编程实例(3) 函数向左或向右平移N点 左移右移
- [iOS UI进阶 - 2.3] 彩票Demo v1.3
- 设计模式_Mediator_调停者模式
- Guide to make CentOS 7 the perfect desktop
- JFinal介绍
- 第二章IPC——IPC与开启多进程
- 前端学PHP之Smarty模板引擎
- 阿里巴巴TXD前端小报 - 2019年3月刊
- Easyui datalist 使用记录
- 『TensorFlow』读书笔记_TFRecord学习
- spring redis @Cacheable注解使用部分错误及无效原因
- thinkphp如何利用反射实现钩子方法
- Android的Databinding-普通绑定
- RedHat6.5安装zookeeper集群
- TextView右上角显示小红点,小红点根据TextView的长度移动,小红点被TextView挤出去不显示的问题;
- Linux内核分析第一二章读书笔记
- C#处理MySql多个返回集的方法
- 【snmp】Linux开启snmp及查询
热门文章
- Java之Tomcat、Dynamic web project与Servlet
- SaltStack之Salt-ssh
- Code Forces 645B Mischievous Mess Makers
- java开源模板引擎
- java通过ping 判断网络是否正常
- INFORMATION_SCHEMA.STATISTICS 统计 表 库 大小
- jquery.easing的使用
- 解决kindeidtor与struts2框架交互WARN OgnlValueStack:68 - Error setting value [[Ljava.lang.String;@10da4df]的bug
- mysql5.7.22在centos7.5下的安装
- centos下vsftpd不能显示文件,不能创建文件及文件夹