modernize multiple seqs and fix deprecated use of endCheckEmpty

This commit is contained in:
2022-12-12 16:42:25 +01:00
parent dbb8cac539
commit 7391de1ddd
18 changed files with 199 additions and 232 deletions

View File

@@ -1,11 +1,11 @@
#!/bin/bash
#toolName=mytool
toolDownSite="https://raspi.debian.net/tested-images"
readonly toolDownSite="https://raspi.debian.net/tested-images"
toolDownUrl=
toolDownFile=
toolEssentialDeps="vim bash-completion man-db locales wget"
readonly toolEssentialDeps="vim bash-completion man-db locales wget"
SDDEV=
SDBOOT=
@@ -14,25 +14,18 @@ SDROOT=
SDROOTDEV=
SDROOTPUUID=
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
APTOPT=
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
quiet && APTOPT="-y"
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() {
echo "Download latest xz-compressed image [IMAGE FILE URL] [SD CARD DEVICE]"
echo "Download latest xz-compressed image"
echoinfo "$toolDownSite"
}
step_1_options() { echo "[IMAGE FILE URL] [SD CARD DEVICE]"; }
step_1_alias() { echo "install"; }
step_1() {
shift
@@ -71,7 +64,8 @@ step_1() {
endReturn -o $? "SHA256 checksum error"
}
step_2_info() { echo "Write image to device [DEVICE]"; }
step_2_info() { echo "Write image to device"; }
step_2_options() { echo "[DEVICE]"; }
step_2() {
shift
if [ -z "$SDDEV" ] ; then
@@ -130,8 +124,8 @@ step_10() {
fi
exe apt update
exe apt full-upgrade $APTOPT
exe apt install $toolEssentialDeps $APTOPT
exe apt full-upgrade ${sq_aptOpt}
exe apt install $toolEssentialDeps ${sq_aptOpt}
}
step_11_info() { echo "Set timezone"; }
@@ -156,12 +150,13 @@ step_12() {
}
localesConfigLoc="/etc/locale.gen"
step_14_info() { echo "Change hostname [HOSTNAME]"; }
step_14_info() { echo "Change hostname"; }
step_14_options() { echo "[HOSTNAME]"; }
step_14_alias() { echo "hostname"; }
step_14() {
shift
local localHostname=$1
endCheckEmpty localHostname "No hostname provided"
endIfEmpty localHostname "No hostname provided"
if [ $(grep -r "$localHostname" "$hostsLoc">>/dev/null; echo $?) -eq 0 ] ; then
info "Hostname $localHostname already defined"
return 0
@@ -175,7 +170,7 @@ hostsLoc="/etc/hosts"
step_16_info() { echo "Install cifs mounting requirements"; }
step_16_alias() { echo "cifs"; }
step_16() {
exe apt install cifs-utils $APTOPT
exe apt install cifs-utils ${sq_aptOpt}
}
step_17_info() { echo "Cifs notes"; }
@@ -296,5 +291,8 @@ read_sd_dev() {
}
SDBOOTPARTNO=1
SDROOTPARTNO=2
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh