Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/mongodb/install.sh

107 lines
2.5 KiB

4 years ago
#!/bin/bash
2 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
4 years ago
export PATH
2 years ago
# https://www.mongodb.com/try/download/community
1 year ago
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
2 years ago
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
2 years ago
4 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=$2
sysName=`uname`
3 years ago
echo "use system: ${sysName}"
2 years ago
OSNAME=`bash ${rootPath}/scripts/getos.sh`
2 years ago
if [ "" == "$OSNAME" ];then
OSNAME=`cat ${rootPath}/data/osname.pl`
fi
2 years ago
if [ "macos" != "$OSNAME" ];then
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
fi
if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi
2 years ago
Install_app()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source
2 years ago
2 years ago
# if id mongodb &> /dev/null ;then
# echo "mongodb uid is `id -u mongodb`"
# echo "mongodb shell is `grep "^mongodb:" /etc/passwd |cut -d':' -f7 `"
# else
# groupadd mongodb
# useradd -g mongodb mongodb
# fi
2 years ago
# if [ "centos" == "$OSNAME" ];then
# OSNAME=rhel
# fi
2 years ago
2 years ago
# if [ "fedora" == "$OSNAME" ];then
# OSNAME=rhel
# fi
2 years ago
2 years ago
# if [ "rocky" == "$OSNAME" ];then
# OSNAME=rhel
# fi
2 years ago
cd ${rootPath}/plugins/php/lib && /bin/bash openssl_11.sh
2 years ago
shell_file=${curPath}/versions/${VERSION}/${OSNAME}.sh
if [ -f $shell_file ];then
bash -x $shell_file
2 years ago
else
2 years ago
echo '不支持...' > $install_tmp
exit 1
2 years ago
fi
4 years ago
3 years ago
if [ "$?" == "0" ];then
mkdir -p $serverPath/mongodb
3 years ago
echo "${VERSION}" > $serverPath/mongodb/version.pl
2 years ago
echo 'mongodb安装完成'
3 years ago
#初始化
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install
fi
4 years ago
}
Uninstall_app()
{
2 years ago
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py stop
4 years ago
rm -rf $serverPath/mongodb
2 years ago
if [ -f /usr/lib/systemd/system/mongodb.service ] || [ -f /lib/systemd/system/mongodb.service ];then
systemctl stop mongodb
systemctl disable mongodb
rm -rf /usr/lib/systemd/system/mongodb.service
rm -rf /lib/systemd/system/mongodb.service
systemctl daemon-reload
fi
2 years ago
echo 'mongodb卸载完成'
4 years ago
}
action=$1
if [ "${1}" == 'install' ];then
Install_app
else
Uninstall_app
fi