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 |
| 4 | DOCKER_ENGINE="docker-engine" |
| 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 | |
| 20 | CONTAINER_LIST=$(docker ps --format '{{.ID}} {{.Names}}' | grep -v ' registry$' | grep -v ' registry-mirror$' | awk '{print $1}') |
| 21 | |
| 22 | docker kill $CONTAINER_LIST |
| 23 | docker rm -f $CONTAINER_LIST |
| 24 | if [ $KEEP_DOCKER -eq 0 ]; then |
| 25 | docker rmi -f $(docker images -aq) |
| 26 | fi |
| 27 | |
| 28 | sudo apt-get remove --purge -y bind9 apache2 $DOCKER_ENGINE ansible $(dpkg --get-selections | grep maas | cut -f1) |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 29 | |
| 30 | sudo rm -rf \ |
| 31 | /etc/maas \ |
| 32 | /etc/bind \ |
| 33 | /etc/apache2 \ |
| 34 | /var/www \ |
| 35 | /var/log/maas \ |
| 36 | /var/lib/maas \ |
| 37 | /etc/apt/apt.conf.d/02apt-cacher-ng \ |
| 38 | /etc/apt/sources.list.d/apt_dockerproject_org_repo.list \ |
| 39 | /etc/apt/sources.list.d/ppa_juju_stable_trusty.list \ |
| 40 | /etc/apt/sources.list.d/docker.list \ |
| 41 | /etc/apt/sources.list.d/ppa_maas_stable_trusty.list \ |
| 42 | /etc/apt/sources.list.d/ppa_ansible_ansible_trusty.list \ |
| 43 | /etc/network/if-pre-up.d/nat \ |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 44 | $DOCKER_REGISTRY |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 45 | |
| 46 | sudo apt-get update -y |
| 47 | |
| 48 | # remove NAT rules |
| 49 | sudo iptables --table nat --delete POSTROUTING --out-interface eth3 -j MASQUERADE |
| 50 | sudo iptables --delete FORWARD --in-interface mgmtbr -j ACCEPT |