-
Notifications
You must be signed in to change notification settings - Fork 2
/
kube_purge.sh
executable file
·95 lines (80 loc) · 2.35 KB
/
kube_purge.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# SCRIPT: kube_purge.sh
# REV: Version 1.0
# PLATFORM: Linux
# AUTHOR: Coenraad
#
# PURPOSE: ROOT Kube control
#
##########################################################
########### DEFINE FILES AND VARIABLES HERE ##############
##########################################################
##########################################################
################ BEGINNING OF MAIN #######################
##########################################################
# Run as root.
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1mMust be ROOT to run this script!\e[0m"
echo -e "\e[1mMust be ROOT to run this script!\e[0m"
echo -e "\e[1mMust be ROOT to run this script!\e[0m"
exit 1
fi
clear
function clean()
{
echo
echo -e "\e[40;38;5;82m [+] \e[30;48;5;82m Purging System for reset!!! THE SYSTEM WILL RESTART \e[0m"
echo
echo "Reseting system"
echo
kubeadm reset
docker system prune -a
service kubelet restart
service docker restart
shutdown -r now
}
function purge()
{
echo
echo -e "\e[40;38;5;82m [+] \e[30;48;5;82m Purging System !!! \e[0m"
echo
echo "Delete old docker images"
echo
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
}
function show_menus()
{
echo -e "Docker Kuberenetes ROOT admin "
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'a' for !!! PURGE AND RESET SYSTEM !!! \e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'b' for Delete old Docker images ect. !!!\e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'x' for Exit!!!\e[0m"
echo
echo "Pick Option:"
}
show_menus
read choice
if [ "$choice" == a ]; then
clean
show_menus
read choice
fi
if [ "$choice" == b ]; then
purge
show_menus
read choice
fi
if [ "$choice" == x ]; then
clear
sleep 2
echo -e "\e[40;38;5;82m [*] \e[30;48;5;82m THANK YOU FOR USING ME !!! \e[0m"
echo -e "\e[40;38;5;82m [*] \e[30;48;5;82m Have a nice day! \e[0m"
exit 0
fi
####################################################
################ END OF MAIN #######################
####################################################
exit 0
# End of script