when I started ubuntu I found that firefox download manager don't handel resuming
I installed other download managers but none was multi-user nor could run off-session
I searched and found 2 php download manager daemons, one didn't work and I couldn't fix it, the other one don't separate between different users files.
So the story goes on, and the bad programmer didn't have a choice but to write his own half cooked script daemon , the perfection of loosy conception.
the script is based on Aleskey's wget-list script.
http://www.linux.com/articles/59457
here it is, workin but unpredictable :
the /etc/init.d/zdownload file
Code:
#DAEMON=/home/scripts/wget/wget-list
DAEMON=/usr/local/sbin/wget-list
NAME=wgetd
DESC="WGET Daemon"
test -x $DAEMON || exit 0
set -e
start(){
echo -n "Starting $DESC: $NAME"
(sudo -u user1 bash -c $DAEMON 2 >&1 1>/dev/null &)&
(sudo -u user2 bash -c $DAEMON 2 >&1 1>/dev/null &)&
echo "."
#;;
}
stop(){
echo -n "Stoping $DESC: $NAME"
kill -s TERM `ps -fed | grep "wget-list" | grep -v grep | awk '{print $2 }'|head -n1` && echo wget-list end
kill -s TERM `ps -fed | grep " wget " | grep -v grep | awk '{print $2 }'|head -n1` && echo wget end
reload)
stop
start
;;
force-reload|restart)
stop
start
;;
*)
echo "Usage: /etc/init.d/amule-daemon {start|stop|restart|force-reload|reload}"
exit 1
;;
esac
exit 0
I've left the commented code, so that everyone know how aweful i'am at programing
the wget-list file
Code:
#!/bin/bash
function completedownload {
mv -bv *.* done2/
cd done2
for x in *.*~ ;do
mv -bv "$x" "[0]"`ls "$x" |awk -F"~" '{print $1}'`;
for ((y=1 ;y<=10; y+=1 )) ;do
for z in \[?]*~ ;do
name=`ls "$z" |awk -F"~" '{print $1}'`
firstpart=`ls "$name" |awk -F"[" '{print $1 "["}'`
lastpart=`ls "$name" |awk -F"]" '{print "]" $2}'`
copynum=`ls "$name" |awk -F"[" '{print $2}'|awk -F"]" '{print $1}'`
mv -bv "$z" "$firstpart"$(($copynum+1))"$lastpart"
done
done
done
cd ..
}
function clean_up {
exit 0
}
trap clean_up SIGHUP SIGINT SIGTERM
[ ! -d ~/download/done ] && mkdir -p ~/download/done && touch ~/download/.wget-list
cd ~/download/
while [[ 1==1 ]]
do
while [ `find .wget-list -size +0` ]
do
url=`head -n1 .wget-list`
if [ -f ".incomplet" ] ;then
echo -e "resuming\n"
if wget -c $url ; then ( sed -si 1d .wget-list ; rm -f .incomplet;completedownload) else echo error ;break ;fi
else
echo -e "downloading\n"
touch .incomplet
if wget $url ; then ( sed -si 1d .wget-list;mv -bv *.* done2/;completedownload) else echo error;breack ;fi
fi
done
sleep 60
done
clean_up
I've got a long way to go to make it flawless
-------update---------
from the posts people have put down i preasume that my post isn't clear
the script I've posted here do work I already downloaded 2 Gb of data with them
I'm posting them here to share them with exigent people that want :
1- A download manager daemon
2- A download manager that is multi-users
3- A download manager that run all-time not only where one is loged
4- A download manager that resume files on all situations and not with a proprietary format
and this download manager can be integrated to firefox via flashgot plugin
and I hope that interrested peolpe will contribute to this to make it better ,because I think I didn't find a single download manager that fill those requirements.
Bookmarks