#!/usr/bin/env bash # Bash3 Boilerplate. Copyright (c) 2014, kvz.io #set -o errexit #set -o pipefail #set -o nounset #set -o xtrace # Set magic variables for current file & dir __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" __file="${__dir}/$(basename "${BASH_SOURCE[0]}")" __base="$(basename ${__file} .sh)" __root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on your app REGIONS=$(cat ${__dir}/regions.txt) REGIONFILE="${__dir}/regions.txt" MAPTYPE="gpx" RDPUSER= RDPUSERPASS= LOGINOK= #Filechecks printf "Cirque de Cilaos\nCirque de Mafate\nCirque de Salazie\nEst\nNord\nOuest\nSud\nVolcan\nAilleurs\nAll" > $REGIONFILE #https://stackoverflow.com/questions/4813092/how-to-read-entire-line-from-bash #so we don't use a while loop IFS=$'\n' _download() { while read linefromfile; do mkdir -p ${__dir}/randopfiles/"${linefromfile}" cd ${__dir}/randopfiles/"${linefromfile}" WEBREGION=$(echo ${linefromfile} | sed 's/ de /\-/g' | tr '[:upper:]' '[:lower:]') FILENBRS=$(wget -qO- https://randopitons.re/randonnees/region/${WEBREGION} | grep " $MATCHEDFILE if [ -s $MATCHEDFILE ];then echo "Nothing matched or you entered an empty value." _help fi printf "Your region choice was '$1'\nMatches are:\n" cat $MATCHEDFILE _download $MATCHEDFILE ;; -a | --all ) printf "\nThis will download all the hitchiking routes from all regions.\nIf no extension is specified (with -mp or --maptype), it will default to gpx.\nPausing for 5 seconds before downloading..." sleep 5 _download $REGIONFILE ;; -em | --elevator-music ) echo "Initiating elevator music" mpv --no-audio --really-quiet https://www.youtube.com/watch?v=KfNXGY9O5VY || printf "\nmpv is not installed." ;; -h | --help ) _help ;; * ) _help esac shift done