条件有三:

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

这样权限就有了

最新文章

  1. 【emWin】例程一:emWin系列教程简介
  2. AngularJS图片上传功能的实现
  3. Matlab编程实例(3) 函数向左或向右平移N点 左移右移
  4. [iOS UI进阶 - 2.3] 彩票Demo v1.3
  5. 设计模式_Mediator_调停者模式
  6. Guide to make CentOS 7 the perfect desktop
  7. JFinal介绍
  8. 第二章IPC——IPC与开启多进程
  9. 前端学PHP之Smarty模板引擎
  10. 阿里巴巴TXD前端小报 - 2019年3月刊
  11. Easyui datalist 使用记录
  12. 『TensorFlow』读书笔记_TFRecord学习
  13. spring redis @Cacheable注解使用部分错误及无效原因
  14. thinkphp如何利用反射实现钩子方法
  15. Android的Databinding-普通绑定
  16. RedHat6.5安装zookeeper集群
  17. TextView右上角显示小红点,小红点根据TextView的长度移动,小红点被TextView挤出去不显示的问题;
  18. Linux内核分析第一二章读书笔记
  19. C#处理MySql多个返回集的方法
  20. 【snmp】Linux开启snmp及查询

热门文章

  1. Java之Tomcat、Dynamic web project与Servlet
  2. SaltStack之Salt-ssh
  3. Code Forces 645B Mischievous Mess Makers
  4. java开源模板引擎
  5. java通过ping 判断网络是否正常
  6. INFORMATION_SCHEMA.STATISTICS 统计 表 库 大小
  7. jquery.easing的使用
  8. 解决kindeidtor与struts2框架交互WARN OgnlValueStack:68 - Error setting value [[Ljava.lang.String;@10da4df]的bug
  9. mysql5.7.22在centos7.5下的安装
  10. centos下vsftpd不能显示文件,不能创建文件及文件夹