shell脚本
#!/bin/bash
#mail:xuel@anchnet.com
#function:auto install mongodb
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1
logfile="/var/log/mongod_install.log"
softdir="/software"
installdir="/usr/local"
sys_version=$(rpm -q centos-release|cut -d- -f3)
clear
echo "##########################################"
echo "# Auto Install mongodb for centos6/7.x ##"
echo "# Press Ctrl + C to cancel ##"
echo "# Any key to continue ##"
echo "##########################################"
echo "(1) Install Mongodb-3.2"
echo "(2) Install Mongodb-3.4"
echo "(3) Install Mongodb-3.6"
echo "(4) EXIT"
read -p "Please input your choice:" NUM
if [ ${sys_version} == "6" ];then
case $NUM in
1)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.20.tgz"
software_version="mongodb-3.2"
;;
2)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.10.tgz"
software_version="mongodb-3.4"
;;
3)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.6.5.tgz"
software_version="mongodb-3.6"
;;
4)
echo -e "\033[41;37m You choice channel! \033[0m" && exit 0
;;
*)
echo -e "\033[41;37m Input Error! Place input{1|2|3|4} \033[0m" && exit 1
;;
esac
elif [ ${sys_version} == "7" ];then
case $NUM in
1)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.20.tgz"
software_version="mongodb-3.2"
;;
2)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.10.tgz"
software_version="mongodb-3.4"
;;
3)
mongodb_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-