-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaintenance.sh
executable file
·146 lines (128 loc) · 4.17 KB
/
maintenance.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
###############################################################################
## A shell script that allows to do a complete maintenance of the Linux system.
## Copyright (C) Corentin Michel - All Rights Reserved
## Contact: [email protected] [https://github.com/SKOHscripts]
###############################################################################
rouge='\e[1;31m'
vert='\e[1;33m'
bleu='\e[1;34m'
violet='\e[1;35m'
vert='\e[1;32m'
neutre='\e[0;m'
if [ "$UID" -eq "0" ]
then
zenity --warning --height 80 --width 400 --title "EREUR" --text "Merci de lancez le script sans sudo : \n<b>./maintenance.sh</b>\nVous devrez entrer le mot de passe root par la suite."
exit
fi
which notify-send > /dev/null
if [ $? = 1 ]
then
sudo apt install -y libnotify-bin
fi
which zenity > /dev/null
if [ $? = 1 ]
then
sudo apt install -y zenity
fi
zenity --question --no-wrap --height 40 --width 300 --title "Maintenance d'Ubuntu" --text "Lancer la maintenance complète ?"
if [ $? == 0 ]
then
echo ""
echo -e -n "$vert [1/8]$rouge MISE A JOUR APT "
for i in `seq 24 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
notify-send -i system-software-update "Maintenance d'Ubuntu" "Mises à jour"
sudo dpkg --configure -a
sudo apt update
sudo apt full-upgrade -y
echo " "
echo -e -n "$vert [2/8]$rouge MISE A JOUR DES PACKAGES PYTHON "
for i in `seq 40 $COLUMNS`;
do echo -n "."
done
which pipupgrade > /dev/null
if [ $? = 1 ]
then
pip install pipupgrade
fi
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Mise à jour des packages python"
pipupgrade --self --yes
pipupgrade --pip --yes
echo " "
echo -e -n "$vert [3/8]$rouge MISE A JOUR SNAPS ET FLATPAK "
for i in `seq 37 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Mise à jour des snaps"
sudo snap refresh
flatpak update -y
echo " "
echo -e -n "$vert [4/8]$rouge AUTO-REMOVE "
for i in `seq 20 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Auto-remove"
sudo apt autoremove --purge -y
echo " "
echo -e -n "$vert [5/8]$rouge CLEAN "
for i in `seq 14 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Clean"
sudo apt autoclean
echo " "
echo -e -n "$vert [6/8]$rouge PURGE "
for i in `seq 14 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Purge"
sudo apt purge $(COLUMNS=200 dpkg -l | grep "^rc" | tr -s ' ' | cut -d ' ' -f 2) -y
echo " "
echo -e -n "$vert [7/8]$rouge RESOLUTION DES DEPENDANCES "
for i in `seq 35 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Réparation des dépendances"
sudo apt install -fy
echo ""
TRASH=$(date --date="2 week ago" "+%d %B")
echo -e -n "$vert [8/8]$rouge FICHIERS ANTERIEURS AU $TRASH "
for i in `seq 40 $COLUMNS`;
do echo -n "."
done
echo -e " $neutre"
# notify-send -i system-software-update "Maintenance d'Ubuntu" "Suppression des fichiers de la corbeille antérieurs au $TRASH"
echo " "
which trash-cli > /dev/null
if [ $? = 1 ]
then
sudo apt install -y trash-cli
fi
for i in `seq 0 14`;
do trash-list | grep $(date --date="$i day ago" "+%Y-%m-%d")
done
echo " "
echo -e " $rouge"
for i in `seq 15 60`;
do trash-list | grep $(date --date="$i day ago" "+%Y-%m-%d")
done
echo -e " $neutre"
zenity --question --height 40 --width 300 --title "Maintenance d'Ubuntu" --text "Voulez-vous supprimer les fichiers de la corbeille antérieurs au <b>$TRASH</b> ?"
if [ $? == 0 ]
then
trash-empty -f 14
fi
notify-send -i dialog-ok "Maintenance d'Ubuntu" "Terminée avec succès"
else
notify-send -i dialog-close "Maintenance d'Ubuntu" "Annulé"
exit
fi