source: client/shared/scripts/updateCache @ 51db584

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 51db584 was 2338c95f, checked in by ramon <ramongomez@…>, 14 years ago

Rama version1.0:

  • Redistribución de directorios para el cliente.
  • Modificación del instalador para adaptarse a la nueva estructura de directorios.
  • Desinstalador quita los recursos de OpenGnSys en Samba.
  • Documentación actualizada para la nueva versión.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@1526 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.5 KB
Line 
1#!/bin/bash
2
3# Scirpt para la actualizacion de datos en la cache.
4# Versión: 0.9.1, 2008/03/17, - integracion eac
5# Versión: 0.9.2, 2010/07/27, -  integracion opengnsys
6
7
8
9#1 REPO
10#2 nombre del fichero con su extension, tipo /imagen1.img  o /ubuntu.iso
11#3 Protocolo TORRENT | MULTICAST    | UNICAST
12#4 opciones protocolo   
13#5 opciones de update cache
14
15
16PROG="$(basename $0)"
17if [ $# -lt 4 ]; then
18    ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG str_REPO _str_Relative_Path_OGIMG_with_/ PROTOCOLO OPCIONES_PROTOCOLO OPCIONES_UPDATECACHE"
19    exit $?
20fi
21
22REPOSITORIO=$1
23PROTOCOLO=$3
24OPTPROTOCOLO=$4
25echo $REPOSITORIO $PROTOCOLO $OPTPROTOCOLO
26# Si el repositorio local CACHE no existe salimos.
27if ! $(ogFindCache >/dev/null); then
28        ogRaiseError $OG_ERR_NOTFOUND "CACHE"
29        exit $?
30fi
31
32
33CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
34FILESIZE=$(ls -sk $(ogGetPath $1 $2) | cut -f1 -d" ")
35
36if [ "$FILESIZE" -ge "$CACHESIZEFREE" ] 
37then
38        echo "el tamanio del fichero $2 = $FILESIZE es mayor que el espacio dispinible en la cache = $CACHESIZEFREE"
39        exit 1
40fi
41
42ogUpdateCacheIsNecesary $1 $2 || exit 0
43
44ogMountCache
45
46## Si no existe, crear subdirectorio para el fichero en la cache.
47IMGDIR=$(ogGetParentPath "$1" "/$2")
48if [ $? != 0 ]; then
49    echo "[5] Crear subdirectorio del fichero  \"$2 $(dirname "$2")."
50   ogMakeDir "CACHE" $(dirname "/$2")
51   IMGDIR=$(ogGetParentPath "$1" "/$2") || exit $?
52fi
53
54
55echo "ogCopyFile $1 $2.torrent absolute $OGCAC$OGIMG"
56ogCopyFile $1 $2.torrent $OGCAC$OGIMG
57#TODO: comprobar que el tracker definido en el fichero es correcto.
58case "$PROTOCOLO" in
59        torrent | TORRENT )
60        #[ -z $OPTPROTOCOLO ] && OPTPROTOCOL=leecher:10
61        echo "ogTorrentStart CACHE $2.torrent $4"
62        ogTorrentStart CACHE $2.torrent $4
63        ;;
64        multicast | MULTICAST )
65        echo "determinando puerto principal y auxiliar."
66        PORT=$(echo $OPTPROTOCOLO | cut -f1 -d":")
67        let PORTAUX=$PORT+1
68        echo "comprobando que el servidor está activo"
69        if (nmap -n -sU -p $PORTAUX $repo | grep open)
70        then
71           ogMcastReceiverFile $PORT CACHE $2
72        else
73           echo "solicita la apertura:  hose $repo 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO""
74           hose $repo 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO"
75           #echo "espero y llamo a: ogMcastReceiverFile $PORT CACHE $2"
76           sleep 30
77           ogMcastReceiverFile $PORT CACHE $2     
78        fi
79        ;;
80        unicast | UNICAST )
81        echo "unicast"
82        ;;
83esac
84
85if ogUpdateCacheIsNecesary $1 $2
86then
87        echo "algo ha fallado"
88        exit 1
89else
90        echo "updateCache ok"
91        exit 0
92fi
93
94
95
96#
Note: See TracBrowser for help on using the repository browser.