#!/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") MSG_URL_NOT_EXISTS=$(gettext "Your URL don't exists, imposible to download the file") MSG_BUTTON_OK=$(gettext "OK") MSG_BUTTON_CANCEL=$(gettext "Cancel") MSG_DONWLOADING=$(gettext "Downloading") MSG_FROM=$(gettext "from") MSG_AT=$(gettext "at") MSG_IN=$(gettext "in") MSG_EXISTS_FILE=$(gettext "exists, you have to delete it before if you want to download it again") ZEN_BUTTON_OK="--ok-label=$MSG_BUTTON_OK" ZEN_BUTTON_CANCEL_OK="--cancel-label=$MSG_BUTTON_CANCEL $ZEN_BUTTON_OK" #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" #zenity --error --text "$2/$NAME_FILE exists, you have to delete it before if you want to download it again" $ZEN_BUTTON_OK zenity --error --text "$2/$NAME_FILE $MSG_EXISTS_FILE" $ZEN_BUTTON_OK 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 "" zenity --error --text "$MSG_URL_NOT_EXISTS" $ZEN_BUTTON_OK 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