Advertisement
Guest User

update_johander.sh

a guest
Jan 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Colors
  4. bold="\e[1m"
  5. gray="\e[2m"
  6. underlined="\e[4m"
  7. red="\e[31m"
  8. green="\e[32m"
  9. normal="\e[0m"
  10.  
  11. script_exe=$(basename "${0}")
  12.  
  13. check_sudo() {
  14. if [ "$EUID" -ne 0 ]; then
  15. echo -e "${red}Run this script as root${normal}\n"
  16.  
  17. if [ $(ls | grep -o "${script_exe}") ]; then
  18. echo -e "${gray}$ ./${script_exe} [clean|update]"
  19. else
  20. echo -e "${gray}$ ${script_exe} [clean|update]"
  21. fi
  22.  
  23. exit 1
  24. fi
  25. }
  26.  
  27. update() {
  28. check_sudo
  29.  
  30. echo -e "${bold}Updating...${normal}\n"
  31.  
  32. cd /root
  33.  
  34. echo -en "Updating database... "
  35. apt -qq update
  36. echo -e "${green}OK!${normal}"
  37.  
  38. echo -en "Updating youtube-dl... "
  39. pip3 install -q -U youtube-dl
  40. echo -e "${green}OK!${normal}"
  41.  
  42. echo -en "Upgrading packages... "
  43. apt-fast upgrade -y
  44. echo -e "${green}OK!${normal}"
  45. }
  46.  
  47. clean() {
  48. check_sudo
  49.  
  50. echo -e "${bold}Cleaning...${normal}\n"
  51.  
  52. echo -en "Cleaning the PC... "
  53.  
  54. rm -rf /var/cache/apt/archives/*
  55. echo -e "${green}OK!${normal}"
  56.  
  57. echo -en "Cleaning the dima's home "
  58.  
  59. cd /home/dima
  60. rm -rf .wget-hsts
  61. rm -rf .viminfo
  62. rm -rf .bash_history
  63. rm -rf .thumbnails
  64. rm -rf .cache/thumbnails
  65. rm -rf .sudo_as_admin_successfull
  66. rm -rf .node_repl_history
  67. rm -rf .cache/vlc
  68. echo -e "${green}OK!${normal}"
  69. }
  70.  
  71. case "$1" in
  72. update)
  73. update
  74. ;;
  75. clean)
  76. clean
  77. ;;
  78. *)
  79. update
  80. clean
  81. ;;
  82. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement