Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I am using Fedora Core 8 (updated to kernel 2.6.26.8-57-fc . The main aim is to execute some commands which stop and unload a Wi-Fi module, before the systems ...
  1. #1
    Just Joined!
    Join Date
    Jul 2009
    Posts
    2

    Fedora shutdown not exec init.d script

    Hello,

    I am using Fedora Core 8 (updated to kernel 2.6.26.8-57-fc. The main aim is to execute some commands which stop and unload a Wi-Fi module, before the systems halts or reboots ("init 0" or "init 6"). The problem is that the desired commands ("ifconfig rausb down" and "rmmod rt73") are not executed when the system halts or reboots, and if these commands are not executed then the systems hangs in the execution of "init 0" or "init 6".

    The name of script is: freerausb (which is placed in the directory: /etc/init.d)

    A simplified version of the "freerausb" script is:

    #! /bin/bash
    #
    # chkconfig: 2345 99 99
    # description: unload RT73
    # sets down the rausb interface and unloads the rt73 module
    # processname: freerausb

    case "$1" in
    start)
    /bin/echo "Start" >> /root/rausbUmount.log #Only for debug purposes
    /bin/touch /var/lock/subsys/freerausb #I have read that this is necessary
    ;;
    stop)
    /bin/echo "Stop" >> /root/rausbUmount.log #Only for debug purposes
    /sbin/ifconfig rausb0 down
    /bin/sleep 2
    /sbin/rmmod rt73
    /bin/rm -f /var/lock/subsys/freerausb
    ;;
    *)
    exit 1
    esac
    exit 0

    Then I execute, in the "/etc/init.d" directory, the following command in order to register the aforementioned script:

    chkconfig --add freerausb

    And in order to see if it has been registered successfully:
    chkconfig --list | grep freerausb
    whose result is:
    freerausb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

    I have also checked the links created in the rc0.d, rc6.d directories (and also rc1.d, rc2.d and so on) and they are OK (according to the settings:
    # chkconfig: 2345 99 99
    of the freerausb script). In addition I have executed manually both:
    "/etc/init.d/freerausb start" and "/etc/init.d/freerausb stop" and the execution has been successfully.

    After doing the previous steps, when the system starts then the "start)" section is executed, but when the systems stops or reboots it is not executed the "stop)" section (I have noticed that because the command:
    /bin/echo "Stop" >> /root/rausbUmount.log
    is never executed).


    I have tried other options like changing:

    # chkconfig: 2345 99 99

    for:

    # chkconfig: 06 00 00

    This is supposed to execute the "start)" section of the script when the "init 0" or "init 6" are called (so the ifconfig and rmmod commands are moved to this section). However I have realized that is not executed because no entry is created in the log file "/root/rausbUmount.log":
    /bin/echo "Start" >> /root/rausbUmount.log

    I have also checked the configurations:

    # chkconfig: 06 99 99
    # chkconfig: 2345 00 00

    I do not know what I have to do in order to instruct my script "freerausb" to execute "ifconfig" and "rmmod" when the commands "init 0" or "init 6" are called.

    Any comments will be welcomed.

  2. #2
    Just Joined!
    Join Date
    Jul 2009
    Posts
    2

    Set the script to the suitable level

    Hello,

    The problem is that the system hangs when it is rebooted or halted; specifically when the network script tries do shutdown the network connections (Ethernet, Wi-Fi, ...), so if the script "freerausb", which tries to stop in a proper way the USB Wi-Fi, is not executed before the script which tries to stop the network services, then the problem appears.

    In order to solve the problem, the "freerausb" script has to be similar to:

    #! /bin/bash
    #
    # chkconfig: 2345 99 00
    # description: unload RT73
    # sets down the rausb interface and unloads the rt73 module
    # processname: freerausb

    case "$1" in
    start)
    /bin/touch /var/lock/subsys/freerausb
    ;;
    stop)
    /sbin/ifconfig rausb0 down
    /bin/sleep 2
    /sbin/rmmod rt73
    /bin/rm -f /var/lock/subsys/freerausb
    /bin/sleep 5
    ;;
    *)
    exit 1
    esac
    exit 0


    Notice the following line which is the key of the solution:

    # chkconfig: 2345 99 00

    In addition some sleep times have been added.

    This means that for levels 0 and 6 (init 0 and init 6), then the "stop)" section of the aforementioned script will be executed, and this script will be executed before other init.d scripts when the system reboots or shutdowns.

    Regards,

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,281
    chkconfig --list | grep freerausb
    whose result is:
    freerausb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    This is teeling the system to not execute the script when shutting down.

    To change this run the following
    Code:
    chkconfig --level 06 freerausb on
    This will tell the script to run during those sessions.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

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