LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices



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

Rep: Reputation: 0
Modify Startup and Shutdown Scripts


Hi,

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.

http://www.mscs.dal.ca/~selinger/ups/belkin-universal-ups.html#workaround]

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

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

Code:
# NEAR END OF 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..."
    reboot
fi
Quote:
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.

Code:
# NEAR BEGINNING OF STARTUP SCRIPT:
# 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
fi
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, 02:55 PM   #2
Tanc
Member
 
Registered: Sep 2003
Location: France
Distribution: Debian etch
Posts: 99

Rep: Reputation: 15
Hi,

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
#!/bin/sh
# belkin

case "$1" in
'start')
# bootup sequence
;;
'stop')
# shutdown sequence
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
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.

Pierre

Last edited by Tanc; 12-01-2008 at 02:58 PM.
 
Old 12-01-2008, 10:28 PM   #3
explosive_tom
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, 01:09 AM   #4
Tanc
Member
 
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/ ?

Addon
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 01:41 AM.
 
  


Reply


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 05:11 AM
Mandriva startup scripts (need to add something to startup before X starts) thunderweasel Mandriva 3 01-01-2006 01:55 AM
shutdown scripts? mushmaster Linux - Software 5 02-15-2005 07:23 PM
Emergency Shutdown scripts? samroberts Linux - Enterprise 3 10-29-2004 05:48 AM
Where do you place shutdown scripts? zer0halo Linux - Newbie 3 08-24-2004 04:43 PM


All times are GMT -5. The time now is 08:17 AM.

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