mdserver-web/plugins/supervisor/install.sh

78 lines
1.9 KiB
Bash
Raw Normal View History

2022-06-15 10:54:44 -04:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
VERSION=$2
2026-05-06 23:40:52 -04:00
# cd /www/server/mdserver-web/plugins/supervisor && bash install.sh install 1.0
2026-05-06 23:40:09 -04:00
# /www/server/mdserver-web/bin/supervisord -n -c /etc/supervisor/supervisord.conf
2023-11-27 23:28:04 -05:00
# /www/server/mdserver-web/bin/supervisorctl -c /www/server/supervisor/supervisor.conf
2024-01-14 09:38:40 -05:00
# cmd | status
2026-05-07 00:03:23 -04:00
# systemctl status supervisor
2026-05-06 23:51:06 -04:00
# journalctl -u supervisor -f
2022-06-15 10:54:44 -04:00
2022-07-11 07:00:57 -04:00
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
2022-07-11 07:38:51 -04:00
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
2022-06-15 10:54:44 -04:00
2022-07-25 09:02:03 -04:00
if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi
2022-07-11 08:08:01 -04:00
2022-06-15 10:54:44 -04:00
Install_app()
{
2023-11-25 09:09:17 -05:00
echo '正在安装[supervisor]...'
2022-06-15 10:54:44 -04:00
mkdir -p $serverPath/source
mkdir -p $serverPath/supervisor
2022-06-16 09:05:01 -04:00
mkdir -p $serverPath/supervisor/log
mkdir -p $serverPath/supervisor/run
2022-06-15 10:54:44 -04:00
echo 'supervisor install...'
if [ "centos" == "$OSNAME" ] || [ "fedora" == "$OSNAME" ];then
2022-06-16 09:05:01 -04:00
pip install supervisor
2022-06-15 10:54:44 -04:00
elif [ "ubuntu" == "$OSNAME" ] || [ "debian" == "$OSNAME" ] ;then
2022-07-11 07:04:43 -04:00
pip install supervisor
2022-06-15 10:54:44 -04:00
else
2022-07-11 07:04:43 -04:00
pip install supervisor
2022-06-16 09:05:01 -04:00
# brew install supervisor
2022-06-15 10:54:44 -04:00
fi
2022-06-16 09:05:01 -04:00
echo "${VERSION}" > $serverPath/supervisor/version.pl
2024-11-23 17:16:14 -05:00
cd ${rootPath} && python3 plugins/supervisor/index.py start
cd ${rootPath} && python3 plugins/supervisor/index.py initd_install
2023-11-25 09:09:17 -05:00
echo '安装完成[supervisor]'
2022-06-15 10:54:44 -04:00
}
Uninstall_app()
{
2022-06-17 02:03:05 -04:00
2022-07-11 03:18:48 -04:00
if [ -f /usr/lib/systemd/system/supervisor.service ] || [ -f /lib/systemd/system/supervisor.service ];then
systemctl stop supervisor
systemctl disable supervisor
2022-07-03 10:25:18 -04:00
rm -rf /usr/lib/systemd/system/supervisor.service
2022-07-11 03:18:48 -04:00
rm -rf /lib/systemd/system/supervisor.service
systemctl daemon-reload
2022-06-17 02:03:05 -04:00
fi
2022-07-11 07:51:28 -04:00
pip uninstall supervisor -y
2022-07-11 07:04:43 -04:00
rm -rf $serverPath/supervisor
2023-11-25 09:09:17 -05:00
echo "卸载完成[supervisor]"
2022-06-15 10:54:44 -04:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_app
else
Uninstall_app
fi