--- mongodb-3.2.0.ebuild.orig 2015-12-16 16:05:03.873283609 -0500 +++ mongodb-3.2.0.ebuild 2015-12-16 21:32:26.953413766 -0500 @@ -44,8 +44,44 @@ S=${WORKDIR}/${MY_P} pkg_setup() { - enewgroup mongodb - enewuser mongodb -1 -1 /var/lib/${PN} mongodb + if [[ ${REPLACING_VERSIONS} < 3.0 ]]; then + ewarn "!! ERROR !!" + ewarn "You cannot directly upgrade a mongodb version 2.x" + ewarn "deployment to ${PN}-${PV}. Instead, you must upgrade" + ewarn "to a 3.0.x version first and then upgrade that to" + ewarn "${PN}-${PV}. " + ewarn " " + ewarn "Terminating ebuild." + die "Terminating ebuild." + fi + + # Determine if a mongod is running at this time + # Issue warning and die if server is running. + + ps -A | grep -q '[m]ongod' + if [ "$?" -eq "0" ]; then + ewarn "!! ERROR!!" + ewarn "You must shut down the running mongod server" + ewarn "before continuing with this ebuild." + ewarn "Shut down the mongod server and try again." + die "Terminating ebuild." + fi + + # If the user mongodb already exists we do not neeed + # to add these users to the system. If the user and + # group do not exist, we create them. + + getent group mongodb > /dev/null 2&>1 + + if [ "$?" -eq "1" ]; then + enewgroup mongodb + fi + + getent passwd mongodb > /dev/null 2&>1 + + if [ "$?" -eq "1" ]; then + enewuser mongodb -1 -1 /var/lib/${PN} mongodb + fi # Maintainer notes # @@ -140,20 +176,27 @@ } pkg_postinst() { - if [[ ${REPLACING_VERSIONS} < 3.0 ]]; then - ewarn "!! IMPORTANT !!" - ewarn " " - ewarn "${PN} configuration files have changed !" - ewarn " " - ewarn "Make sure you migrate from /etc/conf.d/${PN} to the new YAML standard in /etc/${PN}.conf" - ewarn " http://docs.mongodb.org/manual/reference/configuration-options/" - ewarn " " - ewarn "Make sure you also follow the upgrading process :" - ewarn " http://docs.mongodb.org/master/release-notes/3.0-upgrade/" - ewarn " " - ewarn "MongoDB 3.0 introduces the WiredTiger storage engine." - ewarn "WiredTiger is incompatible with MMAPv1 and you need to dump/reload your data if you want to use it." - ewarn "Once you have your data dumped, you need to set storage.engine: wiredTiger in /etc/${PN}.conf" - ewarn " http://docs.mongodb.org/master/release-notes/3.0-upgrade/#change-storage-engine-to-wiredtiger" - fi + ewarn "!! IMPORTANT !!" + ewarn " " + ewarn "Make sure you check your configuration file in /etc/${PN}.conf" + ewarn "For more information about configuration options, see:" + ewarn " " + ewarn " https://docs.mongodb.org/manual/reference/configuration-options/" + ewarn " " + ewarn "If upgrading from an older deployment of ${PN}, Make sure you also follow" + ewarn "the upgrading process :" + ewarn " https://docs.mongodb.org/manual/release-notes/3.2-upgrade/" + ewarn " " + ewarn "MongoDB 3.2 uses the WiredTiger storage engine by default for new deployments. For" + ewarn "existing deployments in the version 3.0 series, MongoDB 3.2 will use the mmapv1 " + ewarn "storage engine if your existing databases were created with it. If you want to convert" + ewarn "from the mmapv1 storage engine to WiredTiger, you will need to dump your databases" + ewarn "with mongodump. Set the storage engine and specify a new dbpath in /etc/${PN}.conf." + ewarn "Create the dbpath and chmod it so that user mongodb has owner and group rwx permissions." + ewarn "You may also want to change the name of the logfile that mongod writes to." + ewarn " " + ewarn " https://docs.mongodb.org/release-notes/3.0-upgrade/#change-storage-engine-to-wiredtiger" + ewarn " " + ewarn "After emerging this package, remember to start the mongod server again. If needed, " + ewarn "restore databases with mongorestore." }