Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Debian This forum is for the discussion of Debian Linux.


  Search this Thread
Old 12-01-2008, 04:32 AM   #1
LQ Newbie
Registered: Dec 2008
Posts: 13

Rep: Reputation: 0
Modify Startup and Shutdown Scripts


I am using Debian Etch.

I have purchased a Belkin Universal UPS and have set it up using NUT, but in order to have the automatic shutdown and restart work I need to apply a fix.]

The fix says to add a script to both the startup and shutdown scripts:

The intention is that one puts commands such as the following as the last part of the computer's shutdown script:

# if shutdown was caused by UPS, perform Belkin UPS workaround.
if [ -f /etc/killpower ] ; then
    echo "Waiting for AC power, or for UPS batteries to run out..."
    /usr/bin/belkinunv -x wait /dev/ttyS1

    # we get here if the power came back on. Reboot.
    echo "Power is back. Rebooting..."
Put this before any disks are mounted read/write, and before any file system integrity checks, so that the system is in a safe state.

# if we are recovering from a power failure, wait for the UPS to
# charge to a comfortable level before writing anything to disk
if [ -f /etc/killpower ] ; then
    echo "Waiting for UPS battery charge to reach 60%..."
    /usr/bin/belkinunv -x wait=60 -x nohang /dev/ttyS1
Would anyone be able to point me in the right direction as to the scripts (and the correct point within them) I should add these to?

Many thanks.
Old 12-01-2008, 01:55 PM   #2
Registered: Sep 2003
Location: France
Distribution: Debian etch
Posts: 99

Rep: Reputation: 15

Never done that, but /etc/init.d is the folder where to find startup and shutdown script.
So i would create in root

1. a file in here, name could be belkin
touch belkin
chmod 755 belkin

2. vi belkin then add the following by typing i or use another editor
# belkin

case "$1" in
# bootup sequence
# shutdown sequence
echo "Usage: $0 { start | stop }"
exit 0
3. in Console, run the following
update-rc.d belkin defaults
( put update-rc.d -f belkin remove to remove it )

As i am a novice, it should be validated by a more experienced linux user.
hope it helps.


Last edited by Tanc; 12-01-2008 at 01:58 PM.
Old 12-01-2008, 09:28 PM   #3
LQ Newbie
Registered: Dec 2008
Posts: 13

Original Poster
Rep: Reputation: 0
Hi Tanc,

Thanks for the suggestion.
I don't think that is going to work as the startup script needs to be run before the disks go RW and the shutdown after they have been made Read-Only. I think the init.d scripts get run at the wrong time for that?
Old 12-02-2008, 12:09 AM   #4
Registered: Sep 2003
Location: France
Distribution: Debian etch
Posts: 99

Rep: Reputation: 15
Hi Tom,
I will continue to dig, but did you ever had a look at this folder /etc/initramfs-tools/scripts/ ?

I did create a script named before in /etc/initramfs-tools/scripts/init-premount containing an echo command
chmod a+x
then /usr/sbin/update-initramfs -k all -u

At boot, i can see it before disk are mounted.
Will try to confirm that with logs messages in couple of mn

Last edited by Tanc; 12-02-2008 at 12:41 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i modify shutdown option in main menu ? viapillai Linux - Desktop 4 07-11-2008 04:11 AM
Mandriva startup scripts (need to add something to startup before X starts) thunderweasel Mandriva 3 01-01-2006 12:55 AM
shutdown scripts? mushmaster Linux - Software 5 02-15-2005 06:23 PM
Emergency Shutdown scripts? samroberts Linux - Enterprise 3 10-29-2004 04:48 AM
Where do you place shutdown scripts? zer0halo Linux - Newbie 3 08-24-2004 03:43 PM

All times are GMT -5. The time now is 04:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration