2 # arg 1 is recovery api version, generally 3.
3 # arg 2 is the pipe fd, to the recovery binary.
4 # communicate with it using the recovery api.
5 # arg 3 is the zip file
6 echo -n -e 'ui_print Installing Superuser...\n' > /proc/self/fd/$2
7 echo -n -e 'ui_print\n' > /proc/self/fd/$2
9 # detect binary versions to install
10 X86=$(uname -a | grep x86)
11 I686=$(uname -a | grep i686)
12 I386=$(uname -a | grep i386)
13 if [ ! -z "$X86" -o ! -z "$I686" -o ! -z "$I386" ]
27 cp /cache/su $PLATFORM/su
28 cp /cache/Superuser.apk .
29 cp /cache/install-recovery.sh .
33 echo -n -e 'ui_print Installing '$PLATFORM' binaries...\n' > /proc/self/fd/$2
34 echo -n -e 'ui_print\n' > /proc/self/fd/$2
39 rm -f /system/app/Superuser.*
40 rm -f /system/app/Supersu.*
41 rm -f /system/app/superuser.*
42 rm -f /system/app/supersu.*
43 rm -f /system/app/SuperUser.*
44 rm -f /system/app/SuperSU.*
46 cp $PLATFORM/su /system/xbin/su
47 chown 0:0 /system/xbin/su
48 chmod 6755 /system/xbin/su
49 ln -s /system/xbin/su /system/bin/su
51 cp Superuser.apk /system/app
52 chmod 644 /system/app/Superuser.apk
54 # if the system is at least 4.3, and there is no su daemon built in,
55 # let's try to install it using install-recovery.sh
56 BUILD_RELEASE_VERSION=$(cat /system/build.prop | grep ro\\.build\\.version\\.release)
57 IS_43=$(echo $BUILD_RELEASE_VERSION | grep 4\\.3)
58 if [ -z "$IS_43" -o "$IS_43" \> "4.3" -o "$IS_43" == "4.3" ]
60 # check for rom su daemon before clobbering install-recovery.sh
61 if [ ! -f "/system/etc/.has_su_daemon" ]
63 echo -n -e 'ui_print Installing Superuser daemon...\n' > /proc/self/fd/$2
64 echo -n -e 'ui_print\n' > /proc/self/fd/$2
65 cp install-recovery.sh /system/etc/install-recovery.sh
66 chmod 755 /system/etc/install-recovery.sh
67 # note that an post install su daemon was installed
68 # so recovery doesn't freak out and recommend you disable
69 # the install-recovery.sh execute bit.
70 touch /system/etc/.installed_su_daemon