#!/bin/bash# Version: v0.0.1 # Debian/Ubuntu Linux systems. (May 10, 2019)# (GNU/General Public License version 2.0)# For Centos 7 and up, Linux lzone_zkong_cluster_01 3.10.0-862.el7.x86_64.# ...And away we go!Package='/server/tools'function tools { if [ ! -d "$Package" ]; then mkdir "$Package" -p fi}function INSTALL {cp /usr/local/esl/scripts/docker-19.03.9.tgz $Package cd $Package && tar xf docker-19.03.9.tgz mv $Package/docker/* /usr/bin/cat >/etc/systemd/system/docker.service <<-EOF[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=network-online.target[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by dockerExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sockExecReload=/bin/kill -s HUP $MAINPID# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNOFILE=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s[Install]WantedBy=multi-user.targetEOFchmod +x /etc/systemd/system/docker.servicesystemctl daemon-reload && systemctl start docker && systemctl enable docker.service >/dev/null 2>&1systemctl status docker >/dev/null 2>&1 echo "当前Docker版本: `docker -v`"}function UNINSTALL { cd /usr/local/esl/ && docker-compose stop && systemctl stop docker rpm -qa | grep docker | xargs yum remove -y >/dev/null 2>&1 rm -rf /var/lib/docker sed -i '/web_code.sh/d;/Monitoring.sh/d;/docker-log.sh/d' /var/spool/cron/root sed -i '/Monitoring/d;/Check/d;/Clear/d' /var/spool/cron/root Package=`rpm -qa|grep bridge-utils|wc -l` if [ $Package -ne 1 ];then yum -y install bridge-utils fi BRIDGE_LIST=$( brctl show | cut -f 1 | grep br-) ifconfig $BRIDGE_LIST down brctl delbr $BRIDGE_LIST}echo 'Please enter the action you want to perform:"install" | "uninstall"请输入您要执行的操作:“安装install” 或者 “卸载uninstall”'read -p "Please enter the action you want to perform: " actioncase $action in install) tools INSTALL ;; uninstall) UNINSTALL && echo 'Docker uninstall Successfully' ;; *) echo ' The action you entered is not supported. Please enter the following format: install | uninstall' exit 1esac