Last active
January 6, 2017 22:26
-
-
Save parvez/f07b0b8d142b4ffdd17deccfdd01c951 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- init.d-mongod | |
+++ patched.init.d-mongod | |
@@ -11,22 +11,26 @@ | |
# NOTE: if you change any OPTIONS here, you get what you pay for: | |
# this script assumes all options are in the config file. | |
-CONFIGFILE="/etc/mongod.conf" | |
-OPTIONS=" -f $CONFIGFILE" | |
+CONFIGFILE_AUTH="/etc/mongodb/auth.conf" | |
+CONFIGFILE_NOAUTH="/etc/mongodb/noauth.conf" | |
+SCRIPT_CREATE_USER_ROOT="/etc/mongodb/create_user_root.js" | |
+SCRIPT_CREATE_USER_APP="/etc/mongodb/create_user_app.js" | |
mongod=${MONGOD-/usr/bin/mongod} | |
+mongo=${MONGO-/usr/bin/mongo} | |
- echo -n $"Starting mongod: " | |
- daemon --user "$MONGO_USER" --check $mongod "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1" | |
+ echo -n $"Starting mongod without auth: " | |
+ daemon --user "$MONGO_USER" --check $mongod "$NUMACTL $mongod -f $CONFIGFILE_NOAUTH >/dev/null 2>&1" | |
+ | |
+ if [ -f "$SCRIPT_CREATE_USER_ROOT" ]; then | |
+ echo -n $"Adding Root User: " | |
+ $mongo admin $SCRIPT_CREATE_USER_ROOT | |
+ /bin/rm $SCRIPT_CREATE_USER_ROOT | |
+ fi | |
+ if [ -f "$SCRIPT_CREATE_USER_APP" ]; then | |
+ echo -n $"Adding Users for my_app: " | |
+ $mongo my_app $SCRIPT_CREATE_USER_APP | |
+ /bin/rm $SCRIPT_CREATE_USER_APP | |
+ fi | |
+ | |
+ usleep 50000 | |
+ stop | |
+ usleep 50000 | |
+ | |
+ echo -n $"Starting mongod with auth: " | |
+ daemon --user "$MONGO_USER" --check $mongod "$NUMACTL $mongod -f $CONFIGFILE_AUTH >/dev/null 2>&1" | |
+ | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment