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
37 chattr -i /system/bin/su
38 chattr -i /system/xbin/su
41 rm -f /system/app/Superuser.*
42 rm -f /system/app/Supersu.*
43 rm -f /system/app/superuser.*
44 rm -f /system/app/supersu.*
45 rm -f /system/app/SuperUser.*
46 rm -f /system/app/SuperSU.*
48 cp $PLATFORM/su /system/xbin/su
49 chown 0:0 /system/xbin/su
50 chmod 6755 /system/xbin/su
51 ln -s /system/xbin/su /system/bin/su
53 cp Superuser.apk /system/app
54 chmod 644 /system/app/Superuser.apk
56 # if the system is at least 4.3, and there is no su daemon built in,
57 # let's try to install it using install-recovery.sh
58 BUILD_RELEASE_VERSION=$(cat /system/build.prop | grep ro\\.build\\.version\\.release)
59 IS_43=$(echo $BUILD_RELEASE_VERSION | grep 4\\.3)
62 if [ "$IS_43" \> "4.3" -o "$IS_43" == "4.3" ]
64 # check for rom su daemon before clobbering install-recovery.sh
65 if [ ! -f "/system/etc/.has_su_daemon" ]
67 echo -n -e 'ui_print Installing Superuser daemon...\n' > /proc/self/fd/$2
68 echo -n -e 'ui_print\n' > /proc/self/fd/$2
69 chattr -i /system/etc/install-recovery.sh
70 cp install-recovery.sh /system/etc/install-recovery.sh
71 chmod 755 /system/etc/install-recovery.sh
72 # note that an post install su daemon was installed
73 # so recovery doesn't freak out and recommend you disable
74 # the install-recovery.sh execute bit.
75 touch /system/etc/.installed_su_daemon