de linuxmanr4, 4 años han pasado desde su publicación, escrito en Bash.
Enlace corto
http://gw.gd/NA2S
Insertar vínculo
  1. #!/bin/bash
  2.  
  3. # 27-April-2013: Updated to use the new pacman-mirrors -g to rankmirrors. :)
  4. #
  5. # allservers.sh - inspired by Manjaro's Carl & Phil, initially hung together
  6. # by handy, the script's display prettied up & progress information added by Phil,
  7. # the menu & wiki page added by handy.
  8. # Latest revision now calls everything via the menu.
  9. # The following wiki page is about this script:
  10. # http://wiki.manjaro.org/index.php/Allservers.sh_Script:-_Rankmirrors,_Synchronise_Pacman_Database
  11. # Following wiki page will introduce CacheClean & related information:
  12. # http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety
  13. #___________________________________________________________
  14. #
  15. # allservers.sh is now completely menu driven. The Menu describes
  16. # what it does for you, if you need more detail see the two
  17. # wiki page links listed above.
  18. ###########################################################
  19.  
  20. err() {
  21.    ALL_OFF="\e[1;0m"
  22.    BOLD="\e[1;1m"
  23.    RED="${BOLD}\e[1;31m"
  24.         local mesg=$1; shift
  25.         printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  26. }
  27.  
  28. msg() {
  29.    ALL_OFF="\e[1;0m"
  30.    BOLD="\e[1;1m"
  31.    GREEN="${BOLD}\e[1;32m"
  32.         local mesg=$1; shift
  33.         printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  34. }
  35.  
  36.  
  37. if  `whoami` != "root" ;
  38. then
  39.   err "Must use 'sudo su' before you run this script."
  40.   exit
  41. fi
  42.  
  43.  
  44. # The menu:
  45.  
  46. clear # Clear the screen.
  47.  
  48. echo
  49. echo -e "\033[1m                      allservers.sh \033[0m"
  50. echo
  51. echo -e "\e[1;32m    Enter your Option's number OR hit Return to exit. "
  52. echo
  53. echo
  54. echo  "    [1] Rank Mirrors & update mirrorlist: pacman-mirrors -g "
  55. echo  "        & then sync/refresh package lists: pacman -Syy "
  56. echo
  57. echo  "    [2] Option 1. plus Upgrade the System: pacman -Syu "
  58. echo  "        & then run CacheClean: cacheclean -v 2 "
  59. echo
  60. echo  "    [3] Option 1. plus Upgrade the System & AUR: yaourt -Syua "
  61. echo  "        & then run CacheClean: cacheclean -v 2 "
  62. echo
  63. echo  "    [4] Upgrade the System only: pacman -Syu "
  64. echo  "        & then run CacheClean: cacheclean -v 2 "
  65. echo
  66. echo  "    [5] Upgrade the System & AUR only: yaourt - Syua "
  67. echo  "        & then run CacheClean: cacheclean -v 2 "
  68. echo
  69. echo  "    CacheClean can be obtained via the AUR - yaourt -S cacheclean "
  70. echo  "    CacheClean is set to remove all installation packages in your "
  71. echo  "    /var/cache/pacman/pkg directory EXCEPT the two most recent "
  72. echo  "    versions. See the Manjaro wiki for details. "
  73. echo -e "    http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety \033[0m"
  74. echo
  75. echo -e "\033[1m  Enter Your Choice: \033[0m"
  76. echo    
  77.  
  78. read option
  79.  
  80. case "$option" in
  81. # Note variable is quoted.
  82.  
  83.  "1")
  84.  echo
  85.  msg "Processing mirrors"
  86.  echo
  87.  pacman-mirrors -g
  88.  echo
  89.  msg "Refreshing your pacman databases"
  90.  echo
  91.  pacman -Syy
  92.  ;;
  93. # Note double semicolon to terminate each option.
  94.  
  95.  "2")
  96.  echo
  97.  msg "Processing mirrors"
  98.  echo
  99.  pacman-mirrors -g
  100.  echo
  101.  msg "Refreshing your pacman databases"
  102.  echo
  103.  pacman -Syy
  104.  echo
  105.  msg "Upgrading System:"
  106.  echo
  107.  pacman -Syu
  108.  echo
  109.  msg "System update complete."
  110.  echo
  111.  msg "CacheClean will now remove all but the 2 most "
  112.  msg "recent versions of the installation packages in "
  113.  msg "/var/cache/pacman/pkg directory:"
  114.  echo
  115.  cacheclean -v 2
  116.  echo
  117.  msg "CacheClean has done its job. "
  118.  echo
  119.  ;;
  120. # Note double semicolon to terminate each option.
  121.  
  122.  "3")
  123.  echo
  124.  msg "Processing mirrors"
  125.  echo
  126.  pacman-mirrors -g
  127.  echo
  128.  msg "Refreshing your pacman databases"
  129.  echo
  130.  pacman -Syy
  131.  echo
  132.  msg "Upgrading System & AUR:"
  133.  echo
  134.  yaourt -Syua
  135.  echo
  136.  msg "System including AUR packages are up to date."
  137.  echo
  138.  msg "CacheClean will now remove all but the 2 most "
  139.  msg "recent versions of the installation packages in "
  140.  msg "/var/cache/pacman/pkg directory:"
  141.  echo
  142.  cacheclean -v 2
  143.  echo
  144.  msg "CacheClean has done its job. "
  145.  echo
  146.  ;;
  147. # Note double semicolon to terminate each option.
  148.  
  149.  "4")
  150.  echo
  151.  msg "Upgrading System:"
  152.  echo
  153.  pacman -Syu
  154.  echo
  155.  msg "System update complete."
  156.  echo
  157.  msg "CacheClean will now remove all but the 2 most "
  158.  msg "recent versions of the installation packages in "
  159.  msg "/var/cache/pacman/pkg directory:"
  160.  echo
  161.  cacheclean -v 2
  162.  echo
  163.  msg "CacheClean has done its job. "
  164.  echo
  165.  ;;
  166. # Note double semicolon to terminate each option.
  167.  
  168.  "5")
  169.  echo
  170.  msg "Upgrading System & AUR: "
  171.  echo
  172.  yaourt -Syua
  173.  echo
  174.  msg "System including AUR packages are up to date. "
  175.  echo
  176.  msg "CacheClean will now remove all but the 2 most "
  177.  msg "recent versions of the installation packages in "
  178.  msg "/var/cache/pacman/pkg directory:"
  179.  echo
  180.  cacheclean -v 2
  181.  echo
  182.  msg "CacheClean has done its job. "
  183.  echo
  184.  ;;
  185.  
  186. esac
  187.  
  188.  
  189. exit 0