Skip to content

Commit 6e44c36

Browse files
author
Richard Kreuter
committed
Backport 2b7eb10 (RPM improvements) to 1.2. SERVER-575, SERVER-576
1 parent 639c391 commit 6e44c36

File tree

4 files changed

+48
-27
lines changed

4 files changed

+48
-27
lines changed

rpm/init.d-mongod

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,37 @@
1212

1313
# things from mongod.conf get there by mongod reading it
1414

15+
16+
1517
OPTIONS=" -f /etc/mongod.conf"
18+
SYSCONFIG="/etc/sysconfig/mongod"
1619

1720
mongod=${MONGOD-/usr/bin/mongod}
18-
pidfile=${PIDFILE-/var/run/mongod.pid}
19-
lockfile=${LOCKFILE-/var/lock/subsys/mongod}
21+
22+
MONGO_USER=mongod
23+
MONGO_GROUP=mongod
24+
25+
. "$SYSCONFIG" || true
2026

2127
start()
2228
{
2329
echo -n $"Starting mongod: "
24-
#daemon --pidfile=${pidfile} $mongod $OPTIONS > /var/log/mongod
25-
$mongod $OPTIONS > /var/log/mongod 2>&1 &
30+
daemon --user "$MONGO_USER" $mongod $OPTIONS
2631
RETVAL=$?
27-
[ $RETVAL = 0 ] && touch ${lockfile}
28-
echo OK
32+
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod && success
2933
}
3034

3135
stop()
3236
{
3337
echo -n $"Stopping mongod: "
34-
#killproc -p ${pidfile} -d 10 $mongod
35-
#RETVAL=$?
36-
killall mongod > /dev/null 2>&1
37-
#[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
38-
echo OK
38+
killproc -p /var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
39+
RETVAL=$?
40+
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod &7 success
41+
}
42+
43+
restart () {
44+
stop
45+
start
3946
}
4047

4148
ulimit -n 12000
@@ -48,15 +55,17 @@ case "$1" in
4855
stop)
4956
stop
5057
;;
51-
restart)
52-
stop
53-
start
58+
restart|reload|force-reload)
59+
restart
60+
;;
61+
condrestart)
62+
[ -f /var/lock/subsys/mongodb ] && restart || :
63+
;;
64+
status)
65+
status $mongod
5466
;;
55-
# status)
56-
# status -p ${pidfile} $mongod
57-
# ;;
5867
*)
59-
echo $"Usage: $0 {start|stop|restart}"
68+
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
6069
RETVAL=1
6170
esac
6271

rpm/mongo.spec

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: mongo
2-
Version: 1.2.4
2+
Version: 1.3.3
33
Release: mongodb_1%{?dist}
44
Summary: mongo client shell and tools
55
License: AGPL 3.0
@@ -23,6 +23,7 @@ client utilities.
2323
%package server
2424
Summary: mongo server, sharding server, and support scripts
2525
Group: Applications/Databases
26+
Requires: mongo
2627

2728
%description server
2829
Mongo (from "huMONGOus") is a schema-free document-oriented database.
@@ -56,17 +57,19 @@ cp rpm/init.d-mongod $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
5657
chmod a+x $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
5758
mkdir -p $RPM_BUILD_ROOT/etc
5859
cp rpm/mongod.conf $RPM_BUILD_ROOT/etc/mongod.conf
60+
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
61+
cp rpm/mongod.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/mongod
5962
mkdir -p $RPM_BUILD_ROOT/var/lib/mongo
60-
mkdir -p $RPM_BUILD_ROOT/var/log
61-
touch $RPM_BUILD_ROOT/var/log/mongo
63+
mkdir -p $RPM_BUILD_ROOT/var/log/mongo
64+
touch $RPM_BUILD_ROOT/var/log/mongo/mongod.log
6265

6366
%clean
6467
scons -c
6568
rm -rf $RPM_BUILD_ROOT
6669

6770
%pre server
68-
#/usr/sbin/useradd -M -o -r -d /var/mongo -s /bin/bash \
69-
# -c "mongod" mongod > /dev/null 2>&1 || :
71+
/usr/sbin/useradd -M -r -U -d /var/lib/mongo -s /bin/false \
72+
-c mongod mongod > /dev/null 2>&1
7073

7174
%post server
7275
if test $1 = 1
@@ -98,10 +101,12 @@ fi
98101
%{_bindir}/mongorestore
99102

100103
%{_mandir}/man1/mongo.1*
104+
%{_mandir}/man1/mongod.1*
101105
%{_mandir}/man1/mongodump.1*
102106
%{_mandir}/man1/mongoexport.1*
103107
%{_mandir}/man1/mongofiles.1*
104108
%{_mandir}/man1/mongoimport.1*
109+
%{_mandir}/man1/mongosniff.1*
105110
%{_mandir}/man1/mongorestore.1*
106111

107112
%files server
@@ -114,15 +119,18 @@ fi
114119
/etc/rc.d/init.d/mongod
115120
/etc/sysconfig/mongod
116121
#/etc/rc.d/init.d/mongos
117-
%attr(0755,root,root) %dir /var/mongo
118-
%attr(0640,root,root) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo
122+
%attr(0755,mongod,mongod) %dir /var/lib/mongo
123+
%attr(0755,mongod,mongod) %dir /var/log/mongo
124+
%attr(0640,mongod,mongod) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo/mongod.log
119125

120126
%files devel
121127
/usr/include/mongo
122128
%{_libdir}/libmongoclient.a
123129
#%{_libdir}/libmongotestfiles.a
124130

125131
%changelog
132+
* Thu Jan 28 2010 Richard M Kreuter <[email protected]>
133+
- Minor fixes.
134+
126135
* Sat Oct 24 2009 Joe Miklojcik <[email protected]> -
127136
- Wrote mongo.spec.
128-

rpm/mongod.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# mongo.conf
22

33
#where to log
4-
logpath=/var/log/mongod
4+
logpath=/var/log/mongo/mongod.log
5+
6+
# fork and run in background
7+
fork = true
58

69
#port = 27017
710

rpm/mongod.sysconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: add relevant configuration stuff here.

0 commit comments

Comments
 (0)