| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | #/** |
|---|
| 4 | # updateBootCache |
|---|
| 5 | #@brief acelerador arranque pxe. incorpora a la cache el initrd y el kernel. |
|---|
| 6 | #@param 1 |
|---|
| 7 | #@param ejemplo: |
|---|
| 8 | #@return |
|---|
| 9 | #@exception OG_ERR_NOTCACHE # 15 si cache no existe 15 |
|---|
| 10 | #@exception OG_ERR_NOTFOUND=2 # Fichero o dispositivo no encontrado. |
|---|
| 11 | #@note |
|---|
| 12 | #@todo: |
|---|
| 13 | #@version 1.0.1 - requiere el gestor de arranque grub2dos |
|---|
| 14 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
|---|
| 15 | #@date 2010/07/27 |
|---|
| 16 | #@version 1.1.0 - Permite varios ogLive dentro de subdirectorios |
|---|
| 17 | #@author Irina Gómez. ETSII Universidad de Sevilla |
|---|
| 18 | #@date 2017/04/27 |
|---|
| 19 | #@version 1.1.0 - Se permite varios ogLives en la CACHE |
|---|
| 20 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 21 | #@date 2017/05/31 |
|---|
| 22 | #@version 1.1.0 - Limpieza de codigo, control errores |
|---|
| 23 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
|---|
| 24 | #@date 2018-01-21 |
|---|
| 25 | #*/ ## |
|---|
| 26 | |
|---|
| 27 | OGLIVEDIR=${oglivedir:-"ogLive"} |
|---|
| 28 | OGBTFTP="/opt/oglive/tftpboot/$OGLIVEDIR" |
|---|
| 29 | OGBCACHE="$OGCAC/boot/$OGLIVEDIR" |
|---|
| 30 | |
|---|
| 31 | #control de errores |
|---|
| 32 | [ -d "$OGBTFTP" ] || exit $(ogRaiseError $OG_ERR_NOTFOUND "$OGBTFTP"; echo $?) |
|---|
| 33 | ogMountCache || exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?) |
|---|
| 34 | |
|---|
| 35 | [ -d $OGBCACHE ] || mkdir -p $OGBCACHE |
|---|
| 36 | |
|---|
| 37 | # comparamos los del server |
|---|
| 38 | SERVERVMLINUZ=`cat ${OGBTFTP}/ogvmlinuz.sum 2>/dev/null` |
|---|
| 39 | SERVERINITRD=`cat ${OGBTFTP}/oginitrd.img.sum 2>/dev/null` |
|---|
| 40 | |
|---|
| 41 | #comparamos los de la cache |
|---|
| 42 | CACHEVMLINUZ=`cat ${OGBCACHE}/ogvmlinuz.sum 2>/dev/null` |
|---|
| 43 | CACHEINITRD=`cat ${OGBCACHE}/oginitrd.img.sum 2>/dev/null` |
|---|
| 44 | |
|---|
| 45 | echo "MD5 on SERVER: $SERVERVMLINUZ $SERVERINITRD" |
|---|
| 46 | echo "MD5 on CACHE: $CACHEVMLINUZ $CACHEINITRD" |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | if [ "$CACHEVMLINUZ" != "$SERVERVMLINUZ" ] |
|---|
| 50 | then |
|---|
| 51 | echo "ogvmlinuz updating" |
|---|
| 52 | cp "${OGBTFTP}/ogvmlinuz" "${OGBCACHE}/ogvmlinuz" |
|---|
| 53 | cp "${OGBTFTP}/ogvmlinuz.sum" "${OGBCACHE}/ogvmlinuz.sum" |
|---|
| 54 | DOREBOOT=true |
|---|
| 55 | fi |
|---|
| 56 | if [ "$CACHEINITRD" != "$SERVERINITRD" ] |
|---|
| 57 | then |
|---|
| 58 | echo "oginitrd updating" |
|---|
| 59 | cp "${OGBTFTP}/oginitrd.img" "${OGBCACHE}/oginitrd.img" |
|---|
| 60 | cp "${OGBTFTP}/oginitrd.img.sum" "${OGBCACHE}/oginitrd.img.sum" |
|---|
| 61 | DOREBOOT=true |
|---|
| 62 | fi |
|---|
| 63 | |
|---|
| 64 | echo $DOREBOOT |
|---|
| 65 | # [ "$DOREBOOT" == "true" ] && busybox reboot -f |
|---|