Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Tue Feb 27, 2018 15:10 Post subject: Re: Where are startup scripts in ddwrt
emm wrote:
I cannot find system startup scripts in my router.
For example what script or application setups for IP on wired interface or SSID on radio according to the nvram config.
Posted: Tue Feb 27, 2018 16:54 Post subject: Re: Where are startup scripts in ddwrt
mwchang wrote:
emm wrote:
I cannot find system startup scripts in my router.
For example what script or application setups for IP on wired interface or SSID on radio according to the nvram config.
I think they're looking for system init, not user init. I'm not sure there are scripts for it, probably all compiled as that would use less flash. I found one file for a script example, but this is qtn (QuaNTana I presume), not Broadcom:
http://svn.dd-wrt.com/browser/src/router/qtn/images/router_command.sh
You'll have to search and dig around the code. _________________ #NAT/SFE/CTF: limited speed w/ DD#Repeater issues#DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo#
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
I think they're looking for system init, not user init. I'm not sure there are scripts for it, probably all compiled as that would use less flash. I found one file for a script example, but this is qtn (QuaNTana I presume), not Broadcom:
http://svn.dd-wrt.com/browser/src/router/qtn/images/router_command.sh
You'll have to search and dig around the code.
You hit my point, this was a question about. This script file is more or less I am looking for, but for broadcom ddwrt. So source code is only direction? Are there any development documentation regarding boot phase?
d0ug wrote:
Unless you download the source and make the edits yourself and then compile it, you are not going to be able to make any changes to the startup process. The whole file system is read only.
I do not care about changeing, I want to see how (commands/API, etc) some things are setup on router.
This script file is more or less I am looking for, but for broadcom ddwrt. So source code is only direction? Are there any development documentation regarding boot phase?
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat Mar 26, 2022 8:48 Post subject: Re: Where are startup scripts in ddwrt
emm wrote:
I cannot find system startup scripts in my router.
For example what script or application setups for IP on wired interface or SSID on radio according to the nvram config.
I just learnt that Admin->Commands->Save USB created a file "/tmp/.rc_usb". "Save Startup" should create a file with similar name, possibly ".rc_startup" or whatever... and after a few clicks, got these:
Code:
root@dd-wrt:/tmp# ls -la .rc*
-rwx------ 1 root root 26 Mar 26 16:49 .rc_firewall
-rwx------ 1 root root 16 Mar 26 16:49 .rc_shutdown
-rwx------ 1 root root 3 Mar 26 16:48 .rc_startup
-rwx------ 1 root root 417 Mar 26 16:38 .rc_usb
But then I don't know when these scripts would be executed, notably .rc_startup and .rc_usb. I never knew precisely when sysinit of DD-WRT ended. What should I look for in /var/log/messages? Or was it a signal file?
Modern Linux init executes startup stuffs in parallel, NOT in predefined, predictable order and manner.
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Posted: Sat Mar 26, 2022 9:43 Post subject:
All these are stored in nvram for startup, firewall, usb, for a quick test add a startup script and run via terminal nvram show | grep startup, you can test the others also.
Anything on /tmp/rc_whatever are generated from the nvram stored bits.
I dont use jffs so idk how this would behave then, if special config is required to store stuff on there for these, bu in any case /tmp stuff is generated from nvram values typically.
Mind these have to be one liners or be escaped properly depending on what you do.
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat Mar 26, 2022 12:47 Post subject:
the-joker wrote:
also just noticed this is mwchang necroposted a reply to a OP req from 2018 so my bad for following that necro up too.
My bad, I was trying to find out when and where DD-WRT's sysinit finished its business, and then I found this old thread. I should start a new thread. Sorry... my apology!
BTW, here is the log which shown repeated attempts to start the same set of services. If you looked and counted closely, only "[inadyn]" and "[ddns]" were not executed too many times.
Could this part of the sysinit process optimized? By doing so, the router's startup time could be reduced.
Code:
Jan 1 08:00:12 RT-N18U-HST user.info : [klogd] : daemon successfully started
Jan 1 08:00:12 RT-N18U-HST user.info : [resetbutton] : resetbutton daemon successfully started
Jan 1 08:00:12 RT-N18U-HST user.info : [bridge] : bridge br0 successfully added
Jan 1 08:00:12 RT-N18U-HST user.info : [bridge] : interface vlan1 successfully added to bridge br0
Jan 1 08:00:13 RT-N18U-HST user.info : [bridge] : interface eth1 successfully added to bridge br0
Jan 1 08:00:14 RT-N18U-HST user.info : [klogd] : kernel log daemon successfully stopped
Jan 1 08:00:14 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:14 RT-N18U-HST user.info : [syslogd] : syslog daemon successfully stopped
Jan 1 08:00:16 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Jan 1 08:00:17 RT-N18U-HST user.info : [vpn modules] : vpn modules successfully unloaded
Jan 1 08:00:17 RT-N18U-HST user.info : [dnsmasq] : daemon successfully started
Jan 1 08:00:20 RT-N18U-HST user.info : [httpd] : http daemon successfully started
Jan 1 08:00:20 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:23 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:24 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Jan 1 08:00:24 RT-N18U-HST user.info : [dropbear] : ssh daemon successfully started
Jan 1 08:00:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:32 RT-N18U-HST user.info : [wland] : daemon successfully stopped
Jan 1 08:00:32 RT-N18U-HST user.info : [wland] : daemon successfully started
Jan 1 08:00:32 RT-N18U-HST user.info : [dnsmasq] : daemon successfully stopped
Jan 1 08:00:32 RT-N18U-HST user.info : [dnsmasq] : daemon successfully started
Jan 1 08:00:32 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Jan 1 08:00:32 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Jan 1 08:00:32 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:33 RT-N18U-HST user.info : [vpn modules] : vpn modules successfully unloaded
Jan 1 08:00:34 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:35 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:35 RT-N18U-HST user.info : [process_monitor] : successfully started
Jan 1 08:00:35 RT-N18U-HST user.info : [ddns] : inadyn daemon successfully started
Mar 26 20:27:36 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Mar 26 20:27:36 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:27:36 RT-N18U-HST user.info : [nas] : NAS lan (wl0 interface) successfully started
Mar 26 20:27:37 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Mar 26 20:27:37 RT-N18U-HST user.info : [nas] : daemon successfully stopped
Mar 26 20:27:38 RT-N18U-HST user.info : [nas] : NAS lan (wl0 interface) successfully started
Mar 26 20:27:38 RT-N18U-HST user.info : [httpd] : daemon successfully stopped
Mar 26 20:27:38 RT-N18U-HST user.info : [httpd] : http daemon successfully started
Mar 26 20:27:38 RT-N18U-HST user.info : [resetbutton] : daemon successfully stopped
Mar 26 20:27:38 RT-N18U-HST user.info : [resetbutton] : resetbutton daemon successfully started
Mar 26 20:27:39 RT-N18U-HST user.info : [vpn modules] : vpn modules successfully unloaded
Mar 26 20:27:40 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:27:41 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:27:42 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Mar 26 20:27:42 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Mar 26 20:27:42 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Mar 26 20:27:43 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Mar 26 20:27:43 RT-N18U-HST user.info : [process_monitor] : daemon successfully stopped
Mar 26 20:27:43 RT-N18U-HST user.info : [wsdd2] : windows service discovery daemon successfully stopped
Mar 26 20:27:43 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully stopped
Mar 26 20:27:43 RT-N18U-HST user.info : [ksmbd.mountd] : samba daemon successfully stopped
Mar 26 20:27:43 RT-N18U-HST user.info : [process_monitor] : successfully started
Mar 26 20:27:43 RT-N18U-HST user.info : [lighttpd] : daemon successfully stopped
Mar 26 20:27:47 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Mar 26 20:27:48 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully stopped
Mar 26 20:27:48 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Mar 26 20:28:12 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Mar 26 20:28:12 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully stopped
Mar 26 20:28:13 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Mar 26 20:28:13 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Mar 26 20:28:13 RT-N18U-HST user.info : [wsdd2] : windows service discovery daemon successfully stopped
Mar 26 20:28:14 RT-N18U-HST user.info : [ksmbd.mountd] : samba daemon successfully stopped
Mar 26 20:28:15 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully stopped
Mar 26 20:28:15 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Mar 26 20:33:05 RT-N18U-HST user.info : [dnsmasq] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [wland] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [wsdd2] : windows service discovery daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [lighttpd] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [dnsmasq] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [pptpd] : daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [ksmbd.mountd] : samba daemon successfully stopped
Mar 26 20:33:05 RT-N18U-HST user.info : [nas] : daemon successfully stopped
Mar 26 20:33:06 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Mar 26 20:33:06 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:06 RT-N18U-HST user.info : [udhcpc] : udhcp client process successfully stopped
Mar 26 20:33:06 RT-N18U-HST user.info : [bridge] : interface vlan1 successfully deleted from bridge br0
Mar 26 20:33:06 RT-N18U-HST user.info : [bridge] : interface eth1 successfully deleted from bridge br0
Mar 26 20:33:06 RT-N18U-HST user.info : [bridge] : bridge br0 successfully deleted
Mar 26 20:33:07 RT-N18U-HST user.info : [resetbutton] : daemon successfully stopped
Mar 26 20:33:07 RT-N18U-HST user.info : [ipv6] : successfully stopped
Mar 26 20:33:07 RT-N18U-HST user.info : [klogd] : kernel log daemon successfully stopped
Mar 26 20:33:07 RT-N18U-HST user.info : [syslogd] : syslog daemon successfully stopped
Mar 26 20:33:07 RT-N18U-HST user.info : [resetbutton] : resetbutton daemon successfully started
Mar 26 20:33:07 RT-N18U-HST user.info : [bridge] : bridge br0 successfully added
Mar 26 20:33:07 RT-N18U-HST user.info : [bridge] : interface vlan1 successfully added to bridge br0
Mar 26 20:33:07 RT-N18U-HST user.info : [bridge] : interface eth1 successfully added to bridge br0
Mar 26 20:33:08 RT-N18U-HST user.info : [klogd] : kernel log daemon successfully stopped
Mar 26 20:33:08 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully stopped
Mar 26 20:33:08 RT-N18U-HST user.info : [wland] : daemon successfully started
Mar 26 20:33:08 RT-N18U-HST user.info : [dnsmasq] : daemon successfully started
Mar 26 20:33:08 RT-N18U-HST user.info : [syslogd] : syslog daemon successfully stopped
Mar 26 20:33:09 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Mar 26 20:33:10 RT-N18U-HST user.info : [httpd] : daemon successfully stopped
Mar 26 20:33:10 RT-N18U-HST user.info : [httpd] : http daemon successfully started
Mar 26 20:33:10 RT-N18U-HST user.info : [vpn modules] : vpn modules successfully unloaded
Mar 26 20:33:10 RT-N18U-HST user.info : [minidlna] : DLNA Media Server successfully started
Mar 26 20:33:10 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:11 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:13 RT-N18U-HST user.info : [nas] : NAS lan (wl0 interface) successfully started
Mar 26 20:33:14 RT-N18U-HST user.info : [nas] : daemon successfully stopped
Mar 26 20:33:14 RT-N18U-HST user.info : [nas] : NAS lan (wl0 interface) successfully started
Mar 26 20:33:14 RT-N18U-HST user.info : [httpd] : daemon successfully stopped
Mar 26 20:33:14 RT-N18U-HST user.info : [httpd] : http daemon successfully started
Mar 26 20:33:14 RT-N18U-HST user.info : [resetbutton] : daemon successfully stopped
Mar 26 20:33:14 RT-N18U-HST user.info : [resetbutton] : resetbutton daemon successfully started
Mar 26 20:33:15 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Mar 26 20:33:15 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:16 RT-N18U-HST user.info : [wland] : daemon successfully stopped
Mar 26 20:33:16 RT-N18U-HST user.info : [wland] : daemon successfully started
Mar 26 20:33:16 RT-N18U-HST user.info : [dnsmasq] : daemon successfully stopped
Mar 26 20:33:16 RT-N18U-HST user.info : [dnsmasq] : daemon successfully started
Mar 26 20:33:16 RT-N18U-HST user.info : [unbound] : daemon successfully stopped
Mar 26 20:33:16 RT-N18U-HST user.info : [unbound] : recursive dns resolver daemon successfully started
Mar 26 20:33:16 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Mar 26 20:33:18 RT-N18U-HST user.info : [vpn modules] : vpn modules successfully unloaded
Mar 26 20:33:18 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:19 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Mar 26 20:33:19 RT-N18U-HST user.info : [process_monitor] : daemon successfully stopped
Mar 26 20:33:19 RT-N18U-HST user.info : [inadyn] : dynamic dns daemon successfully stopped
Mar 26 20:33:19 RT-N18U-HST user.info : [process_monitor] : successfully started
Mar 26 20:33:19 RT-N18U-HST user.info : [ddns] : inadyn daemon successfully started
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
I suspect the sysinit timed out too early when starting those NAS services, making another attempt to start all NAS services NOT before killing all started NAS services, which timed out too soon again, and attempted again... so and so forth.
The easy solution is not to read the source codes of sysinit, but to let users to specify the timeout value in the WEBUI.
Of course, not relying on timeout is the better approach, but you would need a way to tell whether a daemon was successfully started, and hence not to be started again. That requires reading and altering the source codes.
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Posted: Tue Mar 29, 2022 12:53 Post subject:
Well you can within reason script the queries with bash to find out if a specific service is already running and than do whatever you want based on the return.
I wouldnt use admin > commands > startup, but instead save as a firewall script, maybe even calling jffs2/or usb scripts so you workaround limitations of syntax etc, when saving something as a admin > command > something script.
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Wed Mar 30, 2022 9:50 Post subject:
the-joker wrote:
I wouldnt use admin > commands > startup, but instead save as a firewall script, maybe even calling jffs2/or usb scripts so you workaround limitations of syntax etc, when saving something as a admin > command > something script.
Reason why save as firewall script, is because startup is only excetuted at startup, while firewall scripts are executed when you click apply (causing services to restart) or at startup. (yep egc taught me that)
I found that my "Save USB" script was executed TWICE!!! I think this deserves a new thread with serious discussion...
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Joined: 18 Mar 2014 Posts: 12915 Location: Netherlands
Posted: Wed Mar 30, 2022 10:27 Post subject:
WireGuard is even starting 3 times
Depending on how and what it can cause problems (if it starts before WAN is up and if you have multiple tunnels etc. )
I had to write a patch which serialize and use locking when starting WireGuard tunnels to counter these bootup problems (the patch is not in production yet).
I recently added Avahi to DDWRT (also needed expat, libdaemon and DBus) so I had to dive in again in the startup, because I wanted it to run as a service and at startup etc, but it really makes your head spin.
Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Posted: Wed Mar 30, 2022 10:54 Post subject:
I have noticed networking is initialized at least twice on router boot, I noticed more specifically that I get the static IP to the PC Ethernet, once and then its goes off again, to unrecognized network and the second time it stabilizes and regains that IP again.
So something is definitely not right. However discussing these issues with BS, requires a great deal of patience because everything is denied a few times and then maybe there comes a patch to fix whatever, honestly I dont have the patience or time to initiate these discussions at this time in my life, due to personal issues lately which have my head spinning and my life turned inside out and upside down.
discussing these issues with BS, requires a great deal of patience because everything is denied a few times and then maybe there comes a patch to fix whatever
hmmm ...well, at least that has not changed over the many years