You are not logged in.
Pages: 1
I've noticed that the vast majority of scripts in /etc/rc.d are essentially the same. They can all be replaced by this script below.
#!/bin/bash
source /etc/rc.conf
source /etc/rc.d/functions
name="$2"; path="`which $name 2> /dev/null`"
_wait='1'
if [ -x /etc/rc.d/$name ]; then
/etc/rc.d/$name $@; exit $?; fi
info="Usage: $0 (start|stop|restart) daemon"
[ -z "$name" ] ||
[ -z "$path" ] &&
echo $info && exit 1
[ -r /etc/conf.d/$name ] &&
source /etc/conf.d/$name
PID=$(pidof -o %PPID "`readlink -f $path`")
case "$1" in
start)
stat_busy "Starting $name Daemon"
[ -z "$PID" ] && $path $OPT &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else stat_done; add_daemon $name
echo $PID > /var/run/$name.pid
fi ;;
stop)
stat_busy "Stopping $name Daemon"
[ -z "$PID" ] || kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else stat_done; rm_daemon $name
rm -f /var/run/$name.pid; fi ;;
restart) $0 stop; sleep $_wait; $0 start ;;
esac
exit 0
Called for example like
./service start crond
And you could use this script transparently by dropping it in /sbin and patching /etc/rc.d/functions with
--- functions.backup 2010-10-26 01:39:30.660989232 -0400
+++ functions 2010-10-26 01:42:43.740987456 -0400
@@ -183,22 +183,29 @@
ck_depends() {
for daemon in $@; do
if ck_daemon $daemon; then
- /etc/rc.d/$daemon start
+ [ -x /etc/rc.d/$daemon ] && /etc/rc.d/$daemon start
+ /sbin/service start $daemon
fi
done
}
start_daemon() {
- /etc/rc.d/$1 start
+ [ -x /etc/rc.d/$1 ] && /etc/rc.d/$1 start
+ /sbin/service start $1
}
start_daemon_bkgd() {
- stat_bkgd "Starting $1"
- (/etc/rc.d/$1 start) &>/dev/null &
+ stat_bkgd "Starting $1"
+
+ [ -x /etc/rc.d/$1 ] &&
+ (/etc/rc.d/$1 start) &>/dev/null &
+
+ (/sbin/service start $1) &> /dev/null &
}
stop_daemon() {
- /etc/rc.d/$1 stop
+ [ -x /etc/rc.d/$1 ] && /etc/rc.d/$1 stop
+ /sbin/service stop $1
}
# Status functions
Then maintainers who are lazy can just delete the repetitive rc.d scripts and users wouldn't even notice. Any thoughts?
Last edited by kaitocracy (2010-10-30 13:48:44)
Offline
I guess that's similar to what some other distros do but we stick to the good old BSD style
Offline
You would need to include something to allow packages to 'override' this script with their own if required (eg, PostgreSQL does database initialization etc, as well as using "pg_ctl" to start instead of the 'postgres' or 'postgresql' commands)
if [ -x /etc/rc.d/$name ] ; then
/etc/rc.d/$name $1
exit $?
fi
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
To get feedback from the people who matter, submit this as a feature request on the bugtracker.
Offline
I like this idea. but what fukawi2 said. There are a bunch of scripts that do something custom
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Pages: 1