3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/servers/server-scripts/generic/functions
Armijn Hemel 617d06c71c add a "name" action, which pretty prints the "nice name" for a package (so,
mailserver or smtpd or so for a mailserver like sendmail)

svn path=/nixpkgs/trunk/; revision=5043
2006-03-15 13:47:03 +00:00

83 lines
1.3 KiB
Bash

#! @bash@/bin/sh -e
## Generic service scripts for NixOS, which provide
## * functions to write state to files (/var/run/nix-services)
## * functions to read state from file (/var/run/nix-services)
## * sanity checking functions
STATEDIR=/var/run/nix-services
RCDIR=/etc/rc.d/
## resolve $deps to real start/stop scripts first
start_deps() {
for i in $deps; do
$i start
RETVAL=$?
if test $RETVAL != 0; then
exit $RETVAL
fi
done
}
start_softdeps() {
for i in $softdeps; do
echo $i
$i start
RETVAL=$?
if test $RETVAL != 0; then
continue
fi
done
}
start() {
# are we already running?
# if so, exit with code 0
if test -a $STATDIR/$prog; then
exit 0
fi
# if not, continue
# launch all hard dependencies
#start_deps
# launch all preferred dependencies
echo "softdeps" $softdeps
start_softdeps
# launch our own program
startService
# if successful, then register
register
}
stop() {
echo "stopping $prog"
# are we running? If so, then stop, otherwise, do nothing...
if ! test -a $STATEDIR/$prog; then
exit 0
fi
# stop our own program
stopService
unregister
}
register() {
touch $STATEDIR/$prog
}
unregister() {
rm $STATEDIR/$prog
}
status() {
# are we running? If so, report
if test -a $STATEDIR/$prog; then
echo "running"
else
echo "stopped"
fi
}
name() {
echo $prog
}