Hirdetés
-
IT café
ASUS WL-500G Premium
Új hozzászólás Aktív témák
-
Kelvin
őstag
Nem tudom, hogy a 13. sorban mi a baj azzal az & jellel...
Belinkelem a S99rtorrent-emet#!/bin/sh
config="/opt/etc/rtorrent.conf"
OPTIONS="-n -o import=${config}"
BASE="/opt/etc/samba/Share/torrent"
SRNAME=rtorrent
logfile="/opt/var/log/rtorrentInit.log"
PATH=/opt/bin:/opt/sbin:/usr/bin:/sbin:/bin:/usr/sbin
DESC=rtorrent
NAME=rtorrent
# Do not proceed unless some apps are available.
test -x /opt/bin/screen || ( echo "screen 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: $0 {start|stop|restart|force-reload}" >&2
exit 1;;
esac
exit 0"A legvégén nem az fog számítani,hogy mennyi év volt életedben,hanem hogy mennyi élet volt éveidben"
Új hozzászólás Aktív témák
Hirdetés
● Olvasd el az összefoglalót!
- Witcher topik
- Gitáros topic
- A fociról könnyedén, egy baráti társaságban
- Kintről jön a hideg, vagy csak a ventilátorok pörögtek fel?
- Ukrajnai háború
- Nyomtató topik
- iPad topik
- Autós topik
- Intel Core i3 / i5 / i7 4xxx "Haswell" és "Haswell Refresh / Devil's Canyon" (LGA1150)
- Alan Wake II - Napokon belül érkezik a The Lake House című DLC
- További aktív témák...
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Ozeki Kft
Város: Debrecen