Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions rpi-clone
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ then
exit 1
fi

raspbian=0
raspbian_buster=0
if [ -f /etc/os-release ]
rpios=0
rpios_recent=0
if [ -f /etc/os-release ] && [ -f /proc/device-tree/model ]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I see this test should check whether it's a Raspberry HW. Are you sure /proc/device-tree/model is an unique idetifier for a Raspberry HW? /etc/rpi-issue exists on Raspberry OS Builds only.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm rather sure, but your proposition with /etc/rpi-issue is cleaner and easier to understand, I'll change.

then
pretty=`cat /etc/os-release | grep PRETTY`
if [[ "$pretty" == *"Raspbian"* ]]
osversion=`cat /etc/os-release | grep VERSION_ID | cut -d'"' -f2`
model=`tr -d '\0' < /proc/device-tree/model`
if [[ "$pretty" == *"Raspbian"* || ("$model" == *"Raspberry"* && "$pretty" == *"Debian"*) ]]
then
raspbian=1
rpios=1
fi
if ((raspbian)) && [[ "$pretty" == *"buster"* ]]
if ((rpios)) && ((osversion >= 10))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this check for the osversion 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, normally, it should work with later versions of Debian.

then
raspbian_buster=1
rpios_recent=1
fi
fi

Expand Down Expand Up @@ -224,7 +226,7 @@ qecho()
echo "$@"
fi
}

qprintf()
{
if ((!quiet))
Expand Down Expand Up @@ -1320,7 +1322,7 @@ Use -U for unattended even if initializing.
then
printf "%-22s : %s\n" " " \
"Possible options:"
if ((raspbian))
if ((rpios))
then
printf "%-22s : %s\n" " " \
" Use -f2 to force a two partition initialize clone."
Expand All @@ -1338,14 +1340,14 @@ Use -U for unattended even if initializing.

readable_MiB $((last_part_sectors + 7812)) "512" image_space_readable

echo "== Initialize: IMAGE partition table - $reason =="
echo "== Initialize: IMAGE partition table - $reason =="
print_image_actions
print_options

printf "%-22s : %s\n" "** WARNING **" \
"All destination disk $dst_disk data will be overwritten!"

if ((raspbian_buster && p1_size_new == 0 && src_size_sectors[1] < 400000))
if ((rpios_recent && p1_size_new == 0 && src_size_sectors[1] < 400000))
then
printf "%-22s : %s\n" "** WARNING **" \
"Your source /boot partition is smaller than the"
Expand Down Expand Up @@ -1530,7 +1532,7 @@ Use -U for unattended even if initializing.
else
src_sync_part[p]=1
fi
fi
fi
else
printf " => dd if=${src_device[$p]} of=$dst_dev bs=1M ..."
dd if=${src_device[$p]} of=$dst_dev bs=1M &>> /tmp/$PGM-output
Expand Down Expand Up @@ -1606,7 +1608,7 @@ else
exit 1
fi

if ((raspbian_buster && dst_size_sectors[1] < 500000))
if ((rpios_recent && dst_size_sectors[1] < 500000))
then
qprintf "%-22s : %s\n" "** WARNING **" \
"Your destination /boot partition is smaller than the"
Expand Down Expand Up @@ -1814,7 +1816,7 @@ qprintf " Start - %s End - %s Elapsed Time - %d:%02d\n" \
if ((!unattended))
then
echo -n $"
Cloned partitions are mounted on $clone for inspection or customizing.
Cloned partitions are mounted on $clone for inspection or customizing.

Hit Enter when ready to unmount the /dev/$dst_disk partitions ..."

Expand Down