From d5dc787ec1fbc78c3bd11c8f5e11660ab33e6af8 Mon Sep 17 00:00:00 2001 From: RikkaW Date: Sun, 21 Feb 2021 21:20:48 +0800 Subject: [PATCH] Recreate /data/local/tmp if it is broken --- manager/src/main/res/raw/start.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/manager/src/main/res/raw/start.sh b/manager/src/main/res/raw/start.sh index db309ff32..d32cbdcde 100644 --- a/manager/src/main/res/raw/start.sh +++ b/manager/src/main/res/raw/start.sh @@ -5,13 +5,36 @@ 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 - echo "info: copy starter from $SOURCE_PATH" fi if [ -f $STARTER_PATH ]; then