[bd7b0ec] | 1 | #!/bin/bash |
---|
| 2 | #@file upgrade-clients-udeb.sh |
---|
| 3 | #@brief Actualiza los paquetes udeb que deben ser exportados a los clientes. |
---|
[b9a5881] | 4 | #@arg \c distrib - nombre de la distribución de Ubuntu (karmic, jaunty, ...). |
---|
[bd7b0ec] | 5 | #@note El script debe ser copiado a \c opengnsys/bin y el fichero de configuración a \c opengnsys/etc |
---|
| 6 | #@note Formato del fichero \c udeb.list : {install|remove}:paquete |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | # Variables |
---|
| 10 | PROG="$(basename $0)" |
---|
| 11 | OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} |
---|
[f56f8b2] | 12 | test "$(lsb_release -is 2>/dev/null)" == "Ubuntu" && DEFDISTRIB="$(lsb_release -cs)" |
---|
[28c96b3] | 13 | DEFDISTRIB=${DEFDISTRIB:-"lucid"} |
---|
| 14 | DISTRIB=${1:-"$DEFDISTRIB"} # Si no se indica, usar distribución por defecto. |
---|
[f56f8b2] | 15 | CFGFILE="$OPENGNSYS/etc/udeblist-$DISTRIB.conf" |
---|
[bd7b0ec] | 16 | OGUDEB="$OPENGNSYS/client/lib/udeb" |
---|
| 17 | TMPUDEB="/tmp/udeb" |
---|
| 18 | UDEBLIST="/etc/apt/sources.list.d/udeb.list" |
---|
[8908baa] | 19 | KERNELVERS=$(strings $OPENGNSYS/tftpboot/linux | awk '/2.6.*generic/ {print $1}') |
---|
[bd7b0ec] | 20 | |
---|
[f56f8b2] | 21 | # Comprobar fichero de configuración. |
---|
[bd7b0ec] | 22 | if [ ! -f "$CFGFILE" ]; then |
---|
| 23 | echo "$PROG: No existe el fichero de configuración \"$CFGFILE\"" >&2 |
---|
| 24 | exit 1 |
---|
| 25 | fi |
---|
| 26 | PACKAGES_INSTALL=$(awk -F: '$1~/install/ {print $2}' $CFGFILE) |
---|
[8908baa] | 27 | PACKAGES_INSTALL=${PACKAGES_INSTALL//KERNELVERS/$KERNELVERS} |
---|
[bd7b0ec] | 28 | PACKAGES_REMOVE=$(awk -F: '$1~/remove/ {print $2}' $CFGFILE) |
---|
[8908baa] | 29 | PACKAGES_REMOVE=${PACKAGES_REMOVE//KERNELVERS/$KERNELVERS} |
---|
[bd7b0ec] | 30 | if [ -z "$PACKAGES_INSTALL" ]; then |
---|
| 31 | echo "$PROG: No hay paquetes para descargar." >&2 |
---|
| 32 | exit 2 |
---|
| 33 | fi |
---|
| 34 | |
---|
[f56f8b2] | 35 | # Crear configuración para apt-get |
---|
| 36 | echo "deb http://archive.ubuntu.com/ubuntu/ $DISTRIB main/debian-installer universe/debian-installer" >$UDEBLIST |
---|
[8908baa] | 37 | echo "deb http://archive.ubuntu.com/ubuntu/ $DISTRIB-updates main/debian-installer universe/debian-installer" >>$UDEBLIST |
---|
[bd7b0ec] | 38 | mkdir -p $TMPUDEB/partial |
---|
| 39 | rm -f $TMPUDEB/*.udeb |
---|
| 40 | |
---|
[f56f8b2] | 41 | # Descargar paquetes udeb, borrar los descartables y moverlos al NFS. |
---|
[50038e9] | 42 | apt-get update |
---|
[bd7b0ec] | 43 | apt-get install -y -o dir::cache::archives=$TMPUDEB -d $PACKAGES_INSTALL |
---|
| 44 | for i in $PACKAGES_REMOVE; do |
---|
| 45 | rm -f $TMPUDEB/${i}_*.udeb |
---|
| 46 | done |
---|
| 47 | rm -f $OGUDEB/*.udeb |
---|
| 48 | mv $TMPUDEB/*.udeb $OGUDEB |
---|
| 49 | rm -f $UDEBLIST |
---|
| 50 | |
---|