#!/bin/bash export TEXTDOMAIN="zero-center" MSG_DONWLOADED=$(gettext "is downloaded in your directory") MSG_STARTING=$(gettext "Starting to download your file") MSG_CANCELLED=$(gettext "Your dowloading has been cancelled about your file") #Esta funcion intentara bajar lo que sea sin saber si existe o no en la red #Arg1: detecta si es "-u" o no. #Arg2: URL del fichero a descargar #Arg3: Donde se descargara. function untester { if [ "$1" == "-u" ]; then #OBTENGO EL NOMBRE DEL FICHERO A DESCARGAR if [ "$4" == "" ]; then NAME_FILE=$(echo $2 | rev | cut -d "/" -f1 | rev) else NAME_FILE="$4" fi mainwget "$2" "$3" "$NAME_FILE" exit 0 fi } function check_parameters { #Compruebo que el directorio existe [ -d $2 ] || mkdir -p $2 #Compruebo que la direccion existe if wget --spider -o /tmp/axel.log "$1"; then #OBTENGO EL NOMBRE DEL FICHERO A DESCARGAR NAME_FILE=$(echo $1 | rev | cut -d "/" -f1 | rev) #Si el fichero ya estaba descargado no puedo descargarlo de nuevo, antes he de borrarlo if [ -f "$2"/"$NAME_FILE" ] ; then echo "$2/$NAME_FILE exists, you have to delete it before if you want to download it again" exit 1 else #Todo es correcto no existe el fichero y si existe la URL puedo descargarlo echo "" echo "URL exists, downloading......." fi else echo "" echo "URL does not exist: $1" echo "Please check it." echo "" exit 1 fi if [ -f "/tmp/axel.log" ]; then rm /tmp/axel.log -rf fi } function helper { if [ $1 = "--help" ] || [ $1 = "-h" ]; then echo echo "----ZERO-DOWNLOADED-HELPER----" echo echo "zero-lliurex-axel