Posting @babo’s script here, because files at Mega are much less persistent than Jolla’s forum (in my experience):
#!/bin/sh
set -e
WORK_DIR="/home/defaultuser/work"
echo "Stoping appsupport..."
systemctl stop aliendalvik
sleep 4
echo "Checking if system.img exists..."
if [ ! -f "$WORK_DIR/origsystem.img" ]; then
echo "copying system.img..."
cp /opt/appsupport/system.img "$WORK_DIR/origsystem.img"
echo "system.img copied"
else
echo "system.img already exists, skipping copy"
fi
echo "extracting system.img..."
unsquashfs "$WORK_DIR/origsystem.img"
cp "$WORK_DIR/start.sh" squashfs-root/system/bin/
echo "start.sh copied"
chmod +x "$WORK_DIR/squashfs-root/system/bin/start.sh"
echo "executable permissions set"
cp "$WORK_DIR/shizuku.rc" squashfs-root/system/etc/init
echo "shizuku.rc copied"
echo "building new system.img..."
mksquashfs "$WORK_DIR/squashfs-root" "$WORK_DIR/system.img" -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments
echo "Cleaning up..."
rm -r -f "$WORK_DIR/squashfs-root"
echo "new system.img built"
while true; do
read -p "Do you wish to replace the old system.img in /opt/appsupport with the new one? (yes/no): " yn
case $yn in
[Yy]* )
echo "Replacing old system.img in /opt/appsupport..."
mv "$WORK_DIR/system.img" /opt/appsupport
break;;
[Nn]* )
echo "Operation cancelled. The new system.img will not be moved."
break;;
* )
echo "Please answer yes or no.";;
esac
done