[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] where to add a beep on shutdown
And Lo! The Great Prophet "Chris Johnson" uttered these words of wisdom:
> I have a debian server that I use without a monitor attached and I want it
> to beep when it starts up and beep when its finished shutting down so that I
> can hear when its gone down so I can press the power switch and hear when
> its come up again so I can start working on it. IPCop does this with a
> series or increasing pitch beeps on power up and a series of decreasing
> beeps on power down.
>
> Any hints as to what commands I should be placing where will be much
> appreciated.
Debian uses SysV startup, so create a script in /etc/init.d named (say)
beep then symlink it to rc6.d and rc0.d -- have a look at the naming scheme
in those directories, you'll see they're [SK]xxnnnn - First a 'S' (for
start) or 'K' (for kill) to identify the type of script (does it start or
stop a daemon), then xx is a number nnnn in a description. The scripts are
ran in that order, thus you'd want to do something like:
cd /etc/rc6.d
ln -s ../init.d/beep K99beep
(change the 99 to whatever you want if you want to change its execute
position). (I've also googled for this as I don't have Debian, so hopefully
my info isn't out of date or just plain wrong -- should give you a pointer
or two anyhow; the only thing that possibly will change are the location of
the files from /etc).
Startup scripts are named Sxxnnnn and generally live in other rc.n
directories (where 0 <= n <= 6 generally -- these are your runlevels[1]).
Your default runlevel when you boot the system can be found in
/etc/inittab -- look for the line that reads something like:
id:3:initdefault
It's the initdefault that is important -- this identifies the initial
runlevel line, and the 3 tells you the default runlevel. id is simply a unique
identifier. Thus a startup beep script you'd want in /etc/rc3.d.
there's probably also an rc.init or rc.S or similar which is always
executed as /the/ init script which handles all the fsck stuff at boot.
Now as for the 'beep' script itself; two ways:
1. A simple shell script that does an echo of CTRL-G followed by sleep -
e.g, this will beep 5 times with a wait of 1 second between each one:
#!/bin/sh
for i in 1 2 3 4 5
do
echo ^G
sleep 1
done
## End of script
How you enter the CTRL-G depends on your editor (vi: in insert mode: ctrl-v
ctrl-g). If you can't work it out, change the echo to:
echo g | tr 'g' '\007'
2. A C program; this would allow more control over the beep sequence (to a
finer resolution than 1 second); it could even be configurable in some way.
You could probably also knock summat up in Perl, but I'll leave that for
the perl hackers :-) Personally, I think perl's overkill for this.
Chris...
[1] Runlevels vary from system to system but generally follow this:
0 = HALT
1 = Single-user
2, 3, 4, 5 = System specific
6 = Reboot
There can also be a run-level S for single user. 2-5 used to be better
defined (many many years ago):
2 = Multi-user no networking
3 = Multi-user with networking
4 = Multi-user, networking, XDM
5 = System specific
But don't rely on these as I've seen completely different configs,
unfortuantly.
--
\ Chris Johnson \ NP: Icon Of Coil - 13. Pursuit
\ cej [at] nightwolf.org.uk \
\ http://cej.nightwolf.org.uk/ \
\ http://redclaw.org.uk/ ~---------------------------------------
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.