Changeset 1644
- Timestamp:
- May 23, 2016, 12:58:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zero-center/trunk/fuentes/install-files/usr/bin/zero-lliurex-wget
r1294 r1644 5 5 MSG_STARTING=$(gettext "Starting to download your file") 6 6 MSG_CANCELLED=$(gettext "Your dowloading has been cancelled about your file") 7 MSG_URL_NOT_EXISTS=$(gettext "Your URL don't exists, imposible to download the file") 7 8 9 NAME_FILE="" 8 10 11 function helper { 12 if [ $1 = "--help" ] || [ $1 = "-h" ]; then 13 echo 14 echo "----ZERO-DOWNLOADED-HELPER----" 15 echo 16 echo "zero-lliurex-wget <arg1> <arg2> <arg3>" 17 echo 18 echo "arg1: Is the URL from you download the file, with the file" 19 echo "arg2: Is the directory to save the file." 20 echo "arg3: It is an optional argument, you can define the name for the untested downloads" 21 echo 22 echo "If arg2 is blank you can restore the download when you want, and the directory to save it, it will be the actually." 23 echo "--------------------------------------------" 24 echo 25 echo "example: zero-lliurex-wget http://sourceforge.net/projects/arasuite/files/arasuite_unix_2.1.sh /tmp/borrame" 26 echo 27 exit 1 28 fi 29 } 30 9 31 10 #Esta funcion intentara bajar lo que sea sin saber si existe o no en la red 11 #Arg1: detecta si es "-u" o no. 12 #Arg2: URL del fichero a descargar 13 #Arg3: Donde se descargara. 14 function untester { 15 if [ "$1" == "-u" ]; then 32 #Averiguamos el nombre del fichero a descargar. 33 function namefile { 16 34 #OBTENGO EL NOMBRE DEL FICHERO A DESCARGAR 17 if [ "$ 4" == "" ]; then18 NAME_FILE=$(echo $ 2| rev | cut -d "/" -f1 | rev)35 if [ "$3" == "" ]; then 36 NAME_FILE=$(echo $1 | rev | cut -d "/" -f1 | rev) 19 37 else 20 NAME_FILE="$ 4"38 NAME_FILE="$3" 21 39 fi 22 mainwget "$2" "$3" "$NAME_FILE"23 exit 024 fi25 40 26 41 } … … 32 47 33 48 if wget --spider -o /tmp/axel.log "$1"; then 34 #OBTENGO EL NOMBRE DEL FICHERO A DESCARGAR 35 NAME_FILE=$(echo $1 | rev | cut -d "/" -f1 | rev) 49 #Si esta instruccion funciona sigo comprobando cosas 36 50 #Si el fichero ya estaba descargado no puedo descargarlo de nuevo, antes he de borrarlo 51 TEMP_FILE="$2"/"$NAME_FILE" 52 [ $(rm "$TEMP_FILE") ] || echo "Continue..." 37 53 if [ -f "$2"/"$NAME_FILE" ] ; then 38 54 echo "$2/$NAME_FILE exists, you have to delete it before if you want to download it again" 55 zenity --error --text "$2/$NAME_FILE exists, you have to delete it before if you want to download it again" 39 56 exit 1 40 57 else 41 #Todo es correcto no existe el fichero y si existe la URL puedo descargarlo 42 echo "" 43 echo "URL exists, downloading......." 58 #Todo es correcto no existe el fichero y si existe la URL puedo descargarlo 59 echo "" 60 echo "URL exists, downloading......." 61 if [ -f "/tmp/axel.log" ]; then 62 rm /tmp/axel.log -rf 63 fi 44 64 fi 45 65 … … 49 69 echo "Please check it." 50 70 echo "" 71 zenity --error --text "$MSG_URL_NOT_EXISTS" 72 if [ -f "/tmp/axel.log" ]; then 73 rm /tmp/axel.log -rf 74 fi 51 75 exit 1 52 fi53 54 if [ -f "/tmp/axel.log" ]; then55 rm /tmp/axel.log -rf56 76 fi 57 77 } 58 78 59 function helper {60 if [ $1 = "--help" ] || [ $1 = "-h" ]; then61 echo62 echo "----ZERO-DOWNLOADED-HELPER----"63 echo64 echo "zero-lliurex-axel <option> <arg1> <arg2> <arg3>"65 echo66 echo "-u option: you can untested if URL exsist, downloading forced"67 echo68 echo "arg1: Is the URL from you download the file"69 echo "arg2: Is the directory to save the file."70 echo "arg3: It is an optional argument, you can define the name for the untested downloads"71 echo72 echo "If arg2 is blank you can restore the download when you want, and the directory to save it, it will be the actually."73 echo "--------------------------------------------"74 echo75 echo "example: zero-lliurex-axel http://sourceforge.net/projects/arasuite/files/arasuite_unix_2.1.sh /tmp/borrame"76 echo77 exit 178 fi79 }80 79 81 80 … … 150 149 # Old instruction: 151 150 #( wget -O "$2"/"$3" "$1" 2>&1 | grep --line-buffered -o "[0-9]*%" | sed -u -e 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloaded \1\ from "'$NAME'" at \2\/s, ETA \3/' | zenity --progress percentage=0 --auto-close --auto-kill --width 600 --title="Zero-Downloader-Helper" > /dev/null 2>&1 )|| rc=1 152 ( wget -O "$2"/"$3" "$1" 2>&1 | sed -u 's/.*\ \([0-9]\+\)%\ \+\(.*\)$/\1\n#Downloaded \1\% from "'$NAME'" at \2/' | zenity --progress percentage=0 --auto-close --auto-kill --width 600 --title="Zero-Downloader-Helper" --text="$MSG_STARTING '$NAME' ........." > /dev/null 2>&1 )|| rc=1151 ( wget -O "$2"/"$3" "$1" 2>&1 | sed -u 's/.*\ \([0-9]\+\)%\ \+\(.*\)$/\1\n#Downloaded \1\% from "'$NAME'" at \2/' | zenity --progress percentage=0 --auto-close --auto-kill --width 600 --title="Zero-Downloader-Helper" --text="$MSG_STARTING '$NAME' in '$2'........." > /dev/null 2>&1 )|| rc=1 153 152 154 153 #Esta parte cancela el proceso del wget si se cancela la descarga en el zenity. … … 176 175 } 177 176 177 178 178 helper "$1" 179 untester "$1" "$2" "$3" "$4" 179 namefile "$1" "$2" "$3" 180 ( 181 echo "60" 182 echo "# Cheking net parameters to download $NAME_FILE, please keep calm" 180 183 check_parameters "$1" "$2" 184 echo "100" 185 echo "# All is OK, continue to download the file." 186 ) | 187 zenity --progress --title="ZERO-CENTER-WGET" --percentage=0 --auto-close --auto-kill --width 600 --no-cancel 188 181 189 mainwget "$1" "$2" "$NAME_FILE" 182 190 191 183 192 exit 0 184
Note: See TracChangeset
for help on using the changeset viewer.