← Back to team overview

ubuntu-phone team mailing list archive

[PATCH] ubuntu_chroot: introduce "init" to get uchroot to start

 

Fixes the phone shutting down when one mistakenly calls ubuntu_chroot
without arguments.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu-tl@xxxxxxxxxx>
---
 ubuntu_chroot | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/ubuntu_chroot b/ubuntu_chroot
index 0127e7d..db9bfad 100644
--- a/ubuntu_chroot
+++ b/ubuntu_chroot
@@ -21,6 +21,7 @@ export USER=root
 ROOT=/data/ubuntu
 MOUNT=/system/bin/mount
 CHROOT=/system/xbin/chroot
+PGREP=/system/xbin/pgrep
 ECHO=/system/xbin/echo
 MKDIR=/system/bin/mkdir
 UCHROOT=/system/bin/uchroot
@@ -90,14 +91,24 @@ launch_shell()
     exec $CHROOT $ROOT /bin/bash -c su -
 }
 
-if [ "$1" == "shell" ]
+arg=$1
+
+if [ -z "$arg" ]
+then
+    if ! $PGREP -f /system/bin/uchroot >/dev/null 2>&1
+    then
+	arg=init
+    fi
+fi
+
+if [ "$arg" == "shell" ]
 then
     launch_shell
-elif [ -n "$1" ]
+elif [ "$arg" == "init" ]
 then
-    echo "[shell] is the only supported argument"
-else
     setup_mounts
     enable_swap
     launch_uchroot
+else
+    echo "[shell] and [init] are the only supported arguments"
 fi
-- 
1.8.1.2