Tiny Core Base > Raspberry Pi

Little piCore bug

(1/2) > >>

CentralWare:
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: ---#!/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

--- End code ---
It's a simple hack, but does the trick :)

Rich:
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: ---[ -x /opt/shutdown.sh ] && /opt/shutdown.sh
--- End code ---

/opt/shutdown.sh has a line near the beginning that states:

--- Code: ---# put user shutdown commands here
--- End code ---
This 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: ---    sudo /sbin/reboot
--- End code ---
or:

--- Code: ---    sudo /sbin/poweroff
--- End code ---

/sbin/init then calls  /etc/init.d/rc.shutdown  as directed
by its  /etc/inittab  configuration file:

--- Code: ---# 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
--- End code ---

Paul_123:
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.

CentralWare:

--- Quote from: Paul_123 on January 09, 2025, 12:15:52 PM ---exitcheck.sh is what should be called.  That is what the graphical environments call.

--- End quote ---
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
--- End quote ---
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.")

Rich:
Hi CentralWare

--- Quote from: CentralWare on January 10, 2025, 02:31:36 AM ---
--- Quote from: Paul_123 on January 09, 2025, 12:15:52 PM ---exitcheck.sh is what should be called.  That is what the graphical environments call.

--- End quote ---
Yes, what graphical environments call... ...
--- End quote ---
You should also call it when running in text mode, like this:

--- Code: ---exitcheck.sh reboot
--- End code ---
or like this:

--- Code: ---exitcheck.sh shutdown
--- End code ---


--- Quote --- ... ...but I didn't think it got called from sudo poweroff/restart directly ...
--- End quote ---
It doesn't get called from sudo poweroff/restart. It calls sudo poweroff/restart reboot:

--- Code: ---#!/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
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version