Hi Debians,
I am new to GNU/Debian Linux and just setup my first system. However I was wondering why the initscripts in /etc/init.d/ just don't have a status arg like SuSE. Gentoo, which I also had a look at, has also a very nice feature where you can check with one command what service is running and which are unused. Does anybody know a good solution?
Greets
mamars
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Daemon status with init scripts
I can't really give you a prefab solution, but the following two (more or less obvious) procedures give you some information:
1) Just look at
or if you want to know if sshd is up in a script, do something like
(the plus is in there to prevent the (e)grep command itself from showing up).
2) Look at the files in /var/run. E.g.:
HTH,
1) Just look at
Code: Select all
ps -ef
Code: Select all
if ps -e | egrep 'ssh+d' > /dev/null ; then ... fi
2) Look at the files in /var/run. E.g.:
Code: Select all
$ cat /var/run/sshd.pid
3493
$ cat /proc/3493/cmdline
/usr/sbin/sshd
Thank you for your suggestion.
However, I think, that Debian is not prepared for such a feature, because you need at least two thinks, as far as I can assess this.
SuSE uses rc{service} which are sym.linked to /etc/init.d/{service}
Postfix for example looks like this:
Look for the executables
Then they use startproc, killproc and checkproc for start, stop, status cases.
The "Starting postfix .... " is done in this file, the result however is done by the rc.status script which is sourced.
Here is just an extract of the rc.status:
It's really a pity that Debian lacks these functions .
so long
mamars
However, I think, that Debian is not prepared for such a feature, because you need at least two thinks, as far as I can assess this.
- 1. A "status case" in the init scripts
2. A universal script which handles "nice" output
SuSE uses rc{service} which are sym.linked to /etc/init.d/{service}
Postfix for example looks like this:
Code: Select all
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
Code: Select all
MASTER_BIN=/usr/lib/postfix/master
POSTFIX_BIN=/usr/sbin/postfix
test -x $POSTFIX_BIN || exit 5
test -x $MASTER_BIN || exit 5
The "Starting postfix .... " is done in this file, the result however is done by the rc.status script which is sourced.
Here is just an extract of the rc.status:
Code: Select all
# check whether splash screen animations are installed.
_rc_splash=0
test -f /etc/sysconfig/bootsplash && . /etc/sysconfig/bootsplash
test -x /sbin/splash && _rc_splash=1
if test -z "$LINES" -o -z "$COLUMNS" ; then
eval `stty size 2>/dev/null | (read L C; \
echo LINES=${L:-24} COLUMNS=${C:-80})`
fi
test $LINES -eq 0 && LINES=24
test $COLUMNS -eq 0 && COLUMNS=80
export LINES COLUMNS
if test -t 1 -a "$TERM" != "raw" -a "$TERM" != "dumb" && stty size > /dev/null 2>&1 ; then
esc=`echo -en "\033"`
extd="${esc}[1m"
warn="${esc}[1;31m"
done="${esc}[1;32m"
attn="${esc}[1;33m"
norm=`echo -en "${esc}[m\017"`
stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[10D"`
rc_done="${stat}${done}done${norm}"
rc_running="${stat}${done}running${norm}"
rc_failed="${stat}${warn}failed${norm}"
rc_missed="${stat}${warn}missing${norm}"
rc_skipped="${stat}${attn}skipped${norm}"
rc_dead="${stat}${warn}dead${norm}"
rc_unused="${stat}${extd}unused${norm}"
rc_unknown="${stat}${attn}unknown${norm}"
rc_done_up="${esc}[1A${rc_done}"
rc_failed_up="${esc}[1A${rc_failed}"
rc_reset="${norm}"
rc_save="${esc}7"
rc_restore="${esc}8"
function rc_cuu () { echo -en "\033[${1}A"; }
function rc_timer_on () {
so long
mamars
Hi again,
Actually, the rc.status file just contains the functions used to print out the pieces "... done" and such. I think you want to look at (for e.g. postfix, to stay with the same example) for the part where it says something like:
Then there's a section for all the possible arguments, including one that starts like this:
The code after that is executed if you run
Now I don't have a SuSE system at hand here, so I can't give you the line numbers or something, and it might even be that a couple of scripts do things differently. But this is usually the general structure.
The equivalent of startproc and killproc in Debian is called start-stop-daemon, by the way. As we already discussed, there's no equivalent to checkproc (which is what you'd want).
HTH,
Actually, the rc.status file just contains the functions used to print out the pieces "... done" and such. I think you want to look at (for e.g. postfix, to stay with the same example) for the part where it says something like:
Code: Select all
case $1 in
Then there's a section for all the possible arguments, including one that starts like this:
Code: Select all
status)
Code: Select all
/etc/init.d/postfix status
The equivalent of startproc and killproc in Debian is called start-stop-daemon, by the way. As we already discussed, there's no equivalent to checkproc (which is what you'd want).
HTH,