OpenWRT开机自启动脚本

  1. 在/etc/init.d目录下创建文件,例如
touch /etc/init.d/frpC
  1. 编辑文件内容,如下例所示自启动frpC
#!/bin/sh /etc/rc.common

USE_PROCD=1
START=99

start_service() {
         procd_open_instance frpC
         procd_set_param command /usr/bin/frpc -c /etc/config/frp/frpc.ini

         # respawn automatically if something died, be careful if you have an alternative process supervisor
         # if process dies sooner than respawn_threshold, it is considered crashed and after 5 retries the service is stopped
         procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}

         procd_close_instance
}
  1. 使用命令启动、自启动、检查状态
/etc/init.d/frpC start
/etc/init.d/frpC enable
/etc/init.d/frpC status
  • 注意文件的备份,否则系统更新后可能会丢失该脚本。
  • OpenWRT的服务控制方式为service非systemctl,脚本风格为proc。