openwrt 應用程式 開機自啟動

2021-09-28 17:01:12 字數 2530 閱讀 3309

這幾介紹一下openwrt 應用程式包開機自啟動的兩種方法 使用的平台是mtk7688開發板

首先寫乙個以及可以跑起來的工程,這裡對工程就不做展開,以helloworld工程為例:

helloworld工程寫在:openwrt/package/helloworld 下

自啟動指令碼檔案都是要的 檔案為helloworld

#!/bin/sh /etc/rc.common

start=48

stop=10

start()

stop()

restart()

第一種方法:

可以參考如下方法:我是參考這個的過程實現的,但是有點出入

概括的步驟就是:

1.1、在 openwrt/package/base-files/files/etc/init.d/下新增自啟動指令碼,就是上面那個檔案

1.2、該目錄下給指令碼賦予可執行許可權,執行命令 chmod +x helloworld

1.3、編譯 make v=99

1.4、檢視openwrt/build_dir/target-mipsel_24kc_musl/root-ramips/etc/init.d目錄下是否生成helloworld檔案

1.5、檢視openwrt/build_dir/target-mipsel_24kc_musl/root-ramips/etc/rc.d目錄下是否生成s48helloworld檔案

s48就是指令碼檔案的 start=48 的這個值。

親測可行。

第二種方法:

2.1、在openwrt/package/helloworld/ 下建立新資料夾files

2.2、在openwrt/package/helloworld/files新增自啟動指令碼

2.3、修改openwrt/package/helloworld/下的makefile

include $(topdir)/rules.mk

pkg_name:=helloworld

pkg_release:=1

pkg_build_dir := $(build_dir)/$(pkg_name)

include $(include_dir)/package.mk

define package/helloworld

section:=utils

category:=utilities

title:=roco---helloworld -- prints a snarky message

endef

define package/helloworld/description

if you can't figure out what this program does, you're probably

brain-dead and need immediate medical attention.

endef

define build/prepare

mkdir -p $(pkg_build_dir)

$(cp) ./src/* $(pkg_build_dir)/

endef

define package/helloworld/install

$(install_dir) $(1)/bin

$(install_bin) $(pkg_build_dir)/helloworld $(1)/bin/

$(install_dir) $(1)/etc/init.d

$(install_bin) ./files/helloworld $(1)/etc/init.d/helloworld

endef

$(eval $(call buildpackage,helloworld))

這個makefile很多地方都能一樣

主要就是

define package/helloworld/install

$(install_dir) $(1)/bin

$(install_bin) $(pkg_build_dir)/helloworld $(1)/bin/

# 這裡不一樣,增加這個

$(install_dir) $(1)/etc/init.d

$(install_bin) ./files/helloworld $(1)/etc/init.d/helloworld

endef

這個鏈結裡面有makefile的與非說明,想知道的更清楚的可以點開看一下:

2.3、編譯 make v=99

2.4、檢視openwrt/build_dir/target-mipsel_24kc_musl/root-ramips/etc/init.d目錄下是否生成helloworld檔案

2.5、檢視openwrt/build_dir/target-mipsel_24kc_musl/root-ramips/etc/rc.d目錄下是否生成s48helloworld檔案

s48就是指令碼檔案的 start=48 的這個值。

同樣 親測可行

設定openwrt應用程式開機和崩潰時自動啟動

設定openwrt應用程式開機和崩潰時自動啟動 在 etc init.d 中新增helloworld啟動指令碼,內容如下 bin sh etc rc.common start 90 use procd 1 prog helloworld helloworld start service 這是乙個最簡...

Ubuntu 桌面程式開機自啟

只是方法之一,使用.desktop檔案。desktop entry檔案是 linux 桌面系統中用於描述程式啟動配置資訊的檔案,它以.desktop為字尾名,相當於windows系統下的桌面快捷方式。通常乙個二進位制可執行程式是乙個沒有字尾沒有圖示的檔案,不可以隨意移動。以kgt.desktop為例...

phpstudy 開機自啟

phpstudy每次開機就要重啟一次,單單吧phpstudy面板加入自啟動目錄毫無意義,還是需要點選啟動才能執行。所以考慮如何自啟。其實主要就是apache和資料庫都自動啟動即可 因此主要包含兩部分 第一部分apach的自啟動 進入到自己的phpstudy的apache下的bin目錄,在命令列輸入h...