Deleted ERR cleanup and added check for rc.local existance

This commit is contained in:
framp 2020-05-31 21:09:51 +02:00
parent d38666fefd
commit 0a45a5fdae
1 changed files with 10 additions and 6 deletions

View File

@ -173,7 +173,7 @@ if [ -n "$2" ]; then
fi
# cleanup at script exit
trap cleanup ERR EXIT
trap cleanup EXIT
#Gather info
info "Gathering data"
@ -200,9 +200,10 @@ if [ "$should_skip_autoexpand" = false ]; then
mountdir=$(mktemp -d)
mount "$loopback" "$mountdir"
if [ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "0542054e9ff2d2e0507ea1ffe7d4fc87" ]; then
if [[ -f "$mountdir/etc/rc.local" ]] && [[ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "0542054e9ff2d2e0507ea1ffe7d4fc87" ]]; then
echo "Creating new /etc/rc.local"
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
#####Do not touch the following lines#####
cat <<\EOF1 > "$mountdir/etc/rc.local"
@ -238,7 +239,10 @@ cat <<EOF > /etc/rc.local &&
#!/bin/sh
echo "Expanding /dev/$ROOT_PART"
resize2fs /dev/$ROOT_PART
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
if [[ -f /etc/rc.local.bak ]]; then
cp -f /etc/rc.local.bak /etc/rc.local
/etc/rc.local
fi
EOF
reboot