WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Little piCore bug  (Read 172 times)

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 801
Little piCore bug
« on: January 09, 2025, 10:33:33 AM »
TCL 15.x armhf
RasPi Zero-W

I hadn't noticed this in the past (or may not have been in this situation?)
I have a CIFS mount to a NAS unit on the network using Zero's WiFi pointing to /mnt/os
I issued a reboot command and...

1. rc.shutdown calls sync ~line 10
2. WiFi disconnects from AP ~line 20 when processes are killed
3. rc.shutdown displays it's unloading file systems ~line 50+
4. System hangs (cannot cleanly unload CIFS since wireless is down)

Now it may have actually rebooted after so many minutes/timeout, but 30+ seconds went by before I did a hard reset

I created /etc/init.d/rc.dismount which I call from rc.shutdown after the sync command
Code: [Select]
#!/bin/busybox ash
. /etc/init.d/tc-functions
useBusybox

echo none > /sys/class/leds/ACT/trigger
echo mmc0 > /sys/class/leds/mmc0/trigger           # <-- resets the LED if being used for something else

##=> System hangs if CIFS is not dismounted before WIFI
MOUNTS=$(mount | grep -v loop | grep // | awk '{print $3}')   # <-- Get mount points that start with // (ie: //10.0.0.1/some/mount/point)
for MNT in $MOUNTS
do
    echo "${CYAN}Dismounting ${MAGENTA}$MNT${NORMAL}"
    umount $MNT
done

echo -n "${BLUE}"         # <-- to put things back how we found 'em
It's a simple hack, but does the trick :)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11735
Re: Little piCore bug
« Reply #1 on: January 09, 2025, 11:41:17 AM »
Hi CentralWare
Assuming pi hasn't deviated from x86/x86_64, this should
be possible without having to modify  /etc/init.d/rc.shutdown.

/usr/bin/exitcheck.sh calls /opt/shutdown.sh if it exists:
Code: [Select]
[ -x /opt/shutdown.sh ] && /opt/shutdown.sh
/opt/shutdown.sh has a line near the beginning that states:
Code: [Select]
# put user shutdown commands hereThis might be the right place to add your code.

After /opt/shutdown.sh completes, control returns to
/usr/bin/exitcheck.sh which executes either:
Code: [Select]
    sudo /sbin/rebootor:
Code: [Select]
    sudo /sbin/poweroff
/sbin/init then calls  /etc/init.d/rc.shutdown  as directed
by its  /etc/inittab  configuration file:
Code: [Select]
# Stuff to do when restarting the init
# process, or before rebooting.
::restart:/etc/init.d/rc.shutdown
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/etc/init.d/rc.shutdown

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1291
Re: Little piCore bug
« Reply #2 on: January 09, 2025, 12:15:52 PM »
piCore follows tinycore CoreScripts.

exitcheck.sh is what should be called.  That is what the graphical environments call.

The other thing I do is to add the PID of wpa_supplicant into /tmp/k5skip
This keeps wifi up for just a bit longer as other processes get killed.


Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 801
Re: Little piCore bug
« Reply #3 on: January 10, 2025, 02:31:36 AM »
exitcheck.sh is what should be called.  That is what the graphical environments call.
Yes, what graphical environments call...
...but I didn't think it got called from sudo poweroff/restart directly (VERY few TCL related devices here or at the office have a desktop.)
Just like /opt/shutdown.sh --- also a GUI script

Quote
The other thing I do is to add the PID of wpa_supplicant into /tmp/k5skip
Okay...  so we skip WPA getting the boot...  file systems are already shut down...  yeah, that sounds reasonable!  (WPA and its endless chatter -- if being logged to SD/Flash/etc I could see that ending poorly.  When we disconnect the file systems, this should be prevented I'm assuming.)  I still like the idea, though, of potentially looping through everything non-tcz related and dismounting cleanly.  I'm going to do some experimenting with all sorts of mounting methods and see what shakes loose.

NOTE: I ran a pair of tests about half an hour ago -- there IS an eventual timeout (I didn't time it -- I left the room after a sudo reboot was called on a pair of Pi-Zero-W and about 5 minutes later when I had returned they had done so already. Somewhere ~1-5 minutes is our "ignore and continue.")

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11735
Re: Little piCore bug
« Reply #4 on: January 10, 2025, 01:32:11 PM »
Hi CentralWare
exitcheck.sh is what should be called.  That is what the graphical environments call.
Yes, what graphical environments call... ...
You should also call it when running in text mode, like this:
Code: [Select]
exitcheck.sh rebootor like this:
Code: [Select]
exitcheck.sh shutdown
Quote
... ...but I didn't think it got called from sudo poweroff/restart directly ...
It doesn't get called from sudo poweroff/restart. It calls sudo poweroff/restart reboot:
Code: [Select]
#!/bin/busybox ash
# Check for optional local shutdown before actual shutdown/reboot.
# Called from exittc
# (c) Robert Shingledecker 2006-2010
. /etc/init.d/tc-functions
useBusybox

[ -x /opt/shutdown.sh ] && /opt/shutdown.sh

ACTION="$1"
case "$ACTION" in
  reboot )
    sudo /sbin/reboot
  ;;
  shutdown )
    sudo /sbin/poweroff
  ;;
  * )
    sudo /sbin/poweroff
  ;;
esac

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 801
Re: Little piCore bug
« Reply #5 on: Today at 12:52:02 AM »
It doesn't get called from sudo poweroff/restart. It calls sudo poweroff/restart reboot:
Yeah...  yeah...  reboot...  restart...
When posting at 2:30 in the morning I get a pass! :) Artistic License!?!?

Quote
exitcheck.sh reboot
Yeah...  nah...  my fingers are programmed "suuuudoooo  reSTART :)"
Deviating after all these years could cause more harm than good.
The CerialBellum isn't as flexible as it used to be.  What's that called...  short-temper memory loss?

LOL - I appreciate everyone's efforts and thinking outside the hostname=box

If others gripe over existing mounts hanging at poweroff/resomething we'll worry about it then; in the meantime it'll just be a core fork on our end once I've finished experimenting with other mounts/filesystems.

Take care and have a wonderful weekend!  Another 5" of the "S" word in the past ~5 hours -- fewer idiots on the road tonight, hopefully!?!?

N A H ! !