Allservers.sh : Un script para actualizar Manjaro Linux

Allservers.sh es un script en bash que nos permite automatizar varias tareas de actualizaci贸n en nuestro sistema en Manjaro Linux.

Siempre es bueno darse una vuelta al wiki de Manjaro, hasta hace unos d铆as estaba bastante c贸modo actualizando mi sistema con el m茅todo tradicional usando pacman sudo pacman -Syyu.

Pero descubr铆 el script en Bash Allservers que le da otra vuelta a la tuerca y automatiza varias tareas importantes dentro de la forma de actualizar Manjaro.

allservers actualizando el sistema

allservers actualizando el sistema

Por ejemplo:

  • Actualiza la lista de los mirrors m谩s recientes de Manjaro y esto es importante porque constantemente se dan de alta nuevos o dejan de funcionar otros.
  • Crea una lista de los tres mejores mirrors bas谩ndose en su velocidad (rankmirrors).
  • Sincroniza la base de datos de paquetes.
  • Actualiza el sistema base y los paquetes AUR.
  • Limpia el cache de paquetes usando el script cacheclean que elimina paquetes antiguos pero deja las dos 煤ltimas versiones. Esto es muy 煤til, porque ahorramos espacio, pero guardamos un par de paquetes por si algo sale mal y queremos hacer una desactualizaci贸n ( downgrade).

Alservers necesita que instalemos primero el paquete cacheclean

yaourt -S cacheclean

Luego descargamos el script (copiar y pegar) y lo guardamos en el un archivo de nuestro home:

#!/bin/bash

# 27-April-2013: Updated to use the new pacman-mirrors -g to rankmirrors. :)
#
# allservers.sh - inspired by Manjaro's Carl & Phil, initially hung together
# by handy, the script's display prettied up & progress information added by Phil,
# the menu & wiki page added by handy.
# Latest revision now calls everything via the menu.
# The following wiki page is about this script:
# http://wiki.manjaro.org/index.php/Allservers.sh_Script:-_Rankmirrors,_Synchronise_Pacman_Database
# Following wiki page will introduce CacheClean & related information:
# http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety
#___________________________________________________________
#
# allservers.sh is now completely menu driven. The Menu describes
# what it does for you, if you need more detail see the two
# wiki page links listed above.
###########################################################

err() {
    ALL_OFF="e[1;0m"
    BOLD="e[1;1m"
    RED="${BOLD}e[1;31m"
    local mesg=$1
    shift
    printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}n" "$@" >&2
}

msg() {
    ALL_OFF="e[1;0m"
    BOLD="e[1;1m"
    GREEN="${BOLD}e[1;32m"
    local mesg=$1
    shift
    printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}n" "$@" >&2
}

if $(whoami) != "root"; then
    err "Must use 'sudo su' before you run this script."
    exit
fi

# The menu:

clear # Clear the screen.

echo
echo -e "33[1m                      allservers.sh 33[0m"
echo
echo -e "e[1;32m    Enter your Option's number OR hit Return to exit. "
echo
echo "    [1] Rank Mirrors & update mirrorlist: pacman-mirrors -g "
echo "        & then sync/refresh package lists: pacman -Syy "
echo
echo "    [2] Option 1. plus Upgrade the System: pacman -Syu "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [3] Option 1. plus Upgrade the System & AUR: yaourt -Syua "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [4] Upgrade the System only: pacman -Syu "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [5] Upgrade the System & AUR only: yaourt - Syua "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    CacheClean can be obtained via the AUR - yaourt -S cacheclean "
echo "    CacheClean is set to remove all installation packages in your "
echo "    /var/cache/pacman/pkg directory EXCEPT the two most recent "
echo "    versions. See the Manjaro wiki for details. "
echo -e "    http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety 33[0m"
echo
echo -e "33[1m  Enter Your Choice: 33[0m"
echo

read option

case "$option" in
# Note variable is quoted.

"1")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    ;;
    # Note double semicolon to terminate each option.

"2")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    echo
    msg "Upgrading System:"
    echo
    pacman -Syu
    echo
    msg "System update complete."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"3")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    echo
    msg "Upgrading System & AUR:"
    echo
    yaourt -Syua
    echo
    msg "System including AUR packages are up to date."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"4")
    echo
    msg "Upgrading System:"
    echo
    pacman -Syu
    echo
    msg "System update complete."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"5")
    echo
    msg "Upgrading System & AUR: "
    echo
    yaourt -Syua
    echo
    msg "System including AUR packages are up to date. "
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;

esac

exit 0

Para darle permisos de ejecuci贸n, en una terminal tecleamos:

chmod +x ./allservers.sh

Para ejecutar el script Allservers:

sudo ./allservers.sh

Y elegir alguna de las opciones del men煤.

allservers menu principal

allservers menu principal

Simplemente la actualizaci贸n de mirrors y su calificaci贸n hacen que este script valga la pena.

Actualizaci贸n 27-abr-2013

Hubo una actualizaci贸n a este script, usa la nueva estructura de paquetes y el comando pacman-mirrors -g para actualizar y calificar los mejores mirrors para Manjaro.

#!/bin/bash

# 27-April-2013: Updated to use the new pacman-mirrors -g to rankmirrors. :)
#
# allservers.sh - inspired by Manjaro's Carl & Phil, initially hung together
# by handy, the script's display prettied up & progress information added by Phil,
# the menu & wiki page added by handy.
# Latest revision now calls everything via the menu.
# The following wiki page is about this script:
# http://wiki.manjaro.org/index.php/Allservers.sh_Script:-_Rankmirrors,_Synchronise_Pacman_Database
# Following wiki page will introduce CacheClean & related information:
# http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety
#___________________________________________________________
#
# allservers.sh is now completely menu driven. The Menu describes
# what it does for you, if you need more detail see the two
# wiki page links listed above.
###########################################################

err() {
    ALL_OFF="e[1;0m"
    BOLD="e[1;1m"
    RED="${BOLD}e[1;31m"
    local mesg=$1
    shift
    printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}n" "$@" >&2
}

msg() {
    ALL_OFF="e[1;0m"
    BOLD="e[1;1m"
    GREEN="${BOLD}e[1;32m"
    local mesg=$1
    shift
    printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}n" "$@" >&2
}

if $(whoami) != "root"; then
    err "Must use 'sudo su' before you run this script."
    exit
fi

# The menu:

clear # Clear the screen.

echo
echo -e "33[1m                      allservers.sh 33[0m"
echo
echo -e "e[1;32m    Enter your Option's number OR hit Return to exit. "
echo
echo "    [1] Rank Mirrors & update mirrorlist: pacman-mirrors -g "
echo "        & then sync/refresh package lists: pacman -Syy "
echo
echo "    [2] Option 1. plus Upgrade the System: pacman -Syu "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [3] Option 1. plus Upgrade the System & AUR: yaourt -Syua "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [4] Upgrade the System only: pacman -Syu "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    [5] Upgrade the System & AUR only: yaourt - Syua "
echo "        & then run CacheClean: cacheclean -v 2 "
echo
echo "    CacheClean can be obtained via the AUR - yaourt -S cacheclean "
echo "    CacheClean is set to remove all installation packages in your "
echo "    /var/cache/pacman/pkg directory EXCEPT the two most recent "
echo "    versions. See the Manjaro wiki for details. "
echo -e "    http://wiki.manjaro.org/index.php/Maintaining_/var/cache/pacman/pkg_for_System_Safety 33[0m"
echo
echo -e "33[1m  Enter Your Choice: 33[0m"
echo

read option

case "$option" in
# Note variable is quoted.

"1")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    ;;
    # Note double semicolon to terminate each option.

"2")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    echo
    msg "Upgrading System:"
    echo
    pacman -Syu
    echo
    msg "System update complete."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"3")
    echo
    msg "Processing mirrors"
    echo
    pacman-mirrors -g
    echo
    msg "Refreshing your pacman databases"
    echo
    pacman -Syy
    echo
    msg "Upgrading System & AUR:"
    echo
    yaourt -Syua
    echo
    msg "System including AUR packages are up to date."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"4")
    echo
    msg "Upgrading System:"
    echo
    pacman -Syu
    echo
    msg "System update complete."
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;
    # Note double semicolon to terminate each option.

"5")
    echo
    msg "Upgrading System & AUR: "
    echo
    yaourt -Syua
    echo
    msg "System including AUR packages are up to date. "
    echo
    msg "CacheClean will now remove all but the 2 most "
    msg "recent versions of the installation packages in "
    msg "/var/cache/pacman/pkg directory:"
    echo
    cacheclean -v 2
    echo
    msg "CacheClean has done its job. "
    echo
    ;;

esac

exit 0

Si su sistema tiene instalado pacman 4.1 (o superior) probablemente les convenga usar este script en lugar del anterior.

Licensed under CC BY-NC-SA 4.0
脷ltima actualizaci贸n 25 feb. 2013 225:00 CST
Todas las im谩genes, nombres de productos y nombres de empresa o logotipos citados en esta p谩gina web son propiedad de sus respectivos propietarios.
Creado con Hugo
Tema Stack dise帽ado por Jimmy