de linuxmanr4, 4 años han pasado desde su publicación, escrito en Plain Text.
Enlace corto
http://gw.gd/3Idy
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 the 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. #
  14. # allservers.sh is now completely menu driven. The Menu describes
  15. # what it does for you, if you need more detail see the two
  16. # wiki page links listed above.
  17.  
  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 & run pacman -Syy "
  55. echo
  56. echo  "    [2] Option 1. plus Upgrade the System - pacman -Syu "
  57. echo  "        & then run CacheClean - cacheclean -v 2 "
  58. echo
  59. echo  "    [3] Option 1. plus Upgrade the System & AUR - yaourt -Syu --aur "
  60. echo  "        & then run CacheClean - cacheclean -v 2 "
  61. echo
  62. echo  "    [4] Upgrade the System only - pacman -Syu "
  63. echo  "        & then run CacheClean - cacheclean -v 2 "
  64. echo
  65. echo  "    [5] Upgrade the System & AUR only - yaourt - Syu --aur "
  66. echo  "        & then run CacheClean - cacheclean -v 2 "
  67. echo
  68. echo  "    CacheClean can be obtained via the AUR - yaourt -S cacheclean "
  69. echo  "    CacheClean is set to remove all installation packages in your "
  70. echo  "    /var/cache/pacman/pkg directory EXCEPT the two most recent "
  71. echo  "    versions. See the Manjaro wiki for details. "
  72. echo -e "    http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety \033[0m"
  73. echo
  74. echo -e "\033[1m  Enter Your Choice: \033[0m"
  75. echo    
  76.  
  77. read option
  78.  
  79. case "$option" in
  80. # Note variable is quoted.
  81.  
  82.  "1")
  83.  echo
  84.  msg "Downloading latest mirrorlist"
  85.  wget http://git.manjaro.org/packages-sources/basis/blobs/raw/abd4c76ae4b83f7750d1038a0b7df6dfb063f580/pacman-mirrorlist/mirrorlist -O /etc/pacman.d/allservers >& /dev/null
  86.  msg "Editing allservers file"
  87.  sed -ie s'/# Server/Server/'g /etc/pacman.d/allservers
  88.  msg "Running rankmirrors"
  89.  rankmirrors -n 3 /etc/pacman.d/allservers > /etc/pacman.d/mirrorlist
  90.  msg "Updating your pacman databases"
  91.  echo
  92.  pacman -Syy
  93.  ;;
  94. # Note double semicolon to terminate each option.
  95.  
  96.  "2")
  97.  echo
  98.  msg "Downloading latest mirrorlist"
  99.  wget http://git.manjaro.org/packages-sources/basis/blobs/raw/abd4c76ae4b83f7750d1038a0b7df6dfb063f580/pacman-mirrorlist/mirrorlist -O /etc/pacman.d/allservers >& /dev/null
  100.  msg "Editing allservers file"
  101.  sed -ie s'/# Server/Server/'g /etc/pacman.d/allservers
  102.  msg "Running rankmirrors"
  103.  rankmirrors -n 3 /etc/pacman.d/allservers > /etc/pacman.d/mirrorlist
  104.  msg "Updating your pacman databases"
  105.  echo
  106.  pacman -Syy
  107.  echo
  108.  msg "Upgrading System:"
  109.  echo
  110.  pacman -Syu
  111.  echo
  112.  msg "System update complete."
  113.  echo
  114.  msg "CacheClean will now remove all but the 2 most "
  115.  msg "recent versions of the installation packages in "
  116.  msg "/var/cache/pacman/pkg directory:"
  117.  echo
  118.  cacheclean -v 2
  119.  echo
  120.  msg "CacheClean has done its job. "
  121.  echo
  122.  ;;
  123. # Note double semicolon to terminate each option.
  124.  
  125.  "3")
  126.  echo
  127.  msg "Downloading latest mirrorlist"
  128.  wget http://git.manjaro.org/packages-sources/basis/blobs/raw/abd4c76ae4b83f7750d1038a0b7df6dfb063f580/pacman-mirrorlist/mirrorlist -O /etc/pacman.d/allservers >& /dev/null
  129.  msg "Editing allservers file"
  130.  sed -ie s'/# Server/Server/'g /etc/pacman.d/allservers
  131.  msg "Running rankmirrors"
  132.  rankmirrors -n 3 /etc/pacman.d/allservers > /etc/pacman.d/mirrorlist
  133.  msg "Updating your pacman databases"
  134.  echo
  135.  pacman -Syy
  136.  echo
  137.  msg "Upgrading System & AUR:"
  138.  echo
  139.  yaourt -Syu --aur
  140.  echo
  141.  msg "System including AUR packages are up to date."
  142.  echo
  143.  msg "CacheClean will now remove all but the 2 most "
  144.  msg "recent versions of the installation packages in "
  145.  msg "/var/cache/pacman/pkg directory:"
  146.  echo
  147.  cacheclean -v 2
  148.  echo
  149.  msg "CacheClean has done its job. "
  150.  echo
  151.  ;;
  152. # Note double semicolon to terminate each option.
  153.  
  154.  "4")
  155.  echo
  156.  msg "Upgrading System:"
  157.  echo
  158.  pacman -Syu
  159.  echo
  160.  msg "System update complete."
  161.  echo
  162.  msg "CacheClean will now remove all but the 2 most "
  163.  msg "recent versions of the installation packages in "
  164.  msg "/var/cache/pacman/pkg directory:"
  165.  echo
  166.  cacheclean -v 2
  167.  echo
  168.  msg "CacheClean has done its job. "
  169.  echo
  170.  ;;
  171. # Note double semicolon to terminate each option.
  172.  
  173.  "5")
  174.  echo
  175.  msg "Upgrading System & AUR: "
  176.  echo
  177.  yaourt -Syu --aur
  178.  echo
  179.  msg "System including AUR packages are up to date. "
  180.  echo
  181.  msg "CacheClean will now remove all but the 2 most "
  182.  msg "recent versions of the installation packages in "
  183.  msg "/var/cache/pacman/pkg directory:"
  184.  echo
  185.  cacheclean -v 2
  186.  echo
  187.  msg "CacheClean has done its job. "
  188.  echo
  189.  ;;
  190.  
  191. esac
  192.  
  193.  
  194. exit 0