New indents broke rc.local md5sum, startup script

The indentation was introduced in cad2e0e11a, not when the safety hash check was added in 2c6f069c2f, my first guess.
The indentations makes the rc.local begin with spaces instead of `#!/bin/bash` and will not run. But it gets better.
The md5 safety check is based on rc.local without indents, so after the added indentations the if-block will never be skipped. If the script is run a second time, the original rc.local backed up in rc.local.bak will be overwritten, and on boot result in a never ending loop, trying to expand the filesystem each time. A user could run the pishrink.sh a second time on a disk image, e.g. after making more edits.
This commit is contained in:
Carl Jensen 2016-08-18 03:01:14 +02:00 committed by GitHub
parent abb17e217e
commit 8388774c3e
1 changed files with 5 additions and 4 deletions

View File

@ -63,11 +63,12 @@ if [ "$should_skip_autoexpand" = false ]; then
if [ `md5sum $mountdir/etc/rc.local | cut -d ' ' -f 1` != "a27a4d8192ea6ba713d2ddd15a55b1df" ]; then if [ `md5sum $mountdir/etc/rc.local | cut -d ' ' -f 1` != "a27a4d8192ea6ba713d2ddd15a55b1df" ]; then
echo Creating new /etc/rc.local echo Creating new /etc/rc.local
mv $mountdir/etc/rc.local $mountdir/etc/rc.local.bak mv $mountdir/etc/rc.local $mountdir/etc/rc.local.bak
#Do not touch the following 6 lines including EOF. The md5sum check above depends on having the extact same bytes.
cat <<\EOF > $mountdir/etc/rc.local cat <<\EOF > $mountdir/etc/rc.local
#!/bin/bash #!/bin/bash
/usr/bin/raspi-config --expand-rootfs /usr/bin/raspi-config --expand-rootfs
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; reboot rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; reboot
exit 0 exit 0
EOF EOF
chmod +x $mountdir/etc/rc.local chmod +x $mountdir/etc/rc.local
fi fi