SOLVED - How to force reboot via CLI

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Goto page Previous  1, 2
Author Message
kernel-panic69
DD-WRT Guru


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

PostPosted: Mon Oct 23, 2023 13:43    Post subject: Reply with quote
ArjenR49 wrote:
Upgraded my R7800 from build 53714 to 53734 half an hour ago using easyddup.
Had to resort to the Linux Magic System to reboot:
echo b > /proc/sysrq-trigger

Rebooted using the GUI a few times after that. The Magic reboot had left one of the thumbdrive partitions 'dirty' judging from result of the e2fsck check in my shutdown command script (rsyslog).

If this is going to be the new routine, it should be helpful to precede the boot trick with:
echo s > /proc/sysrq-trigger
echo u > /proc/sysrq-trigger
for sync and unmount ...

_________________
"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
Sponsor
mwchang
DD-WRT Guru


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

PostPosted: Tue Nov 07, 2023 8:47    Post subject: Reply with quote
For the record:

Beware that the reboot command is not exactly a command, but a function in Ash shell script /etc/profile. To access the TRUE reboot command directly, specify the full path "/sbin/reboot"! But then there will be no shutdown script execution.
Code:
# cat /etc/profile
export PATH=/bin:/usr/bin:/sbin:/usr/sbin ....
....
reboot() {
  for f in /opt/etc/init.d/K* ; do
    [ -x "$f" ] && "$f" stop
  done
  echo "#!/bin/sh" > /tmp/.rc_shutdown
  echo "$(nvram get rc_shutdown)" >> /tmp/.rc_shutdown
  if [ -f /tmp/.rc_shutdown ]; then
    chmod +x /tmp/.rc_shutdown
    /tmp/.rc_shutdown
  fi
  /sbin/reboot
  }

_________________
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
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6447
Location: UK, London, just across the river..

PostPosted: Wed Nov 08, 2023 7:32    Post subject: Reply with quote
have you tried it, when reboot command is stalling ?
as not all shell commands are working...
i also tried to give it a path and some other tricks, but at last the magic number was the shortest cut... Razz (at least it worked) as my R7800 is in the locked room and me miles away of it...and lots of clients rely on it to be operational...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
mwchang
DD-WRT Guru


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

PostPosted: Wed Nov 08, 2023 13:03    Post subject: Reply with quote
Alozaros wrote:
have you tried it, when reboot command is stalling ?
as not all shell commands are working...
i also tried to give it a path and some other tricks, but at last the magic number was the shortest cut... Razz

Maybe the better question is:

Why isn't /sbin/reboot using the magic key to reboot, also after running the shutdown script? Better, run sync (also magic key) as well to flush all disk caches.

I suspect /sbin/reboot is not DD-WRT's own work. The answer is of course in the source codes. Well... if you got time... Smile

_________________
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
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions 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