easyddup a simple upgrade/downgrade utility

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page Previous  1, 2, 3 ... 16, 17, 18, 19, 20, 21  Next
Author Message
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Mon Oct 24, 2022 17:14    Post subject: Reply with quote
Well ash has no support for job control in any case the shebang in these scripts is for ash not bash but to run the scripts sh +/-switch <scriptname> should work. Bash will also run ash shebang crap with the obvious implications.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
Sponsor
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Mon Oct 24, 2022 18:13    Post subject: Reply with quote
I narrowed it down to the first line of the startup script:

# AR - 09-08-2018, 21-09-2018, 17-10-2018, 21-05-2020, 27-05-2020, 13-09-2020,

It's a comment ... what can I say?

If I remove it, nvram-save.sh runs ok ...

Something fishy ...

The shutdown script has the 'same' line, just different dates, and it doesn't cause a crash.

My shutdown script:

# AR - 02-05-2022, 04-06-2022, 13-06-2022
# Shutdown script
logger -t --- "$0 script: Stopping rc.unslung"
/opt/etc/init.d/rc.unslung stop
sleep 5
logger -t --- "$0 script: Unmounting /jffs and /opt"
umount -f /jffs
umount -f /opt
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Mon Oct 24, 2022 18:28    Post subject: Reply with quote
you souldnt add useless stuff to scripts it all takes space in nvram, spacing and such and new lines all should be one line for ultimate space saving. It also makes script size smaller.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)


Last edited by the-joker on Mon Oct 24, 2022 18:31; edited 2 times in total
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Mon Oct 24, 2022 18:28    Post subject: Reply with quote
Could it be the overall startup script length that's too big:

3824 bytes when nvram-save.sh still works, a few bytes more and it crashes.

I removed the dates from the first line and it worked.
I could add two dates, but not three before it crashed. (characters added by typing)

EDIT:
Later I added rc_firewall and rc_usb to the ini file.
Even though rc_firewall is longer and starts with the same kind of comment line as rc_startup, this didn't cause any segmentation fault.
Odd ...
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Mon Oct 24, 2022 23:14    Post subject: Reply with quote
the-joker wrote:
you souldnt add useless stuff to scripts it all takes space in nvram, spacing and such and new lines all should be one line for ultimate space saving. It also makes script size smaller.


OK. I get it. However, comments are helpful for the human administering it all.
So ... the way to go is to store all scripts in /jffs or /opt ...

Thanks.
An automatic backup of /jffs and /opt has been arranged in the mean time.

EDIT:
all 4 scripts moved to /jffs successfully ... router boots, looks normal ...
nvram backup size went down by about 20% from 51 kB to 41 kB.

No shebangs in the scripts btw. Never had ...
Is that OK?

The syslog doesn't show any logger command output now.
Maybe better read the script file like in
< /jffs/whatever


Last edited by ArjenR49 on Tue Oct 25, 2022 0:30; edited 1 time in total
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14246
Location: Texas, USA

PostPosted: Tue Oct 25, 2022 0:04    Post subject: Reply with quote
the-joker wrote:
Well ash has no support for job control...

Unless the .config*** files here are not used, uhm....

https://svn.dd-wrt.com/browser/src/router/busybox/.config_std#L914

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Tue Oct 25, 2022 0:26    Post subject: Reply with quote
the-joker wrote:
Its easier to run the script with debug bash|sh -x <scriptname> You also have set -x or set +x and further you have -v which can be done as bash|sh -xv <scriptname>

e.g. reference https://linuxconfig.org/how-to-debug-bash-scripts


eeh .. was that supposed to mean:
use either
bash -x <scriptname>
OR
sh -x <scriptname>

I ran literally bash|sh -x <scriptname> ... it didn't complain
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 373

PostPosted: Tue Oct 25, 2022 13:07    Post subject: Reply with quote
ArjenR49 wrote:
Later I added rc_firewall and rc_usb to the ini file.
Even though rc_firewall is longer and starts with the same kind of comment line as rc_startup, this didn't cause any segmentation fault.
Odd ...
I was subscribed to the busybox mailing list for a while. There was quite a bit of traffic from users trying to run scripts that worked on other platforms and were failing on busybox. For nvram-save.sh, these dd-wrt scripts are just data to save/restore like any other variable.

My gut feeling is the segmentation fault is a lower level bug in busybox not nvram-save.sh. A buggy script shouldn't segfault.

Adding rc_custom, rc_firewall and rc_usb to the sample ini file in the easyddup package sounds like a good idea.
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Tue Oct 25, 2022 13:56    Post subject: Reply with quote
So I tried with all 4 command scripts on /jffs.
At first it looked like the router worked OK, but is was already past 2 a.m. and I wasn't too sharp.

The troubles showed up in the morning:

My startup script has commands for a virtual LAN and the VLAN broke.
I had to put that handful of commands (starting with swconfig, vconfig and brctl) back into the GUI.
The rest is still in the script which resides on /jffs, but it doesn't look like it's working, either.

Later I noticed my firewall rules to accommodate the virtual LAN etc. were obviously not in action. So I had to put those back into the GUI, too.

At the moment only the shutdown and USB scripts reside on /jffs and are called in the GUI.
It remains to be seen if they actually work this way, unlike the firewall script. It doesn't cause immediate havoc when they don't.

The command I call the scripts with is of this form:

/jffs/command_scripts/<script name>

I tried with
< /jffs/command_scripts/<script name>
as well. Can't tell if there was a difference.

Either the way I call the scripts is wrong, or it cannot work that way, which I doubt.

None of the scripts currently have a shebang ...
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 373

PostPosted: Tue Oct 25, 2022 15:38    Post subject: Reply with quote
Are you sure your storage is up and ready when the scripts get run? I've had this as my first startup command for ages. I think people have something better these days if you search the forums.
Code:
/bin/sh -c 'until [ -f /opt/etc/init.d/rc.unslung ]; do sleep 1 ; done'
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 373

PostPosted: Wed Oct 26, 2022 2:59    Post subject: Reply with quote
I tried adding a bunch of that fateful comment to the beginning of my startup script to make it 6790 bytes and couldn't get nvram-save.sh to segfault. What's your dd-wrt build number and busybox version shown when logging in at the terminal in case busybox has fixed this already? Also dd-wrt has recently removed windows CRLF line endings from multi-line variables in favor of linux line endings so no more Ctrl-M's.

Can you PM me a zipped startup script that causes segfaults?
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Wed Oct 26, 2022 21:58    Post subject: Reply with quote
I haven't been able to find out why the first line in my startup script, a comment line, caused the recurring Segmentation fault when running nvram-save.sh, so I took it out.
In order to save nvram, I attempted to move all scripts from the GUI to /jffs, but ran into trouble. Probably tried to change too much at once.

After going back to all command scripts in the GUI, and based on experience gained along the way, I did away with the usb script, moving its essence to the startup script.
Moving all of the startup script to a file on /jffs didn't work, but moving the last part, which only contains the code to mount USB drives to fixed mounting points by UUID, is apparently ok being called from the GUI startup command window as a script on /jffs.

Setting up a VLAN, changing cpu governor settings, waiting for /opt to be mounted, setting dnsmasq.leases to be written to /jffs and starting rc_unslung, seem best to be left in the GUI startup window.

Moving all of the firewall script to /jffs is OK, as far as I have been able to check.

All of the shutdown script is still in the GUI. It contains code to stop rc_unslung, unmount /jffs and /opt and finally do a check with automatic repair of the file system of these two partitions with e2fsck.

/jffs and /opt reside on a USB thumbdrive which has a tendency to develop faults in its file systems. I use to check them on a Linux Mint system every now and then. The disks utility says there are faults. The repair is said to be unsuccessful, but a renewed check turns up a clean fs.
The check with e2fsck in the shutdown script is an attempt to correct these faults automatically, but in reality I don't know when the shutdown script runs. Likely not when it matters most, namely when cutting power to the router.

There's a logout button the the GUI of recent builds, but no shutdown button for a clean powering down.

The way to call a script on /jffs from the GUI command window, that works best for me, is like this:

sh /jffs/<directory>/<script>.sh
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 373

PostPosted: Thu Oct 27, 2022 1:12    Post subject: Reply with quote
ArjenR49 wrote:
/jffs and /opt reside on a USB thumbdrive which has a tendency to develop faults in its file systems. I use to check them on a Linux Mint system every now and then. The disks utility says there are faults. The repair is said to be unsuccessful, but a renewed check turns up a clean fs.
The check with e2fsck in the shutdown script is an attempt to correct these faults automatically, but in reality I don't know when the shutdown script runs. Likely not when it matters most, namely when cutting power to the router.

My shutdown script in the GUI starts with the following so I can track when it runs.
Code:
echo 'in rc_shutdown at: ' $(/bin/date) >> /mnt/sda3/shutdown.txt

I solved the faults on the thumbdrive by buying good USB storage that can run ext4 and journaling.
ArjenR49 wrote:
There's a logout button the the GUI of recent builds, but no shutdown button for a clean powering down.

That sounds like a good enhancement request for creating a ticket. I've got an alias in my .profile so I can clean power down. I also have one for reboot.
Code:
"alias shutdown='cd;startservice run_rc_shutdown'

ArjenR49 wrote:
The way to call a script on /jffs from the GUI command window, that works best for me, is like this:

sh /jffs/<directory>/<script>.sh

Maybe if your scripts had a shebang they'd run from the GUI without the sh prefix.
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Thu Oct 27, 2022 10:48    Post subject: Reply with quote
yoyoma2 wrote:
ArjenR49 wrote:
/jffs and /opt reside on a USB thumbdrive which has a tendency to develop faults in its file systems. I use to check them on a Linux Mint system every now and then. The disks utility says there are faults. The repair is said to be unsuccessful, but a renewed check turns up a clean fs.
The check with e2fsck in the shutdown script is an attempt to correct these faults automatically, but in reality I don't know when the shutdown script runs. Likely not when it matters most, namely when cutting power to the router.

My shutdown script in the GUI starts with the following so I can track when it runs.
Code:
echo 'in rc_shutdown at: ' $(/bin/date) >> /mnt/sda3/shutdown.txt


Great tip! I applied it immediately. When I rebooted the router I could see afterwards that rc_showdown ran.

I solved the faults on the thumbdrive by buying good USB storage that can run ext4 and journaling.

I have some M2 SSD's in USB enclosures that I could use, but it feels like overkill. The thumbdrive I use is just 2GB and is plenty big at that ... You can't get them so small anymore. I'd rather keep the M2's for my Raspberry Pi's ...

ArjenR49 wrote:
There's a logout button the the GUI of recent builds, but no shutdown button for a clean powering down.

That sounds like a good enhancement request for creating a ticket. I've got an alias in my .profile so I can clean power down. I also have one for reboot.
Code:
"alias shutdown='cd;startservice run_rc_shutdown'

Now that I've got shutdown script 'tracking' I must try the logout function, although I don't suppose it run the shutdown script.

I know about the alias thing per se. I haven't used aliases myself and I don't know about .profile. I suppose it must be a file in the R7800 router that maybe I can edit in an ssh session ??
Having a shutdown command sounds very sensible.

ArjenR49 wrote:
The way to call a script on /jffs from the GUI command window, that works best for me, is like this:

sh /jffs/<directory>/<script>.sh

Maybe if your scripts had a shebang they'd run from the GUI without the sh prefix.


It should work like that, too, and it probably does, but considering all the malfunctioning that came down upon me when I tried to change too much at the same time, I figured I leave it at calling with sh when I got back in control of the router ...

I tried bash, too, because I know there are essential differences in syntax, and I thought I may have used some in a script, but it looked like the command windows can't use bash even though it has been installed, I think. While the router is starting up or shutting down, it is hard to tell what is available and when from USB memory, like /opt and /jffs.


One of my reasons to use dd-wrt is that I have hundreds of hours of effort in it, so if one day I need a new router, I hopefully can switch without another hundreds of hours of work on a different GUI/OS.

I am sorry this post is a bit messy. I've got a BT keyboard problem. The cursor suddenly jumps elsewhere sometimes. The keys are too close together. It's hard to use. The laptop's own keyboard is malfunctioning, dropping some keys.
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 666
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Thu Oct 27, 2022 10:57    Post subject: Reply with quote
yoyoma2 wrote:

Code:
"alias shutdown='cd;startservice run_rc_shutdown'



I suppose the double quote before alias is a mistake.

I found /etc/profile and am adding the shutdown alias as I write. Let's see what happens when I send that command.

EDIT:
/etc/profile is the wrong place as I could have guessed. It is read only...
There was no .profile to be seen (ls -la command)

Should I add the alias to /opt/etc/profile?
Goto page Previous  1, 2, 3 ... 16, 17, 18, 19, 20, 21  Next Display posts from previous:    Page 17 of 21
Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload 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 cannot attach files in this forum
You cannot download files in this forum