-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuke_vm.sh
More file actions
65 lines (51 loc) · 1.21 KB
/
nuke_vm.sh
File metadata and controls
65 lines (51 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -Eeuo pipefail
TARGET_USER="${SUDO_USER:-${USER:-moha}}"
if command -v docker >/dev/null 2>&1; then
systemctl stop docker.service docker.socket 2>/dev/null || true
apt-get purge -y \
docker-ce \
docker-ce-cli \
docker-ce-rootless-extras \
docker-buildx-plugin \
docker-compose-plugin \
docker.io \
containerd.io || true
rm -rf \
/var/lib/docker \
/var/lib/containerd \
/etc/docker
rm -f \
/etc/apt/sources.list.d/docker.list \
/etc/apt/keyrings/docker.gpg
fi
if command -v terraform >/dev/null 2>&1; then
apt-get purge -y terraform
rm -f \
/etc/apt/sources.list.d/hashicorp.list \
/etc/apt/keyrings/hashicorp.gpg
fi
if command -v ansible >/dev/null 2>&1; then
apt-get purge -y ansible
fi
if [ -x /usr/local/bin/aws ]; then
rm -rf /usr/local/aws-cli
rm -f \
/usr/local/bin/aws \
/usr/local/bin/aws_completer
fi
rm -f \
/usr/bin/yq \
/usr/local/bin/lazygit
apt-get purge -y direnv || true
rm -rf \
"$HOME/.ansible" \
"$HOME/.terraform.d"
apt-get autoremove -y
apt-get clean
if command -v ufw >/dev/null 2>&1; then
echo "y" | ufw reset
ufw disable
fi
rm -rf "/home/${TARGET_USER}/repos"
echo "Purge completed."