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. 20145332卢鑫 WEB安全基础实验

    20145332 WEB安全基础实验 实验过程 ·SQL字符串注入 ·Database Backdoors step1 ·Database Backdoors step2 ·Phishing with ...

  2. UVa 1451 Average - 斜率优化

    A DNA sequence consists of four letters, A, C, G, and T. The GC-ratio of a DNA sequence is the numbe ...

  3. React 回忆录(四)React 中的状态管理

    Hi 各位,欢迎来到 React 回忆录!

  4. datagridview控件的使用

    http://home.cnblogs.com/group/topic/40730.html datagridview定位到最后一行的方法 this.dataGridView2.CurrentCell ...

  5. Codeforces Round #530 (Div. 1)

    A - Sum in the tree 就是贪心选尽量让上面的点权尽量大,那么对于偶数层的点,其到根节点的和即为所有儿子中的最大值. #include<bits/stdc++.h> usi ...

  6. Gym - 100345H Settling the Universe Up(bitset)

    https://vjudge.net/problem/Gym-100345H 题意: 给出一个图,求图中u能到达v的对数,并且u<v.并且会有更新和查询操作. 思路: bitset直接暴力,对于 ...

  7. Intel微处理器学习笔记(二) 三种模式

    三种模式:实模式.保护模式和平展模式. 实模式存储器(DOS存储器)位于00000H~FFFFFH,共1M空间(任何型号微处理器都支持). 保护模式存储器(Windows存储器)可位于整个保护存储系统 ...

  8. bash Shell 中如何实现条件判断之if判断

    http://blog.51cto.com/lovelace/1211353 bash中如何实现条件判断?条件测试类型:    整数测试    字符测试    文件测试 一.条件测试的表达式:     ...

  9. javascript对象使用总结

    javascript对象使用总结 一.总结 一句话总结:js对象的主要知识点是创建对象和继承,并且创建对象和继承的方法都是逐步层层递进的 创建对象 继承 原型 创建对象 1 <script> ...

  10. secs/gem协议

    介绍SECS/GEM SEMI SECS/GEM标准概述 SECS/GEM是由国际半导体设备与材料协会(SEMI)制定的连接性标准.此连接性标准用于在设备和工厂的资讯和控制系统间建立通讯. SECS是 ...