1 | #!/bin/bash |
---|
2 | #@file upgrade-clients-udeb.sh |
---|
3 | #@brief Actualiza los paquetes udeb que deben ser exportados a los clientes. |
---|
4 | #@arg \c distrib - nombre de la distribución de Ubuntu (karmic, jaunty, ...). |
---|
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"} |
---|
12 | test "$(lsb_release -is 2>/dev/null)" == "Ubuntu" && DEFDISTRIB="$(lsb_release -cs)" |
---|
13 | DEFDISTRIB=${DEFDISTRIB:-"lucid"} |
---|
14 | DISTRIB=${1:-"$DEFDISTRIB"} # Si no se indica, usar distribución por defecto. |
---|
15 | CFGFILE="$OPENGNSYS/etc/udeblist-$DISTRIB.conf" |
---|
16 | OGUDEB="$OPENGNSYS/client/lib/udeb" |
---|
17 | TMPUDEB="/tmp/udeb" |
---|
18 | UDEBLIST="/etc/apt/sources.list.d/udeb.list" |
---|
19 | KERNELVERS=$(strings $OPENGNSYS/tftpboot/linux | awk '/2.6.*generic/ {print $1}') |
---|
20 | |
---|
21 | # Comprobar fichero de configuración. |
---|
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) |
---|
27 | PACKAGES_INSTALL=${PACKAGES_INSTALL//KERNELVERS/$KERNELVERS} |
---|
28 | PACKAGES_REMOVE=$(awk -F: '$1~/remove/ {print $2}' $CFGFILE) |
---|
29 | PACKAGES_REMOVE=${PACKAGES_REMOVE//KERNELVERS/$KERNELVERS} |
---|
30 | if [ -z "$PACKAGES_INSTALL" ]; then |
---|
31 | echo "$PROG: No hay paquetes para descargar." >&2 |
---|
32 | exit 2 |
---|
33 | fi |
---|
34 | |
---|
35 | # Crear configuración para apt-get |
---|
36 | echo "deb http://archive.ubuntu.com/ubuntu/ $DISTRIB main/debian-installer universe/debian-installer" >$UDEBLIST |
---|
37 | echo "deb http://archive.ubuntu.com/ubuntu/ $DISTRIB-updates main/debian-installer universe/debian-installer" >>$UDEBLIST |
---|
38 | mkdir -p $TMPUDEB/partial |
---|
39 | rm -f $TMPUDEB/*.udeb |
---|
40 | |
---|
41 | # Descargar paquetes udeb, borrar los descartables y moverlos al NFS. |
---|
42 | apt-get update |
---|
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 | |
---|