Last active
November 21, 2019 14:56
-
-
Save krishnaTORQUE/4277cd3fe3c87561478a258ef312ed17 to your computer and use it in GitHub Desktop.
Quick Maintain Shell Linux System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# :: Commands :: | :: Descriptions :: | |
# : | |
# update : Update & Upgrade All | |
# clean : Clean & Empty & Remove Apps, Packages, Trash, Temp, Old Kernel | |
# both : Update & Clean | |
# fix : Fixing Installed Apps & Configuration | |
# all : Run All (Update, Clean & Fix) | |
# superclean : Remove Root / System Cache, Unnecessary Files + 'Clean' | |
# super : Everything at once | |
# :: Usage :: | |
# C Flag (-c) = Command | |
# S Flag (-s) = System | |
# | |
# ~/quik.sh | |
# >> Commands choose from description | |
# | |
# ./quik.sh -c update | |
# >> Direct Command Only | |
# | |
# ./quik.sh -c update -s shutdown || ./quik.sh -s shutdown -c update | |
# >> Command & Shutdown/Restart | |
# :: Tested OS :: | |
# Debian | |
# Raspbian | |
# Ubuntu | |
# Mint | |
# Kali | |
# :: Tested Environment :: | |
# CLI | |
# Gnome | |
# KDE | |
# Cinnamon | |
# :: Note :: | |
# Require Network Connection (Must) | |
# Codes are Well tested, but I am not responsible for any break to your system. | |
# :: Project Link :: | |
# https://gist.github.com/krishnaTORQUE/4277cd3fe3c87561478a258ef312ed17 | |
# License (C) 2019 under GNU GPL V2. | |
bold_txt=$(tput bold) | |
normal_txt=$(tput sgr0) | |
date_a=$(date '+%A %d-%m-%Y %I:%M:%S%P'); | |
printf " | |
####### ## ## #### ## ## | |
## ## ## ## ## ## ## | |
## ## ## ## ## ## ## | |
## ## ## ## ## ##### | |
## ## ## ## ## ## ## ## | |
## ## ## ## ## ## ## | |
##### ## ####### #### ## ## | |
Stable : v1.5 | |
${date_a} | |
" | |
# Option Flag # | |
if_func_run=f | |
while getopts c:s: option; do | |
case $option in | |
c) _command=$OPTARG;; | |
s) s_flag=$OPTARG;; | |
esac | |
done | |
# Update / Upgrade # | |
function run_update() { | |
sudo apt update -y | |
sudo apt list --upgradable -a | |
sudo apt upgrade -y | |
sudo apt upgrade --with-new-pkgs | |
sudo apt full-upgrade -y | |
sudo apt dist-upgrade -y | |
if_func_run=t | |
} | |
# Fix # | |
function run_fix() { | |
sudo dpkg --configure -a | |
sudo apt install -f | |
sudo apt update --fix-missing | |
sudo apt --fix-broken install -y | |
if_func_run=t | |
} | |
# Clean # | |
function run_clean() { | |
sudo apt autoremove --purge -y | |
sudo apt autoclean -y | |
sudo rm -rf /home/$USER/.local/share/Trash/* | |
sudo find /tmp/ -type f -mtime +1 -exec sudo rm {} \; | |
sudo find /tmp/ -type f -atime +1 -exec sudo rm {} \; | |
sudo apt remove -y | |
sudo apt clean -y | |
sudo apt clean all -y | |
if_func_run=t | |
} | |
# Super Clean # | |
function run_super_clean() { | |
sudo rm /home/$USER/.bash_history | |
sudo rm /home/$USER/.local/share/user-places.xbel.bak | |
sudo rm -rf /tmp/* | |
sudo rm -rf /var/tmp/* | |
sudo rm -rf /var/crash | |
sudo rm -rf /home/$USER/.cache/evolution/* | |
sudo rm -rf /home/$USER/.cache/thumbnails/* | |
sudo rm -rf /home/$USER/.cache/pip | |
find /home/$USER/.cache/ -type f -mtime +1 -exec rm {} \; | |
find /home/$USER/.cache/ -type f -atime +1 -exec rm {} \; | |
sudo find /var/backups/ -type f -mtime +1 -exec sudo rm {} \; | |
sudo find /var/backups/ -type f -atime +1 -exec sudo rm {} \; | |
sudo find /var/log/ -type f -mtime +1 -exec sudo rm {} \; | |
sudo find /var/log/ -type f -atime +1 -exec sudo rm {} \; | |
sudo find /var/cache/apt/archives/ -type f -mtime +1 -exec sudo rm {} \; | |
sudo find /var/cache/apt/archives/ -type f -atime +1 -exec sudo rm {} \; | |
if_func_run=t | |
} | |
# User Input # | |
if [ -z $_command ]; then | |
printf " | |
${bold_txt}** Network Connection Must Require **${normal_txt} | |
-- Commands -- | -- Descriptions -- | |
: | |
update : Update & Upgrade All | |
clean : Clean & Empty & Remove Apps, Packages, Trash, Temp, Old Kernel | |
both : Update & Clean | |
fix : Fixing Installed Apps & Configuration | |
all : Run All (Update, Clean & Fix) | |
superclean : Remove Root / System Cache, Unnecessary Files + 'Clean' | |
super : Everything at once | |
Default is: ${bold_txt}both${normal_txt} | |
Press ${bold_txt}command${normal_txt} or ${bold_txt}control + c ${normal_txt}to cancel. | |
\n${bold_txt}Enter Command:\n${normal_txt}" | |
read _command | |
fi | |
# Perform Command # | |
printf "\n *** COMMAND : ${bold_txt}${_command}${normal_txt} *** \n\n" | |
# System Command # | |
if [[ $s_flag != "" ]]; then | |
printf " *** SYSTEM : ${bold_txt}${s_flag}${normal_txt} *** \n\n" | |
fi | |
# Do Perform # | |
case $_command in | |
update) run_update;; | |
clean) run_clean;; | |
*|both) run_clean | |
run_update | |
run_clean | |
;; | |
fix) run_update | |
run_fix | |
run_clean | |
;; | |
all) run_clean | |
run_update | |
run_fix | |
run_clean | |
;; | |
superclean) run_clean | |
run_super_clean | |
;; | |
super) run_clean | |
run_super_clean | |
run_update | |
run_fix | |
run_clean | |
;; | |
esac | |
# Complete Time # | |
if [ $if_func_run = t ]; then | |
date_b=$(date '+%A %d-%m-%Y %I:%M:%S%P'); | |
printf "\n${bold_txt}${_command} - Complete | ${date_b} ${normal_txt} \n\n" | |
# System Action If Performed # | |
case $s_flag in | |
shutdown) sudo shutdown -P now;; | |
hibernate) sudo systemctl hibernate;; | |
restart) sudo reboot;; | |
logout) sudo pkill -KILL -u $USER;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment