source: repoman/bin/torrent-creator @ cc2032b

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 cc2032b was cc2032b, checked in by ramon <ramongomez@…>, 15 years ago

Script de creación de ficheros .torrent para el Repositorio de imágenes.

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

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2
3#Version 0.3   Ejecución desde cron cada minuto,
4# Trabaja sólo con la primera imagen que tenga asociado un fichero .doTorrent
5##  echo "  * * * * *    root   /opt/opengnsys/bin/torrent-creator" > /etc/cron.d/torrent-creator.cron
6
7
8# Variables.
9PROG=$(basename $0)
10OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
11PATH=$PATH:$OPENGNSYS/bin
12OGIMG="$OPENGNSYS/images"
13source $OPENGNSYS/etc/ogAdmRepo.cfg
14TRACKERURL="http://$IPlocal:6969/announce"
15LOGFILE="$OPENGNSYS/log/$PROG.log"
16
17if [ "$(pgrep "$PROG")" != "$$" ]; then
18        echo "`date` : Proceso ya en ejecución" >> $LOGFILE
19        exit
20fi
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
27for IMG in *.img; do
28        # Saltar al siguiente si no existe el fichero.
29        [ -f "$IMG" ] || continue
30        # Comprobar si ya existe el fichero Torrent para esa imagen.
31        TORRENT="$IMG.torrent"
32        if [ -f "$TORRENT"  ]; then
33                FILESIZE="$(ls -l $IMG | awk '{print $5}')"
34                read -e TORRFILE TORRSIZE <<<"$(ctorrent -x $TORRENT | awk '$1~/<1>/ {print $2,$3}')"
35                [ "$(basename $IMG)" = "$TORRFILE" -a "[$FILESIZE]" = "$TORRSIZE" ] && continue
36        fi
37        # Crear fichero Torrent.
38        echo "`date` : Inicio creación de fichero $TORRENT" >> $LOGFILE
39        rm -f "$TORRENT"
40        nice -8 ctorrent -t "$IMG" -u $TRACKERURL -s "$TORRENT"
41        if [ -f "$TORRENT"  ]; then
42                echo "`date` : Fin creación de fichero $TORRENT" >> $LOGFILE
43        else
44                echo "`date` : ERROR en creación de fichero $TORRENT" >> $LOGFILE
45        fi
46done
47       
48popd >/dev/null
49
Note: See TracBrowser for help on using the repository browser.