mdserver-web/plugins/docker/install.sh

82 lines
1.8 KiB
Bash
Raw Normal View History

2023-04-20 00:19:33 -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")
2023-05-01 23:26:27 -04:00
# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh uninstall 1.0
# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh install 1.0
2023-04-20 00:19:33 -04:00
install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=$2
Install_Docker()
{
2023-05-01 23:34:00 -04:00
which docker
if [ "$?" == "0" ];then
echo '安装已经完成docker' > $install_tmp
exit 0
fi
2023-04-20 00:19:33 -04:00
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source
2023-04-21 01:02:42 -04:00
if [ ! -d $serverPath/docker ];then
curl -fsSL https://get.docker.com | bash
mkdir -p $serverPath/docker
fi
2023-04-21 00:55:38 -04:00
if [ -d $serverPath/docker ];then
echo "${VERSION}" > $serverPath/docker/version.pl
2023-04-20 00:19:33 -04:00
echo '安装完成' > $install_tmp
2023-04-21 00:55:38 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py initd_install
2023-04-20 00:19:33 -04:00
fi
}
Uninstall_Docker()
{
2023-05-01 23:19:03 -04:00
CMD=yum
which apt
if [ "$?" == "0" ];then
CMD=apt
fi
2023-04-21 00:55:38 -04:00
# if [ -f /usr/lib/systemd/system/docker.service ];then
# systemctl stop docker
# systemctl disable docker
# rm -rf /usr/lib/systemd/system/docker.service
# systemctl daemon-reload
# fi
# if [ -f $serverPath/docker/initd/docker ];then
# $serverPath/docker/initd/docker stop
# fi
2023-05-01 23:26:27 -04:00
$CMD remove -y docker docker-ce-cli
2023-05-01 23:19:03 -04:00
# docker-client \
# docker-client-latest \
# docker-common \
# docker-latest \
# docker-latest-logrotate \
# docker-logrotate \
# docker-selinux \
# docker-engine-selinux \
# docker-engine \
# docker-ce
2023-04-21 00:58:50 -04:00
2023-04-21 00:55:38 -04:00
rm -rf $serverPath/docker
echo "Uninstall_Docker" > $install_tmp
2023-04-20 00:19:33 -04:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_Docker
else
Uninstall_Docker
fi