David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 3 | KEEP_DOCKER=0 |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 4 | DOCKER_ENGINE="docker-ce" |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 5 | DOCKER_REGISTRY="/docker-registry /docker-registry-mirror" |
| 6 | CONTAINER_LIST=$(docker ps -qa) |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 7 | |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 8 | while [ $# -gt 0 ]; do |
| 9 | case $1 in |
| 10 | -k|--keep-docker) |
| 11 | KEEP_DOCKER=1 |
| 12 | DOCKER_ENGINE= |
| 13 | DOCKER_REGISTRY= |
| 14 | CONTAINER_LIST=$(docker ps --format '{{.ID}} {{.Names}}' | grep -v ' registry$' | grep -v ' registry-mirror$' | awk '{print $1}') |
| 15 | ;; |
| 16 | esac |
| 17 | shift |
| 18 | done |
| 19 | |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 20 | docker rm -f $(docker ps -aq) |
| 21 | docker rmi -f $(docker images -q) |
| 22 | docker volume rm -f $(docker volume ls -q) |
| 23 | docker network rm $(docker network ls -q) |
| 24 | sudo apt-get remove --purge -y bind9 apache2 apt-cacher-ng $DOCKER_ENGINE ansible $(dpkg --get-selections | grep maas | cut -f1) |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 25 | |
| 26 | sudo rm -rf \ |
| 27 | /etc/maas \ |
| 28 | /etc/bind \ |
| 29 | /etc/apache2 \ |
| 30 | /var/www \ |
| 31 | /var/log/maas \ |
| 32 | /var/lib/maas \ |
| 33 | /etc/apt/apt.conf.d/02apt-cacher-ng \ |
| 34 | /etc/apt/sources.list.d/apt_dockerproject_org_repo.list \ |
| 35 | /etc/apt/sources.list.d/ppa_juju_stable_trusty.list \ |
| 36 | /etc/apt/sources.list.d/docker.list \ |
| 37 | /etc/apt/sources.list.d/ppa_maas_stable_trusty.list \ |
| 38 | /etc/apt/sources.list.d/ppa_ansible_ansible_trusty.list \ |
| 39 | /etc/network/if-pre-up.d/nat \ |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 40 | /etc/apt/apt.conf.d/03apt-cacher-ng \ |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 41 | $DOCKER_REGISTRY |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 42 | |
| 43 | sudo apt-get update -y |
| 44 | |
| 45 | # remove NAT rules |
| 46 | sudo iptables --table nat --delete POSTROUTING --out-interface eth3 -j MASQUERADE |
| 47 | sudo iptables --delete FORWARD --in-interface mgmtbr -j ACCEPT |