FedoraForum.org - Fedora Support Forums and Community
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2010
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    halt.local / rc.local.shutdown for Fedora?

    Is there a file in Fedora that is executed before the standard shutdown / reboot scripts? With Arch Linux there is rc.local.shutdown and OpenSUSE has halt.local. They serve as the complimentary file to rc.local, where a user can dump custom commands to be executed.

    I found a way to do this with Ubuntu using update-rc.d, although it's not quite as straight forward as the Arch / SUSE methods. Doing some research on Fedora landed me on outdated articles and forum posts. The closest thing I could find was a reference to /sbin/halt.local, but this file does not exist on my Fedora 13 system.

    If I create a file called /sbin/halt.local and make it executable, will Fedora automatically treat it in the same manner as the other distros?

    If there's a better way to achieve this, I don't mind trying something new.

  2. #2
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: halt.local / rc.local.shutdown for Fedora?

    You can always put in a script in the rcx.d directories (or more properly
    put in /etc/init.d). As long as the name in rcx.d occurs in K00<name>,
    then it will be invoked FIRST (as there are no other K00 names in there.

    If you want it last (after all the others) there are only cpuspeed and
    and lvm2 scripts that are present, so name it K99z<something>.

    If you want it run first on startup name it with S00<something>, if last
    then name it with S99z<something>.

    This is as far as the SysV init style can go. upstart has a different configuration, and I'm sure systemd will be something else...

    Upstart configurations are in /etc/init. Maybe you can identify something
    that can do what you want.

  3. #3
    Join Date
    Dec 2009
    Location
    Belgium
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: halt.local / rc.local.shutdown for Fedora?

    It's /etc/rc0.d/ (for shutdown) or /etc/rc6.d/ (for reboot) you want to save your scripts in.

  4. #4
    Join Date
    May 2010
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: halt.local / rc.local.shutdown for Fedora?

    Thanks for the replies!

    Here is a follow up, since I got it working on Fedora. I had to do something similar to the method in Ubuntu, but it works, and that's all that matters.

    I used your advice about the SysV style of handling startup/shutdown. The only thing I had to do differently was use S instead of K. When I gave it default "stop" values (K), it was ignored when I shut down. I guess this is because it's not an actual service, so it was never really "running." This is just a script that executes my custom commands before shutdown/reboot. So I have it "start" before everything else on shutdown.

    Here is what I did, with some insight from your posts.

    I created the file and saved it as /etc/init.d/custom-halt, and made it executable.

    I then did chkconfig --add custom-halt, which created sym-links in rc0.d and rc6.d, since I made those the "Default-Start" for this script, and it named them as S00custom-halt inside those two directories.

    This is what it looks like inside the custom-halt file.

    Code:
    #! /bin/sh
    
    # chkconfig: - 00 00
    # description: Do custom commands before shutdown or reboot
    
    ### BEGIN INIT INFO
    # Provides: custom-halt
    # Required-Start:
    # Required-Stop:
    # Default-Start: 0 6
    # Default-Stop:
    # Short-Description: Custom halt commands
    # Description: Do custom commands before shutdown or reboot
    ### END INIT INFO
    
    command 1
    
    command 2
    
    command 3
    
    command 4
    
    exit
    I used other services under /etc/init.d/ as an idea of what format I should follow. The two most important parts are the lines # chkconfig - 00 00 and # Default-Start: 0 6. I chose 00 (for S00) because I want it to execute before anything else when the system halts.

    It ain't no halt.local, but it does its job!
    Last edited by flansuse; 10th December 2010 at 04:08 AM.

  5. #5
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: halt.local / rc.local.shutdown for Fedora?

    You got it -. S00xxx is invoked when the run level is started/entered. K00xxx
    would be called when the runlevel is ended.

    The nice thing about the chkconfig is that if you wanted/needed to suspend
    the script, you can easily enable/disable it.

Similar Threads

  1. Sending mail to a 'local' user who is actually not local
    By danscott in forum Servers & Networking
    Replies: 0
    Last Post: 28th February 2010, 06:03 PM
  2. fedora 10 local hostlogin
    By amarjeet sharma in forum EOL (End Of Life) Versions
    Replies: 10
    Last Post: 19th February 2010, 10:23 PM
  3. local repo fedora 10
    By moromete in forum Using Fedora
    Replies: 2
    Last Post: 23rd May 2009, 02:00 AM
  4. FC2 and Shutdown/Halt Problems
    By Nabeshin in forum EOL (End Of Life) Versions
    Replies: 3
    Last Post: 18th July 2008, 08:36 PM
  5. Replies: 5
    Last Post: 29th June 2007, 01:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •