summaryrefslogtreecommitdiffstats
path: root/filehooker
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-03-26 16:26:10 +0100
committermakefu <github@syntax-fehler.de>2014-03-26 16:26:10 +0100
commit69a0b3b50de75a81dc95fe84d73895b753fc3cbe (patch)
tree5c8d684ca66d689cbb3f30192f565fdf4e16c8cd /filehooker
parentef2a1f113b0240515982bf1e7525b26f6b9577b2 (diff)
filehooker: ftpget can now retrieve dirs, list_downloads is better
Diffstat (limited to 'filehooker')
-rwxr-xr-xfilehooker/root-image/krebs/etc/Reaktor/commands/ftpget42
-rwxr-xr-xfilehooker/root-image/krebs/etc/Reaktor/commands/list_downloads2
2 files changed, 38 insertions, 6 deletions
diff --git a/filehooker/root-image/krebs/etc/Reaktor/commands/ftpget b/filehooker/root-image/krebs/etc/Reaktor/commands/ftpget
index 10e73a2f..74e76f8e 100755
--- a/filehooker/root-image/krebs/etc/Reaktor/commands/ftpget
+++ b/filehooker/root-image/krebs/etc/Reaktor/commands/ftpget
@@ -1,12 +1,37 @@
#!/bin/sh
+# usage: $0 [-d] uri sharename[/subdirs]
exec 2>&1
set -euf
ncdc_user=hooker
+usage(){
+ cat <<EOF
+usage: $0 [-d] uri share[/subdirs]
+ -d -- uri is a directory to be mirrored
+ share -- vag[0-n]
+EOF
+}
+examples(){
+ cat <<EOF
+examples: ftpget -d http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/0.8 vag0/firefox_releases
+ -> 0.8 directory is stored to /media/vag0/firefox_releases
+
+ ftpget -d http://speedtest.qsc.de/10MB.qsc vag0/
+ -> 10MB.qsc is stored to /media/vag0/10MB.qsc
+EOF
+}
+if test "${1:--h}" == '-h' -o "${1:-}" == '--help';then
+ usage
+ examples
+ exit 0
+fi
+if test ${1:-} == '-d' ;then
+ is_dir=true
+ shift
+fi
target="${1:-}"
-if !( echo "$target" | egrep -q '^(ftp://|http://)' );then
- echo "target must be ftp:// or http://"
+if !( echo "$target" | egrep -q '^(ftps*://|https*://)' );then
exit 23
fi
@@ -16,11 +41,18 @@ realshare="/media/$share"
test ! -e "$sharepath" && echo "$sharepath does not exist!" && exit 23
sudo -u $ncdc_user /usr/bin/mkdir -p "$realshare"
-if ! sudo -u $ncdc_user /usr/bin/tmux has-session -t dl >/dev/null 2>&1 ;then
- sudo -u $ncdc_user /usr/bin/tmux new-session -s dl -d -c "$realshare" "lftpget \"$target\""
+
+if test -z ${is_dir:-};then
+ cmd="lftpget \"$target\""
else
- sudo -u $ncdc_user /usr/bin/tmux new-window -t dl -c "$realshare" "lftpget \"$target\""
+ cmd="lftp -e \"mirror;exit\" $target"
fi
+
+ if ! sudo -u $ncdc_user /usr/bin/tmux has-session -t dl >/dev/null 2>&1 ;then
+ sudo -u $ncdc_user /usr/bin/tmux new-session -s dl -d -c "$realshare" "$cmd"
+ else
+ sudo -u $ncdc_user /usr/bin/tmux new-window -t dl -c "$realshare" "$cmd"
+ fi
#sudo -u $ncdc_user /usr/bin/tmux new-window -t dl
#cd "$realshare" ;sudo -u hooker /usr/bin/lftpget "$target"
echo "download started, check with 'list_downloads'"
diff --git a/filehooker/root-image/krebs/etc/Reaktor/commands/list_downloads b/filehooker/root-image/krebs/etc/Reaktor/commands/list_downloads
index cb1e07be..f53067d8 100755
--- a/filehooker/root-image/krebs/etc/Reaktor/commands/list_downloads
+++ b/filehooker/root-image/krebs/etc/Reaktor/commands/list_downloads
@@ -4,5 +4,5 @@ count=$(sudo -u $ncdc_user /usr/bin/tmux list-windows -t dl 2>/dev/null| wc -l)
test $count -eq 0 && echo "no downloads running" && exit 0
for i in $(seq 0 $(($count-1)));do
- sudo -u $ncdc_user /usr/bin/tmux capture-pane -t dl:$i -p |head -1
+ sudo -u $ncdc_user /usr/bin/tmux capture-pane -t dl:$i -p | grep -v '^$' | tail -n 1
done