WIP new steps to download raspbian lite image and write to SD card

This commit is contained in:
2019-12-23 23:14:13 +01:00
parent ef572f9d7e
commit 742fc70798

View File

@@ -15,6 +15,64 @@ WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
# #. "$CONFIG_FILE" # #. "$CONFIG_FILE"
#} #}
step_1_info() { echo "Download latest raspbian lite image from"
echoinfo "$downUrl"; }
step_1_alias() { ALIAS="setup"; }
step_1() {
if [ ! -f "$downLoc" ] ; then
exe wget "$downUrl" -O "$downLoc"
echo -ne " [I] sha256 sum of download:\n "
exe sha256sum "$downLoc"
fi
downImgName="${downDir}/$(zipinfo -1 "$downLoc")"
if [ ! -f "$downImgName" ] ; then
exe unzip "$downLoc" -d "$downDir"
endReturn -o $? "Unzip raspbian image failed"
fi
}
downUrl="https://downloads.raspberrypi.org/raspbian_lite_latest"
downImgName=""
downDay=$(date +%Y%m%d)
downDir="/tmp"
downLoc="${downDir}/raspbian_$downDay.zip"
step_2_info() { echo -n "Write raspbian image to SD card "
if [ ! -z $2 ] ; then echo "$2"; else echo "[SD CARD DEVICE]"; fi }
step_2_alias() { ALIAS="writesd"; }
step_2() {
local sdDev=""
if [ "$downImgName" == "" ] ; then
# called again to make sure $downImgName is populated
step setup
fi
if [ ! -f "$downImgName" ] ; then
echoerr " [E] No raspian image found"
return 1
fi
if [ ! -z $2 ] && [ "$2" != "" ] ; then
sdDev="$2"
else
exe lsblk -p
exe read -p "Provide SD card device (e.g. /dev/sdb): " sdDev
fi
# check if device is a block special file
if [ ! -b "$sdDev" ] ; then
echoerr " [E] $sdDev not found"
return 1
fi
exe dd bs=4M if="$downImgName" of="$sdDev" conv=fsync
exe sync
#x TODO ? automatic remount
echoerr " [W] Please remove SD now and plug it back in."
exe read -p " Press enter to contiue."
}
step_3_info() { echo "Prepare SD for first run"; }
step_3() {
#TODO
echo exe touch "$partSdBoot"/ssh
}
step_20_info() { echo "Disable swap file and remove it"; } step_20_info() { echo "Disable swap file and remove it"; }
step_20_alias() { ALIAS="disableswap"; } step_20_alias() { ALIAS="disableswap"; }
step_20() { step_20() {
@@ -53,5 +111,5 @@ resizeDevice="/dev/mmcblk0"
resizePartNo=2 resizePartNo=2
resizePart="${resizeDevice}p${resizePartNo}" resizePart="${resizeDevice}p${resizePartNo}"
VERSION_SEQREV=8 VERSION_SEQREV=9
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh