OSDN Git Service

Superuser: UG translation, added Uyghur translation.
[android-x86/external-koush-Superuser.git] / Superuser / assets / update-binary
1 #!/sbin/sh
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
8
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" ]
14 then
15   PLATFORM=x86
16 else
17   PLATFORM=armeabi
18 fi
19
20 cd /tmp
21 mkdir superuser
22 cd superuser
23 unzip -o "$3"
24 if [ "$?" -ne "0" ]
25 then
26   mkdir -p $PLATFORM
27   cp /cache/su $PLATFORM/su
28   cp /cache/Superuser.apk .
29   cp /cache/install-recovery.sh .
30 fi
31
32
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
35
36 mount /system
37 chattr -i /system/bin/su
38 chattr -i /system/xbin/su
39 rm -f /system/bin/su
40 rm -f /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.*
47
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
52
53 cp Superuser.apk /system/app
54 chmod 644 /system/app/Superuser.apk
55
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)
60 if [ ! -z "$IS_43" ]
61 then
62   if [ "$IS_43" \> "4.3"  -o "$IS_43" == "4.3" ]
63   then
64     # check for rom su daemon before clobbering install-recovery.sh
65     if [ ! -f "/system/etc/.has_su_daemon" ]
66     then
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
76     fi
77   fi
78 fi
79
80 umount /system