Explorar o código

Added fix services, extended cleaning and added conditions

pmacko hai 4 semanas
pai
achega
0de515884d
Modificáronse 1 ficheiros con 20 adicións e 12 borrados
  1. 20 12
      clean.sh

+ 20 - 12
clean.sh

@@ -2,24 +2,32 @@
 #########################################################################
 #                         Script for cleaning logs                      #
 #                             Created by DoIT                           #
-#                                 ver 0.6                               #
+#                                 ver 0.8                               #
 #########################################################################
-echo -e "- [\e[1;33mCleaning\e[0m] logs and history"
-HIS=$(find /home/ -name .bash_history)
+echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mhistory\e[0m]"
+HIS=$(find /home/ -name .bash_history | egrep "pmacko|doit")
 for h in $HIS; do rm -rf $h; done
 rm -rf /root/.bash_history
-rm -rf /opt/log2ram*
+test -d /opt/log2ram && rm -rf /opt/log2ram*
+history -c
+echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mlogs\e[0m]"
+find /var/log/ -name "*-*" -type f -delete
 find /var/log/ -name "*.gz" -type f -delete
 find /var/log/ -name "*.log.*" -type f -delete
 find /var/log/ -name "*.[0-9]*" -type f -delete
+find /var/log/* -size +10M -exec rm -rf {} \;
 test -d /var/lib/clamav && rm -rf /var/lib/clamav/tmp*
-history -c
-echo -e "- [\e[1;33mCleaning\e[0m] APT archives"
-apt autoclean > /dev/null 2>&1
-apt clean > /dev/null 2>&1
-apt autoremove -y > /dev/null 2>&1
-pip cache purge > /dev/null 2>&1
-echo -e "- [\e[1;33mCleaning\e[0m] Journal"
+test -f /usr/local/bin/log2ram && systemctl restart log2ram > /dev/null 2>&1
+systemctl restart logrotate
+systemctl restart rsyslog
+echo -e "- \e[1;33mCleaning\e[0m package [\e[1;35marchives\e[0m]"
+test -f /usr/bin/apt && apt autoclean > /dev/null 2>&1
+test -f /usr/bin/apt && apt clean > /dev/null 2>&1
+test -f /usr/bin/apt && apt autoremove -y > /dev/null 2>&1
+test -f /usr/bin/yum && yum clean all > /dev/null 2>&1
+test -f /usr/bin/pip && /usr/bin/pip cache purge > /dev/null 2>&1
+test -f /usr/bin/pip3 && /usr/bin/pip3 cache purge > /dev/null 2>&1
+echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mjournal\e[0m]"
 journalctl --vacuum-size=100M > /dev/null 2>&1
-echo -e "- [\e[1;32mActual size\e[0m] of partition"
+echo -e "- \e[1;32mActual size\e[0m] of [\e[1;35mpartition\e[0m]"
 df -h | grep -v tmpfs | sed 's/ on//g'