oneuptime/Ci/scripts/cleanup.sh

52 lines
2.1 KiB
Bash
Raw Normal View History

2020-03-27 20:01:03 +00:00
#
2021-07-08 19:49:38 +00:00
sudo dpkg --configure -a
2020-03-27 20:01:03 +00:00
echo "Running Cleanup Script..."
2020-04-21 20:40:08 +00:00
if [[ $(which helm) ]]
then
2022-01-28 22:34:06 +00:00
# Remove oneuptime if helm is installed
echo "RUNNING COMMAND: sudo helm uninstall oneuptime || echo 'oneuptime not installed'"
sudo helm uninstall oneuptime || echo 'oneuptime not installed'
2020-04-21 20:40:08 +00:00
fi
2020-08-26 14:10:10 +00:00
if [[ $(which microk8s) ]]
then
# Stop microk8s VM
echo "Stopping microk8s..."
# Delete microk8s cluster so it can be fresh for next job.
echo "Delete microk8s Cluster..."
echo "RUNNING COMMAND: sudo usermod -a -G microk8s $USER"
sudo usermod -a -G microk8s $USER || echo "microk8s group not found"
echo "RUNNING COMMAND: microk8s.reset || 'microk8s cannot delete'"
sudo microk8s.reset || 'microk8s cannot delete'
echo "RUNNING COMMAND: microk8s.kubectl delete all --all || 'microk8s.kubectl cannot delete'"
sudo microk8s.kubectl delete all --all || 'microk8s.kubectl cannot delete'
echo "RUNNING COMMAND: microk8s.stop || 'microk8s cannot Stop'"
sudo microk8s.stop || "microk8s cannot Stop"
echo "RUNNING COMMAND: sudo snap remove microk8s || 'microk8s cannot be removed.'"
sudo snap remove microk8s || 'microk8s cannot be removed.'
fi
if [[ $(which docker) ]]
then
# Stop all docker containers
echo "Stop and Delete all docker containers..."
echo "RUNNING COMMAND: sudo docker stop \$(sudo docker ps -aq) || echo 'No docker containers'"
sudo docker stop $(sudo docker ps -aq) || echo 'No docker containers'
# Remove all docker containers.
echo "RUNNING COMMAND: sudo docker rm \$(sudo docker ps -aq) || echo 'No docker containers'"
sudo docker rm $(sudo docker ps -aq) || echo 'No docker containers'
# Delete all locally built images. (Comment this out to reduce build times)
# echo "RUNNING COMMAND: sudo docker rmi -f \$(sudo docker images -q) || echo 'No docker containers'"
# sudo docker rmi -f $(sudo docker images -q) || echo 'No docker containers'
2021-06-16 20:12:33 +00:00
# Comment line below to reduce build times.
# sudo docker system prune -a --volumes --force
2020-08-26 14:10:10 +00:00
fi
2021-11-28 11:13:53 +00:00
# fix broken unmet dependencies
2021-11-28 11:42:23 +00:00
sudo apt --fix-broken install -y -y
2021-11-28 11:13:53 +00:00
2020-07-14 21:49:00 +00:00
# remove any service holding port 80
sudo apt remove apache2 nginx -y
sudo apt purge apache2 nginx -y
sudo apt autoremove -y