Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: lovelypp on March 27, 2023, 03:19:04 AM
-
there is a script /opt/shutdown.sh,but when reboot, it is not executed.
I want to execute a script when user run reboot, how ?
thanks!
-
The shutdown script gets ran from exitcheck.sh
https://github.com/tinycorelinux/Core-scripts/blob/master/usr/bin/exitcheck.sh
-
Hi lovelypp
If you call:
exitcheck.sh reboot
then /opt/shutdown.sh will get called right before the system reboots.
If you call:
exitcheck.sh poweroff
then /opt/shutdown.sh will get called right before the system powers off.
When using a GUI, the Exit icon and the Exit from the desktop menu call exitcheck.sh the same way.
If you want /opt/shutdown.sh to know it was called to reboot or poweroff , add this to /opt/shutdown.sh:
ACTION="$(busybox ps | grep "exitcheck.sh")"
case "$ACTION" in
*"reboot"*)
# Commands to execute right before
# you reboot go here.
;;
*"poweroff"*)
# Commands to execute right before
# you power off go here.
;;
*)
# What to do if exitcheck.sh gets called
# with no or incorrect value goes here.
;;
esac
If you want to run something after you reboot, add this line to the reboot section:
touch /etc/sysconfig/tcedir/REBOOT
Then add the following to /opt/bootsync.sh or /opt/bootlocal.sh:
if [ -e /etc/sysconfig/tcedir/REBOOT ]
then
rm -f /etc/sysconfig/tcedir/REBOOT
# Commands to execute after
# you reboot go here.
fi
-
thanks