forked from ombhd/Cleaner_42
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CleanerInstaller.sh
executable file
·78 lines (68 loc) · 2.56 KB
/
CleanerInstaller.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
#!/bin/bash
#Author Omar BOUYKOURNE
#42login obouykou
echo -en "\n By: "
echo -e "\033[33m𝒐𝒃𝒐𝒖𝒚𝒌𝒐𝒖\033[0m"
echo -e "\n report any issues to me in:"
echo -e " GitHub ~> \033[4;1;34mombhd\033[0m"
echo -e " 42 Slack ~> \033[4;1;34mobouykou\033[0m\n"
sleep 2
#update
git pull &>/dev/null
#get the shell configuration file name
shell_f=$(echo -n "$SHELL" | awk -F / '{print $3}')
shell_f="${HOME}/.${shell_f}rc"
#test if it is already installed
if grep "alias cclean='bash ~/Cleaner_42.sh'" <"$shell_f" &>/dev/null && ls "$HOME"/Cleaner_42.sh &>/dev/null; then
sleep 0.5
echo -e "\033[33m\n -- cclean Already installed --\n\033[0m"
sleep 0.5
echo -e "\033[36m -- Please, run this command now : [\033[33m source $shell_f\033[0m\033[36m ] Then run [\033[33m cclean \033[0m\033[36m]--\n\033[0m"
sleep 0.5
echo -e "\033[36m -- For updates, run [\033[33m cclean update \033[0m\033[36m] --\n\033[0m"
exit 0
fi
#take confirmation
while true; do
echo "cclean program/command removes: "
sleep 0.2
echo " - the Trash contents."
sleep 0.2
echo " - 42 caches from Library and Home directories."
sleep 0.2
echo " - Chrome Caches."
sleep 0.2
echo " - VSCode Caches and its workspaces cache storage."
sleep 0.2
echo " - Social Media Apps Caches, like Slack and Discord."
sleep 0.2
echo " - FileSystems which are located in browsers profiles directories, such as Chrome and Chromium."
sleep 0.2
echo -en "\n\033[33mDo you really want to install this program ? \033[0m\0"
read -r yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo -e "\n\033[31mPlease answer yes or no !\033[0m\0\n" ;;
esac
done
#remove the old Cleaner and Cleaner42 if there are any, then copy the current one to Home dir
/bin/rm -rf ~/Cleaner_42.sh &>/dev/null
/bin/rm -rf ~/Cleaner.sh &>/dev/null
cp -f ./Cleaner_42.sh "$HOME"
if ! grep "alias cclean='bash ~/Cleaner_42.sh'" <"$shell_f" &>/dev/null; then
echo -e "\nalias cclean='bash ~/Cleaner_42.sh'" >>"$shell_f"
fi
if grep "alias cclean='bash ~/Cleaner_42.sh'" <"$shell_f" &>/dev/null && ls "$HOME"/Cleaner_42.sh &>/dev/null; then
sleep 0.5
echo -e "\n\033[32m -- cclean command has been successfully installed ! Enjoy :) --\n\033[0m"
sleep 0.5
echo -e "\033[36m -- Please, run this command now : [\033[33m source $shell_f\033[0m\033[36m ] Then run [\033[33m cclean \033[0m\033[36m]--\n\033[0m"
sleep 0.5
echo -e "\033[36m -- For updates, run [\033[33m cclean update \033[0m\033[36m] --\n\033[0m"
else
sleep 0.5
echo -e "\033[31m\n -- cclean command has NOT been installed ! :( --\n\033[0m"
exit 1
fi
exit 0