yaks-apt-update.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env bash
  2. ################################################################################
  3. # FILE : yaks-apt-update.sh
  4. # DESCRIPTION: Update my Debian-Ubuntu system for each Cronjob the machine runs.
  5. # AUTHOR : SVAKSHA, http://svaksha.com/pages/Bio
  6. # SOURCE : http://svaksha.github.io/yaksha
  7. # COPYRIGHT© : 2005-Now SVAKSHA, All Rights Reserved.
  8. # LICENSE : GNU AGPLv3 and subject to meeting all the terms in the LICENSE
  9. # file: https://github.com/svaksha/yaksha/blob/master/LICENSE.md
  10. # DATES : Created:2006mar31 - Updated:2016jan14
  11. ################################################################################
  12. #
  13. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14. # A script for weekly system updates.
  15. # Usage: "./yaks-apt-update.sh"
  16. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. # Clear the Terminal.
  18. clear
  19. # directory
  20. yaksha_dir=~/yaksha/
  21. # Log the date and time of execution of bash script into the `output` files.
  22. date +"%c|started running `apt-get`:$?" >> out-yaks-apt-update-cron.log
  23. date +"%c|completed running: $?" >> out-yaks-apt-update-cron.log
  24. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  25. # Cron will automatically install the weekly updates
  26. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27. function update_deb() {
  28. echo "Remember to finish installation with a dist-upgrade"
  29. # Echo more messages
  30. echo '******************************************************'
  31. echo "* yaks-apt-update.sh | Yaksha Update Script | `hostname -f` *"
  32. echo '******************************************************'
  33. # resynchronize the package index files from their internet sources to fetch the latest packages
  34. sudo apt-get -y update
  35. # Install the newest versions of all packages currently installed on this system.
  36. sudo apt-get -y upgrade
  37. # Install kernel updates on a Ubuntu LTS server and the "smart" conflict
  38. # resolution system can handle changing dependencies with new package versions.
  39. sudo apt-get -y dist-upgrade
  40. sudo apt-get -y safe-upgrade
  41. # Remove junk stuff
  42. #sudo apt-get --purge autoremove
  43. # Now clean the installed packages
  44. sudo apt-get -y clean
  45. sudo apt-get -y autoclean
  46. # Are we done?
  47. echo "Finished updating debuntu :-)"
  48. }
  49. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50. # Dont forget to update Anaconda
  51. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  52. function update_conda() {
  53. cd
  54. cd anaconda3
  55. conda update -y conda
  56. conda update -y anaconda
  57. cd
  58. cd yaksha
  59. # Are we done yet?
  60. echo "Finished updating Anaconda :-)"
  61. }
  62. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63. # Funcs
  64. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  65. update_deb='all'
  66. key="$1"
  67. key="$2"
  68. case $key in
  69. -c|--clean)
  70. update_deb="$1"
  71. shift
  72. ;;
  73. -u|--update)
  74. update_deb="$2"
  75. shift
  76. ;;
  77. *)
  78. echo "usage:
  79. -c|--clean - remove dotfiles before installation
  80. -u|--update [type] copy the yaksha dotfiles into home"
  81. ;;
  82. esac
  83. case $update_deb in
  84. debupdate)
  85. update_deb
  86. ;;
  87. conda)
  88. update_conda
  89. ;;
  90. all)
  91. update_deb
  92. update_conda
  93. ;;
  94. *)
  95. echo "Installation in progress, almost done!"
  96. esac