#!/bin/sh
#
if_install=`rpm -qa | grep mongodb-enterprise-server | wc -l`
if [ $if_install -eq 0 ];then
     yum install http://devops.drugeyes.vip:8000/tools/mongodb/7.0/mongodb-enterprise-server-7.0.16-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/7.0/mongodb-enterprise-tools-7.0.16-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/7.0/mongodb-mongosh-2.3.8.x86_64.rpm  http://devops.drugeyes.vip:8000/tools/mongodb/7.0/mongodb-enterprise-database-tools-extra-7.0.16-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/7.0/mongodb-database-tools-100.10.0-1.x86_64.rpm -y
    mkdir /data/mongo  /data/logs/mongodb -p
    chown mongod:mongod  /data/mongo  /data/logs/mongodb -R
    sed -i 's/var\/lib\/mongo/data\/mongo/g'      /etc/mongod.conf
    sed -i 's/var\/log\/mongodb/data\/logs\/mongodb/g'  /etc/mongod.conf
    sed -i '/#security.*/a\#\ \ authorization: enabled' /etc/mongod.conf 
    systemctl start mongod ; systemctl enable mongod
    echo "Mongodb install Sucessefull."
    echo "Set password Usage:"
    echo "> use admin"
    echo "> db.createUser("
    echo "  {"
    echo '    user: "root",'
    echo '    pwd: "123456",'
    echo '    roles: [ { role: "root", db: "admin" } ]'
    echo '  }'
    echo ')'
else 
   echo "Mongodb-server have installed !"
fi 
