From: Sergey Matveev Date: Sun, 18 Feb 2018 11:04:08 +0000 (+0300) Subject: Example downloading scripts X-Git-Tag: 3.0^2~2 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=501a1d49867a5ed1e2f633e1c8ed6522dd2943ed;p=nncp.git Example downloading scripts --- diff --git a/doc/aria2-downloaded.sh b/doc/aria2-downloaded.sh new file mode 100755 index 0000000..0a1c776 --- /dev/null +++ b/doc/aria2-downloaded.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +TORRENTS_DIR=/storage/torrents +REMOTE=stargrave.org + +if [ "$2" -eq 0 ]; then + # downloaded .torrent/.metalink + exit 0 +fi + +if [ "$2" -gt 1 ]; then + cd "$3" + while [ "$(pwd)" != $TORRENTS_DIR ]; do + name="$(basename "$(pwd)")" + cd .. + done + tartmp=$(mktemp ./finished.XXXXXX) + tar cf $tartmp "$name" + nncp-file $tartmp $REMOTE:"$name".tar + rm $tartmp +else + nncp-file "$3" $REMOTE: +fi diff --git a/doc/integration.texi b/doc/integration.texi index 62c0933..bd53119 100644 --- a/doc/integration.texi +++ b/doc/integration.texi @@ -247,37 +247,9 @@ URIs, Web-seeding, selective downloads, LPD. @command{aria2} can accelerate HTTP*/*FTP downloads by segmented multiple parallel connections. -You can queue you files after they are completely downloaded: -@verbatim -% cat send-downloaded.sh -#!/bin/sh - -if [ "$2" -eq 0 ]; then - # This could be downloaded .torrent file itself - exit 0 -fi - -if [ "$2" -gt 1 ]; then - # This is directory downloaded with BitTorrent - wholedir="$(dirname "$3")" - name=$(basename "$wholedir") - cd "$wholedir"/.. - tartmp=$(mktemp ./finished.XXXXXX) - tar cf $tartmp "$name" - nncp-file -chunked $(( 1024 * 100 )) $tartmp remote:"$name".tar - rm $tartmp -else - nncp-file -chunked $(( 1024 * 100 )) "$3" remote: -fi - -% aria2c \ - --on-download-complete send-downloaded.sh \ - http://example.org/file.iso \ - http://example.org/file.iso.asc -% aria2c \ - --on-bt-download-complete send-downloaded.sh \ - http://example.org/file.torrent -@end verbatim +You can queue you files after they are completely downloaded. +@file{aria2-downloaded.sh} contents: +@verbatiminclude aria2-downloaded.sh Also you can prepare @url{http://aria2.github.io/manual/en/html/aria2c.html#files, input file} @@ -289,7 +261,7 @@ http://www.nncpgo.org/download/nncp-0.11.tar.xz http://www.nncpgo.org/download/nncp-0.11.tar.xz.sig out=nncp.txz.sig % aria2c \ - --on-download-complete send-downloaded.sh \ + --on-download-complete aria2-downloaded.sh \ --input-file jobs @end verbatim and all that downloaded (@file{nncp.txz}, @file{nncp.txz.sig}) files @@ -308,57 +280,16 @@ exec: wgeter: ["/bin/sh", "/path/to/wgeter.sh"] aria2c: [ "/usr/local/bin/aria2c", - "--on-download-complete", "send-downloaded.sh", - "--on-bt-download-complete", "send-downloaded.sh" + "--on-download-complete", "aria2-downloaded.sh", + "--on-bt-download-complete", "aria2-downloaded.sh" ] @end verbatim @file{warcer.sh} contents: - -@verbatim -#!/bin/sh -ex - -user_agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27" - -name="$1" -read cmdline - -tmp=$(mktemp -d) -cd $tmp -warc_name=$name-$(date '+%Y%M%d%H%m%S') -wget \ - --page-requisites \ - --convert-links \ - --adjust-extension \ - --restrict-file-names=ascii \ - --span-hosts \ - --random-wait \ - --execute robots=off \ - --user-agent "$user_agent" \ - --reject '*.woff*,*.ttf,*.eot,*.js' \ - --tries 10 \ - --warc-file $warc_name \ - --no-warc-compression \ - --no-warc-keep-log \ - $cmdline || : -xz -9 "$warc_name".warc -nncp-file -nice $NNCP_NICE "$warc_name".warc.xz $NNCP_SENDER: -rm -r $tmp -@end verbatim +@verbatiminclude warcer.sh @file{wgeter.sh} contents: - -@verbatim -#!/bin/sh -ex - -name="$1" -read cmdline -tmp=$(mktemp) -wget --output-document=$tmp $cmdline -xz -9 $tmp -nncp-file -nice $NNCP_NICE $tmp.xz $NNCP_SENDER:$name.xz -rm $tmp.xz -@end verbatim +@verbatiminclude wgeter.sh Now you can queue that node to send you some website's page, file or BitTorrents: diff --git a/doc/warcer.sh b/doc/warcer.sh new file mode 100755 index 0000000..9448592 --- /dev/null +++ b/doc/warcer.sh @@ -0,0 +1,24 @@ +#!/bin/sh -ex + +name="$1"-$(date '+%Y%M%d%H%m%S') +read cmdline + +tmp=$(mktemp -d) +cd $tmp +wget \ + --page-requisites \ + --convert-links \ + --adjust-extension \ + --restrict-file-names=ascii \ + --span-hosts \ + --random-wait \ + --execute robots=off \ + --reject '*.woff*,*.ttf,*.eot,*.js' \ + --tries 10 \ + --warc-file "$name" \ + --no-warc-compression \ + --no-warc-keep-log \ + $cmdline || : +xz -9 "$name".warc +nncp-file -nice $NNCP_NICE "$name".warc.xz $NNCP_SENDER: +rm -r $tmp diff --git a/doc/wgeter.sh b/doc/wgeter.sh new file mode 100755 index 0000000..5f80d81 --- /dev/null +++ b/doc/wgeter.sh @@ -0,0 +1,10 @@ +#!/bin/sh -ex + +name=$1-$(date '+%Y%M%d%H%m%S') +read cmdline + +tmp=$(mktemp) +wget --output-document=$tmp $cmdline +xz -9 $tmp +nncp-file -nice $NNCP_NICE $tmp.xz $NNCP_SENDER:$name.xz +rm $tmp.xz