Current File : //root/patch17042019all.sh
filechk="/etc/sentora/panel/patch17042019.log"
if [ -f "$filechk" ]
then
    echo "Patch 17042019 Already Updated" >> /etc/sentora/panel/patch17042019.log
    exit
fi
touch /etc/sentora/panel/patch17042019.log
echo "Patch 17042019 started here" >> /etc/sentora/panel/patch17042019.log
echo "Mongo DB security patch start" >> /etc/sentora/panel/patch17042019.log
port_check=`lsof -i:27017 -S | tail -1 |  cut -d " " -f1`
if [ ! -z "$port_check" ]; then
        line_no=`grep -no "#security" /etc/mongod.conf | awk '{print $1}' FS=":"`
        line=$line_no"s"
        line1=`expr "$line_no" + "1"`
        line2=$line1"i"
        `sed -i "$line/#security/security/" /etc/mongod.conf`
        `ex -s -c "$line2|  authorization: \"enabled\"" -c x /etc/mongod.conf`
        service mongod restart
fi
echo "Mongo DB security patch end" >> /etc/sentora/panel/patch17042019.log
echo "Patch 17042019 Ended here" >> /etc/sentora/panel/patch17042019.log