[OpenWrt-Devel] Opkg automatically enable my service just after I install it?
Zhao Zhang
zhao.zhang.glacier at gmail.com
Fri Jan 29 01:50:00 EST 2016
I'm writing some daemon scripts on OpenWrt trunk, and made a ipk to install.
However, it seems OPKG automatically enable it and run it, even if the
default value controlling enable/disable state of the service in
/etc/config/myconfig is 0, means off. It's wired I never meet this problem
on BB.
The logic of my service is, when installed it doesn't need to start at
once, users should configure values in /etc/config/myconfig than start it
manually.
Could you please tell me how to not let it enabled by default since opkg
document in wiki.openwrt.org seems outdated and I cannot find other
resources?
My default config in /etc/config/myservice is below:
config entry 'setting'
option name ''
option passwd ''
option enabled '0'
My script in /etc/init.d/myservice is below,
#!/bin/sh /etc/rc.common
START=99
STOP=99
start()
{
enabled=`uci get myservice.setting.enabled`
if [ "$enabled" -ne 1 ]
then
rm -rf /var/state/myservice
exit
fi
/usr/bin/myservice 2>>/tmp/thunder_myservice_log &
}
stop()
{
pid=`uci -P /var/state get myservice.pid 2>/dev/null`
if [ `echo -n "$pid" | wc -c` -ne 0 ]
then
if [ "$pid" -gt 0 ]
then
kill "$pid"
fi
fi
}
restart()
{
stop
start
}
enable()
{
uci set myservice.setting.enabled=1
uci commit myservice
restart
}
disable()
{
uci set myservice.setting.enabled=0
uci commit myservice
stop
}
--
Best Regards,
Zhao Zhang,
Undergraduate from
Dept. of Computer Science & Technology,
Ocean University of China,
Qingdao, China, 266100
Phone 18678430893
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20160129/530f2bc4/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list