fix for dietpi (final)

This commit is contained in:
Clemens Arth 2020-09-18 21:31:21 +02:00
parent d17cdade6d
commit 058cfc339b
1 changed files with 33 additions and 26 deletions

View File

@ -79,7 +79,7 @@ function set_autoexpand() {
fi
if ([[ -f "$mountdir/etc/rc.local" ]] && [[ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "1c579c7d5b4292fd948399b6ece39009" ]]); then
echo "Creating new /etc/rc.local"
info "Creating new /etc/rc.local"
isok=1
rclocal=1
boothook=/etc/rc.local
@ -87,7 +87,7 @@ function set_autoexpand() {
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
fi
elif [[ -d "$mountdir/var/lib/dietpi/postboot.d" ]]; then
echo "Using postboot hooks..."
info "Using postboot hooks..."
isok=1
rclocal=0
boothook=/var/lib/dietpi/postboot.d/inflatefs.sh
@ -126,16 +126,20 @@ p
w
EOF
cat <<EOF > $boothook &&
cat <<EOF > BOOTHOOKFILE &&
#!/bin/sh
echo "Expanding /dev/$ROOT_PART"
resize2fs /dev/$ROOT_PART
rm -f $boothook
EOF
if [ "RCLOCAL" -eq "1" ]; then
echo "rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local" >> BOOTHOOKFILE
else
echo "rm -f BOOTHOOKFILE" >> BOOTHOOKFILE
fi
reboot
exit
}
raspi_config_expand() {
/usr/bin/env raspi-config --expand-rootfs
if [[ $? != 0 ]]; then
@ -146,13 +150,14 @@ else
exit
fi
}
raspi_config_expand
echo "WARNING: Using backup expand..."
sleep 5
do_expand_rootfs
echo "ERROR: Expanding failed..."
sleep 5
if [ "$rclocal" -eq "1" ]; then
if [ "RCLOCAL" -eq "1" ]; then
if [[ -f /etc/rc.local.bak ]]; then
cp -f /etc/rc.local.bak /etc/rc.local
/etc/rc.local
@ -160,6 +165,9 @@ if [ "$rclocal" -eq "1" ]; then
fi
exit 0
EOF1
sed -i "s#BOOTHOOKFILE#$boothook#g; s#RCLOCAL#$rclocal#g" $mountdir$boothook
cat $mountdir$boothook | grep RCLOCAL
#####End no touch zone#####
chmod +x "$mountdir$boothook"
fi
@ -435,4 +443,3 @@ aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
logVariables $LINENO aftersize
info "Shrunk $img from $beforesize to $aftersize"