#my own humble download accelerator frontend for axel.
#(c) copyright 2004 Barry Kauler www.goosee.com/puppy
#choices:
# multiple servers or one
# if one, then number connections
# destination path.
COMMANDTAIL="$@"
if [ "$COMMANDTAIL" ];then
#this means that a url has been passed in on the commandline.
echo "$COMMANDTAIL" | grep -i "http://"
if [ ! $? -eq 0 ];then #=0 if found.
echo "$COMMANDTAIL" | grep -i "ftp://"
if [ ! $? -eq 0 ];then
Xdialog --wmclass "puppyaxel" --title "Puppy download accelerator" --no-buttons --icon "/usr/local/lib/X11/pixmaps/warning24.xpm" --infobox "The URL is incomplete. It needs http:// or ftp:// prefix." 0 0 20000 &
fi
fi
fi
DOSETUPLOOP="true"
while [ "$DOSETUPLOOP" = "true" ];do
DOSETUPLOOP="false"
RETSTR=`Xdialog --wmclass "puppyaxel" --title "Puppy Axel download accelerator" --stdout --left --separator "|" --icon "/usr/share/images/ftp64.png" --check "Bypass any proxy server" off --3inputsbox "This is a frontend for the Axel download accelerator.\nIt is capable of multiple connections to the same server,\nor download simultaneously from multiple servers.\n\nNote: you can paste from the clipboard with CTRL-V.\nDo not forget the ftp:// or http:// prefix.\nRecommend leave bypass-proxy checkbox unticked." 0 0 "First server URL:" "$COMMANDTAIL" "Second server URL (optional):" "" "Third server URL (optional):" ""`
MULTICONN=`Xdialog --wmclass "puppyaxel" --title "Puppy Axel download accelerator" --stdout --no-tags --radiolist "Choose one or more simultaneous connections to the server.\nMultiple connections will speed download, but a slow\ndialup connection may still be the bottleneck\n(choose 3 and above only if you have broadband).\nAlso, some servers will disconnect if download\nacceleration is attempted." 0 0 0 "1" "Single connection, no acceleration" on "2" "Two simultaneous connections" off "3" "Three simultaneous connections" off "4" "Four simultaneous connections" off`
fi
if [ ! $? -eq 0 ];then
exit
fi
DESTDIR="`Xdialog --wmclass "puppyaxel" --title "Choose destination directory:" --wizard --no-cancel --help "if you leave the Selection field blank, the destination filename\nwill be the same as the source filename.\nOtherwise, type in the new name for the downloaded file." --stdout --dselect "/root/" 0 0 `"
RETVAL=$?
#note, returns 3 if "previous" button clicked.
if [ $RETVAL -eq 3 ];then #=0 "next".
DOSETUPLOOP="true"
else
if [ ! $RETVAL -eq 0 ];then
exit
fi
fi
done
#now do the actual download...
ls "$DESTDIR" 2>&1 | grep "No such file or directory"
if [ $? -eq 0 ];then
#this means that dest is not an existing file nor directory, so must
#have typed a filename into directory selection dialog.
FULLDEST="$DESTDIR"
else
file $DESTDIR | grep "directory"
if [ $? -eq 0 ];then
#DESTDIR is only a path. get filename off url...
FILEDEST=`basename "$URL1"`
FULLDEST="$DESTDIR$FILEDEST"
else
#dest filename must already exist.
FULLDEST="$DESTDIR"
fi
fi
if [ "$BYPASSPROXY" = "checked" ];then
BYPASSPROXY="--no-proxy"
else
BYPASSPROXY=""
fi
echo -e "#!/bin/sh
axel $BYPASSPROXY --alternate --verbose --num-connections=\"$MULTICONN\" --output=\"$FULLDEST\" \"$URL1\" $URL2 $URL3