source: repoman/bin/torrent-creator @ 8fc9552

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 8fc9552 was 2b2144f, checked in by ramon <ramongomez@…>, 14 years ago

El script de repositorio torrent-creator no trata las imágenes que están bloqueadas.
Refs #298.

git-svn-id: https://opengnsys.es/svn/trunk@1471 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 1.7 KB
RevLine 
[cc2032b]1#!/bin/bash
[9ee62ad]2# Genera los ficheros .torrent de las imágenes almacenadas en el repositorio.
[cc2032b]3#Version 0.3   Ejecución desde cron cada minuto,
[9ee62ad]4##  echo "* * * * *   root   /opt/opengnsys/bin/torrent-creator" > /etc/cron.d/torrentcreator
[cc2032b]5
6
[9ee62ad]7# Comprobar si el proceso ya está en ejecución.
[cc2032b]8PROG=$(basename $0)
[9ee62ad]9[ "$(pgrep "$PROG")" != "$$" ] && exit
10
11# Variables.
[cc2032b]12OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
13PATH=$PATH:$OPENGNSYS/bin
14OGIMG="$OPENGNSYS/images"
[9ee62ad]15REPOCFG="$OPENGNSYS/etc/ogAdmRepo.cfg"
[cc2032b]16LOGFILE="$OPENGNSYS/log/$PROG.log"
[9ee62ad]17# Error si no está bien configurado el repositorio de imágenes.
18[ -d $OGIMG -a -f $REPOCFG ] || exit 1
19source $REPOCFG
20TRACKERURL="http://$IPlocal:6969/announce"
[cc2032b]21
22# Directorio de imágenes.
23pushd $OGIMG >/dev/null
24
25# Procesar ficheros de imágenes.
26trap 'echo "`date` : Proceso interrumpido" >> $LOGFILE; exit ' 1 2 3 6 9 15
[0fbc05e]27for IMG in *.{img,pgz}; do
[2b2144f]28        # Saltar al siguiente si la imagen está bloqueada o si no existe el fichero.
29        if [ -f "$IMG.lock" -o ! -f "$IMG" ]; then
30                continue
31        fi
[cc2032b]32        # Comprobar si ya existe el fichero Torrent para esa imagen.
33        TORRENT="$IMG.torrent"
34        if [ -f "$TORRENT"  ]; then
35                FILESIZE="$(ls -l $IMG | awk '{print $5}')"
36                read -e TORRFILE TORRSIZE <<<"$(ctorrent -x $TORRENT | awk '$1~/<1>/ {print $2,$3}')"
37                [ "$(basename $IMG)" = "$TORRFILE" -a "[$FILESIZE]" = "$TORRSIZE" ] && continue
38        fi
39        # Crear fichero Torrent.
40        echo "`date` : Inicio creación de fichero $TORRENT" >> $LOGFILE
41        rm -f "$TORRENT"
42        nice -8 ctorrent -t "$IMG" -u $TRACKERURL -s "$TORRENT"
43        if [ -f "$TORRENT"  ]; then
44                echo "`date` : Fin creación de fichero $TORRENT" >> $LOGFILE
45        else
46                echo "`date` : ERROR en creación de fichero $TORRENT" >> $LOGFILE
47        fi
48done
49       
50popd >/dev/null
51
Note: See TracBrowser for help on using the repository browser.