`

mapdata/ci/scripts/mapDownload.sh

阅读更多

#!/bin/bash

 

######################################################################

# Download map data files from xxx Maps website: 

# 1. download the fileDownloadable.xml which contains downloading info

# 2. parse fileDownloadable.xml to get the filenames, urls and md5sum

# 3. carry out the file downloading

# 4. make md5sum against downloaded files and save result to file

# 5. check md5sum to make sure downloaded files valid

######################################################################

 

set -e

 

## Expected env variables xxx_USERNAME and xxx_PASSWORD

if [[ ! ($xxx_USERNAME && $xxx_PASSWORD) ]]; then

  echo "===> Error: Expected env variable xxx_USERNAME and xxx_PASSWORD!"

  exit 1

fi

 

## install wget if not already installed in the docker container

apt-get update && apt-get -y install wget

wget --version | awk 'NR==1 {print}'

md5sum --version | grep 'GNU'

 

DIR_DOWNLOADED="downloaded"

FILES_DOWNLOADABLE=filesDownloadable.xml

FILES_DOWNLOADABLE_URI="https://xxx.xxx.com/control/navt/login?username=$xxx_USERNAME&password=$xxx_PASSWORD&action=authenticate&accountID=xxxxxx&nextURL=%2Fcontrol%2Fnavt%2FfilesDownloadable%3Faction%3Dxml%26limitDays%3D10"

 

echo "===> Cleaning up any existing files and folders"

if [[ -d $DIR_DOWNLOADED ]]; then

rm -rf $DIR_DOWNLOADED

echo "===> Info: deleted existing folder $DIR_DOWNLOADED"

fi

 

if [[ -f verifymd5.tmp ]]; then

rm verifymd5.tmp

echo "===> Info: deleted existing file verifymd5.tmp"

fi

 

if [[ -f verifymd5.txt ]]; then

rm verifymd5.txt

echo "===> Info: deleted existing file verifymd5.txt"

fi

 

echo "===> xxx maps username: $xxx_USERNAME, xxx maps password: $xxx_PASSWORD"

echo "===> Downloding $FILES_DOWNLOADABLE: url=$FILES_DOWNLOADABLE_URI"

 

wget -q -L -O $FILES_DOWNLOADABLE "$FILES_DOWNLOADABLE_URI"

 

if ! [[ -e $FILES_DOWNLOADABLE && -s $FILES_DOWNLOADABLE ]]; then

  echo "===> Error: $FILES_DOWNLOADABLE was not downloaded or empty!"

  exit 1

fi

 

if [[ $IS_DEV == "true" ]]; then

  echo "===> Info: Print filesDownloadable.xml"

  cat $FILES_DOWNLOADABLE

fi;

 

awk 'BEGIN {filename=""; md5=""; link=""}

     /<FileName>/ {filename=$0; gsub("<FileName><!\\[CDATA\\[", "", filename); gsub("\\]\\]></FileName>", "", filename); gsub("[ \t]", "", filename)}

     /<DownloadLink>/ {link=$0; gsub("<DownloadLink><!\\[CDATA\\[", "", link); gsub("\\]\\]></DownloadLink>", "", link); gsub("[ \t]", "", link); print "wget -L -O \"" filename "\" \"" link"\"" > "dcmd.sh"}

     /<MD5CheckSum>/ {md5=$0; gsub("<MD5CheckSum><!\\[CDATA\\[", "", md5); gsub("\\]\\]></MD5CheckSum>", "", md5); gsub("[ \t]", "", md5); print md5 " " filename > "md5.txt"}

' $FILES_DOWNLOADABLE

 

if ! [[ -e dcmd.sh && -s dcmd.sh && -e md5.txt && -s md5.txt ]]; then

  echo "===> Warn: dcmd.sh and/or md5.txt was not created or empty! There might be no files available for downloading."

  exit 0

fi

 

if [[ $IS_DEV == "true" ]]; then

  cat dcmd.sh | awk 'NR<3 {print > "dcmd.sh"}'

  echo "===> Info: Print reduced wget command list in dcmd.sh"

  cat dcmd.sh

  

  cat md5.txt | awk 'NR<3 {print > "md5.txt"}'

  echo "===> Info: Print reduced hashes in md5.txt"

  cat md5.txt

fi

 

# Allow 60s to manually remove large files from download cmd - comment out in production

#echo "===> Sleeping for 60 seconds... you can manully remove unwanted files now..."

#sleep 60

 

mkdir -p $DIR_DOWNLOADED

cd $DIR_DOWNLOADED

 

echo "===> Downloading xxx Maps data files to folder $DIR_DOWNLOADED ... this may take a while..."

source ../dcmd.sh

 

echo "===> Creating md5sum for downloaded files"

for afile in *

do

  if [[ -f $afile ]]; then

    md5sum $afile >> ../verifymd5.tmp

  fi

done

 

cd ..

awk '{gsub("\*",""); print $1 " " $2 > "verifymd5.txt"}' verifymd5.tmp 

 

echo "===> Verify verifiymd5.txt against md5.txt ..."

while read -r line

do 

  if grep -q "$line" md5.txt; then

    echo "===> Info: md5sum checked OK: $line"

  else

    echo "===> Error: md5sum does not match: $line"

    exit 1

  fi

done < verifymd5.txt

 

# Get s3 version from pipeline input

S3_VERSION=$(cat version/number)

tar -czvf mapload/mapload-${S3_VERSION}.tgz $DIR_DOWNLOADED

echo "===> Info: zipped up files to upload. s3 version number: $S3_VERSION"

 

ls -l $DIR_DOWNLOADED

ls -l mapload

 

echo "===> xxx Maps data downloaded successfully"

 

exit 0

分享到:
评论

相关推荐

    # jquery.cookie ![Build Status](https://travis-ci.org/carhartl/

    [Build Status](https://travis-ci.org/carhartl/jquery-cookie.png?branch=master)](https://travis-ci.org/carhartl/jquery-cookie) A simple, lightweight jQuery plugin for reading, writing and deleting ...

    mac 安装omyzsh后不执行~/.bash_profile、~/.bashrc的完美解决办法

    mac 安装 omyzsh 后, terminal瞬间逼格飙升! 但是! terminal init的时候并不会执行~/.bash_profile、~/.bashrc等脚本了, 这是因为其默认启动执行脚本变为了~/.zshrc。 解决办法就是修改~/.zshrc文件,在其中...

    U-Boot 基本编译教程

    如果你使用64位系统,需要安装32位库,例如在Ubuntu下通过`sudo apt-get install libc6:i386 libgcc1:i38 libstdc++5:i386 libstdc++6:i386`来安装。 2. **基础编译环境**:确保你的系统已经安装了必要的编译工具。...

    Solaris pstack.sh

    The following scripts are located in obisolaris.tar.gz (2013-07-12) obimon (0.1) - monitor memory and connection growth. pcore.sh (0.1) - miniture version of pstack.sh for Solaris, until we work out ...

    Python库 | ci-scripts-1.15.3.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:ci-scripts-1.15.3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    pixelc-kernel-scripts:一组脚本,可简化构建Pixel C内核和启动映像的过程

    Pixel C内核构建脚本 这是一组脚本,用于为Pixel C生成工作内核。 TL; DR ...git clone https://github.com/pixelc-linux/pixelc-kernel-scripts.git ..../mkinitramfs.sh -o ../pixelc-kernel-scripts/initr

    Xperia U Advanced Stock Kernel [版本01]

    it will execute /data/local/userinit.sh & shell scripts in /data/local/userinit.d/ folder [v01 onwards]autorooting (prerooted) su binary & superuser.apk will automatically be installed by kernel ...

    r58_evb_sc5806v4加载TP成功修改config 20160815 2026.7z

    rootroot@rootroot-E400:~/wyb/r58_evb_sc5806/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun50iw1p1 1. sun8iw1p1 2. sun8iw3p1 3. sun8iw5p1 4. sun8iw6p1 5...

    hyperledger fabric 1.4 LTS bootstrap.sh

    文档 《Install Samples, ...原地址为 http://bit.ly/2ysbOFE,是需要科学上网的,这个短地址解析后的地址是 https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh,下载放在这里分享。

    infrastructure:服务器,容器和东西

    基础设施要求的Python 3 本地配置的SSH配置(最好通过部署) 安装在系统上的ansible安装./scripts/ansible/setup.sh cd terraform/ && ./scripts/terraform/terraform.sh init私人设定ansible Vault密码需要在...

    gulp-typescript-issues

    .tmp/test/unit/test.js + .tmp/test/unit/test.js.map ./node_modules/.bin/gulp 脚本 =&gt; 将 app/app.scss 编译为 .tmp/test/unit/app.css + .tmp/test/unit/app.css.map ./node_modules/.bin/gulp scripts:...

    X-CART GOLD v3.4.9

    c) Provider related scripts are located in ./provider directory. d) Common scripts are located in ./include directory. e) Newsletter Mail subsystem scripts are located in ./mail directory. 2. ...

    网件R7000刷梅林固件 打开软件中心方法

    sed -i 's/koolshare.ngrok.wang/ks.ddnsto.com/g' /koolshare/scripts/ks_app_install.sh sed -i 's/koolshare.ngrok.wang/ks.ddnsto.com/g' /koolshare/webs/Main_Soft_center.asp 网件路由器R7000刷了梅林380 ...

    问一个关于echarts本地路径的问题

    $.getJSON('data.json', function(data) { // 在这里处理数据并初始化ECharts图表 }); ``` 如果不在同一目录,需要提供正确的相对路径。 3. **图片路径**:ECharts的一些组件,如地图,可能需要引用本地的图片...

    webrtc源码的下载-对应ios-android-linux-mac-window等平台的编译文档

    webrtc源码的下载-对应ios-android-linux-mac-window等平台的编译文档 举例mac端 //直接连外网代理,如何有连外面vpn就不需要,下面的连接是例子不能直接连改自己IP和端口..../BuildScripts~//build_libwebrtc_macos.sh

    仓库清理工具(针对依赖下载失败)cleanLastUpdate.bat

    仓库清理工具 编辑bat脚本 rem 这里写你的仓库路径 set REPOSITORY_PATH=C:\java\...C:\用户\用户名\.IntelliJIdea2019.2\system\Maven目录下的所有文件夹(这里我用的是IntelliJIdea2019.2这个版本)这个他会自动生成

    simple-bash-scripts:简单的Bash脚本的集合

    简单的Bash脚本的集合。 入门 :获取简单的输出 :在脚本中执行多个命令 :一个简单但非常互动的脚本 :用点(。)绘制菱形图案 :使用while循环从文件读取行 ...weather.sh :默认情况下,检查

    自动修改linux下/etc/sysconfig/network-scripts/ifcfg-ethX网卡文件的脚本

    自动修改linux下/etc/sysconfig/network-scripts/ifcfg-ethX网卡文件的脚本

    网盘高速下载

    https://greasyfork.org/zh-CN/scripts/39776 # 我的网盘内和分享链接页面内显示下载助手按钮; 【EX-百度云盘修改版2018.04.04_0.2.1.Mod】 https://greasyfork.org/zh-CN/scripts/39854 网盘内和分享链接页面均...

    helm-v3.3.1-linux-amd64.tar.gz

    在线安装: ..../get_helm.sh 如不成功,下载离线安装 helm-v3.3.1-linux-amd64.tar.gz mv linux-amd64/helm /usr/local/bin/ helm completion bash &gt; .hermrc ;echo "source .helmrc" &gt;&gt; .bashrc

Global site tag (gtag.js) - Google Analytics