raspberry - Adapt to new raspberry pi OS image compressor
Adding creation of mandatory first user
This commit is contained in:
@@ -56,7 +56,7 @@ evalArgs() {
|
|||||||
local argCount=0
|
local argCount=0
|
||||||
|
|
||||||
for _ in "$@"; do
|
for _ in "$@"; do
|
||||||
case "$1" in
|
case "${1:-}" in
|
||||||
-a|--arch)
|
-a|--arch)
|
||||||
if [ -n "${2:-}" ]; then
|
if [ -n "${2:-}" ]; then
|
||||||
PIARCH="$2"
|
PIARCH="$2"
|
||||||
@@ -97,16 +97,16 @@ step_1() {
|
|||||||
echo -ne " [I] sha256 sum of download:\n "
|
echo -ne " [I] sha256 sum of download:\n "
|
||||||
exe sha256sum "$downLoc"
|
exe sha256sum "$downLoc"
|
||||||
fi
|
fi
|
||||||
downImgName="${downDir}/$(zipinfo -1 "$downLoc")"
|
if [ ! -f "$downImgLoc" ] ; then
|
||||||
if [ ! -f "$downImgName" ] ; then
|
exe unxz "$downLoc"
|
||||||
exe unzip "$downLoc" -d "$downDir"
|
|
||||||
endReturn -o $? "Unzip raspios image $PIARCH failed"
|
endReturn -o $? "Unzip raspios image $PIARCH failed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
downImgName=""
|
|
||||||
downDay=$(date +%Y%m%d)
|
downDay=$(date +%Y%m%d)
|
||||||
downDir="/tmp"
|
downDir="/tmp"
|
||||||
downLoc="${downDir}/raspios_$downDay.zip"
|
downImgName="raspios_${downDay}.img"
|
||||||
|
downImgLoc="${downDir}/${downImgName}"
|
||||||
|
downLoc="${downDir}/${downImgName}.xz"
|
||||||
|
|
||||||
step_2_info() {
|
step_2_info() {
|
||||||
# Shift away args
|
# Shift away args
|
||||||
@@ -122,12 +122,8 @@ step_2() {
|
|||||||
# Shift away args
|
# Shift away args
|
||||||
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
|
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
|
||||||
|
|
||||||
if [ "$downImgName" == "" ] ; then
|
if [ ! -f "$downImgLoc" ] ; then
|
||||||
# called again to make sure $downImgName is populated
|
endReturn -o 1 "Raspios image ${downImgLoc} not found"
|
||||||
step setup
|
|
||||||
fi
|
|
||||||
if [ ! -f "$downImgName" ] ; then
|
|
||||||
endReturn -o 1 "No raspios image found"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(id -u) -ne 0 ] ; then
|
if [ $(id -u) -ne 0 ] ; then
|
||||||
@@ -141,7 +137,7 @@ step_2() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# write image
|
# 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"
|
endReturn -o "$?" "Writing image to $SDDEV failed"
|
||||||
exe sync
|
exe sync
|
||||||
|
|
||||||
@@ -169,6 +165,7 @@ step_3() {
|
|||||||
# Shift away args
|
# Shift away args
|
||||||
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
|
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
|
||||||
|
|
||||||
|
|
||||||
if [ -z "${1:-}" ] && [ -n "${SDDEV:-}" ] ; then
|
if [ -z "${1:-}" ] && [ -n "${SDDEV:-}" ] ; then
|
||||||
if quiet ; then
|
if quiet ; then
|
||||||
answer="n"
|
answer="n"
|
||||||
@@ -196,12 +193,24 @@ step_3() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
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
|
# enable systemd ssh service
|
||||||
echo " [I] Enable SSH access"
|
info "Enable SSH access"
|
||||||
exe touch "$SDBOOT"/ssh
|
exe touch "$SDBOOT"/ssh
|
||||||
|
|
||||||
# save SD boot settings for easy emergency start from SD
|
# 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 "$SDBOOT"/cmdline.txt "$SDBOOT"/cmdline.txt.sd
|
||||||
exe cp -ar "$SDROOT"/etc/fstab "$SDROOT"/etc/fstab.sd
|
exe cp -ar "$SDROOT"/etc/fstab "$SDROOT"/etc/fstab.sd
|
||||||
}
|
}
|
||||||
@@ -583,8 +592,9 @@ step_100() {
|
|||||||
cat <<NOTES_EOF
|
cat <<NOTES_EOF
|
||||||
# Initial configuration steps
|
# Initial configuration steps
|
||||||
|
|
||||||
* Set password for pi (\`passwd\`)
|
* Set password for a user (\`passwd\`)
|
||||||
* Add [\$HOME/.ssh/authorized_keys]
|
* Add [\$HOME/.ssh/authorized_keys]
|
||||||
|
* Disable auto login (\`raspi-config\` -> System Options -> Boot / Auto Login))
|
||||||
* Set hostname (\`raspi-config\` -> System Options))
|
* Set hostname (\`raspi-config\` -> System Options))
|
||||||
* Configure Timezone (\`raspi-confg\` -> Localisation Options)
|
* Configure Timezone (\`raspi-confg\` -> Localisation Options)
|
||||||
* Set GPU memory (\`raspi-config\` -> Performance Options)
|
* Set GPU memory (\`raspi-config\` -> Performance Options)
|
||||||
@@ -593,7 +603,7 @@ step_100() {
|
|||||||
[/etc/fstab]
|
[/etc/fstab]
|
||||||
> \`PARTUUID=******-03 none swap sw 0 0\`
|
> \`PARTUUID=******-03 none swap sw 0 0\`
|
||||||
|
|
||||||
\`$SEQ_NAME disable_swap\`
|
\`$seq_name disable_swap\`
|
||||||
|
|
||||||
* Update system
|
* Update system
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user