Startup scripts on JFFS not executing - My solution

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
gravitron
DD-WRT Novice


Joined: 13 May 2017
Posts: 4

PostPosted: Wed Mar 18, 2020 15:24    Post subject: Startup scripts on JFFS not executing - My solution Reply with quote
Here's how I addressed the issue of ever-increasing time before the USB drive hosting my JFFS becomes available. That situation leads to the startup script(s) on JFFS never being executed.

In the Administration->Commands screen, create a startup script in NVRAM that looks like this:

#!/bin/sh
until [ -f /jffs/IPL.sh -a `nvram get wan_ipaddr` != "0.0.0.0" ]; do
sleep 1
done
/bin/sh /jffs/IPL.sh


In essence, the NVRAM startup script launches the JFFS startup script (IPL.sh in my setup) only after (1) USB drive is mounted and (2) WAN is up. It checks for those 2 conditions every second. That way, no need to code a fixed delay that might need adjustments.

Hope this helps someone else.
Sponsor
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Sun Mar 22, 2020 20:31    Post subject: Reply with quote
Thanks for sharing! I just noticed entware wasn't always starting up on my dev/backup router. Added a one-liner based on yours as the first startup command and the race condition is gone. The second line is the usual entware startup command.

Code:
/bin/sh -c 'until [ -f /opt/etc/init.d/rc.unslung ]; do sleep 1 ; done'
/opt/etc/init.d/rc.unslung start
dTX
DD-WRT User


Joined: 28 Dec 2018
Posts: 83

PostPosted: Sun Jul 25, 2021 16:47    Post subject: Reply with quote
Let me add alternative version for anyone running scripts from USB or SD Card on startup:

Code:
/bin/sh -c 'until $(mount | grep -q '/dev/sda2'); do sleep 1; done'

or
Code:
/bin/sh -c 'until $(df | grep -q '/dev/sda2'); do sleep 1; done'


Adjust the sda... part to your needs Smile

_________________
Router: ASUS AC1900(RT-AC68U)
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1852
Location: Hung Hom, Hong Kong

PostPosted: Mon Jul 26, 2021 3:58    Post subject: Reply with quote
Please also post to Contribution Upload? Use a better topic like "Entware rc.unslung not always working":

DD-WRT Forum :: View Forum - Contributions Upload
https://forum.dd-wrt.com/phpBB2/viewforum.php?f=11

I thiunk the Wiki needs an update as well.

Installing Entware - DD-WRT Wiki
https://wiki.dd-wrt.com/wiki/index.php/Installing_Entware

I think waiting for rc.unslung is the best solution, and the "sleep" could be longer than 1 second to further reduce init delay.


_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Wed Jul 28, 2021 2:08    Post subject: Reply with quote
i wish i had seen these suggestions a year ago, but with the more recent firmwares there is a USB startup script you can use:


USB script.jpg
 Description:
 Filesize:  51.78 KB
 Viewed:  2266 Time(s)

USB script.jpg


Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum