Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #!/bin/sh
  2. # Backup your data
  3. # Use at your own risk
  4. # Usage ./extended-cleanup-rancher2.sh
  5. # Include clearing all iptables: ./extended-cleanup-rancher2.sh flush
  6. docker rm -f $(docker ps -qa)
  7. docker rmi -f $(docker images -q)
  8. docker volume rm $(docker volume ls -q)
  9. for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done
  10. cleanupdirs="/etc/ceph /etc/cni /etc/kubernetes /opt/cni /opt/rke /run/secrets/kubernetes.io /run/calico /run/flannel /var/lib/calico /var/lib/etcd /var/lib/cni /var/lib/kubelet /var/lib/rancher/rke/log /var/log/containers /var/log/pods /var/run/calico"
  11. for dir in $cleanupdirs; do
  12. echo "Removing $dir"
  13. rm -rf $dir
  14. done
  15. cleanupinterfaces="flannel.1 cni0 tunl0"
  16. for interface in $cleanupinterfaces; do
  17. echo "Deleting $interface"
  18. ip link delete $interface
  19. done
  20. if [ "$1" = "flush" ]; then
  21. echo "Parameter flush found, flushing all iptables"
  22. iptables -F -t nat
  23. iptables -X -t nat
  24. iptables -F -t mangle
  25. iptables -X -t mangle
  26. iptables -F
  27. iptables -X
  28. /etc/init.d/docker restart
  29. else
  30. echo "Parameter flush not found, iptables not cleaned"
  31. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement