WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Running custom script at halt/reboot  (Read 6085 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Running custom script at halt/reboot
« on: November 27, 2009, 08:41:40 AM »
I'm missing a custom script which is executed during shutdown/reboot. A practical example is to save amixer settings in a file to restore volume for next boot.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline fratermus

  • Newbie
  • *
  • Posts: 9
Re: Running custom script at halt/reboot
« Reply #1 on: November 27, 2009, 08:39:48 PM »
Agreed;  something like an /opt/shutdownlocal.sh companion to /opt/bootlocal.sh would be useful.

Coincident with the change to the busybox-provisioned mount  my /mnt/sdb1 no longer gets u[n]mounted at shutdown, resulting in errors that have to be fscked away ("not cleanly unmounted" or similar).    At least I think that's what's happening.  If I umount it manually then reboot all is well.  If I leave it mounted and reboot, it won't mount again until fsck.ext2 cleans it up. 

Having /opt/shutdownlocal.sh would allow me to programatically umount the flash card as part of the shutdown process. 

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Running custom script at halt/reboot
« Reply #2 on: November 28, 2009, 01:27:54 AM »
Sounds completely reasonable. Will do for 2.7.
10+ Years Contributing to Linux Open Source Projects.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: Running custom script at halt/reboot
« Reply #3 on: November 28, 2009, 02:00:43 AM »
How about adding a line to exitcheck.sh? (Is exitcheck always called?)

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Running custom script at halt/reboot
« Reply #4 on: November 28, 2009, 02:03:13 AM »
Yes, as you can surely see umix is commented out in exitcheck, so that would be where the call would occur.
10+ Years Contributing to Linux Open Source Projects.

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Running custom script at halt/reboot
« Reply #5 on: November 28, 2009, 03:41:16 PM »
ditto bmarkus's request, though it looks like there's plenty of interest!

Personally, my mydata.tgz file gets corrupted every once in awhile (don't really know why yet?) So I have a script to move the current mydata.tgz into a backup directory before creating the 'new' backup. Allows me to revert in case of any errors.

I was using a modified exitcheck.sh, as jur suggested. Seemed kind of dirty, though...

Offline baz

  • Full Member
  • ***
  • Posts: 216
Re: Running custom script at halt/reboot
« Reply #6 on: December 15, 2009, 02:12:32 AM »
Would this upcoming /opt/shutdownlocal.sh be a good place to unmount my NFS shares that are mounted at boot? Currently shutdown takes a while and displays errors relating to those mounts.

Cheers.

Offline mikshaw

  • Sr. Member
  • ****
  • Posts: 368
Re: Running custom script at halt/reboot
« Reply #7 on: December 15, 2009, 09:38:32 AM »
jur and roberts:  I think that might be assuming too much about the user.  Are you sure exitcheck.sh is always used?  What about those who bypass the TC-specific behavior: kill X and do sudo halt/reboot?

The file /etc/init.d/rc.shutdown is pretty much universally used for this purpose.  It seems that exitcheck.sh was added specifically for backup.  I think a local writable shutdown script in would be more reliably called by rc.shutdown.

Offline Pats

  • Sr. Member
  • ****
  • Posts: 322
Re: Running custom script at halt/reboot
« Reply #8 on: January 01, 2010, 04:52:43 AM »
Knoppix has a nice feature : Save Current Configuration - which allows to save all changes made to .xyzfile (hidden configuration files including /etc/files, Desktop items, mozilla config files etc ) to some HDD/SDA partitions.
And using boot code : myconfig=scan one can restore all the saved settings during next boot.
I like that feature, hope it is already implemented ( I am not aware abt it, since I am still using TCL2.4 due to my specific needs ).
~ Pats

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: Running custom script at halt/reboot
« Reply #9 on: January 01, 2010, 05:35:25 AM »
isn't this the same as tinycore's backup/restore?

Offline Pats

  • Sr. Member
  • ****
  • Posts: 322
Re: Running custom script at halt/reboot
« Reply #10 on: January 01, 2010, 07:08:38 AM »
Yah , It may be like that, but as fratermus has pointed out, I was also facing the problem of corrupted backup of my TCL backup partition  abt which I had posted sometime back in XP rebooting problem.
( I am still using v2.4 due to my specific needs - am hapy with it , though I have tried v2.6 also)

So I kept a separate copy of my succesful setup backup in another
location and I just replace the corrupted TCL backup file with this good backup, whenever needed. I solved my problem on my end like this.

I am eagerly waiting for a nice, stable, feature rich verion of TCL -may be V3 or v4. :)

~ Pats

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running custom script at halt/reboot
« Reply #11 on: January 01, 2010, 07:19:19 AM »

I am eagerly waiting for a nice, stable, feature rich verion of TCL -may be V3 or v4. :)

~ Pats


Hm... Are you saying that current version is not stable? Don't think so. Not feature reach? It is much up to the user's wish and hope. But in my view TC as she is now IS feature reach. Not for dummies? Requires some knowledge on LINUX and computers? Challanging some time? Yes. It is her beauty.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Pats

  • Sr. Member
  • ****
  • Posts: 322
Re: Running custom script at halt/reboot
« Reply #12 on: January 01, 2010, 07:32:42 AM »
Quote
Hm... Are you saying that current version is not stable? ....
Looking at various posts in this forum with different difficulties abt TCL uses along with diff suggestions and expectations and the subsequent upgradations and corrections by TCL Team, I honestly think TCL may need quite a lot improvement in its current version.
And there is nothing wrong in TCLs present form, even the latest Slackware, Debian, RH etc are not perfect to the mark of users and admins expectations.
All systems evolve slowly to good, stable , feature rich final products over the years. And TCL is just quite young in that sense - is not it ? :)
But still many of us love the exciting experience while using TCL !
~ Pats