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
12 # x86 needs to match: i486, i686, x86_64, ...
13 if echo "$ARCH" | grep -q 86; then
15 elif [ "$ARCH" = "mips" -o "$ARCH" = "mips64" ]; then
28 cp /cache/su $PLATFORM/su
29 cp /cache/Superuser.apk .
30 cp /cache/install-recovery.sh .
34 echo -n -e 'ui_print Installing '$PLATFORM' binaries...\n' > /proc/self/fd/$2
35 echo -n -e 'ui_print\n' > /proc/self/fd/$2
38 chattr -i /system/bin/su
39 chattr -i /system/xbin/su
42 rm -f /system/app/Superuser.*
43 rm -f /system/app/Supersu.*
44 rm -f /system/app/superuser.*
45 rm -f /system/app/supersu.*
46 rm -f /system/app/SuperUser.*
47 rm -f /system/app/SuperSU.*
49 cp $PLATFORM/su /system/xbin/su
50 chown 0:0 /system/xbin/su
51 chmod 6755 /system/xbin/su
52 ln -s /system/xbin/su /system/bin/su
54 cp Superuser.apk /system/app
55 chmod 644 /system/app/Superuser.apk
57 # if the system is at least 4.3, and there is no su daemon built in,
58 # let's try to install it using install-recovery.sh
59 BUILD_RELEASE_VERSION="$(grep 'ro\.build\.version\.release' /system/build.prop)"
60 VERSION="${BUILD_RELEASE_VERSION##*=}"
65 if [ "$MAJ" -ge 4 -a "$MIN" -ge 3 ]
67 # on 4.3+, the daemon need not be setuid.
68 chmod 0755 /system/xbin/su
69 # check for rom su daemon before clobbering install-recovery.sh
70 if [ ! -f "/system/etc/.has_su_daemon" ]
72 echo -n -e 'ui_print Installing Superuser daemon...\n' > /proc/self/fd/$2
73 echo -n -e 'ui_print\n' > /proc/self/fd/$2
74 chattr -i /system/etc/install-recovery.sh
75 cp install-recovery.sh /system/etc/install-recovery.sh
76 chmod 755 /system/etc/install-recovery.sh
77 # note that an post install su daemon was installed
78 # so recovery doesn't freak out and recommend you disable
79 # the install-recovery.sh execute bit.
80 touch /system/etc/.installed_su_daemon