example:

download_etcher_cli()
{
local url="https://github.com/resin-io/etcher/releases/download/v1.4.4/etcher-cli-1.4.4-linux-x64.tar.gz"
local hash="54709ad34ac304d2686130c7d22a3bc13b4f491387d987274eeca4f6eea34dce"

local filename=${url##*/}

#replace the suffix 
local dirname=${filename/.tar.gz/-dist}

export PATH="$PATH:$SRC/cache/utility/$dirname"

if [[ -f $SRC/cache/utility/$dirname/.download-complete ]]; then
return
fi

cd $SRC/cache/utility/

display_alert "Downloading" "$dirname"
curl -Lf --progress-bar $url -o $filename

local verified=false
local b=$(sha256sum $filename)

display_alert "Verifying"

[[ "$hash" == "$(sha256sum $filename | cut -d ' ' -f 1)" ]] && verified=true

if [[ $verified == true ]]; then
display_alert "Extracting"
tar --no-same-owner --overwrite -xf $filename && touch $SRC/cache/utility/$dirname/.download-complete && rm $filename
display_alert "Download complete" "" "info"
else
display_alert "Verification failed" "" "wrn"
fi
}

linux command curl and sha256sum implement download verification package的更多相关文章

  1. [Linux][转载]Curl命令详解

    命令:curl 在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,是一款很强大的http命令行工具,当处在无界面的服务器上的时候,利用curl下载上传文件是较为方便的事情. 语法 ...

  2. linux使用curl命令行进行接口测试

    cURL介绍cURL 是很方便的Rest客戶端,可以很方便的完成许多Rest API测试的需求,甚至,如果是需要先登入或认证的rest api,也可以進行测试,利用curl指令,可以送出HTTP GE ...

  3. MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL

    MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠 ...

  4. 《The Linux Command Line》 读书笔记04 Linux用户以及权限相关命令

    Linux用户以及权限相关命令 查看身份 id:Display user identity. 这个命令的输出会显示uid,gid和用户所属的组. uid即user ID,这是账户创建时被赋予的. gi ...

  5. 《The Linux Command Line》 读书笔记02 关于命令的命令

    <The Linux Command Line> 读书笔记02 关于命令的命令 命令的四种类型 type type—Indicate how a command name is inter ...

  6. 《The Linux Command Line》 读书笔记01 基本命令介绍

    <The Linux Command Line> 读书笔记01 基本命令介绍 1. What is the Shell? The Shell is a program that takes ...

  7. Linux Command Line Basics

    Most of this note comes from the Beginning the Linux Command Line, Second Edition by Sander van Vugt ...

  8. Linux Command Line 解析

    Linux Command Line 解析 0 处理模型 Linux kernel的启动包括很多组件的初始化和相关配置,这些配置参数一般是通过command line进行配置的.在进行后续分析之前,先 ...

  9. 15 Examples To Master Linux Command Line History

    When you are using Linux command line frequently, using the history effectively can be a major produ ...

随机推荐

  1. vim 开启我们的Python之旅

    1.在我们的Mac系统下打开“终端”,输入python,然后回车即可看到我们电脑是否安装了python,以及它的版本,这里我的是2.7.5版本,如果未安装请百度之.

  2. C++ 单例模式(转载)

    转载:http://www.cnblogs.com/cxjchen/p/3148582.html 转载:http://blog.csdn.net/hackbuteer1/article/details ...

  3. 微内核VS宏内核【转】

    本文转载自:https://segmentfault.com/a/1190000002711544 内核按照体系结构分为两类 : 微内核(microkernel)与宏内核(macrokernel). ...

  4. SQL 收集

    1.union CREATE TABLE dbo.#testTab ( Id int NOT NULL ) insert into #testTab values(); insert into #te ...

  5. BZOJ3297: [USACO2011 Open]forgot DP+字符串

    Description 发生了这么多,贝茜已经忘记了她cowtube密码.然而,她记得一些有用的信息.首先,她记得她的密码(记为变 量P)长度为L(1 <= L<=1,000)字符串,并可 ...

  6. C# 用Linq查询DataGridView行中的数据是否包含(各种操作)

    http://blog.csdn.net/xht555/article/details/38685845 https://www.cnblogs.com/wuchao/archive/2012/12/ ...

  7. Tomcat Connector

    转自: http://blog.csdn.net/aesop_wubo/article/details/7617416 如下图所示,Tomcat服务器主要有两大核心模块组成:连接器和容器,本节只分析连 ...

  8. Ubuntu 登陆界面无限循环问题 以及 root用户无法使用命令问题

    在Ubuntu下配置好了eclipse之后,马上着手用eclipse试运行ns3.在./waf编译的时候出现了"Permission denied"问题. 在网络上查阅了相关资料之 ...

  9. 【TCP/IP详解 卷一:协议】第二十一章 TCP的超时与重传

    作为TCP的重头戏,本章节涉及了许多关于计算方面的内容,使用了大量的例子来指明一些观点. 我使用的理解方法是:通过别人的博客,以及实例结合进行理解,不然会很吃力. 21.1 引言 reliable T ...

  10. Ubuntu更新软件源出现GPG error

    原因 在sources.list文件中加入了非ubuntu官方源,所以认为加入源是不可信任的. 解决方法导入该源公钥.E084DAB9为PUBKEY后八位 gpg --keyserver keyser ...