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