From 8b5157bb5cd4e3abce4a064a1a0efd2870657f7a Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Thu, 19 Nov 2020 00:44:39 +0100 Subject: Error checking and data dir in .local/share - We use the '--no-config' flag on wget to have a consistent behavior accross machines. - using "curl --silent" instead of wget for trace id retrieval. feels faster. - deleted the elevator music switch, it was useless. - The data generated (cookies.txt, regions.txt, downloaded files) will be stored in $XDG_DATA_HOME/randopitons. - regions.txt is created if needbe. check checksum too. - More error checking has been made. --- randopitons.sh | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/randopitons.sh b/randopitons.sh index 2863c9b..013dfa3 100644 --- a/randopitons.sh +++ b/randopitons.sh @@ -10,7 +10,9 @@ GREEN='\033[32m' RED='\033[31m' STYLE_END='\033[0m' + # Set magic variables for current file & dir +MANPATH="/usr/share/man:$HOME/.local/share/man" DATADIR="$HOME/.local/share/randopitons" COOKIES_FILE="$DATADIR/cookies.txt" REGIONFILE="$DATADIR/regions.txt" @@ -52,29 +54,32 @@ _download() exit 1 fi - DOWNLOAD_DIR=${__dir}/randopfiles/"${linefromfile}"/${MAPTYPE} + DOWNLOAD_DIR="${DATADIR}/tracefiles/${linefromfile}/${MAPTYPE}" printf "Trace files for the ${WEBREGION} with extension '${MAPTYPE}' will be downloaded to ${BOLD}$DOWNLOAD_DIR${STYLE_END}" - mkdir -p $DOWNLOAD_DIR - cd $DOWNLOAD_DIR + mkdir -p "$DOWNLOAD_DIR" + cd "$DOWNLOAD_DIR" WEBREGION=$(echo ${linefromfile} | sed 's/ de /\-/g' | tr '[:upper:]' '[:lower:]') printf "\nExtracting URL to download geo files from...\n" TRACES=$(curl --silent https://randopitons.re/randonnees/region/${WEBREGION} | grep "