Tiny Core Linux
Tiny Core Base => Micro Core => Topic started by: mattrix on March 27, 2011, 11:59:55 PM
-
The title says it,
I want to automate some things after poweroff or reboot is typed,
thanks
-
Hi mattrix
Check out the /opt directory, there are 3 .sh files for what you want to do.
-
Hey Rich
I looked at shutdown.sh but it doesn't seem to be called.
The others are for startup.
A stoplocal.sh would be nice.
-
Hey Rich
I looked at shutdown.sh but it doesn't seem to be called.
The others are for startup.
A stoplocal.sh would be nice.
poweroff is a built-in unix command, it does not start scripts. shutdown.sh is used by TC's own exit utility.
-
so, can I call a script from rc.shutdown then?
-
Hi mattrix
Until someone posts the correct way , try calling your script near the beginning of rc.shutdown.
-
cat `which exitcheck.sh`
-
Until someone posts the correct way
I gotta stop looking for the correct way, and think laterally.
Hows this sound?
Poweroff is in busybox, I just have to link poweroff to my script and call busybox directly from the script.
matt
Now to learn bash scripting, google IS sometimes my friend.
-
IMHO sounds
1. like a dirty hack
2. like reinventing the wheel - when a proper mechanism is provided by the system already
However, that does not mean it could not potentially do the job for a particular system.
Note: bash is not included in base, sh scripting might be preferable where it can be sufficient.
-
So simple. Create two scripts which do what you want, then run poweroff/reboot at the end of it.
You can name these scripts creatively, I would prefer them to be short for my own use.
-
2. like reinventing the wheel - when a proper mechanism is provided by the system already
What is the mechanism provided by the system? The only option I see is replacing rc.shutdown with my own script which calls the original rc.shutdown after doing its thing. I'd rather like rc.shutdown have a line somewhere at the top like
[ -x /opt/shutdown.sh ] /opt/shutdown.sh
-
What is the mechanism provided by the system?
The /etc/inittab (http://git.busybox.net/busybox/tree/examples/inittab) file is the mechanism provided by the system:
::restart:/etc/init.d/rc.shutdown
::restart:/sbin/init
::shutdown:/etc/init.d/rc.shutdown
Simply add your script:
::restart:/usr/local/sbin/myrestart
::restart:/etc/init.d/rc.shutdown
::restart:/sbin/init
::shutdown:/usr/local/sbin/myshutdown
::shutdown:/etc/init.d/rc.shutdown
-
2. like reinventing the wheel - when a proper mechanism is provided by the system already
What is the mechanism provided by the system?
See Reply #3 & Reply #6