summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorRichard Kreuter <richard@10gen.com>2010-02-01 15:45:11 -0500
committerRichard Kreuter <richard@10gen.com>2010-02-01 15:45:11 -0500
commit99dc251ea9f08141ea497d6f595ca3acf214b156 (patch)
tree4fd15b9a2c5bbe894751a5c65403e22d4c6df5ae /debian
parent361e981ecec254cc9bf90af5aaca933756c8f348 (diff)
downloadmongo-99dc251ea9f08141ea497d6f595ca3acf214b156.tar.gz
Address issues in SERVER-591. MINOR
Diffstat (limited to 'debian')
-rw-r--r--debian/init.d81
1 files changed, 23 insertions, 58 deletions
diff --git a/debian/init.d b/debian/init.d
index b4eedf0f0e5..1276a1548a7 100644
--- a/debian/init.d
+++ b/debian/init.d
@@ -48,10 +48,21 @@
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/mongod
-DATA=/var/lib/mongodb
-NAME=MongoDB
DESC=database
+# Default defaults. Can be overridden by the /etc/default/$NAME,
+# below.
+NAME=mongodb
+DATA=/var/lib/mongodb
+LOGDIR=/var/log/mongodb
+PIDFILE=/var/run/$NAME.pid
+LOGFILE=$LOGDIR/$NAME.log # Server logfile
+
+# Include mongodb defaults if available
+if [ -f /etc/default/$NAME ] ; then
+ . /etc/default/$NAME
+fi
+
if test ! -x $DAEMON; then
echo "Could not find $DAEMON"
exit 0
@@ -63,30 +74,23 @@ fi
. /lib/lsb/init-functions
-LOGDIR=/var/log/mongodb
-PIDFILE=/var/run/$NAME.pid
DIETIME=10 # Time to wait for the server to die, in seconds
# If this value is set too low you might not
# let some servers to die gracefully and
# 'restart' will not work
-LOGFILE=$LOGDIR/$NAME.log # Server logfile
-DAEMON_OPTS="--dbpath $DATA --logpath $LOGFILE run"
-
+DAEMONUSER=${DAEMONUSER:-mongodb}
+DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"}
-# Include mongodb defaults if available
-if [ -f /etc/default/$NAME ] ; then
- . /etc/default/$NAME
-fi
-
-DAEMONUSER=mongodb
# Check that the user exists (if we set a user)
# Does the user exist?
-if [ -n "$DAEMONUSER" ] ; then
+if [ -z "$DAEMONUSER" ]; then
+ log_failure_msg "The variable DAEMONUSER is unset or empty."
+ exit 1
+else
+ # Ensure the user exists.
if getent passwd | grep -q "^$DAEMONUSER:"; then
- # Obtain the uid and gid
- DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
- DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
+ true # pass
else
log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
exit 1
@@ -121,17 +125,10 @@ running() {
start_server() {
# Start the process using the wrapper
- if [ -z "$DAEMONUSER" ] ; then
- start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
- --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
- errcode=$?
- else
-# if we are using a daemonuser then change the user id
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
--make-pidfile --chuid $DAEMONUSER \
--exec $DAEMON -- $DAEMON_OPTS
errcode=$?
- fi
return $errcode
}
@@ -152,14 +149,6 @@ stop_server() {
return $errcode
}
-reload_server() {
- [ ! -f "$PIDFILE" ] && return 1
- pid=pidofproc $PIDFILE # This is the daemon's pid
- # Send a SIGHUP
- kill -USR1 $pid
- return $?
-}
-
force_stop() {
# Force the process to die killing it manually
[ ! -e "$PIDFILE" ] && return
@@ -182,7 +171,7 @@ force_stop() {
case "$1" in
start)
- log_daemon_msg "Starting $DESC $NAME"
+ log_daemon_msg "Starting $DESC" "$NAME"
# Check if it's running first
if running ; then
log_progress_msg "apparently already running"
@@ -254,35 +243,11 @@ case "$1" in
exit 1
fi
;;
- # Use this if the daemon cannot reload
+ # MongoDB can't reload its configuration.
reload)
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
log_warning_msg "cannot re-read the config file (use restart)."
;;
- # And this if it cann
- #reload)
- #
- # If the daemon can reload its config files on the fly
- # for example by sending it SIGHUP, do it here.
- #
- # If the daemon responds to changes in its config file
- # directly anyway, make this a do-nothing entry.
- #
- # log_daemon_msg "Reloading $DESC configuration files" "$NAME"
- # if running ; then
- # reload_server
- # if ! running ; then
- # Process died after we tried to reload
- # log_progress_msg "died on reload"
- # log_end_msg 1
- # exit 1
- # fi
- # else
- # log_progress_msg "server is not running"
- # log_end_msg 1
- # exit 1
- # fi
- #;;
*)
N=/etc/init.d/$NAME