forked from green-coding-solutions/green-metrics-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
81 lines (66 loc) · 3.29 KB
/
Copy pathuninstall.sh
File metadata and controls
81 lines (66 loc) · 3.29 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
set -euo pipefail
echo "Please note that this script does not remove pre-requisites like gcc, docker, curl etc. as it does not want to alter the system state"
function uninstall_python() {
python3 -m pip uninstall -y -r requirements.txt
python3 -m pip uninstall -y -r requirements-dev.txt
python3 -m pip uninstall -y -r docker/requirements.txt
python3 -m pip uninstall -y -r metric_providers/psu/energy/ac/xgboost/machine/model/requirements.txt
}
source venv/bin/activate
uninstall_python
deactivate
uninstall_python
docker rm -f green-coding-gunicorn-container
docker rm -f green-coding-nginx-container
docker rm -f green-coding-postgres-container
docker rm -f green-coding-redis-container
docker rmi -f nginx
docker rmi -f green-metrics-tool-test-test-green-coding-gunicorn
docker rmi -f green-metrics-tool-green-coding-gunicorn
docker rmi -f redis:alpine
docker rmi -f martizih/kaniko:slim
docker rmi -f postgres:18
docker volume rm green-metrics-tool_green-coding-redis-data
docker volume rm green-metrics-tool_green-coding-shared-sockets
read -p "Do you also want to remove the database with your data? (y/N) : " remove_db
if [[ "$remove_db" == "Y" || "$remove_db" == "y" ]] ; then
docker volume rm green-metrics-tool_green-coding-postgres-data
fi
docker system prune --volumes
echo 'Removing sudoers.d entries'
# autocomplete might not find files and thus throw an error. We want to capture that
sudo rm -f /etc/sudoers.d/green_coding* || true # legacy / macOS
sudo rm -f /etc/sudoers.d/green-coding* || true # Linux
if [[ $(uname) == "Linux" ]]; then
if cat /etc/os-release | grep -q "Fedora"; then
sudo dnf -y remove msr-tools lm_sensors lm_sensors-devel glib2 glib2-devel tinyproxy stress-ng lshw ipmitool
elif cat /etc/os-release | grep -q "openSUSE"; then
sudo zypper rm -n msr-tools sensors libsensors4-devel glib2-tools glib2-devel tinyproxy stress-ng lshw freeipmi ipmitool
else
sudo apt remove -y msr-tools lm-sensors libsensors-dev libglib2.0-0 libglib2.0-dev tinyproxy stress-ng lshw freeipmi-tools ipmitool
fi
read -p "Do you also want to remove pre-install requirements (curl git make gcc python3 python3-devel)? (y/N) : " pre_install
if [[ "$pre_install" == "Y" || "$pre_install" == "y" ]] ; then
if cat /etc/os-release | grep -q "Fedora"; then
sudo dnf remove -y git make gcc python3 python3-devel curl
elif cat /etc/os-release | grep -q "openSUSE"; then
sudo zypper rm -n git make gcc python313 python313-pip python313-virtualenv curl
else
sudo apt remove -y git make gcc python3 python3-pip python3-venv curl
fi
fi
read -p "Do you also want to remove pre-install requirements (docker)? (y/N) : " pre_docker
if [[ "$pre_docker" == "Y" || "$pre_docker" == "y" ]] ; then
if cat /etc/os-release | grep -q "Fedora"; then
sudo dnf remove -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif cat /etc/os-release | grep -q "openSUSE"; then
sudo zypper rm -n docker docker-compose docker-compose-switch
else
sudo apt remove -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
fi
fi
current_dir=$(pwd)
cd ..
rm -fR $current_dir