Guide - Installing Shizuku

Alright, fixed it.

On my aarch64 install, there seems to be some kind of uid / gid matching issue or whatever. I had to modify the installation script a bit, as UID and GID 50000 seem to be mapped to appsupport-root. Also, shizuku.rc must have a permission mask of 644 in order to have it executed on startup.

install.sh

#!/bin/sh

set -e

WORK_DIR="/home/defaultuser/work"

echo "Stopping 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"

echo "Copying start.sh..."
cp "$WORK_DIR/start.sh" squashfs-root/system/bin/
chmod +x "squashfs-root/system/bin/start.sh"
chown 500000:500000 "squashfs-root/system/bin/start.sh"
echo "start.sh copied and permissions set"

echo "Copying shizuku.rc..."
cp "$WORK_DIR/shizuku.rc" squashfs-root/system/etc/init
chmod 644 "squashfs-root/system/etc/init/shizuku.rc"
chown 500000:500000 "squashfs-root/system/etc/init/shizuku.rc"
echo "shizuku.rc copied and ownership set"

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

Another thing that may or may not have relevance is the formatting of shizuku.rc. All other *.rc files only have 4 spaces indentation.

shizuku.rc

service runapp /system/bin/start.sh class main 
    seclabel u:r:su:s0 user root group root 
    oneshot
 
on property:dev.bootcomplete=1
    start runapp

start.sh was fine from the get-go, I think. Gonna include it in my post anyway.

start.sh

#!/system/bin/sh

SOURCE_PATH="/storage/emulated/0/Android/data/moe.shizuku.privileged.api/starter"
STARTER_PATH="/data/local/tmp/shizuku_starter"

echo "info: start.sh begin"

recreate_tmp() {
  echo "info: /data/local/tmp is possible broken, recreating..."
  rm -rf /data/local/tmp
  mkdir -p /data/local/tmp
}

broken_tmp() {
  echo "fatal: /data/local/tmp is broken, please try reboot the device or manually recreate it..."
  exit 1
}

if [ -f "$SOURCE_PATH" ]; then
    echo "info: attempt to copy starter from $SOURCE_PATH to $STARTER_PATH"
    rm -f $STARTER_PATH

    cp "$SOURCE_PATH" $STARTER_PATH
    res=$?
    if [ $res -ne 0 ]; then
      recreate_tmp
      cp "$SOURCE_PATH" $STARTER_PATH

      res=$?
      if [ $res -ne 0 ]; then
        broken_tmp
      fi
    fi

    chmod 700 $STARTER_PATH
    chown 2000 $STARTER_PATH
    chgrp 2000 $STARTER_PATH
fi

if [ -f $STARTER_PATH ]; then
  echo "info: exec $STARTER_PATH"
    $STARTER_PATH "$1"
    result=$?
    if [ ${result} -ne 0 ]; then
        echo "info: shizuku_starter exit with non-zero value $result"
    else
        echo "info: shizuku_starter exit with 0"
    fi
else
    echo "Starter file not exist, please open Shizuku and try again."
fi

So, installation instructions are:

  • Turn on SSH in developer options
  • Connect via SSH or use the inbuilt terminal app (if you like pain)
  • Create the work folder: mkdir work
  • Enter the folder: cd work
  • Create the script files from above
  • Make install.sh executable: chmod +x install.sh
  • Download the right squashfs-tools package for aarch64 from here, right now, that would be: curl -O https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Everything/aarch64/os/Packages/s/squashfs-tools-4.3-16.fc28.aarch64.rpm
  • Become root: devel-su
  • Install lzip: pkcon refresh && pkcon install lzip
  • Install squashfs-tools: pkcon install-local squashfs-tools-4.3-16.fc28.aarch64.rpm
  • Install: ./install.sh

Now you should be good to go.

2 Likes