diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2022-06-26 01:59:38 +0400 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2022-06-26 01:59:38 +0400 |
commit | 0f437199b65025a903d568be87747cf5eb4b9805 (patch) | |
tree | 72f05f8ce69af6348e5c2521632f5ada5781f3ba | |
parent | 90d1bf5893a9a373eccd40693f801aa74c3ad36b (diff) | |
download | openmtbmap-master.tar.gz openmtbmap-master.tar.bz2 openmtbmap-master.tar.xz openmtbmap-master.zip |
-rwxr-xr-x | download.sh | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | generate.sh | 18 | ||||
-rw-r--r-- | lists/alps.txt | 7 | ||||
-rwxr-xr-x | process.sh | 26 |
4 files changed, 34 insertions, 23 deletions
diff --git a/download.sh b/download.sh index d3ac068..791819e 100755 --- a/download.sh +++ b/download.sh @@ -48,7 +48,8 @@ function check { [ $fail -ne 0 ] && return $fail size=$(du -sm "downloads/$name" | awk '{ print $1 }') - [ $size -lt 2 ] && return 1 + [ -z "$size" ] && return 1 + [ "$size" -lt 2 ] && return 1 return 0 } @@ -63,14 +64,13 @@ for name in $(cat $list); do fail=$? if [ $fail -ne 0 ]; then - echo curl -L --cookie cookies.jar "$url_u/$name" -o "downloads/$name" #&> /dev/null + curl -L --cookie cookies.jar "$url_u/$name" -o "downloads/$name" &> /dev/null check "$?" "$name" fail=$? fail_nonu=1 fi if [ $fail -ne 0 ]; then - exit 1; rm -f downloads/$name fail=0 diff --git a/generate.sh b/generate.sh index ae4fdad..517c2e9 100755..100644 --- a/generate.sh +++ b/generate.sh @@ -7,7 +7,8 @@ function prepare { 7z x -owork $1 &> /dev/null [ $? -ne 0 ] && 7z x -owork $1 - for file_name in `find work -maxdepth 1 -name "???"`; do mv $file_name/* work/ ; done + for file_name in `find work -maxdepth 1 -type d -name "???"`; do mv $file_name/* work/ ; done + for file_name in `find work -maxdepth 1 -type d -regextype posix-extended -iregex ".*($name|mtb$name|velo$name)"`; do mv $file_name/* work/ ; done } function clean { @@ -19,25 +20,18 @@ if [ -z "$1" ]; then exit 1 fi -file=$1 +file="$1" +name="$2" +img="$3" echo "====> Generating Garmin maps for $file" -if [[ "$file" =~ "velo" ]]; then - typ=velo*.TYP - name=`basename $file .exe | cut -c 5-` - img=maps/velo-$name.img -else - name=`basename $file .exe | cut -c 4-` - img=maps/mtb-$name.img -fi - if [ -f $img ]; then echo "Already existing, skipping..." exit 0 fi -prepare $file +prepare "$file" if [ ! -f work/$typ ]; then [ -f work/clas*.TYP ] && typ=clas*.TYP diff --git a/lists/alps.txt b/lists/alps.txt new file mode 100644 index 0000000..cfcae47 --- /dev/null +++ b/lists/alps.txt @@ -0,0 +1,7 @@ +mtbaustria.exe +mtbfrancelinux.7z +mtbgermanylinux.7z +mtbitaly.exe +mtbslovenia.exe +mtbspain.exe +mtbswitzerland.exe @@ -1,17 +1,27 @@ #! /bin/bash -for name in `ls downloads/*.exe`; do - if [[ "$name" =~ "velo" ]]; then - mapname=`basename $name .exe | cut -c 5-` - img=maps/velo-$mapname.img - else - mapname=`basename $name .exe | cut -c 4-` - img=maps/mtb-$mapname.img +for name in `find . -regextype posix-extended -iregex './downloads/.*(linux.7z|.exe)'`; do + if [[ "$name" =~ "linux.7z" ]]; then + if [[ "$name" =~ "velo" ]]; then + mapname=`basename $name linux.7z | cut -c 5-` + img=maps/velo-$mapname.img + else + mapname=`basename $name linux.7z | cut -c 4-` + img=maps/mtb-$mapname.img + fi + else + if [[ "$name" =~ "velo" ]]; then + mapname=`basename $name .exe | cut -c 5-` + img=maps/velo-$mapname.img + else + mapname=`basename $name .exe | cut -c 4-` + img=maps/mtb-$mapname.img + fi fi [ -f $img ] && continue - ./generate.sh $name + bash ./generate.sh "$name" "$mapname" "$img" if [ $? -ne 0 ]; then break fi |