Hirdetés

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

  • meone

    tag

    válasz r0by #5101 üzenetére

    Újból sikerült kijavítanom pár hibát.
    A rendszernek ez a része már 95%-ban múködik.

    A kód jelenleg így nézki:

    #!/bin/sh

    user="root"


    config="/opt/etc/rtorrent.conf"

    options="-n -o import=${config}"

    base="/opt/etc/samba/Share/torrent"

    srname="rtorrent"

    logfile="/opt/etc/samba/Share/download/torrentInit.log"


    PATH=/opt/bin:/opt/sbin:/usr/bin:/sbin:/bin:/usr/sbin
    DESC="rtorrent"
    NAME=rtorrent
    DAEMON=$NAME
    SCRIPTNAME=/etc/init.d/$NAME

    test -x /opt/bin/screen || ( echo "screen not found." | tee -a "$logfile" >&2 ; exit 2 )
    test -x /opt/bin/su -o -x /bin/su || ( echo "su not found." | tee -a "$logfile" >&2 ; exit 2 )
    )

    checkcnfg() {
    exists=0
    for i in `echo "$PATH" | tr ':' '\n'` ; do
    if [ -f $i/$NAME ] ; then
    exists=1
    break
    fi
    done
    if [ $exists -eq 0 ] ; then
    echo "cannot find rtorrent binary in PATH $PATH" | tee -a "$logfile" >&2

    exit 3
    fi

    if ! [ -r "${config}" ] ; then
    echo "cannot find readable config ${config}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2

    exit 3
    fi
    session=`getsession "$config"`
    if ! [ -d "${session}" ] ; then
    echo "cannot find readable session directory ${session} from config ${config}. check permissions" | tee -a "$logfile" >&2


    exit 3
    fi
    }


    getsession() {
    session=`awk '/^[[:space:]]*session[[:space:]]*=[[:space:]]*/{print($3)}' "$config"`
    echo $session
    }

    getprange() {
    ports=`awk '/^[[:space:]]*port_range[[:space:]]*=[[:space:]]*/{print($3)}' "$config" | sed "s/-/ /"`
    echo $ports
    }

    getdhtport() {
    dht_port=`awk '/^[[:space:]]*dht_port[[:space:]]*=[[:space:]]*/{print($3)}' "$config"`
    echo $dht_port
    }

    fwopen() {
    DHT_PORT=`getdhtport "$config"`
    iptables -D INPUT -j DROP
    PORTS=$(seq `getprange "$config"`)
    for P in $PORTS; do
    iptables -I INPUT -i vlan1 -p tcp --syn --dport $P -j ACCEPT
    done
    if [ $DHT_PORT ]; then
    iptables -I INPUT -i vlan1 -p tcp --dport $DHT_PORT -j ACCEPT
    fi
    iptables -A INPUT -j DROP
    }


    fwclose() {
    DHT_PORT=`getdhtport "$config"`
    PORTS=$(seq `getprange "$config"`)
    for P in $PORTS; do
    iptables -D INPUT -i vlan1 -p tcp --syn --dport $P -j ACCEPT
    done
    if [ $DHT_PORT ]; then
    iptables -D INPUT -i vlan1 -p tcp --dport $DHT_PORT -j ACCEPT
    fi
    }

    d_start() {
    [ -d "${BASE}" ] && cd "${BASE}"
    fwopen
    stty stop undef && stty start undef
    screen -ls | grep .$SRNAME[[:space:]] > /dev/null || \screen -dm -S ${SRNAME}
    screen -S ${SRNAME} -X screen rtorrent ${OPTIONS} 2>&1 1>/dev/null | tee -a "$logfile" >&2
    }

    d_stop() {
    fwclose
    session=`getsession "$config"`
    if ! [ -s ${session}/rtorrent.lock ] ; then
    return
    fi
    pid=`cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
    if ps -A | grep -sq ${pid}.*rtorrent ; then # make sure the pid doesn't belong to another process
    kill -s INT ${pid}
    fi
    }

    checkcnfg

    case "$1" in
    start)
    echo -n "Starting $DESC: $NAME"
    d_start
    echo "."
    ;;
    stop)
    echo -n "Stopping $DESC: $NAME"
    d_stop
    echo "."
    ;;
    restart|force-reload)
    echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 1
    d_start
    echo "."
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    #echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
    esac

    exit 0

    Ha kiadom a parancsot egyszerűen akkor ezt jön vissza:

    [root@001346178395 root]$ /opt/etc/init.d/S99rtorrent
    Usage: /etc/init.d/rtorrent {start|stop|restart|force-reload}

    Ha startal adom ki a parancsot akkor meg ez az eredménye:

    [root@001346178395 root]$ /opt/etc/init.d/S99rtorrent start
    Starting rtorrent: rtorrent/opt/etc/init.d/S99rtorrent: /opt/etc/init.d/S99rtorrent: 226: gt: not found
    /opt/etc/init.d/S99rtorrent: /opt/etc/init.d/S99rtorrent: 226: /dev/null: Permission denied
    No Sockets found in /tmp/screens/S-root.
    Use: screen [-opts] [cmd [args]]
    or: screen -r [host.tty]

    Options:
    -a Force all capabilities into each window's termcap.
    -A -[r|R] Adapt all windows to the new display width & height.
    -c file Read configuration file instead of '.screenrc'.
    -d (-r) Detach the elsewhere running screen (and reattach here).
    -dmS name Start as daemon: Screen session in detached mode.
    -D (-r) Detach and logout remote (and reattach here).
    -D -RR Do whatever is needed to get a screen session.
    -e xy Change command characters.
    -f Flow control on, -fn = off, -fa = auto.
    -h lines Set the size of the scrollback history buffer.
    -i Interrupt output sooner when flow control is on.
    -l Login mode on (update /opt/var/run/utmp), -ln = off.
    -list or -ls. Do nothing, just list our SockDir.
    -L Turn on output logging.
    -m ignore $STY variable, do create a new screen session.
    -O Choose optimal output rather than exact vt100 emulation.
    -p window Preselect the named window if it exists.
    -q Quiet startup. Exits with non-zero return code if unsuccessful.
    -r Reattach to a detached screen process.
    -R Reattach if possible, otherwise start a new session.
    -s shell Shell to execute rather than $SHELL.
    -S sockname Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
    -t title Set title. (window's name).
    -T term Use term as $TERM for windows, rather than "screen".
    -U Tell screen to use UTF-8 encoding.
    -v Print "Screen version 4.00.03 (FAU) 23-Oct-06".
    -wipe Do nothing, just clean up SockDir.
    -x Attach to a not detached screen. (Multi display mode).
    -X Execute <cmd> as a screen command in the specified session.

    Error: Specify session-name with -S
    /opt/var/run/utmp: No such file or directory
    *** rTorrent 0.8.4/0.12.4 - 001346178395:297 ***
    [View: main]


    (12:48:11) Using 'select' based polling.
    (12:48:11) Could not read resource file: ~/.rtorrent.rc
    [Throttle off/off KB] [Rate 0.0/ 0.0 KB] [Port: 6932] [U 0/0] [D 0/0] [H 0/32] [S 0/1/768] [F

    Ezt sérelmezi de nem tudom, hogy hogy lehet kijavítani:
    Could not read resource file: ~/.rtorrent.rc a kódban pedig jól van hivatkozva.

    A másik problémálya pedig ez: /opt/etc/init.d/S99rtorrent: 226: gt: not found.
    A kódban a 226.sorban ez a parancs áll: esac

    A process listában pedig így jelenik meg:

    175 ? S 0:00 upnp -D -L br0 -W eth1
    295 ? Ss 0:00 SCREEN -S -X screen rtorrent
    297 pts/2 Ss+ 0:00 rtorrent
    298 ? Ss 0:00 dropbear
    299 pts/0 Ss 0:00 -sh
    302 pts/0 R+ 0:00 ps -ax

    Valakinek valami ötelte még, hogy hol kell kijavítanom a kódot? :F

    Elnézést kérek mindenkitől a helyes írásom ért :)

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