What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Apply changes/updates to jffs scripts without rebooting Asus router

SanMiguel

New Around Here
Is it possible to apply changes made to scripts saved at /jffs/scripts/ (init-start and service-start) without rebooting the router?

For instance, sometimes I only change the time to execute a "cron command" loaded on service-start, but I noticed that until I reboot, the changes do not take effect...

Is there a way to force "refreshig jffs scripts" without rebooting or like a "soft reboot" or "on the fly"?

The main problem is that when rebooting, most of the time my USB stick where I have Entware-NG with lighttpd and PHP fails to mount... And I already had two major disasters where the USB drives went KAPUTT...

Or maybe a way to safely unmount the drive, reboot and mount the drive again to avoid data loss.

Any suggestions welcome!
Thanx!
SM
 
The short answer is "sometimes" ;).

There's nothing to stop you running any scripts at any time. But as these are user created scripts it's impossible to say whether it is appropriate or whether it would have the desired effect.

Some processes have (undocumented) restart commands, but some don't. i.e.

# service restart_dnsmasq

Sometimes you just need to kill and restart the process, i.e.

# killall dnsmasq
# dnsmasq --log-async


Others like cron are designed to be updated using the "contab -e" command (or cru).

But if you have a router that you can't reboot for fear of it "breaking" I suggest that you concentrate your efforts on fixing that first.:eek:
 
The short answer is "sometimes" ;).

There's nothing to stop you running any scripts at any time. But as these are user created scripts it's impossible to say whether it is appropriate or whether it would have the desired effect.

Some processes have (undocumented) restart commands, but some don't. i.e.

# service restart_dnsmasq

Sometimes you just need to kill and restart the process, i.e.

# killall dnsmasq
# dnsmasq --log-async


Others like cron are designed to be updated using the "contab -e" command (or cru).

But if you have a router that you can't reboot for fear of it "breaking" I suggest that you concentrate your efforts on fixing that first.:eek:



Thank you very much for your reply :)
But that was not what I meant.

I was referring to updating and refreshing User Scripts stored in the internal non-volatile flash in the JFFS partition in Asuswrt-Merlin.

Documentation here:
https://github.com/RMerl/asuswrt-merlin/wiki/User-scripts

For example, if I update something in this line contained in "init-start" (or add a new command to execute like this):

cru a DuckDNS "15 * * * * /opt/share/www/duckdns/duck.sh >/dev/null 2>&1"

How do I "force" changes to take effect without having to reboot the Asus Router (RT-AC56U)
Is it even possible?
Is there somewhere esle better than "init-start" to put that "CRON script" that can be updated without rebooting?
i don't mind "restarting services".

Cheer!
 
But that was not what I meant.

I was referring to updating and refreshing User Scripts stored in the internal non-volatile flash in the JFFS partition in Asuswrt-Merlin.
Yes, I understood the question and my answer still stands.

Even though you mentioned init-start, service-start and cron as examples, your question was a general one asking about all JFFS user scripts. It's impossible for me to know what all of your scripts do. There is no magic command that reruns all of the user scripts (other than restarting the router). Most of those scripts probably do things that only make sense at boot time (like firewall-start).

Each script would have to be looked at individually to determine the best course of action. For example, I have a post-mount script that performs some simple ad-blocking. Because of the way it is written it is re-runnable at any time. Other scripts aren't.

In your specific example from init-start. If you wanted to change the time, as well as updating the init-start script, you could use cru to delete the current (running) entry and add a new one. For example;

# cru d DuckDNS
# cru a DuckDNS "45 * * * * /opt/share/www/duckdns/duck.sh >/dev/null 2>&1"


EDIT: Fixed typo in cru command!
 
Last edited:
Mmmm, OK. I think I'm missing something...

I explicitly have these two lines (and some other similar commands) inside /jffs/scripts/init-start

#!/bin/sh
cru a DuckDNS "15 * * * * /opt/share/www/duckdns/duck.sh >/dev/null 2>&1"


Obviously, this gets executed when the router starts (or reboots) because it is inside "init-start" script.
I know I can edit init-start, but I always edit the script using "vi" and any changes/updates work until the router is rebooted and "init-start" is processed...

So... If I use "cru" from a command promt, will my updates be on-the-fly? Something like using "contab -e"?
Will the commands be "restored" on a reboot, or should I update "init-start" but also execute the command for changes to take effect without rebooting?

Thank you very much for your explanation!
 
For simplicity, I use /jffs/scripts/dnsmasq.postconf for adding the cron jobs in AB-Solution.
This way, whenever the rules need updating I can issue a
service restart_dnsmasq
for the changes to take effect.
The cru add does not necessarily need to be in the init-start.
Just make sure the device it references is mounted at the time.
The dnsmasq.postconf AB-Solution uses looks like this, I source a separate file where all the settings are kept and changed. The actual dnsmasq.postconf never changes once AB-Solution is installed, only ab_dnsmasq_postconf.sh:
Code:
#!/bin/sh

if [ -d "/tmp/mnt/<device name>" ];then
    source /tmp/mnt/<device name>/adblocking/scripts/ab_dnsmasq_postconf.sh
    logger "AB-Solution linked ab_dnsmasq_postconf.sh via $0"
fi
Make sure this file is executable.
 
I know I can edit init-start, but I always edit the script using "vi" and any changes/updates work until the router is rebooted and "init-start" is processed...
Sorry, you've lost me. What are you editing, init-start or duck.sh? Both exist in permanent storage (JFFS or USB) so changes to either should not be lost on reboot.

So... If I use "cru" from a command promt, will my updates be on-the-fly? Something like using "contab -e"?
Yes. cru allows you to add or remove lines from the crontab via the command line (or from within scripts). crontab -e has to be interactive because it uses a fullscreen editor.
Will the commands be "restored" on a reboot,
No, the crontab only exists in RAM (/tmp/var/spool/cron/crontabs)
or should I update "init-start" but also execute the command for changes to take effect without rebooting?
Yes, exactly.
 
Sorry, you've lost me. What are you editing, init-start or duck.sh? Both exist in permanent storage (JFFS or USB) so changes to either should not be lost on reboot.

Yes. cru allows you to add or remove lines from the crontab via the command line (or from within scripts). crontab -e has to be interactive because it uses a fullscreen editor.
No, the crontab only exists in RAM (/tmp/var/spool/cron/crontabs)Yes, exactly.


Thank you ALL very much for your suggestions and clarifications!

I have my “personal code and scripts” (like “duckDNS.sh”) stored in permanent USB storage, “init-start” is in JFFS (also permanent).

Now that I understand how “cru” and crontab work, the solution that worked for me was to execute my “cru” commands over telnet from the Asus Router command prompt to apply changes immediately to crontab AND also adding/updating "init-start" (where I keep ALL the “cru” commands I want to execute) so they get “automatically restored” in case someone reboots the router without my consent (or power outage...)

Cheers!
SM
 
For simplicity, I use /jffs/scripts/dnsmasq.postconf for adding the cron jobs in AB-Solution.
This way, whenever the rules need updating I can issue a
service restart_dnsmasq
for the changes to take effect.
The cru add does not necessarily need to be in the init-start.
Just make sure the device it references is mounted at the time.
The dnsmasq.postconf AB-Solution uses looks like this, I source a separate file where all the settings are kept and changed. The actual dnsmasq.postconf never changes once AB-Solution is installed, only ab_dnsmasq_postconf.sh:
Code:
#!/bin/sh

if [ -d "/tmp/mnt/<device name>" ];then
    source /tmp/mnt/<device name>/adblocking/scripts/ab_dnsmasq_postconf.sh
    logger "AB-Solution linked ab_dnsmasq_postconf.sh via $0"
fi
Make sure this file is executable.


Thank you very much for your suggestion!
I think what ColinTaylor suggested was a simpler solution for my needs.

Cheers!
SM
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top