diff --git a/seqs/raspberry.sh b/seqs/raspberry.sh index 50a10ea..84b03c4 100755 --- a/seqs/raspberry.sh +++ b/seqs/raspberry.sh @@ -56,7 +56,7 @@ evalArgs() { local argCount=0 for _ in "$@"; do - case "$1" in + case "${1:-}" in -a|--arch) if [ -n "${2:-}" ]; then PIARCH="$2" @@ -97,16 +97,16 @@ step_1() { 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" + if [ ! -f "$downImgLoc" ] ; then + exe unxz "$downLoc" endReturn -o $? "Unzip raspios image $PIARCH failed" fi } -downImgName="" downDay=$(date +%Y%m%d) downDir="/tmp" -downLoc="${downDir}/raspios_$downDay.zip" +downImgName="raspios_${downDay}.img" +downImgLoc="${downDir}/${downImgName}" +downLoc="${downDir}/${downImgName}.xz" step_2_info() { # Shift away args @@ -122,12 +122,8 @@ step_2() { # Shift away args shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? - if [ "$downImgName" == "" ] ; then - # called again to make sure $downImgName is populated - step setup - fi - if [ ! -f "$downImgName" ] ; then - endReturn -o 1 "No raspios image found" + if [ ! -f "$downImgLoc" ] ; then + endReturn -o 1 "Raspios image ${downImgLoc} not found" fi if [ $(id -u) -ne 0 ] ; then @@ -141,7 +137,7 @@ step_2() { fi # write image - exe dd bs=8M if="$downImgName" of="$SDDEV" conv=fsync + exe dd bs=8M if="$downImgLoc" of="$SDDEV" conv=fsync endReturn -o "$?" "Writing image to $SDDEV failed" exe sync @@ -168,6 +164,7 @@ step_3_info() { step_3() { # Shift away args shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? + if [ -z "${1:-}" ] && [ -n "${SDDEV:-}" ] ; then if quiet ; then @@ -196,12 +193,24 @@ step_3() { return 1 fi + # setup initial user + local lUser="$(ask -- "Username:")" + local lPass + lPass="$(ask -s -- "Password:")"; echo + if ! [[ ${lPass} == "$(ask -s -- "Repeat Password:")" ]] ; then + sqr::echo + fatal "Password missmatch" + fi + local lPass="$(echo "${lPass}" | openssl passwd -6 -stdin)"; echo + addConf -c "${lUser}:${lPass}" "${SDBOOT}/userconf" + unset "lUser" "lPass" + # enable systemd ssh service - echo " [I] Enable SSH access" + info "Enable SSH access" exe touch "$SDBOOT"/ssh # save SD boot settings for easy emergency start from SD - echo " [I] Save SD card boot information for later use" + info "Save SD card boot information for later use" exe cp -ar "$SDBOOT"/cmdline.txt "$SDBOOT"/cmdline.txt.sd exe cp -ar "$SDROOT"/etc/fstab "$SDROOT"/etc/fstab.sd } @@ -583,8 +592,9 @@ step_100() { cat < System Options -> Boot / Auto Login)) * Set hostname (\`raspi-config\` -> System Options)) * Configure Timezone (\`raspi-confg\` -> Localisation Options) * Set GPU memory (\`raspi-config\` -> Performance Options) @@ -593,7 +603,7 @@ step_100() { [/etc/fstab] > \`PARTUUID=******-03 none swap sw 0 0\` - \`$SEQ_NAME disable_swap\` + \`$seq_name disable_swap\` * Update system