#!/bin/bash #toolName=mytool toolDownSite="https://raspi.debian.net/tested-images" toolDownUrl= toolDownFile= SDDEV= SDBOOT= SDBOOTPUUID= SDROOT= SDROOTDEV= SDROOTPUUID= # Get script working directory # (when called from a different directory) WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" CONFIG=0 SCRIPT_NAME=$(basename -- $0) SCRIPT_NAME=${SCRIPT_NAME%%.*} CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" #step_config() { # echo "Called once before executing steps." ## e.g. to source a config file manually: #. "$CONFIG_FILE" ## or to use sequencer api with global config file: #initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ## or to use sequencer api with profile config file support: #initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE" #if [ $? -eq 0 ] ; then # CONFIG=1 #fi #} step_1_info() { echo "Download latest xz-compressed image [IMAGE FILE URL] [SD CARD DEVICE]" echoinfo "$toolDownSite" } step_1_alias() { ALIAS="install"; } step_1() { shift SDDEV="$2" if [ -z "$1" ] && [ $QUIET -eq 0 ] ; then read -p "Provide image download url from $toolDownSite: " toolDownUrl elif [ ! -z "$1" ] ; then toolDownUrl="$1" else echoerr " [E] No image file provided for download" exit -1 fi toolDownFile="/tmp/${toolDownUrl//*\//}" local downSha256="${toolDownUrl%.img.xz}.xz.sha256" local downShaFile="${toolDownFile%.img.xz}.xz.sha256" echo Url: ${toolDownUrl} echo Sha256: $downSha256 echo "Files: $toolDownFile" echo " $downShaFile" if [ ! -f "$downShaFile" ] ; then exe wget -O "$downShaFile" "$downSha256" endReturn -o $? "Error downloading $downShaFile" fi if [ ! -f "$toolDownFile" ] ; then exe wget -O "$toolDownFile" "$toolDownUrl" endReturn -o $? "Error downloading $downDownFile" fi echoseq " [I] Checking SHA256 checksum" exe cd $(dirname "$toolDownFile") exe sha256sum -c "$downShaFile" >>/dev/null endReturn -o $? "SHA256 checksum error" } step_2_info() { echo "Write image to device [DEVICE]"; } step_2() { shift if [ -z "$SDDEV" ] ; then SDDEV="$1" fi read_sd_dev "$SDDEV" # check if device was confirmed if [ $? -ne 0 ] ; then endReturn -o 1 "SD card device not found" fi echoseq " [I] Writing $(basename "$toolDownFile")" exep "xzcat \"$toolDownFile\" | dd of=$SDDEV bs=64k oflag=dsync status=progress" exe sync } step_3_info() { echo "Prepare SD card for first run"; } step_3() { outColor green cat <