| #!/bin/bash |
| |
| KEEP_DOCKER=0 |
| DOCKER_ENGINE="docker-engine" |
| DOCKER_REGISTRY="/docker-registry /docker-registry-mirror" |
| CONTAINER_LIST=$(docker ps -qa) |
| |
| while [ $# -gt 0 ]; do |
| case $1 in |
| -k|--keep-docker) |
| KEEP_DOCKER=1 |
| DOCKER_ENGINE= |
| DOCKER_REGISTRY= |
| CONTAINER_LIST=$(docker ps --format '{{.ID}} {{.Names}}' | grep -v ' registry$' | grep -v ' registry-mirror$' | awk '{print $1}') |
| ;; |
| esac |
| shift |
| done |
| |
| CONTAINER_LIST=$(docker ps --format '{{.ID}} {{.Names}}' | grep -v ' registry$' | grep -v ' registry-mirror$' | awk '{print $1}') |
| |
| docker kill $CONTAINER_LIST |
| docker rm -f $CONTAINER_LIST |
| if [ $KEEP_DOCKER -eq 0 ]; then |
| docker rmi -f $(docker images -aq) |
| fi |
| |
| sudo apt-get remove --purge -y bind9 apache2 $DOCKER_ENGINE ansible $(dpkg --get-selections | grep maas | cut -f1) |
| |
| sudo rm -rf \ |
| /etc/maas \ |
| /etc/bind \ |
| /etc/apache2 \ |
| /var/www \ |
| /var/log/maas \ |
| /var/lib/maas \ |
| /etc/apt/apt.conf.d/02apt-cacher-ng \ |
| /etc/apt/sources.list.d/apt_dockerproject_org_repo.list \ |
| /etc/apt/sources.list.d/ppa_juju_stable_trusty.list \ |
| /etc/apt/sources.list.d/docker.list \ |
| /etc/apt/sources.list.d/ppa_maas_stable_trusty.list \ |
| /etc/apt/sources.list.d/ppa_ansible_ansible_trusty.list \ |
| /etc/network/if-pre-up.d/nat \ |
| $DOCKER_REGISTRY |
| |
| sudo apt-get update -y |
| |
| # remove NAT rules |
| sudo iptables --table nat --delete POSTROUTING --out-interface eth3 -j MASQUERADE |
| sudo iptables --delete FORWARD --in-interface mgmtbr -j ACCEPT |