Temat: [poradnik] Instalacja pyLoad + autostart
PyLoad jest jednym z popularniejszych download managerów które można zainstalować na OpenWRT. Moim celem jest zintegrowanie go z FlexGetem w celu automatycznego pobierania podcastów z kanałów RSS ze stron EEVblog i ted.com
1. Instalujemy wymagane biblioteki.
Ponieważ pyLoad jest napisany w Pythonie to najpierw instalujemy niezbędne biblioteki.
opkg update
opkg install python-curl python-crypto python-sqlite3 python-openssl pyopenssl openssl-util python-expat unzip unrar screen wget
2. Przygotowujemy folder.
Zakładam że program będzie zainstalowany w: /mnt/hdd1/programy/pyload, przechodzimy wiec do katalogu /mnt/hdd1:
cd /mnt/hdd1
tworzymy katalog programy i przechodzimy do niego:
mkdir programy
cd programy/
3. Ściągamy najnowszą wersje pyLoad.
Metoda 1 - na komputerze
Pobieramy najnowszą wersje z https://bitbucket.org/spoob/pyload/get/stable.zip i rozpakowujemy na dysk komputera.
Po rozpakowaniu otrzymamy katalog „spoob-pyload-0dcbf0c60f5e″ lub o podobnej nawie. Zmieniamy nazwę na „pyload” i kopiujemy przez WinSCP do /mnt/hdd1/programy/
Metoda 2 - bezpośrednio na routerze
Przechodzimy do katalogu /mnt/hdd1/programy:
cd /mnt/hdd1/programy
Ściągamy plik stable.zip:
wget https://bitbucket.org/spoob/pyload/get/stable.zip --no-check-certificate
dodanie –no-check-certificate jest konieczne ponieważ połączenie z https jest szyfrowane bez tego zobaczysz błąd weryfikacji certyfikatu:
--2012-07-10 21:59:07-- https://bitbucket.org/spoob/pyload/get/stable.zip
Resolving bitbucket.org... 207.223.240.181, 207.223.240.182
Connecting to bitbucket.org|207.223.240.181|:443... connected.
ERROR: cannot verify bitbucket.org's certificate, issued by `/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV CA-1':
Unable to locally verify the issuer's authority.
To connect to bitbucket.org insecurely, use `--no-check-certificate'.
Rozpakowujemy archiwum:
unzip stable.zip
po rozpakowaniu powinien się pojawić folder „spoob-pyload-0dcbf0c60f5e″.
Ponieważ nawa może być inna w nowszych wersjach, sprawdź nazwę przez polecenie ls -l:
ls -l
Powinno dać taki rezultat:
-rw-r--r-- 1 root root 1608353 Jul 10 21:56 stable.zip
drwxr-xr-x 7 root root 4096 Jul 10 22:03 spoob-pyload-0dcbf0c60f5e
Jak widać mamy plik stable.zip i folder spoob-pyload-0dcbf0c60f5e.
Plik stable.zip już nie będzie nam potrzebny kasujemy go:
rm stable.zip
i zmieniamy nazwę folderu z spoob-pyload-0dcbf0c60f5e na pyload:
mv spoob-pyload-0dcbf0c60f5e/ pyload
Poczekaj! Nikt nie lubi wpisywać długich nazw ręcznie, bądźmy sprytniejsi zacznij pisać mv sp i wciśnij klawisz [Tab], magicznie nazwa została uzupełniona!
4. Pierwsze uruchomienie.
Tworzymy jeszcze katalog /mnt/hdd1/download
cd /mnt/hdd1/
mkdir download
przechodzimy z powrotem do katalogu pyload i uruchamiamy skrypt pyLoadCore.py
cd /mnt/hdd1/programy/pyload/
python ./pyLoadCore.py
teraz konfiguracja (pogrubiony tekst to wybór), pierwsze podejscie:
This is your first start, running configuration assistant now.
Choose your Language / Wähle deine Sprache ([en], de, fr, it, es, nl, sv, ru, pl, cs, sr, pt_BR): [b]en[/b] [b][enter][/b]
Welcome to the pyLoad Configuration Assistent.
It will check your system and make a basic setup in order to run pyLoad.
The value in brackets [] always is the default value,
in case you don't want to change it or you are unsure what to choose, just hit enter.
Don't forget: You can always rerun this assistent with --setup or -s parameter, when you start pyLoadCore.
If you have any problems with this assistent hit STRG-C,
to abort and don't let him start with pyLoadCore automatically anymore.
When you are ready for system check, hit enter. [b][enter][/b]
## System Check ##
Python Version: OK
pycurl: OK
sqlite3: OK
pycrypto: OK
py-OpenSSL: OK
py-imaging: missing
tesseract: missing
jinja2: OK
beaker: OK
JS engine: missing
System check finished, hit enter to see your status report. [b][enter][/b]
## Status ##
Features available: container decrypting, ssl connection, Webinterface
Features missing:
no Captcha Recognition available
Only needed for some hosters and as freeuser.
no JavaScript engine found
You will need this for some Click'N'Load links. Install Spidermonkey, ossp-js, pyv8 or rhino
You can abort the setup now and fix some dependencies if you want.
Continue with setup? ([y]/n): [b][enter][/b]
Do you want to change the config path? Current is /root/.pyload
If you use pyLoad on a server or the home partition lives on an internal flash it may be a good idea to change it.
Change config path? (y/[n]): y
Setting new configpath, current configuration will not be transferred!
Configpath [/root/.pyload]: [b]/mnt/hdd1/programy/.pyload[/b]
Configpath changed, setup will now close, please restart to go on.
Press Enter to exit. [b][enter][/b]
Drugie podejście:
This is your first start, running configuration assistant now.
Choose your Language / Wähle deine Sprache ([en], de, fr, it, es, nl, sv, ru, pl, cs, sr, pt_BR): [b][enter][/b]
Welcome to the pyLoad Configuration Assistent.
It will check your system and make a basic setup in order to run pyLoad.
The value in brackets [] always is the default value,
in case you don't want to change it or you are unsure what to choose, just hit enter.
Don't forget: You can always rerun this assistent with --setup or -s parameter, when you start pyLoadCore.
If you have any problems with this assistent hit STRG-C,
to abort and don't let him start with pyLoadCore automatically anymore.
When you are ready for system check, hit enter. [b][enter][/b]
## System Check ##
Python Version: OK
pycurl: OK
sqlite3: OK
pycrypto: OK
py-OpenSSL: OK
py-imaging: missing
tesseract: missing
jinja2: OK
beaker: OK
JS engine: missing
System check finished, hit enter to see your status report.
## Status ##
Features available: container decrypting, ssl connection, Webinterface
Features missing:
no Captcha Recognition available
Only needed for some hosters and as freeuser.
no JavaScript engine found
You will need this for some Click'N'Load links. Install Spidermonkey, ossp-js, pyv8 or rhino
You can abort the setup now and fix some dependencies if you want.
Continue with setup? ([y]/n): [b][enter][/b]
Do you want to change the config path? Current is /mnt/hdd1/config/.pyload
If you use pyLoad on a server or the home partition lives on an internal flash it may be a good idea to change it.
Change config path? (y/[n]): [b][enter][/b]
Do you want to configure login data and basic settings?
This is recommend for first run.
Make basic setup? ([y]/n): [b][enter]
[/b]
## Basic Setup ##
The following logindata is valid for CLI, GUI and webinterface.
Username [User]: [b]User1[/b] [b][enter]
[/b]Password: [b]pass[/b] [b][enter]
[/b]Password (again): [b]pass[/b] [b][enter][/b]
External clients (GUI, CLI or other) need remote access to work over the network.
However, if you only want to use the webinterface you may disable it to save ram.
Enable remote access ([y]/n): [b][enter]
[/b]
Language ([en], de, fr, it, es, nl, sv, ru, pl, cs, sr, pt_BR): [b]en [enter]
[/b]Downloadfolder [Downloads]: [b]/mnt/hdd1/wspolne/pobrane/pyload [enter]
[/b]Max parallel downloads [3]: [b][enter]
[/b]Use Reconnect? (y/[n]): [b][enter]
[/b]
Do you want to configure ssl?
Configure ssl? (y/[n]): [b][enter]
[/b]Do you want to configure webinterface?
Configure webinterface? ([y]/n): [b][enter]
[/b]
## Webinterface Setup ##
Activate webinterface? ([y]/n): [b][enter][/b]
Listen address, if you use 127.0.0.1 or localhost, the webinterface will only accessible locally.
Address [0.0.0.0]: [b][enter]
[/b]Port [8000]: [b][enter][/b][b]
[/b]
pyLoad offers several server backends, now following a short explanation.
builtin: Default server, best choice if you dont know which one to choose.
threaded: This server offers SSL and is a good alternative to builtin.
fastcgi: Can be used by apache, lighttpd, requires you to configure them, which is not too easy job.
lightweight: Very fast alternative written in C, requires libev and linux knowledge.
Get it from here: https://github.com/jonashaag/bjoern, compile it
and copy bjoern.so to module/lib
Attention: In some rare cases the builtin server is not working, if you notice problems with the webinterface
come back here and change the builtin server to the threaded one here.
Server ([builtin], threaded, fastcgi, lightweight): [b]threaded[/b] [b][enter][/b]
Setup finished successfully.
Hit enter to exit and restart pyLoad [b][enter]
[/b][b]
[/b]
na koniec uruchamiamy pyLoad:
python ./pyLoadCore.py
Pyload powinien teraz wystartować:
11.07.2012 19:51:46 INFO Starting pyLoad 0.4.9
11.07.2012 19:51:46 INFO Using home directory: /mnt/hdd1/programy/.pyload
11.07.2012 19:51:52 INFO Checksum: Checksum validation is disabled in general configuration
11.07.2012 19:51:53 INFO ExtractArchive: Activated UnRar UnZip
11.07.2012 19:51:53 INFO Activated plugins: CaptchaTrader, Checksum, ClickAndLoad, ExternalScripts, ExtractArchive, LinkdecrypterCom, UpdateManager, XFileSharingPro
11.07.2012 19:51:53 INFO Deactivate plugins: AlldebridCom, DownloadScheduler, EasybytezCom, Ev0InFetcher, HotFolder, IRCInterface, MergeFiles, MultiHome, MultishareCz, Premium4Me, PremiumizeMe, RealdebridCom, RehostTo, XMPPInterface, ZeveraCom
11.07.2012 19:51:53 INFO Downloadtime: True
11.07.2012 19:51:53 INFO Starting ThriftBackend: 0.0.0.0:7227
11.07.2012 19:51:54 INFO Free space: 131.78 GiB
11.07.2012 19:51:55 INFO Activating Accounts...
11.07.2012 19:51:55 INFO Activating Plugins...
/usr/lib/python2.6/site-packages/Crypto/Hash/SHA.py:6: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
from sha import *
11.07.2012 19:52:01 INFO Starting threaded webserver: 0.0.0.0:8000
11.07.2012 19:52:02 INFO pyLoad is up and running
11.07.2012 19:52:05 INFO No Updates for pyLoad
11.07.2012 19:52:05 INFO No plugin updates available
Żadnych błędów wiec udało się go skonfigurować. Teraz wciskamy Ctrl + c aby przerwać proces i powrócić do konsoli.
5. Manualne uruchomienie w tle za pomocą screena
Jezeli chcemy uruchomić pyLoad na żądanie, w tle, to wystarczy wykorzystać polecenie screen który tworzy konsole w tle, ktora jest aktyna nawet po zakończeniu bierzacej sesji SSH
cd /mnt/hdd1/programy/pyload/
screen -dmS pyload python ./pyLoadCore.py
aby podglądnać co dzieje się na tej ukrytej konsoli należy wpisać:
screen -r pyload
aby powrócić do głownej konsoli wciśnij "ctrl+a d"
6. Autostart jako usługa systemowa
Tworzymy plik "pyload" w /etc/init.d/ o zawartości:
#!/bin/sh /etc/rc.common
# For OpenWRT 10.03.1 and Pyload 0.49 stable.
START=99
prefix=/opt"
PATH=${prefix}/bin:${prefix}/sbin:/sbin:/bin:/usr/sbin:/usr/bin
SESSIONNAME=pyload"
DAEMON=screen -dmS $SESSIONNAME python [b]/mnt/hdd1/programy/pyload/pyLoadCore.py[/b]"
DAEMON_OPTS="
start() {
if screen -ls | grep $SESSIONNAME ; then
echo "a screen-session of pyLoad is already running"
else
echo "Starting screen-session of pyLoad"
$DAEMON $DAEMON_OPTS
fi
}
stop() {
if screen -ls | grep $SESSIONNAME ; then
echo "Stopping screen-session of pyLoad"
screen -r $SESSIONNAME -X quit
if screen -ls | grep $SESSIONNAME ; then
echo "stop screen-session of pyLoad failed"
else
echo "screen-session of pyLoad stopped"
fi
else
echo "pyLoad is not running"
fi
}
restart() {
stop
sleep 10
start
}
Nadajemy prawa wykonywania:
cd /etc/init.d/
chmod 755 pyload
aktywujemy:
/etc/init.d/pyload enable
Jezeli aktywacja się powiodła to w katalogu /etc/rc.d powstał link symboliczny o nazwie S99pyload.
i uruchamiamy:
/etc/init.d/pyload start
zobaczymy potwierdzenie
Starting screen-session of pyLoad
Podgląd konsoli z uruchomionym pyloadem tak samo jak w punkcie 5.
7. Otwarcie portów dla WebUI i ThriftBackend na firewallu
Aby dostac się do WebUI należy odblokować port 8000 edytujemy /etc/config/firewall dodając na końcu pliku:
config rule
option name pyLoad_WebUI
option src wan
option proto tcp
option dest_port 8000
option target ACCEPT
teraz restart firewalla:
/etc/init.d/firewall restart
Dodatkowo aby pozwolić na dostęp zewnętrznych aplikacji jak Androidowy klien pyLoad nalezy odblokowac port 7227:
config rule
option name pyLoad_ThriftBackend
option src wan
option proto tcp
option dest_port 7227
option target ACCEPT
8. WebUI
Pozostaje teraz wpisac iproutera:8000 i zalogować się danymi podanymi podczas konfiguracji.
Następny artykuł: Integracja pyload i flexget - pobieranie video z RSS
Żródła:
Linux screen keyboard shortcuts
Autostart script
OpenWRT Init scripts
http://www.pawelwozniak.info/