Hirdetés

Új hozzászólás Aktív témák

  • syluccy

    csendes tag

    közben rájöttem, hogy a fun_pkg telepítésekor is ilyen scriptek lettek lefuttatva, úgyhogy nagy valószínűséggel jó ez ide is, viszont nem merem lefuttatni, nehogy összeb*sszam azt, ami működik. átírtam - természetesen username és password nélkül - a scriptet, valaki lektorálná, aki ért hozzá?

    #!/bin/sh

    # *************
    # Configuration
    REMOTE="/mnt/HD_a2/transmission-downloads"
    USERNAME="username"
    PASSWORD="password"
    MAXDOWN="3"
    MAXACTIVE="20"
    CONFIG="/mnt/HD_a2/.transmission-daemon/settings.json"

    # *************
    # Set-up variables
    CMD="$REMOTE --auth $USERNAME:$PASSWORD"
    LOGCMD="/usr/bin/logger -t transmission-queue "
    MAXRATIO=$(cat $CONFIG | grep \"ratio-limit\":)
    MAXRATIO=${MAXRATIO#*\"ratio-limit\": }
    MAXRATIO=${MAXRATIO%*, }

    # *************
    # deal with downloads
    DOWNACTIVE="$($CMD -l | tail --lines=+2 | grep -v 100% | grep -v Sum | grep -v Stopped

    | wc -l)"
    if [ $MAXDOWN -lt $DOWNACTIVE ]; then
    DOWNTOSTOP="$($CMD -l | tail --lines=+2 | grep -v 100% | grep -v Sum | grep -v

    Stopped | \
    tail -n $(expr $DOWNACTIVE - $MAXDOWN) | awk '{ print $1; }')"
    for ID in $DOWNTOSTOP; do
    NAME="$($CMD --torrent $ID --info | grep Name:)"
    $LOGCMD "<<< $ID: ${NAME#*Name: }"
    $CMD --torrent $ID --stop >> /dev/null 2>&1
    done
    else
    [ $(expr $MAXDOWN - $DOWNACTIVE) -gt 0 ] && (
    DOWNINACTIVE="$($CMD -l | tail --lines=+2 | grep -v 100% | grep Stopped | wc

    -l)"
    [ $DOWNINACTIVE -gt 0 ] && (
    DOWNTOSTART="$($CMD -l | tail --lines=+2 | grep -v 100% | grep Stopped

    | \
    head -n $(expr $MAXDOWN - $DOWNACTIVE) | awk '{ print $1; }')"
    for ID in $DOWNTOSTART; do
    NAME="$($CMD --torrent $ID --info | grep Name:)"
    $LOGCMD ">>> $ID: ${NAME#*Name: }"
    $CMD --torrent $ID --start >> /dev/null 2>&1
    done
    )
    )
    fi
    # Then deal with total active
    ACTIVE="$($CMD -l | tail --lines=+2 | grep -v Sum | grep -v Stopped | wc -l)"
    if [ $MAXACTIVE -lt $ACTIVE ]; then
    TOSTOP="$($CMD -l | tail --lines=+2 | grep 100% | grep -v Stopped | \
    tail -n $(expr $ACTIVE - $MAXACTIVE) | awk '{ print $1; }')"
    for ID in $TOSTOP; do
    NAME="$($CMD --torrent $ID --info | grep Name:)"
    $LOGCMD "<<< $ID: ${NAME#*Name: }"
    $CMD --torrent $ID --stop >> /dev/null 2>&1
    done
    else
    [ $(expr $MAXACTIVE - $ACTIVE) -gt 0 ] && (
    SEEDINACTIVE="$($CMD -l | tail --lines=+2 | grep 100% | grep Stopped | \
    awk -v ratio=$MAXRATIO '{ if (strtonum(substr($0,52,4)) < ratio) print

    $0 ;}' | wc -l)"
    [ $SEEDINACTIVE -gt 0 ] && (
    TOSTART="$($CMD -l | tail --lines=+2 | grep 100% | grep Stopped | \
    awk -v ratio=$MAXRATIO '{ if (strtonum(substr($0,52,4)) <

    ratio) print $0 ;}' | \
    head -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }')"
    for ID in $TOSTART; do
    NAME="$($CMD --torrent $ID --info | grep Name:)"
    $LOGCMD ">>> $ID: ${NAME#*Name: }"
    $CMD --torrent $ID --start >> /dev/null 2>&1
    done
    )
    )
    fi

Új hozzászólás Aktív témák

Hirdetés