#!/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/5.0/mongodb-database-tools-100.5.2.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-5.0.6-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-cryptd-5.0.6-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-database-5.0.6-1.el7.x86_64.rpm  http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-database-tools-extra-5.0.6-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-mongos-5.0.6-1.el7.x86_64.rpm  http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-server-5.0.6-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-shell-5.0.6-1.el7.x86_64.rpm http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-enterprise-tools-5.0.6-1.el7.x86_64.rpm  http://devops.drugeyes.vip:8000/tools/mongodb/5.0/mongodb-mongosh-1.3.1.el7.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 
