mdserver-web/plugins/docker/install.sh

105 lines
2.2 KiB
Bash
Raw Permalink 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
VERSION=$2
2023-06-28 02:53:59 -04:00
if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi
2024-06-28 03:39:38 -04:00
# {
# "registry-mirrors": [
# "http://hub-mirror.c.163.com",
# "https://docker.mirrors.ustc.edu.cn",
# "https://registry.docker-cn.com"
# ]
# }
# sudo mkdir -p /etc/docker
# sudo tee /etc/docker/daemon.json <<-'EOF'
# {
# "registry-mirrors": [
# "http://hub-mirror.c.163.com",
# "https://docker.mirrors.ustc.edu.cn",
# "https://registry.docker-cn.com"
# ]
# }
# EOF
# sudo systemctl daemon-reload
# sudo systemctl restart docker
2023-04-20 00:19:33 -04:00
Install_Docker()
{
2023-06-30 00:16:25 -04:00
# which docker
# if [ "$?" == "0" ];then
2024-11-30 08:44:09 -05:00
# echo '安装已经完成docker'
2023-06-30 00:16:25 -04:00
# exit 0
# fi
2023-05-01 23:34:00 -04:00
2024-11-04 12:35:39 -05:00
echo '正在安装脚本文件...'
2023-04-20 00:19:33 -04:00
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-06-28 02:53:59 -04:00
pip install docker
2023-06-30 00:16:25 -04:00
pip install pytz
2023-04-21 01:02:42 -04:00
2023-04-21 00:55:38 -04:00
if [ -d $serverPath/docker ];then
echo "${VERSION}" > $serverPath/docker/version.pl
2024-11-04 12:35:39 -05:00
echo '安装Docker完成'
2023-04-20 00:19:33 -04:00
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-05-01 23:52:56 -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
2023-04-21 00:55:38 -04:00
2023-05-01 23:42:16 -04:00
$CMD remove -y docker docker-ce-cli containerd.io
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
2024-11-04 12:35:39 -05:00
echo "卸载Docker"
2023-04-20 00:19:33 -04:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_Docker
else
Uninstall_Docker
fi