├── LICENSE
├── README.md
├── changes.md
├── classes.dex
├── gxp
├── !zygote.sh
├── .!zygote
│ └── mode
├── .nomedia
├── install.sh
└── uninstall.sh
├── libapp.so
├── libbash.so
├── libbusybox.so
├── libgxp.so
├── libmkshrc.so
├── libmm.so
└── libzip.so
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magisk On Emulator, Android x86 project
2 |
3 | ## About
4 | Integrate Magisk root into Nox Player and other Android x86, emulators
5 |
6 | **Magisk on NoxPlayer Android 9 emulator**
7 |
8 |
9 |
10 | **Magisk on BlissOS 11 - Android 9**
11 |
12 |
13 |
14 | ## Features
15 |
16 | - Bring Magisk / Zygisk to Android x86
17 | - MagiskHide / MagiskDenyList for hiding root
18 | - Magisk / Zygisk modules work properly!
19 |
20 | Note: Some features might not work on some emulator, Please read [Emulator that Magisk can work properly](https://github.com/HuskyDG/MagiskOnNox/wiki/Emulator-that-Magisk-can-work-properly) to know which Magisk features doesn't work.
21 |
22 | ## Requirements
23 | - Android x86 project such as BlissOS 11 (Android 9), BlissOS 14 (Android 11), PrimeOS (Android 11), ...
24 | - Android Emulator (NoxPlayer, MuMuGlobal Player, Bluestacks): [Emulator that Magisk can work properly](https://github.com/HuskyDG/MagiskOnNox/wiki/Emulator-that-Magisk-can-work-properly).
25 | - Supported Android version: Android 7.1+, Recommended Android 9+
26 |
27 | > It is NOT RECOMMENDED to install Magisk on Android 7.1 Emulator (exclude MEmu) anymore as they has broken environment. Magisk v24+ might no longer be able to run on Android 7.1 Emulator. Install Magisk on Android 7.1 x86 project such as Phoenix OS will cause BOOTLOOP
28 |
29 |
30 | ## Installation method
31 | - Install Magisk into `/system`
32 | - Install Magisk into ramdisk image (Android 9 and lower)
33 | - Install Magisk by using GearLock extension
34 |
35 |
36 | ## Download
37 | Download from [**Releases** tag](https://github.com/HuskyDG/MagiskOnNox/releases/)
38 |
39 |
40 |
41 | ## Useful link
42 |
43 | - [Installation Guide](https://github.com/HuskyDG/MagiskOnNox/wiki/Installation) - Learn how to install Magisk on Emulator, Android x86 project
44 |
45 | - [MagiskOnNox Wiki](https://github.com/HuskyDG/MagiskOnNox/wiki)
46 | - [Magisk Documentation](https://topjohnwu.github.io/Magisk/)
47 |
48 | ## Credits
49 | - [Magisk](https://github.com/topjohnwu/Magisk): The most famous root solution on Android
50 | - [Magisk emulator.sh](https://github.com/topjohnwu/Magisk/blob/master/scripts/avd_magisk.sh) : Magisk setup script without patching `boot.img`
51 | - [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA): For Magisk on WSA script, how to integrate Magisk on Emulator
52 | - [TermOnePlus](https://termoneplus.com/) - The best Terminal Emulator app for MagiskOnNox script
53 | - [BSTweaker](https://bstweaker.tk/) - Tools for debugging Bluestacks emulator
54 |
--------------------------------------------------------------------------------
/changes.md:
--------------------------------------------------------------------------------
1 | - **Bind mount data mirror again** in case filesystem mount under `/data` is binding mount of subdirectory from **ext4 partition**, this issue is happened when users install Android x86 into **ext4 partition** instead of **NTFS partition** (with `data.img`), causes Magisk think `/data` come from a device block (ext4 partition) and mount that device block into `(/sbin)/.magisk/mirror/data` which is not mirror for filesystem mount under `/data`
2 | - Do not try to hide Selinux Permissive
3 | - Hide `init.svc_debug_pid.*` magisk service traces on Android 11
4 |
--------------------------------------------------------------------------------
/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/classes.dex
--------------------------------------------------------------------------------
/gxp/!zygote.sh:
--------------------------------------------------------------------------------
1 | PLACEHOLDER_EXTENSION_INFO
--------------------------------------------------------------------------------
/gxp/.!zygote/mode:
--------------------------------------------------------------------------------
1 | 0755 "!zygote.sh"
2 | 0755 "uninstall.sh"
3 | 0775 ".!zygote"
4 | 0664 ".!zygote/mode"
5 | 0755 "gearlock"
6 | 0755 "gearlock/magisk"
7 | 0755 "gearlock/magisk.rc"
8 |
--------------------------------------------------------------------------------
/gxp/.nomedia:
--------------------------------------------------------------------------------
1 | #
2 |
--------------------------------------------------------------------------------
/gxp/install.sh:
--------------------------------------------------------------------------------
1 | ## For proper developer documentation, visit https://supreme-gamers.com/gearlock
2 | # Check `!zygote.sh` to configure your package functions or gearlock can also guide you during the build process
3 |
4 | #####--- Import Functions ---#####
5 | get_base_dir # Returns execution directory path in $BD variable
6 | # get_net_stat
7 | #####--- Import Functions
8 |
9 | GEARHOME="$GHOME"
10 | rm -rf $GEARHOME/unins/Magisk_*
11 | if [ "$GEARHOME" == "/data/ghome" ]; then
12 | echo "- Systemless mode!"
13 | fi
14 |
15 | # recovery mode
16 | INITRC=/android/init.rc
17 | INITRC2=/system/etc/init/hw/init.rc
18 |
19 | if test "$BOOTCOMP" == "yes"; then
20 | # boot mode
21 | INITRC=/init.rc
22 | fi
23 |
24 | GEARBOOT="$GEARHOME/gearboot/overlay/magisk/init"
25 | GEAR_INITDIR="$GEARBOOT"
26 |
27 | if [ ! -f "$INITRC" ]; then
28 | # Android 11 new init.rc
29 | INITRC="$INITRC2"
30 | GEAR_INITDIR="$GEARBOOT/system/etc/init/hw"
31 | fi
32 |
33 | NEW_INITRC="$GEAR_INITDIR/init.rc"
34 |
35 | rm -rf "$GEARBOOT" 2>/dev/null
36 | rm -rf "$GEARHOME/gearboot/overlay/rusty-magisk"
37 | echo "- Make directory: ~/gearboot/overlay/magisk/init"
38 | mkdir -p "$GEAR_INITDIR" 2>/dev/null
39 | echo "- Make directory: ~/.local/magisk"
40 | rm -rf "$GEARHOME/.local/magisk" 2>/dev/null
41 | mkdir -p "$GEARHOME/.local/magisk" 2>/dev/null
42 |
43 | for file in magisk.rc magisk/overlay.sh magisk/loadpolicy.sh; do
44 | sed -i "s|PLACEHOLDER_MAGISKBASE|$GEARHOME/.local/magisk|g" "$BD/$GCOMM/$file"
45 | done
46 |
47 | echo "- Placing neccessary files..."
48 | touch "$GEARBOOT/init.superuser.rc"
49 | cp -af "$BD/$GCOMM/magisk/"* "$GEARHOME/.local/magisk"
50 |
51 | echo "- Setup init.rc overlay..."
52 | cp "$INITRC" "$NEW_INITRC"
53 | chmod 755 "$NEW_INITRC"
54 | cat "$BD/$GCOMM/magisk.rc" >>"$NEW_INITRC"
55 | chmod 750 -R "$GEARHOME/.local/magisk"
56 | echo "- Done!"
--------------------------------------------------------------------------------
/gxp/uninstall.sh:
--------------------------------------------------------------------------------
1 | PLACEHOLDER_UNINSTALL
--------------------------------------------------------------------------------
/libapp.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/libapp.so
--------------------------------------------------------------------------------
/libbash.so:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | AGVARR="$@"; SCRIPT="$0"; AGV1="$1"; AGV2="$2"; AGV3="$3"; AGV4="$4"; AGV5="$5"; exec 2>/dev/null; MYSCRIPT="$(realpath "$0")"; MYPATH="${MYSCRIPT%/*}"; busybox="$MYPATH/libbusybox.so"; PATH="$MYPATH:$PATH:/sbin:/system/bin:/system/xbin"; cmds="$SCRIPT $AGVARR"
3 |
4 |
5 | if [ ! -f "$MYPATH/libbusybox.so" ]; then
6 | echo "Missing libbusybox.so"; exit 1
7 | fi
8 | chmod 775 "$MYPATH/"*
9 |
10 | RC='\033[0m' RED='\033[0;31m' BRED='\033[1;31m' GRAY='\033[1;30m' BLUE='\033[0;34m' BBLUE='\033[1;34m' CYAN='\033[0;34m' CYAN='\033[1;34m' WHITE='\033[1;37m' GREEN='\033[0;32m' BGREEN='\033[1;32m' YELLOW='\033[1;33m' PURPLE='\033[0;35m' BPURPLE='\033[1;35m' ORANGE='\033[0;33m'
11 |
12 | test -z "$USER_ID" && USER_ID="$(id -u)"
13 |
14 | API=$(getprop ro.build.version.sdk)
15 | ABI=$(getprop ro.product.cpu.abi)
16 | if [ "$ABI" = "x86" ]; then
17 | ARCH=x86
18 | ABI32=x86
19 | IS64BIT=false
20 | elif [ "$ABI" = "arm64-v8a" ]; then
21 | ARCH=arm64
22 | ABI32=armeabi-v7a
23 | IS64BIT=true
24 | elif [ "$ABI" = "x86_64" ]; then
25 | ARCH=x64
26 | ABI32=x86
27 | IS64BIT=true
28 | else
29 | ARCH=arm
30 | ABI=armeabi-v7a
31 | ABI32=armeabi-v7a
32 | IS64BIT=false
33 | fi
34 |
35 | DEVICE_API="$API"
36 | DEVICE_ABI="$ABI"
37 | DEVICE_ARCH="$ARCH"
38 | DEVICE_ABI32="$ABI32"
39 | DEVICE_64BIT="$IS64BIT"
40 |
41 |
42 | SYSTEM_AS_ROOT=true
43 | if mount | grep rootfs | grep -q " / " || mount | grep tmpfs | grep -q " / "; then
44 | SYSTEM_AS_ROOT=false
45 | fi
46 |
47 | magisk_name="magisk32"
48 | [ "$IS64BIT" == true ] && magisk_name="magisk64"
49 |
50 | help(){
51 | echo "Magisk Installer script for emulator
52 | usage: inmagisk [OPTION]
53 | Available option:
54 | install Open Menu for install Magisk
55 | install: Install/Update Magisk
56 | uninstall Uninstall Magisk and its modules"
57 | }
58 |
59 | ui_print(){ echo -e "$1"; }
60 | cre(){
61 | echo -ne "${GRAY}@$1${RC}"
62 | }
63 |
64 |
65 |
66 | text_press_enter_menu="PRESS ENTER TO BACK TO MENU"
67 | text_cannot_mm="Cannot install or this app is adready installed"
68 | text_success_mm="Install success!"
69 | text_warn_uninstall_magisk="Do you want to uninstall Magisk?"
70 | text_done="Done!"
71 | text_saved_magisk_apk_to="Saved Magisk APK to"
72 | text_mount_rw_system="Mount system partition (Read-write)"
73 | text_mount_ro_system="Mount system partition (Read-only)"
74 | text_obtain_root="Obtain ROOT access..."
75 | text_obtain_root_failed="Cannot obtain ROOT access"
76 | text_recommended="Recommended"
77 | text_install_app="Install Magisk app"
78 | text_install_app_sug="Please install Magisk app by yourself"
79 | text_install="Install"
80 | text_setup="Initialize Magisk Core"
81 | text_rm_magisk_files="Cleaning trash files"
82 | text_extract_magisk_apk="Extract Magisk APK"
83 | text_failed_mount_system="Looks like the system partition is locked at read-only"
84 | text_enter_magisk_apk="Enter path to your Magisk APK"
85 | text_example="Example"
86 | text_unpack_ramdisk="Unpack the ramdisk image"
87 | text_unpack_ramdisk_fail="Unable to unpack the ramdisk image"
88 | text_patch_ramdisk="Patching ramdisk image"
89 | text_repack_ramdisk="Repack new ramdisk image"
90 | text_repack_ramdisk_fail="Unable to repack new ramdisk image"
91 | text_enter_path_ramdisk="Enter path to your ramdisk"
92 | text_new_ramdisk="New ramdisk image was saved to"
93 | text_uninstall_fail="! No Magisk found on system or GearLock"
94 | text_cannot_mount_part="Unable to mount the partition!"
95 | text_wrong_input="Wrong input, please enter again correctly"
96 | text_enter_part="Enter the ${BGREEN}partition${RC} number where you got this ${BPURPLE}Android-x86 OS${RC} installed"
97 | text_enter_ramdisk="Enter the ${BGREEN}ramdisk.img${RC} number from this ${BPURPLE}Android-x86 OS${RC}"
98 | text_unpatch_ramdisk="Remove patch with magisk from ramdisk"
99 | text_backup_not_exist="Backup not exist, cannot uninstall"
100 | text_uninstall_magisk_in="Uninstall Magisk from system and GearLock"
101 | text_restore_original_ramdisk="Restore ramdisk back to original"
102 | text_choice=CHOICE
103 | text_run_with_root="Run script with root access"
104 | text_cannot_install_magisk="Unable to install Magisk!"
105 | text_cannot_uninstall_magisk="Unable to uninstall Magisk!"
106 | text_added_bs_module="Added Bluestacks Fix Magisk modules"
107 | text_magisk_patched_ramdisk="Magisk patched ramdisk image detected"
108 | text_saved_ramdisk_info="Saved ramdisk information to"
109 | text_unsupport_ramdisk_format="Unsupported ramdisk format"
110 | text_tell_remove_rusty_magisk="You may have rust-magisk installed, please remove it if present!!!"
111 | text_magisk_tmpfs_directory="Magisk tmpfs path"
112 | text_use_current_ramdisk_info="Do you want to use the current ramdisk information"
113 | text_install_gearlock="Please install GearLock first"
114 | text_building_gxp="Build GearLock extension"
115 | text_saved_magisk_gxp_to="Saved extension to"
116 | text_uninstalling_magisk="Uninstall Magisk and its related files"
117 | text_system_not_writeable="System is not writeable! Cannot completely uninstall."
118 | text_grant_inter_access_permission="Please grant app the permission to access Internal Storage"
119 | text_select_magisk_app="Select Magisk version you want to install"
120 | text_guide_rm_magisk_app="Type \"rm\" with a number to delete target version"
121 | text_ask_keep_modules="Do you want to preserve modules (Only remove Magisk)?"
122 | text_cannot_detect_target_ramdisk="Unable to detect target ramdisk"
123 | text_find_ramdisk_auto="It's difficult to detect target ramdisk correctly.
124 | Do you want to automatically find the target ramdisk?"
125 | text_enter_url="Custom link"
126 |
127 | print_ramdisk_method(){
128 | pd "light_cyan" "Install Magisk into ramdisk image"
129 | echo " 1 - Direct install"
130 | echo " 2 - Select ramdisk image and patch"
131 | echo -n "[CHOICE]: "
132 | }
133 |
134 | print_unpatch_ramdisk(){
135 | pd "light_cyan" "Remove Magisk in ramdisk"
136 | echo " 1 - Direct uninstall"
137 | echo " 2 - Select ramdisk image and patch"
138 | echo -n "[CHOICE]: "
139 | }
140 |
141 | print_gxp_method(){
142 | pd "light_cyan" "Install Magisk by using GearLock"
143 | echo " 1 - Direct install"
144 | echo " 2 - Export GearLock extension (GXP)"
145 | echo -n "[CHOICE]: "
146 | }
147 |
148 | blissos_open_menu(){
149 | echo -e "- If you are using ${BPURPLE}Bluestacks${RC} emulator"
150 | echo -e "You can use ${BGREEN}BSTweaker 6.8.5+${RC} to enable Root access"
151 |
152 | pd none "- If you are using ${BPURPLE}Android x86${RC} (BlissOS)"
153 | pd none "You can press ${BGREEN}Alt+F1${RC} and type this command:"
154 |
155 |
156 | }
157 |
158 | print_info(){
159 | p none " Magisk: "; $hasMagisk && pd light_green "$(magisk -v) ($(magisk -V))" || pd light_red "Not installed"
160 | p none " Android Level: "; [ "$SDK" -lt "28" ] && pd light_red "$SDK" || pd light_green "$SDK"
161 | p none " System-as-root: "; [ "$SYSTEM_AS_ROOT" == "true" ] && pd light_green "$SYSTEM_AS_ROOT" || pd light_red "$SYSTEM_AS_ROOT"
162 | }
163 |
164 |
165 | warn_reboot(){
166 | echo " The device will reboot after a few seconds"
167 | pd yellow " IF THE EMULATOR FREEZES, SIMPLY JUST REBOOT IT"
168 | }
169 |
170 | disable_magisk(){
171 | [ -f "$DLPATH/disable" ] && p light_red "[ON]" || p light_red "[OFF]"
172 | }
173 |
174 | disable_magisk_process(){
175 | [ -f "$DLPATH/disable" ] && rm -rf "$DLPATH/disable" || touch "$DLPATH/disable"
176 | }
177 |
178 | need_root_access(){
179 |
180 | [ "$(whoami)" == "root" ] || abortc light_red "! Need root access to perform this action"
181 | }
182 |
183 | print_menu(){
184 | pd gray "=============================================="
185 | echo " Magisk on Nox - Installer Script"
186 | echo " by HuskyDG"
187 | # please don't change this or use "by HuskyDG + your name" for credits :((
188 | echo -e "$(print_info)"
189 | pd gray "=============================================="
190 | echo " 1 - Install/Update Magisk"
191 | pd gray " Integrate Magisk root into Android x86 emulator"
192 | echo " 2 - Uninstall Magisk"
193 | pd gray " Remove Magisk and its modules"
194 | echo " 3 - Install Magisk Modules Manager"
195 | pd gray " Module manager for Magisk"
196 | echo " 4 - Remove all other root methods"
197 | pd gray " Only use if you cannot find Disable root option"
198 | echo "----------"
199 | echo " 0 - Exit menu"
200 | p none "[CHOICE]: "
201 | }
202 |
203 | print_method(){
204 | pd gray "=============================================="
205 | echo " Install/Update Magisk"
206 | pd gray "=============================================="
207 | pd light_cyan "Install Magisk method"
208 | echo " 1 - Install Magisk into \"/system\""
209 | pd gray " The system partition must be mounted as read-write"
210 | pd gray " Recommended for Android Emulator such as NoxPlayer, MEmu, ..."
211 | echo " 2 - Install Magisk into ramdisk image (systemless)"
212 | pd gray " Use this option if you can find ramdisk.img"
213 | pd gray " Do not support system-as-root"
214 | echo " 3 - Install Magisk by using GearLock (system/systemless)"
215 | pd gray " Use GearLock to active Magisk"
216 | pd gray " Recommended for Android x86 project"
217 | echo " 4 - Update binary file into \"/data\""
218 | pd gray " Update Magisk without having to modify system/ramdisk again"
219 | pd gray " Magisk must be installed by this script"
220 | echo "----------"
221 | if [ ! -z "$MAGISK_VER_CODE" ] && [ "$MAGISK_VER_CODE" -lt "23010" ]; then
222 | echo " m - Minimal Magisk mode: `p light_red "$MINIMAL_MAGISK"`"
223 | pd gray " Only MagiskSU and MagiskHide"
224 | fi
225 | echo " 0 - Exit menu"
226 | pd light_red "* Note: Uninstall rusty-magisk to avoid conflicts"
227 | p none "[CHOICE]: "
228 |
229 | }
230 |
231 | print_magisk_builds(){
232 | echo " 1 - Canary `cre topjohnwu`"
233 | echo " 2 - Alpha `cre vvb2060`"
234 | echo " 3 - Canary v23001 `cre topjohnwu`"
235 | echo " 4 - Stable v23.0 `cre topjohnwu`"
236 | echo " 5 - Canary `cre TheHitMan7`"
237 | echo " e - $text_enter_url"
238 | }
239 |
240 |
241 | print_menu_install(){
242 |
243 | pd gray "=============================================="
244 | echo " Install/Update Magisk"
245 | pd gray "=============================================="
246 | pd light_cyan "ONLINE"
247 | print_magisk_builds
248 | pd light_cyan "OFFLINE"
249 | echo " a - Stable v24.1"
250 | echo " x - Choose and install from another Magisk APK"
251 | echo " z - Select downloaded Magisk APK"
252 | pd green "* Please check my wiki page to select suitable Magisk build"
253 | p none "[CHOICE]: "
254 |
255 | }
256 |
257 |
258 |
259 |
260 | language_vn(){
261 |
262 | text_press_enter_menu="NHẤN ENTER ĐỂ TRỞ VỀ MENU"
263 | text_cannot_mm="Không thể cài đặt hoặc ứng dụng đã được cài đặt"
264 | text_success_mm="Cài đặt thành công!"
265 | text_warn_uninstall_magisk="Bạn có muốn gỡ cài đặt Magisk?"
266 | text_ask_keep_modules="Bạn có muốn giữ lại các mô-đun không (Chỉ gỡ Magisk)?"
267 | text_done="Đã xong!"
268 | text_saved_magisk_apk_to="Đã lưu Magisk APK vào"
269 | text_mount_rw_system="Gắn kết phân vùng system (Đọc-ghi)"
270 | text_mount_ro_system="Gắn kết phân vùng system (Chỉ đọc)"
271 | text_obtain_root="Đang lấy quyền ROOT.."
272 | text_obtain_root_failed="Không thể lấy quyền ROOT"
273 | text_recommended="Đề xuất"
274 | text_install_app="Cài đặt ứng dụng Magisk"
275 | text_install_app_sug="Vui lòng cài đặt ứng dụng Magisk thủ công"
276 | text_install="Cài đặt"
277 | text_setup="Thiết lập lõi Magisk"
278 | text_rm_magisk_files="Dọn dẹp các tập tin rác"
279 | text_extract_magisk_apk="Giải nén Magisk APK"
280 | text_failed_mount_system="Gắn kết phân vùng system thất bại"
281 | text_enter_magisk_apk="Nhập đường dẫn tới tệp Magisk APK của bạn"
282 | text_example="Ví dụ"
283 | text_unpack_ramdisk="Giải nén đĩa ảnh ramdisk"
284 | text_unpack_ramdisk_fail="Không thể giải nén đĩa ảnh!"
285 | text_patch_ramdisk="Đang vá đĩa ảnh ramdisk"
286 | text_repack_ramdisk="Đóng gói lại với đĩa ảnh ramdisk mới"
287 | text_repack_ramdisk_fail="Không thể đóng gói đĩa ảnh!"
288 | text_enter_path_ramdisk="Nhập đường dẫn đến đĩa ảnh ramdisk.img"
289 | text_new_ramdisk="Đĩa ảnh ramdisk mới đã lưu vào"
290 | text_uninstall_fail="! Không tìm thấy Magisk trên hệ thống"
291 | text_cannot_mount_part="Không thể gắn kết phân vùng!"
292 | text_wrong_input="Sai dữ liệu, vui lòng nhập lại"
293 | text_enter_part="Nhập số với ${BGREEN}phân vùng${RC} mà bạn đã cài đặt ${BPURPLE}Android-x86 OS${RC} này"
294 | text_enter_ramdisk="Nhập số tương ứng với ${BGREEN}ramdisk.img${RC} từ ${BPURPLE}Android-x86 OS${RC}"
295 | text_unpatch_ramdisk="Loại bỏ bản vá với magisk khỏi ramdisk"
296 | text_unpatch_ramdisk="Loại bỏ bản vá Magisk khỏi ramdisk"
297 | text_backup_not_exist="Bản sao lưu không tồn tại, không thể gỡ"
298 | text_uninstall_magisk_in="Gỡ bỏ Magisk khỏi hệ thống và GearLock"
299 | text_restore_original_ramdisk="Khôi phục ramdisk trở lại ban đầu"
300 | text_choice="CHỌN"
301 | text_run_with_root="Chạy script với quyền root"
302 | text_cannot_install_magisk="Không thể cài đặt Magisk!"
303 | text_cannot_uninstall_magisk="Không thể gỡ cài đặt Magisk!"
304 | text_added_bs_module="Đã thêm Magisk mô-đun Bluestacks Fix"
305 | text_magisk_patched_ramdisk="Đã phát hiện ramdisk đã vá với Magisk "
306 | text_saved_ramdisk_info="Đã lưu thông tin ramdisk vào"
307 | text_unsupport_ramdisk_format="Định dạng ramdisk không được hỗ trợ"
308 | text_tell_remove_rusty_magisk="Bạn có thể đã cài rusty-magisk, vui lòng hãy gỡ nó nếu có!!!"
309 | text_magisk_tmpfs_directory="Đường dẫn Magisk tmpfs"
310 | text_use_current_ramdisk_info="Bạn có muốn sử dụng thông tin ramdisk hiện tại?"
311 | text_install_gearlock="Hãy cài đặt GearLock trước đã"
312 | text_building_gxp="Xây dựng phần mở rộng GearLock"
313 | text_saved_magisk_gxp_to="Đã lưu phần mở rộng vào"
314 | text_uninstalling_magisk="Đang gỡ bỏ Magisk và các tệp liên quan"
315 | text_system_not_writeable="Hệ thống không thể ghi! Không thể gỡ bỏ hoàn toàn"
316 | text_grant_inter_access_permission="Vui lòng cung cấp cho ứng dụng quyền truy cập Bộ nhớ trong"
317 | text_select_magisk_app="Lựa chọn phiên bản Magisk mà bạn muốn cài đặt"
318 | text_guide_rm_magisk_app="Gõ \"rm\" với 1 con số để xóa phiên bản tương ứng"
319 | text_find_ramdisk_auto="Rất khó để phát hiện ramdisk đích một cách chính xác.
320 | Bạn có muốn tìm ramdisk tự động không?"
321 | text_enter_url="Liên kết tùy chỉnh"
322 |
323 | need_root_access(){
324 |
325 | [ "$(whoami)" == "root" ] || abortc light_red "! Cần quyền truy cập root để thực hiện hành động này"
326 | }
327 |
328 |
329 | print_ramdisk_method(){
330 | pd "light_cyan" "Cài đặt Magisk vào đĩa ảnh ramdisk"
331 | echo " 1 - Cài đặt trực tiếp"
332 | echo " 2 - Chọn đĩa ảnh ramdisk và vá"
333 | echo -n "[CHỌN]: "
334 | }
335 |
336 | print_gxp_method(){
337 | pd "light_cyan" "Cài đặt Magisk bằng GearLock"
338 | echo " 1 - Cài đặt trực tiếp"
339 | echo " 2 - Tạo tệp mở rộng GearLock (GXP)"
340 | echo -n "[CHỌN]: "
341 | }
342 |
343 | print_unpatch_ramdisk(){
344 | pd "light_cyan" "Loại bỏ Magisk khỏi ramdisk"
345 | echo " 1 - Gỡ cài đặt trực tiếp"
346 | echo " 2 - Chọn đĩa ảnh ramdisk và vá"
347 | echo -n "[CHỌN]: "
348 | }
349 |
350 |
351 |
352 | warn_reboot(){
353 | echo " Thiết bị sẽ khởi động trong vài giây nữa"
354 | echo " NẾU HỆ THỐNG KHÔNG PHẢN HỒI, VUI LÒNG KHỞI ĐỘNG LẠI"
355 | }
356 |
357 | print_menu(){
358 | pd gray "=============================================="
359 | echo " Magisk on Android x86"
360 | echo " by HuskyDG"
361 | # please don't change this or use "by HuskyDG + your name" for credits :((
362 | echo -e "$(print_info)"
363 | pd gray "=============================================="
364 | echo " 1 - Cài đặt hoặc cập nhật Magisk"
365 | pd gray " Triển khai Magisk root vào Android-x86"
366 | echo " 2 - Gỡ cài đặt Magisk"
367 | pd gray " Loại bỏ Magisk và các mô-đun của nó"
368 | echo " 3 - Cài đặt trình quản lí Magisk mô-đun"
369 | pd gray " Quản lí mô-đun thay thế cho Magisk"
370 | echo " 4 - Loại bỏ các phương pháp ROOT khác"
371 | pd gray " Chỉ sử dụng khi bạn không tìm thấy tùy chọn để tắt Root"
372 | echo "----------"
373 | echo " 0 - Thoát khỏi menu"
374 | p none "[CHỌN]: "
375 | }
376 |
377 | blissos_open_menu(){
378 | echo -e "- Nếu bạn đang sử dụng giả lập ${BPURPLE}Bluestacks${RC}"
379 | echo -e "Bạn có thể sử dụng ${BGREEN}BSTweaker 6.8.5+${RC} để bật quyền Root"
380 |
381 | pd none "- Nếu bạn đang sử dụng ${BPURPLE}Android x86${RC} như BlissOS";
382 | pd none "Bạn có thể nhấn ${BGREEN}ALT+F1${RC} và gõ dòng lệnh:"
383 | }
384 |
385 | print_menu_install(){
386 |
387 | pd gray "=============================================="
388 | echo " Install/Update Magisk"
389 | pd gray "=============================================="
390 | pd light_cyan "TRỰC TUYẾN"
391 | print_magisk_builds
392 | pd light_cyan "NGOẠI TUYẾN"
393 | echo " a - Stable v24.1"
394 | echo " x - Chọn và cài đặt từ Magisk APK khác"
395 | echo " z - Chọn phiên bản Magisk APK đã tải"
396 | pd green "* Vui lòng kiểm tra trang wiki của tôi để chọn bản dựng Magisk phù hợp"
397 | p none "[CHỌN]: "
398 |
399 | }
400 |
401 | print_method(){
402 | pd gray "=============================================="
403 | echo " Cài đặt hoặc cập nhật Magisk"
404 | pd gray "=============================================="
405 | pd light_cyan "Phương thức cài đặt Magisk"
406 | echo " 1 - Cài đặt Magisk vào \"/system\""
407 | pd gray " Phân vùng hệ thống có thể gắn kết đọc ghi"
408 | pd gray " Khuyên dùng cho các giả lập Android như NoxPlayer, MEmu, ..."
409 | echo " 2 - Cài đặt Magisk vào ramdisk.img (systemless)"
410 | pd gray " Sử dụng tùy chọn này nếu bạn tìm thấy Ramdisk"
411 | pd gray " Không hỗ trợ system-as-root"
412 | echo " 3 - Cài đặt Magisk bằng GearLock (system/systemless)"
413 | pd gray " Cần có GearLock, sử dụng GearLock để kích hoạt Magisk"
414 | pd gray " Khuyên dùng cho Android x86 project"
415 | echo " 4 - Cập nhật nhị phân vào trong \"/data\""
416 | pd gray " Cập nhật Magisk mà không cần phải sửa đổi lại hệ thống hoặc ramdisk.img"
417 | pd gray " Magisk phải được cài đặt bởi script này"
418 | echo "----------"
419 | if [ ! -z "$MAGISK_VER_CODE" ] && [ "$MAGISK_VER_CODE" -lt "23010" ]; then
420 | echo " m - Minimal Magisk mode: `p light_red "$MINIMAL_MAGISK"`"
421 | pd gray " Chỉ có MagiskSU và MagiskHide"
422 | fi
423 | echo " 0 - Thoát khỏi menu"
424 | pd light_red "* Lưu ý: Gỡ bỏ rusty-magisk để tránh bị xung đột"
425 | p none "[CHỌN]: "
426 |
427 | }
428 |
429 |
430 |
431 |
432 | }
433 |
434 |
435 | LANGUAGE="$(getprop persist.sys.locale)"
436 | case "$LANGUAGE" in
437 | "vi-VN")
438 | language_vn
439 | ;;
440 | esac
441 |
442 |
443 |
444 |
445 | mount_rw_system(){
446 | IS_SYSTEM_MOUNT=false
447 | if mount | grep rootfs | grep -q " / " || mount | grep tmpfs | grep -q " / "; then
448 | # legacy rootfs
449 | mount -o rw,remount "/system" && IS_SYSTEM_MOUNT=true
450 | else
451 | # system-as-root, mount "/"
452 | mount -o rw,remount "/" && IS_SYSTEM_MOUNT=true
453 | fi
454 | }
455 |
456 | mount_ro_system(){
457 | IS_SYSTEM_MOUNT=false
458 | if mount | grep rootfs | grep -q " / " || mount | grep tmpfs | grep -q " / "; then
459 | # legacy rootfs
460 | mount -o ro,remount "/system" && IS_SYSTEM_MOUNT=true
461 | else
462 | # system-as-root, mount "/"
463 | mount -o ro,remount "/" && IS_SYSTEM_MOUNT=true
464 | fi
465 | }
466 |
467 |
468 |
469 | p(){
470 | COLOR=$1;TEXT="$2";escape="$1"
471 | [ "$COLOR" == "black" ] && escape="0;30"
472 | [ "$COLOR" == "red" ] && escape="0;31"
473 | [ "$COLOR" == "green" ] && escape="0;32"
474 | [ "$COLOR" == "orange" ] && escape="0;33"
475 | [ "$COLOR" == "blue" ] && escape="0;34"
476 | [ "$COLOR" == "purple" ] && escape="0;35"
477 | [ "$COLOR" == "cyan" ] && escape="0;36"
478 | [ "$COLOR" == "light_gray" ] && escape="0;37"
479 | [ "$COLOR" == "gray" ] && escape="1;30"
480 | [ "$COLOR" == "light_red" ] && escape="1;31"
481 | [ "$COLOR" == "light_green" ] && escape="1;32"
482 | [ "$COLOR" == "yellow" ] && escape="1;33"
483 | [ "$COLOR" == "light_blue" ] && escape="1;34"
484 | [ "$COLOR" == "light_purple" ] && escape="1;35"
485 | [ "$COLOR" == "light_cyan" ] && escape="1;36"
486 | [ "$COLOR" == "white" ] && escape="1;37"
487 | [ "$COLOR" == "none" ] && escape="0"
488 | code="\033[${escape}m"
489 | end_code="\033[0m"
490 | echo -en "$code$TEXT$end_code"
491 | }
492 |
493 |
494 | pd(){
495 | p "$1" "$2"; echo
496 | }
497 |
498 |
499 |
500 |
501 |
502 | abortc(){
503 | ERR_CODE="$3"
504 | pd "$1" "$2";
505 | test -z "$ERR_CODE" && ERR_CODE=1
506 | exit "$ERR_CODE"
507 | }
508 |
509 | if [ "$AGV1" != "noexec" ]; then
510 |
511 | priv_dir=/data/data/io.github.huskydg.magiskonnox
512 | [ ! -d "$priv_dir" ] && { echo "Something wrong! Abort"; exit; }
513 | cd "$priv_dir"
514 | DLPATH="$priv_dir/magisk"
515 |
516 | if [ ! -d "$DLPATH" ]; then
517 | rm -rf "$DLPATH" 2>/dev/null
518 | mkdir -p "$DLPATH" 2>/dev/null
519 | fi
520 |
521 | mkdir "$DLPATH/save"
522 |
523 | link(){ (
524 | agv1="$1"; agv2="$2"
525 | [ ! -f "$DLPATH/$agv2" ] && rm -rf "$DLPATH/$agv2" 2>/dev/null
526 | ln -s "$(which "$agv1")" "$DLPATH/$agv2" 2>/dev/null
527 | ) }
528 |
529 | link "libapp.so" "magisk.apk"
530 | link "libbusybox.so" "busybox"
531 | link "liblegacy.so" "legacy.zip"
532 | link "libbash.so" "menu"
533 | link "libgxp.so" "gearlock_extension.zip"
534 |
535 | CACHEDIR="$priv_dir/cache/$$"
536 | DISKINFO="/data/adb/diskinfo"
537 | APKFILE="$JOBPWD/magisk.apk"
538 | MAGISKCORE="/system/etc/magisk"
539 |
540 | busybox_bin(){
541 | mkdir -p "$DLPATH/bin"
542 | "$busybox" busybox --install -s "$DLPATH/bin"
543 | PATH="$DLPATH/bin:$PATH"
544 | }
545 | hasMagisk=false
546 | [ ! -z "$(which magisk)" ] && [ ! -z "$(magisk -v)" ] && hasMagisk=true
547 | busybox_bin 2>/dev/null
548 |
549 |
550 | open_main(){
551 | if [ "$AGV1" == "option" ] && [ "$AGV2" == "help" ]; then
552 | help; exit
553 | fi
554 | if [ "$USER_ID" != "0" ]; then
555 | p none "$text_run_with_root ? "
556 | read ROOT
557 | if [ "$ROOT" == "Y" -o "$ROOT" == "y" ]; then
558 | export UNSHARE_MM=0
559 | export ASH_STANDALONE=1
560 | pd yellow "$text_obtain_root..."
561 | ( su -c "$cmds" || /system/xbin/su -c "$cmds" || /system/bin/su -c "$cmds" || /sbin/su -c "$cmds" ) 2>/dev/null
562 | ERR_CODE="$?"
563 | if [ "$ERR_CODE" != 0 ]; then
564 |
565 | pd "light_red" "$text_obtain_root_failed"
566 | blissos_open_menu
567 | pd light_cyan "/data/data/io.github.huskydg.magiskonnox/magisk/menu"
568 |
569 | fi
570 | exit
571 | elif ! [ "$ROOT" == "N" -o "$ROOT" == "n" ]; then
572 | exit
573 | fi
574 | fi
575 | while true; do
576 | main;
577 | done
578 | }
579 |
580 | fi
581 |
582 | SDK="$(getprop ro.build.version.sdk)"
583 |
584 | function cmdline() {
585 | awk -F"${1}=" '{print $2}' < /proc/cmdline | cut -d' ' -f1 2> /dev/null
586 | }
587 |
588 | get_magisk_path(){
589 |
590 | MAGISK_TMP="$(magisk --path)"
591 | MAGISKDIR="$MAGISK_TMP/.magisk"
592 | [ "$MAGISK_TMP" ] && MAGISK_MIRROR="$MAGISKDIR/mirror"
593 | # SYSTEMDIR="/system"
594 | # SYSTEMROOTDIR="/"
595 | # [ "$MAGISK_TMP" ] && SYSTEMROOTDIR="/system_root"
596 |
597 | # umount to make sure there are no magisk module mount on these folder
598 |
599 | ( umount -l /system/etc
600 | umount -l /system/etc/*
601 | umount -l /system/addon.d
602 | umount -l /system/addon.d/*
603 | umount -l /system/etc/magisk
604 | umount -l /system/etc/init
605 | umount -l /system/etc/magisk/*
606 | umount -l /system/etc/init/*
607 | umount -l /magisk
608 | umount -l /magisk/*
609 | ) &
610 |
611 | # no need to use Magisk's mirror anymore
612 |
613 | SYSTEMDIR="/system"
614 | SYSTEMROOTDIR="/"
615 |
616 | }
617 |
618 |
619 |
620 | # This script is write by HuskyDG
621 | ARG1="$1"
622 | JOBPWD="${0%/*}"
623 | bb=/data/local/tmp/busybox
624 |
625 | get_tmpdir(){
626 |
627 | TMPDIR="$CACHEDIR"
628 | [ "$USER_ID" == "0" ] && TMPDIR=/dev/tmp
629 |
630 | }
631 | get_tmpdir
632 |
633 | abort(){
634 | ERR_CODE="$2"
635 | echo "$1";
636 | test -z "$ERR_CODE" && ERR_CODE=1
637 | exit "$ERR_CODE"
638 | }
639 |
640 |
641 |
642 |
643 |
644 | gxp_template="$DLPATH/gearlock_extension.zip"
645 |
646 | unshare_environment(){
647 | if [ ! "$UNSHARE_MM" == "1" ]; then
648 | export UNSHARE_MM=1
649 | export ASH_STANDALONE=1
650 | "$busybox" unshare -m "$busybox" sh -o standalone "$SCRIPT" "$AGV1" "$AGV2" "$AGV3" "$AGV4" "$AGV5"
651 | exit
652 | fi
653 | }
654 |
655 | [ "$USER_ID" == "0" ] && unshare_environment 2>/dev/null
656 |
657 | [ "$USER_ID" == "0" ] && get_magisk_path
658 |
659 | ISENCRYPTED=false
660 | grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true
661 | [ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true
662 |
663 | canary_v23001_magisk_link="https://github.com/topjohnwu/magisk-files/blob/4f737b70868eb3f8b71e48518f919819cbf5ad63/app-debug.apk?raw=true"
664 | stable_magisk_link="https://github.com/topjohnwu/Magisk/releases/download/v23.0/Magisk-v23.0.apk"
665 | canary_magisk_link="https://github.com/topjohnwu/magisk-files/blob/canary/app-debug.apk?raw=true"
666 | alpha_magisk_link="https://github.com/vvb2060/magisk_files/blob/alpha/app-release.apk?raw=true"
667 | lite_magisk_link="https://github.com/vvb2060/magisk_files/blob/master/app-release.apk?raw=true"
668 |
669 |
670 | clean_flash(){
671 | umount -l "$TMPDIR"
672 | rm -rf "$TMPDIR"
673 | }
674 |
675 | turn_back(){
676 | p yellow "$text_press_enter_menu"
677 | read
678 | }
679 |
680 | random(){
681 | VALUE=$1; TYPE=$2; PICK="$3"; PICKC="$4"
682 | TMPR=""
683 | HEX="0123456789abcdef"; HEXC=16
684 | CHAR="qwertyuiopasdfghjklzxcvbnm"; CHARC=26
685 | NUM="0123456789"; NUMC=10
686 | COUNT=$(seq 1 1 $VALUE)
687 | list_pick=$HEX; C=$HEXC
688 | [ "$TYPE" == "char" ] && list_pick=$CHAR && C=$CHARC
689 | [ "$TYPE" == "number" ] && list_pick=$NUM && C=$NUMC
690 | [ "$TYPE" == "custom" ] && list_pick="$PICK" && C=$PICKC
691 | for i in $COUNT; do
692 | random_pick=$(( $RANDOM % $C))
693 | echo -n ${list_pick:$random_pick:1}
694 | done
695 |
696 | }
697 |
698 | random_str(){
699 | random_length=$(random 1 custom 56789 5);
700 | random $random_length custom "qwertyuiopasdfghjklzxcvbnm0123456789QWERTYUIOPASDFGHJKLZXCVBNM" 63 | base64 | sed "s/=//g"
701 | }
702 |
703 |
704 |
705 |
706 | magisk_loader(){
707 |
708 | MAGISKTMP_TYPE="$1"
709 | test -z "$MAGISKTMP_TYPE" && MAGISKTMP_TYPE=1
710 | MAGISKTMP=/sbin
711 |
712 | [ "$MAGISK_IN_DEV" == "1" -o "$MAGISK_IN_DEV" == "true" ] && MAGISKTMP_TYPE=3
713 |
714 | magisk_overlay=`random_str`
715 | magisk_postfsdata=`random_str`
716 | magisk_service=`random_str`
717 | magisk_daemon=`random_str`
718 | magisk_boot_complete=`random_str`
719 | magisk_loadpolicy=`random_str`
720 | dev_random=`random_str`
721 |
722 | case "$MAGISKTMP_TYPE" in
723 | 1)
724 | #legacy rootfs
725 | mount_sbin="mount -o rw,remount /
726 | rm -rf /.backup_sbin
727 | mkdir /.backup_sbin
728 | ln /sbin/* /.backup_sbin
729 | mnt_tmpfs /sbin
730 | clone /.backup_sbin /sbin"
731 | remove_backup="
732 | rm -rf /.backup_sbin
733 | mount -o ro,remount /"
734 | ;;
735 | 2)
736 | #system-as-root
737 | mount_sbin="overlay /sbin"
738 | ;;
739 | 3)
740 | #system-as-root, /sbin is removal
741 | MAGISKTMP="/dev/$dev_random"
742 | mount_sbin="mkdir -p \"$MAGISKTMP\"
743 | mnt_tmpfs \"$MAGISKTMP\""
744 | ;;
745 | esac
746 |
747 | LOAD_MODULES_POLICY="for module in \$(ls /data/adb/modules); do
748 | if ! [ -f \"/data/adb/modules/\$module/disable\" ] && [ -f \"/data/adb/modules/\$module/sepolicy.rule\" ]; then
749 | echo \"## * module sepolicy: \$module\" >>\"\$MAGISKTMP/.magisk/sepolicy.rules\"
750 | cat \"/data/adb/modules/\$module/sepolicy.rule\" >>\"\$MAGISKTMP/.magisk/sepolicy.rules\"
751 | echo \"\" >>\"\$MAGISKTMP/.magisk/sepolicy.rules\"
752 |
753 | fi
754 | done
755 | \$MAGISKTMP/magiskpolicy --live --apply \"\$MAGISKTMP/.magisk/sepolicy.rules\""
756 |
757 | unset LOG_MAGISK
758 | unset FORCE_MAGISKHIDE
759 | unset ADD_FORCE_MAGISKHIDE
760 | CDMAGISKUPDATE="[ -d \"/data/.magisk_binary\" ] && cd /data/.magisk_binary
761 | chcon u:object_r:app_data_file:s0 /data/.magisk_binary"
762 | RM_RUSTY_MAGISK="#remove rusty-magisk to make sure it is not conflicted
763 | exec u:r:su:s0 -- rm -rf /data/.rusty-magisk
764 | rm /data/.rusty-magisk/magisk.apk
765 | rm /data/.rusty-magisk/magisk
766 | rm /data/ghome/.local/bin/rusty-magisk"
767 |
768 | ADDITIONAL_SCRIPT="( # addition script
769 | rm -rf /data/adb/post-fs-data.d/fix_mirror_mount.sh
770 | rm -rf /data/adb/service.d/fix_modules_not_show.sh
771 | rm -rf /data/adb/service.d/hide_modified_initrc.sh
772 | echo \"
773 | SCRIPT=\\\"\\\$0\\\"
774 | ( #fix bluestacks
775 | MIRROR_SYSTEM=\\\"\$MAGISKTMP/.magisk/mirror/system\\\"
776 | test ! -d \\\"\\\$MIRROR_SYSTEM/android/system\\\" && exit
777 | test \\\"\\\$(cd /system; ls)\\\" == \\\"\\\$(cd \\\"\\\$MIRROR_SYSTEM\\\"; ls)\\\" && exit
778 | mount --bind \\\"\\\$MIRROR_SYSTEM/android/system\\\" \\\"\\\$MIRROR_SYSTEM\\\" )
779 | ( #fix mount data mirror
780 | function cmdline() {
781 | awk -F\\\"\\\${1}=\\\" '{print \\\$2}' < /proc/cmdline | cut -d' ' -f1 2> /dev/null
782 | }
783 | SRC=\\\"\\\$(cmdline SRC)\\\"
784 | test -z \\\"\\\$SRC\\\" && exit
785 | LIST_TEST=\\\"
786 | /data
787 | /data/adb
788 | /data/adb/magisk
789 | /data/adb/modules
790 | \\\"
791 | count=0
792 | for folder in \\\$LIST_TEST; do
793 | test \\\"\\\$(ls -A \$MAGISKTMP/.magisk/mirror/\\\$folder 2>/dev/null)\\\" == \\\"\\\$(ls -A \\\$folder 2>/dev/null)\\\" && count=\\\$((\\\$count + 1))
794 | done
795 | test \\\"\\\$count\\\" == 4 && exit
796 | count=0
797 | for folder in \\\$LIST_TEST; do
798 | test \\\"\\\$(ls -A \$MAGISKTMP/.magisk/mirror/data/\\\$SRC/\\\$folder 2>/dev/null)\\\" == \\\"\\\$(ls -A \\\$folder 2>/dev/null)\\\" && count=\\\$((\\\$count + 1))
799 | done
800 | if [ \\\"\\\$count\\\" == 4 ]; then
801 | mount --bind \\\"\$MAGISKTMP/.magisk/mirror/data/\\\$SRC/data\\\" \\\"\$MAGISKTMP/.magisk/mirror/data\\\"
802 | fi )
803 | rm -rf \\\"\\\$SCRIPT\\\"
804 | \" >/data/adb/post-fs-data.d/fix_mirror_mount.sh
805 | echo \"
806 | SCRIPT=\\\"\\\$0\\\"
807 | while [ \\\"\\\$(\$MAGISKTMP/magisk resetprop sys.boot_completed)\\\" != \\\"1\\\" ]
808 | do
809 | sleep 1
810 | done
811 | sleep 3
812 | LIST=\\\"
813 | $magisk_postfsdata
814 | $magisk_service
815 | $magisk_daemon
816 | $magisk_boot_complete
817 | $magisk_loadpolicy
818 | $magisk_overlay
819 | \\\"
820 | for service in \\\$LIST; do
821 | \$MAGISKTMP/magisk resetprop --delete init.svc.\\\$service
822 | \$MAGISKTMP/magisk resetprop --delete init.svc_debug_pid.\\\$service
823 | done
824 | rm -rf \\\"\\\$SCRIPT\\\"\" >/data/adb/service.d/hide_modified_initrc.sh
825 | echo \"
826 | SCRIPT=\\\"\\\$0\\\"
827 | CHECK=\\\"/data/adb/modules/.mk_\\\$RANDOM\\\$RANDOM\\\"
828 | touch \\\"\\\$CHECK\\\"
829 | test \\\"\\\$(ls -A \$MAGISKTMP/.magisk/modules 2>/dev/null)\\\" != \\\"\\\$(ls -A /data/adb/modules 2>/dev/null)\\\" && mount --bind \$MAGISKTMP/.magisk/mirror/data/adb/modules \$MAGISKTMP/.magisk/modules
830 | rm -rf \\\"\\\$CHECK\\\"
831 | rm -rf \\\"\\\$SCRIPT\\\"\" >/data/adb/service.d/fix_modules_not_show.sh
832 | chmod 755 /data/adb/service.d/hide_modified_initrc.sh
833 | chmod 755 /data/adb/service.d/fix_modules_not_show.sh
834 | chmod 755 /data/adb/post-fs-data.d/fix_mirror_mount.sh; )"
835 |
836 | if [ "$MINIMAL_MAGISK" == "true" ]; then
837 | LOAD_MODULES_POLICY=""
838 | ADDITIONAL_SCRIPT=""
839 | ADD_FORCE_MAGISKHIDE="mkdir -p $MAGISKTMP/.magisk/modules
840 | mkdir -p /data/adb/modules_minimal/force_magiskhide
841 | mount --bind /data/adb/modules_minimal $MAGISKTMP/.magisk/modules
842 | echo \"id=force_magiskhide
843 | name=Force Enable MagiskHide
844 | version=v1.0
845 | versionCode=10000
846 | author=HuskyDG
847 | description=Always enable MagiskHide whenever MagiskHide cannot persist after restart\" >/data/adb/modules_minimal/force_magiskhide/module.prop"
848 | FORCE_MAGISKHIDE="rm -rf /data/adb/modules_minimal/force_magiskhide/remove
849 | if [ ! -f \"/data/adb/modules_minimal/force_magiskhide/disable\" ]; then
850 | $MAGISKTMP/magisk magiskhide disable
851 | $MAGISKTMP/magisk magiskhide enable
852 | fi
853 | [ -f \"/data/adb/modules_minimal/hosts/remove\" ] && rm -rf /data/adb/modules_minimal/hosts
854 | rm -rf /data/adb/modules_minimal/hosts/update
855 | [ ! -f \"/data/adb/modules_minimal/hosts/disable\" ] && mount --bind $MAGISKTMP/.magisk/modules/hosts/system/etc/hosts /system/etc/hosts
856 | "
857 | unset CDMAGISKUPDATE
858 | fi
859 |
860 |
861 | overlay_loader="#!$MAGISKBASE/busybox sh
862 |
863 | export PATH=/sbin:/system/bin:/system/xbin
864 |
865 |
866 | mnt_tmpfs(){ (
867 | # MOUNT TMPFS ON A DIRECTORY
868 | MOUNTPOINT=\"\$1\"
869 | mkdir -p \"\$MOUNTPOINT\"
870 | mount -t tmpfs -o \"mode=0755\" tmpfs \"\$MOUNTPOINT\" 2>/dev/null
871 | ) }
872 |
873 |
874 |
875 | mnt_bind(){ (
876 | # SHORTCUT BY BIND MOUNT
877 | FROM=\"\$1\"; TO=\"\$2\"
878 | if [ -L \"\$FROM\" ]; then
879 | SOFTLN=\"\$(readlink \"\$FROM\")\"
880 | ln -s \"\$SOFTLN\" \"\$TO\"
881 | elif [ -d \"\$FROM\" ]; then
882 | mkdir -p \"\$TO\" 2>/dev/null
883 | mount --bind \"\$FROM\" \"\$TO\"
884 | else
885 | echo -n 2>/dev/null >\"\$TO\"
886 | mount --bind \"\$FROM\" \"\$TO\"
887 | fi
888 | ) }
889 |
890 | clone(){ (
891 | FROM=\"\$1\"; TO=\"\$2\"; IFS=\$\"
892 | \"
893 | [ -d \"\$TO\" ] || exit 1;
894 | ( cd \"\$FROM\" && find * -prune ) | while read obj; do
895 | ( if [ -d \"\$FROM/\$obj\" ]; then
896 | mnt_tmpfs \"\$TO/\$obj\"
897 | else
898 | mnt_bind \"\$FROM/\$obj\" \"\$TO/\$obj\" 2>/dev/null
899 | fi ) &
900 | sleep 0.05
901 | done
902 | ) }
903 |
904 | overlay(){ (
905 | # RE-OVERLAY A DIRECTORY
906 | FOLDER=\"\$1\";
907 | TMPFOLDER=\"/dev/vm-overlay\"
908 | #_____
909 | PAYDIR=\"\${TMPFOLDER}_\${RANDOM}_\$(date | base64)\"
910 | mkdir -p \"\$PAYDIR\"
911 | mnt_tmpfs \"\$PAYDIR\"
912 | #_________
913 | clone \"\$FOLDER\" \"\$PAYDIR\"
914 | mount --move \"\$PAYDIR\" \"\$FOLDER\"
915 | rm -rf \"\$PAYDIR\"
916 | #______________
917 | ) }
918 |
919 | exit_magisk(){
920 | echo -n >/dev/.magisk_unblock
921 | }
922 |
923 |
924 | API=\$(getprop ro.build.version.sdk)
925 | ABI=\$(getprop ro.product.cpu.abi)
926 | if [ \"\$ABI\" = \"x86\" ]; then
927 | ARCH=x86
928 | ABI32=x86
929 | IS64BIT=false
930 | elif [ \"\$ABI\" = \"arm64-v8a\" ]; then
931 | ARCH=arm64
932 | ABI32=armeabi-v7a
933 | IS64BIT=true
934 | elif [ \"\$ABI\" = \"x86_64\" ]; then
935 | ARCH=x64
936 | ABI32=x86
937 | IS64BIT=true
938 | else
939 | ARCH=arm
940 | ABI=armeabi-v7a
941 | ABI32=armeabi-v7a
942 | IS64BIT=false
943 | fi
944 |
945 | magisk_name=\"magisk32\"
946 | [ \"\$IS64BIT\" == true ] && magisk_name=\"magisk64\"
947 |
948 | # umount previous /sbin tmpfs overlay
949 |
950 | count=0
951 | ( magisk --stop ) &
952 |
953 | umount -l /init.rc
954 | umount -l /system/etc/init/hw/init.rc
955 |
956 | until ! mount | grep -q \" /sbin \"; do
957 | [ "$count" -gt "10" ] && break
958 | umount -l /sbin 2>/dev/null
959 | sleep 0.1
960 | count=$(($count+1))
961 | test ! -d /sbin && break
962 | done
963 |
964 | $mount_sbin
965 |
966 |
967 | chcon u:r:rootfs:s0 /sbin
968 |
969 | [ -f \"/data/.magisk_binary/remove\" ] && rm -rf \"/data/.magisk_binary\"
970 |
971 | cd $MAGISKBASE
972 | $CDMAGISKUPDATE
973 |
974 | test ! -f \"./\$magisk_name\" && { echo -n >/dev/.overlay_unblock; exit_magisk; exit 0; }
975 |
976 | MAGISKTMP=$MAGISKTMP
977 | MAGISKBIN=/data/adb/magisk
978 | mkdir -p \$MAGISKBIN 2>/dev/null
979 | for mdir in modules post-fs-data.d service.d; do
980 | test ! -d /data/adb/\$mdir && rm -rf /data/adb/\$mdir
981 | mkdir /data/adb/\$mdir 2>/dev/null
982 | done
983 | for file in magisk32 magisk64 magiskinit; do
984 | cp -af ./\$file \$MAGISKTMP/\$file 2>/dev/null
985 | chmod 755 \$MAGISKTMP/\$file
986 | TEXT_LOG=\"add \$MAGISKBIN/\$file\"
987 | cp -af ./\$file \$MAGISKBIN/\$file 2>/dev/null
988 | chmod 755 \$MAGISKBIN/\$file
989 | done
990 | cp -af ./magiskboot \$MAGISKBIN/magiskboot
991 | cp -af ./busybox \$MAGISKBIN/busybox
992 | cp -af ./loadpolicy.sh \$MAGISKTMP
993 | cp -af ./assets/* \$MAGISKBIN
994 |
995 |
996 |
997 | ln -s ./\$magisk_name \$MAGISKTMP/magisk 2>/dev/null
998 | ln -s ./magisk \$MAGISKTMP/su 2>/dev/null
999 | ln -s ./magisk \$MAGISKTMP/resetprop 2>/dev/null
1000 | ln -s ./magisk \$MAGISKTMP/magiskhide 2>/dev/null
1001 | ln -s ./magiskinit \$MAGISKTMP/magiskpolicy 2>/dev/null
1002 |
1003 | mkdir -p \$MAGISKTMP/.magisk/mirror
1004 | mkdir \$MAGISKTMP/.magisk/block
1005 | touch \$MAGISKTMP/.magisk/config
1006 | $ADD_FORCE_MAGISKHIDE
1007 |
1008 | cd \$MAGISKTMP
1009 | # SELinux stuffs
1010 | ln -sf ./magiskinit magiskpolicy
1011 | if [ -f /vendor/etc/selinux/precompiled_sepolicy ]; then
1012 | ./magiskpolicy --load /vendor/etc/selinux/precompiled_sepolicy --live --magisk 2>&1
1013 | elif [ -f /sepolicy ]; then
1014 | ./magiskpolicy --load /sepolicy --live --magisk 2>&1
1015 | else
1016 | ./magiskpolicy --live --magisk 2>&1
1017 | fi
1018 |
1019 | #remount system read-only
1020 | $remove_backup
1021 | mount -o ro,remount /
1022 | mount -o ro,remount /system
1023 | mount -o ro,remount /vendor
1024 | mount -o ro,remount /product
1025 | mount -o ro,remount /system_ext
1026 |
1027 | restorecon -R /data/adb/magisk
1028 |
1029 | $ADDITIONAL_SCRIPT
1030 | $LOAD_MODULES_POLICY
1031 |
1032 | touch /dev/.overlay_unblock
1033 | UID_MYAPP=\$(ls -ld \"$priv_dir\" | awk '{ print \$3 }') || UID_MYAPP=root
1034 | chown \$UID_MYAPP:\$UID_MYAPP /data/.magisk_binary
1035 | rm -rf /dev/.overlay_unblock
1036 | sleep 3
1037 |
1038 | [ ! -f \"\$MAGISKTMP/magisk\" ] && exit_magisk
1039 | # test ! \"\$(pidof magiskd)\" && exit_magisk
1040 |
1041 | ( while [ \"\$(getprop sys.boot_completed)\" != \"1\" ]
1042 | do
1043 | sleep 1
1044 | done
1045 |
1046 |
1047 | $FORCE_MAGISKHIDE
1048 | # hide magisk modify init.rc
1049 | ) &
1050 |
1051 | "
1052 |
1053 | cd "$JOBPWD"
1054 | shloadpolicy="#!$MAGISKBASE/busybox sh
1055 | #stub"
1056 | EXPORT_PATH="export PATH /sbin:/system/bin:/system/xbin:/vendor/bin:/gearlock/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin"
1057 |
1058 | magiskloader="
1059 |
1060 | on early-init
1061 | $EXPORT_PATH
1062 |
1063 |
1064 | on post-fs-data
1065 | $RM_RUSTY_MAGISK
1066 | start logd
1067 | start adbd
1068 | rm /dev/.overlay_unblock
1069 | rm /dev/.magisk_unblock
1070 | start $magisk_overlay
1071 | wait /dev/.overlay_unblock 10
1072 | rm /dev/.overlay_unblock
1073 |
1074 | start $magisk_daemon
1075 | start $magisk_loadpolicy
1076 | start $magisk_postfsdata
1077 | wait /dev/.magisk_unblock 40
1078 | rm /dev/.magisk_unblock
1079 |
1080 | service $magisk_overlay $MAGISKBASE/busybox sh -o standalone $MAGISKBASE/overlay.sh
1081 | user root
1082 | group root
1083 | seclabel u:r:su:s0
1084 | oneshot
1085 |
1086 | service $magisk_loadpolicy $MAGISKBASE/busybox sh -o standalone $MAGISKTMP/loadpolicy.sh
1087 | user root
1088 | seclabel u:r:magisk:s0
1089 | oneshot
1090 |
1091 | service $magisk_postfsdata $MAGISKTMP/magisk --post-fs-data
1092 | user root
1093 | seclabel u:r:magisk:s0
1094 | oneshot
1095 |
1096 | service $magisk_service $MAGISKTMP/magisk --service
1097 | class late_start
1098 | user root
1099 | seclabel u:r:magisk:s0
1100 | oneshot
1101 |
1102 | service $magisk_daemon $MAGISKTMP/magisk --daemon
1103 | user root
1104 | seclabel u:r:magisk:s0
1105 | oneshot
1106 |
1107 | on property:sys.boot_completed=1
1108 | start $magisk_boot_complete
1109 |
1110 | service $magisk_boot_complete $MAGISKTMP/magisk --boot-complete
1111 | user root
1112 | seclabel u:r:magisk:s0
1113 | oneshot"
1114 |
1115 | [ "$MINIMAL_MAGISK" == "true" ] && magiskloader="
1116 |
1117 | on early-init
1118 | $EXPORT_PATH
1119 |
1120 |
1121 | on post-fs-data
1122 | start logd
1123 | start adbd
1124 | $RM_RUSTY_MAGISK
1125 |
1126 | on property:sys.boot_completed=1
1127 |
1128 | rm /dev/.overlay_unblock
1129 | start $magisk_overlay
1130 | wait /dev/.overlay_unblock 10
1131 | rm /dev/.overlay_unblock
1132 | start $magisk_daemon
1133 | start $magisk_loadpolicy
1134 |
1135 | service $magisk_overlay $MAGISKBASE/busybox sh -o standalone $MAGISKBASE/overlay.sh
1136 | user root
1137 | group root
1138 | seclabel u:r:su:s0
1139 | oneshot
1140 |
1141 | service $magisk_loadpolicy $MAGISKBASE/busybox sh -o standalone $MAGISKTMP/loadpolicy.sh
1142 | user root
1143 | seclabel u:r:magisk:s0
1144 | oneshot
1145 |
1146 | service $magisk_daemon $MAGISKTMP/magisk --daemon
1147 | user root
1148 | seclabel u:r:magisk:s0
1149 | oneshot
1150 |
1151 |
1152 | "
1153 |
1154 | }
1155 |
1156 | extract_magisk_apk(){
1157 |
1158 | [ "$IS64BIT" == "true" ] && mkdir -p "$TMPDIR/magisk32"
1159 | mkdir -p "$TMPDIR/magisk"
1160 | mkdir -p "$TMPDIR/magisktool"
1161 |
1162 |
1163 | unzip -oj "$APKFILE" "lib/$ABI/*" -d "$TMPDIR/magisk" &>/dev/null
1164 | chmod -R 777 "$TMPDIR/magisk"
1165 | ln -s "./libmagiskinit.so" "$TMPDIR/magisk/magiskinit"
1166 |
1167 | if [ "$IS64BIT" == "true" ]; then
1168 | unzip -oj "$APKFILE" "lib/$ABI32/*" -d "$TMPDIR/magisk32" &>/dev/null
1169 | ln -s "./libmagiskinit.so" "$TMPDIR/magisk32/magiskinit"
1170 | chmod -R 777 "$TMPDIR/magisk32"
1171 | fi
1172 |
1173 | rm -rf "$MAGISKCORE/.rw" 2>/dev/null
1174 | touch "$MAGISKCORE/.rw" 2>/dev/null || abortc light_red "$text_cannot_install_magisk"
1175 | rm -rf "$MAGISKCORE/.rw" 2>/dev/null
1176 |
1177 | for file in magisk32 magisk64 magiskinit busybox; do
1178 | rm -rf $MAGISKCORE/$file
1179 | done
1180 |
1181 | ( cd "$TMPDIR/magisk"
1182 | for file in lib*.so; do
1183 | chmod 755 $file
1184 | cp -f "$file" "$MAGISKCORE/${file:3:${#file}-6}" && echo " add magisk binary: ${file:3:${#file}-6}"
1185 | done
1186 |
1187 | if [ "$IS64BIT" == "true" ]; then
1188 | cd "$TMPDIR/magisk32"
1189 | for file in lib*.so; do
1190 | chmod 755 $file
1191 | [ ! -f "$MAGISKCORE/${file:3:${#file}-6}" ] && cp -f "$file" "$MAGISKCORE/${file:3:${#file}-6}" && echo " add magisk binary: ${file:3:${#file}-6}"
1192 | done
1193 |
1194 | fi
1195 |
1196 | if [ ! -f "$MAGISKCORE/magisk64" ] && [ "$IS64BIT" == "true" ]; then
1197 | "$TMPDIR/magisk/magiskinit" -x magisk "$MAGISKCORE/magisk64" && echo " add magisk binary: magisk64"
1198 | fi
1199 |
1200 | if [ ! -f "$MAGISKCORE/magisk32" ]; then
1201 | whatmagisk="magisk"
1202 | [ "$IS64BIT" == "true" ] && whatmagisk="magisk32"
1203 | "$TMPDIR/$whatmagisk/magiskinit" -x magisk "$MAGISKCORE/magisk32" && echo " add magisk binary: magisk32"
1204 | fi
1205 |
1206 | )
1207 |
1208 | mkdir -p "$MAGISKCORE/assets"
1209 | unzip -oj "$APKFILE" 'assets/*' -x 'assets/chromeos/*' -d "$MAGISKCORE/assets" &>/dev/null
1210 |
1211 | }
1212 |
1213 | unpatch_ramdisk(){
1214 | RAMDISK="$1"
1215 | REPLACE_CURRENT="$2"
1216 |
1217 | #magisk in ramdisk
1218 |
1219 | MAGISKBASE="/magisk"
1220 |
1221 | echo "******************************"
1222 | echo " Magisk uninstaller"
1223 | echo "******************************"
1224 |
1225 | rm -rf "$TMPDIR"
1226 | mkdir -p "$TMPDIR"
1227 | [ ! -f "$RAMDISK" ] && abortc light_red "! Ramdisk does not exist!"
1228 |
1229 | echo "- $text_unpack_ramdisk"
1230 | mkdir -p "$TMPDIR/ramdisk"
1231 |
1232 | ( cd "$TMPDIR/ramdisk" && zcat "$RAMDISK" | cpio -iud ) || abortc light_red "! $text_unpack_ramdisk_fail"
1233 | echo "- $text_unpatch_ramdisk"
1234 | # restore init.rc
1235 | if [ -f "$TMPDIR/ramdisk/magisk/init.rc" ]; then
1236 | # found init.rc backup!
1237 | cat "$TMPDIR/ramdisk/magisk/init.rc" >"$TMPDIR/ramdisk/init.rc"
1238 | else
1239 | abortc light_red "$text_backup_not_exist" 2
1240 | fi
1241 |
1242 | rm -rf "$TMPDIR/ramdisk/magisk"
1243 | echo "- $text_repack_ramdisk"
1244 | NEWRAMDISK="/sdcard/Magisk/unpatch_ramdisk_$RANDOM$RANDOM.img"
1245 | if [ "$REPLACE_CURRENT" != "true" ]; then
1246 | mkdir -p "/sdcard/Magisk" 2>/dev/null
1247 | echo "- $text_new_ramdisk"
1248 | echo " $NEWRAMDISK"
1249 | else
1250 | [ -f "${RAMDISK}.bak" ] || mv "${RAMDISK}" "${RAMDISK}.bak"
1251 | NEWRAMDISK="$RAMDISK"
1252 | fi
1253 | ( cd "$TMPDIR/ramdisk" && find * | cpio -o -H newc | gzip >$NEWRAMDISK ) || abortc light_red "! $text_repack_ramdisk_fail" 2
1254 | rm -rf /data/.magisk_binary 2>/dev/null
1255 | clean_flash
1256 | echo "- $text_done"
1257 | true
1258 |
1259 |
1260 | }
1261 |
1262 | check_magisk_apk(){
1263 | [ ! -f "$APKFILE" ] && abortc light_red "! File does not exist"
1264 | unzip -oj "$APKFILE" 'assets/util_functions.sh' -d "$TMPDIR" &>/dev/null
1265 |
1266 | MAGISK_VER=""
1267 | MAGISK_VER_CODE=""
1268 | [ -f "$TMPDIR/util_functions.sh" ] || abortc light_red "This apk is not Magisk app" 2
1269 | MAGISK_VERINFO="$( . $TMPDIR/util_functions.sh; echo "$MAGISK_VER $MAGISK_VER_CODE"; )"
1270 | MAGISK_VER="$(echo "$MAGISK_VERINFO" | awk '{ print $1 }')"
1271 | MAGISK_VER_CODE="$(echo "$MAGISK_VERINFO" | awk '{ print $2 }')"
1272 | pd green "** Magisk version: $MAGISK_VER ($MAGISK_VER_CODE)"
1273 | }
1274 |
1275 | patch_ramdisk(){
1276 | RAMDISK="$1"
1277 | REPLACE_CURRENT="$2"
1278 |
1279 | #magisk in ramdisk
1280 |
1281 | MAGISKBASE="/magisk"
1282 |
1283 | echo "******************************"
1284 | echo " Magisk installer"
1285 | echo "******************************"
1286 |
1287 | rm -rf "$TMPDIR"
1288 | mkdir -p "$TMPDIR"
1289 |
1290 |
1291 | [ ! -f "$RAMDISK" ] && abortc light_red "! Ramdisk does not exist!"
1292 |
1293 | magisk_loader
1294 |
1295 | check_magisk_apk
1296 |
1297 | echo "- $text_unpack_ramdisk"
1298 |
1299 | #unpack ramdisk to TMPDIR
1300 |
1301 | mkdir -p "$TMPDIR/ramdisk"
1302 |
1303 | ( cd "$TMPDIR/ramdisk" && zcat "$RAMDISK" | cpio -iud ) || abortc light_red "! $text_unpack_ramdisk_fail"
1304 | echo "- $text_patch_ramdisk"
1305 | # ramdisk was unpack to $TMPDIR/ramdisk
1306 | [ -d "$TMPDIR/ramdisk/sbin" ] || magisk_loader 3
1307 |
1308 | if file "$TMPDIR/ramdisk/init" | grep "x86" | grep -q "32-bit"; then
1309 | ARCH=x86
1310 | ABI32=x86
1311 | IS64BIT=false
1312 | ABI=x86
1313 | elif file "$TMPDIR/ramdisk/init" | grep "arm64" | grep -q "64-bit"; then
1314 | ARCH=arm64
1315 | ABI32=armeabi-v7a
1316 | IS64BIT=true
1317 | ABI=arm64-v8a
1318 | elif file "$TMPDIR/ramdisk/init" | grep "x86-64" | grep -q "64-bit"; then
1319 | ARCH=x64
1320 | ABI32=x86
1321 | IS64BIT=true
1322 | ABI=x86_64
1323 | else
1324 | ARCH=arm
1325 | ABI=armeabi-v7a
1326 | ABI32=armeabi-v7a
1327 | IS64BIT=false
1328 | fi
1329 | echo "- ${text_magisk_tmpfs_directory}: $MAGISKTMP"
1330 | echo "- ARCH: $ARCH, 64-bit: $IS64BIT"
1331 |
1332 | mkdir "$TMPDIR/ramdisk/magisk"
1333 | if [ -f "$TMPDIR/ramdisk/magisk/init.rc" ]; then
1334 | # found init.rc backup!
1335 | cat "$TMPDIR/ramdisk/magisk/init.rc" >"$TMPDIR/ramdisk/init.rc"
1336 | echo "- $text_magisk_patched_ramdisk"
1337 | echo "$magiskloader" >>"$TMPDIR/ramdisk/init.rc"
1338 | else
1339 | # no backup init
1340 | cp "$TMPDIR/ramdisk/init.rc" "$TMPDIR/ramdisk/magisk/init.rc"
1341 | echo "$magiskloader" >>"$TMPDIR/ramdisk/init.rc"
1342 | fi
1343 | rm -rf "$TMPDIR/ramdisk/magisk/loadpolicy.sh" "$TMPDIR/ramdisk/magisk/overlay.sh"
1344 | echo "$shloadpolicy" >"$TMPDIR/ramdisk/magisk/loadpolicy.sh"
1345 | echo "$overlay_loader" >"$TMPDIR/ramdisk/magisk/overlay.sh"
1346 | echo "( mount -o rw,remount /
1347 | cat "/magisk/init.rc" >/init.rc
1348 | rm -rf /magisk
1349 | mount -o ro,remount / ) &" >>"$TMPDIR/ramdisk/magisk/overlay.sh"
1350 | chmod 755 "$TMPDIR/ramdisk/init.rc"
1351 | ( MAGISKCORE="$TMPDIR/ramdisk/magisk"; IS64BIT=true; extract_magisk_apk )
1352 | chmod -R 777 "$TMPDIR/ramdisk/magisk"
1353 | echo "- $text_repack_ramdisk"
1354 | NEWRAMDISK="/sdcard/Magisk/magisk_ramdisk_$RANDOM$RANDOM.img"
1355 | if [ "$REPLACE_CURRENT" != "true" ]; then
1356 | mkdir -p "/sdcard/Magisk" 2>/dev/null
1357 | echo "- $text_new_ramdisk:"
1358 | echo " $NEWRAMDISK"
1359 | else
1360 | [ -f "${RAMDISK}.bak" ] || mv "${RAMDISK}" "${RAMDISK}.bak"
1361 | NEWRAMDISK="$RAMDISK"
1362 | fi
1363 | ( cd "$TMPDIR/ramdisk" && find * | cpio -o -H newc | gzip >$NEWRAMDISK ) || abortc light_red "! $text_repack_ramdisk_fail"
1364 | rm -rf /data/.magisk_binary
1365 | clean_flash
1366 | echo "- $text_done"
1367 | true
1368 | }
1369 |
1370 |
1371 | update_magiskbin(){
1372 | need_root_access
1373 | rm -rf /data/.magisk_binary
1374 | mkdir -p /data/.magisk_binary
1375 | rm -rf "$TMPDIR"
1376 | mkdir -p "$TMPDIR"
1377 | check_magisk_apk
1378 |
1379 | ( MAGISKCORE="/data/.magisk_binary"; extract_magisk_apk
1380 | mkdir -p $MAGISKBIN 2>/dev/null
1381 | unzip -oj "$APKFILE" 'assets/*' -x 'assets/chromeos/*' -d $MAGISKBIN &>/dev/null
1382 | mkdir $NVBASE/modules 2>/dev/null
1383 | mkdir $POSTFSDATAD 2>/dev/null
1384 | mkdir $SERVICED 2>/dev/null )
1385 |
1386 | chmod -R 750 /data/.magisk_binary
1387 | clean_flash
1388 |
1389 | }
1390 |
1391 | extension_info(){
1392 | cat </dev/null
1433 | rm -rf "\$GEARHOME/.local/magisk" 2>/dev/null
1434 | rm -rf \$GEARHOME/unins/Magisk_* 2>/dev/null
1435 | rm -rf \\
1436 | /cache/*magisk* /cache/unblock /data/*magisk* /data/cache/*magisk* /data/property/*magisk* \\
1437 | /data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh /data/adb/*magisk* \\
1438 | /data/adb/post-fs-data.d /data/adb/service.d /data/adb/modules* \\
1439 | /data/unencrypted/magisk /metadata/magisk /persist/magisk /mnt/vendor/persist/magisk /data/.magisk_binary /magisk \\
1440 | /data/ghome/unins/Magisk_* /system/ghome/unins/Magisk_*
1441 | if test "\$BOOTCOMP" == "yes"; then
1442 | echo "- The device will reboot after a few seconds"
1443 | (sleep 8; reboot) &
1444 | fi
1445 |
1446 | EOF
1447 | }
1448 |
1449 |
1450 | install_magisk_gearlock(){
1451 | echo "******************************"
1452 | echo " Magisk installer"
1453 | echo "******************************"
1454 | SYSTEMLESS=true
1455 | GEARHOME=/data/ghome
1456 | if [ -d "$GEARHOME" ]; then
1457 | true # stub
1458 | elif [ -d "/system/ghome" ]; then
1459 | GEARHOME="/system/ghome"
1460 | SYSTEMLESS=false
1461 | else
1462 | abortc light_red "$text_install_gearlock !"
1463 | fi
1464 | GEARBOOT="$GEARHOME/gearboot/overlay/magisk/init"
1465 | echo "- GearLock Home: $GEARHOME"
1466 | $SYSTEMLESS && echo "- Systemless mode!"
1467 | GEARLOCK=true
1468 | mkdir -p "$TMPDIR"
1469 | INITRC=/init.rc
1470 | INITRC2=/system/etc/init/hw/init.rc
1471 | rm -rf "$GEARHOME/gearboot/overlay/rusty-magisk"
1472 | GEAR_INITDIR="$GEARBOOT"
1473 | if [ ! -f "$INITRC" ]; then
1474 | # Android 11 new init.rc
1475 | INITRC="$INITRC2"
1476 | GEAR_INITDIR="$GEARBOOT/system/etc/init/hw"
1477 | fi
1478 | NEW_INITRC="$GEAR_INITDIR/init.rc"
1479 | rm -rf "$GEARBOOT"
1480 | mkdir -p "$GEAR_INITDIR"
1481 | first_setup
1482 | rm -rf $GEARHOME/unins/Magisk_* 2>/dev/null
1483 |
1484 |
1485 | echo "$(extension_info)
1486 |
1487 | do_unins_custom(){
1488 | $(extension_unins)
1489 | }">"$GEARHOME/unins/Magisk_extension_$MAGISK_VER"
1490 | setup_magisk_env
1491 | echo "- $text_install Magisk loader..."
1492 | rm -rf $MAGISKCORE/overlay.sh
1493 | echo "$overlay_loader" >"$MAGISKCORE/overlay.sh"
1494 | touch "$GEARBOOT/init.superuser.rc"
1495 | cp "$INITRC" "$NEW_INITRC"
1496 | echo "$magiskloader" >>"$NEW_INITRC"
1497 | rm -rf "$MAGISKCORE/loadpolicy.sh"
1498 | echo "$shloadpolicy" >"$MAGISKCORE/loadpolicy.sh"
1499 | clean_flash
1500 | echo "- $text_done"
1501 | }
1502 |
1503 | first_setup(){
1504 | need_root_access
1505 |
1506 | check_magisk_apk
1507 |
1508 | if mount | grep rootfs | grep -q " / " || mount | grep tmpfs | grep -q " / "; then
1509 | # legacy rootfs
1510 | MAGISKBASE="/system/etc/magisk"
1511 | SYSTEMTYPE=1
1512 | elif [ -d "/sbin" ]; then
1513 | # SAR
1514 | MAGISKBASE="/magisk"
1515 | MAGISKCORE="/magisk"
1516 | SYSTEMTYPE=3
1517 | fi
1518 |
1519 | if [ "$GEARLOCK" == "true" ]; then
1520 | MAGISKBASE="$GEARHOME/.local/magisk"
1521 | MAGISKCORE="$GEARHOME/.local/magisk"
1522 | fi
1523 |
1524 | magisk_loader "$SYSTEMTYPE"
1525 |
1526 | if [ -e "/init" ] && [ -e "/init.real" ]; then
1527 | pd light_red "$text_tell_remove_rusty_magisk"
1528 | # /dev mode to not conflit with rusty-Magisk
1529 | magisk_loader 3
1530 | fi
1531 | echo "- ${text_magisk_tmpfs_directory}: $MAGISKTMP"
1532 | rm -rf "$MAGISKCORE"
1533 | mkdir -p "$MAGISKCORE"
1534 | }
1535 |
1536 |
1537 |
1538 | setup_magisk_env(){
1539 |
1540 | echo "- $text_extract_magisk_apk"
1541 |
1542 | extract_magisk_apk
1543 |
1544 | }
1545 |
1546 |
1547 |
1548 |
1549 | build_gxp(){
1550 | GEARLOCK=true
1551 | echo "******************************"
1552 | echo " Magisk installer"
1553 | echo "******************************"
1554 | get_tmpdir
1555 | MAGISKBASE="PLACEHOLDER_MAGISKBASE"
1556 | MAGISKCORE="$TMPDIR/gxp/gearlock/magisk"
1557 | rm -rf "$TMPDIR"
1558 | mkdir -p "$MAGISKCORE"
1559 | check_magisk_apk
1560 | magisk_loader 3
1561 | echo "- ${text_magisk_tmpfs_directory}: $MAGISKTMP"
1562 | unzip -o "$gxp_template" -d "$TMPDIR/gxp" &>/dev/null
1563 | extract_magisk_apk
1564 | echo "- $text_install Magisk loader..."
1565 | rm -rf $MAGISKCORE/overlay.sh
1566 | echo "$overlay_loader" >"$MAGISKCORE/overlay.sh"
1567 | rm -rf "$TMPDIR/gxp/gearlock/magisk.rc"
1568 | echo "$magiskloader" >"$TMPDIR/gxp/gearlock/magisk.rc"
1569 | rm -rf "$MAGISKCORE/loadpolicy.sh"
1570 | echo "$shloadpolicy" >"$MAGISKCORE/loadpolicy.sh"
1571 | extension_info > "$TMPDIR/gxp/!zygote.sh"
1572 | extension_unins >"$TMPDIR/gxp/uninstall.sh"
1573 | echo "- $text_building_gxp"
1574 | cd "$TMPDIR/gxp" || abortc light_red "$text_cannot_install_magisk"
1575 | libzip.so -r "$TMPDIR/gxp.zip" "./" &>/dev/null
1576 | [ ! -d "/sdcard/Magisk" ] && rm -rf "/sdcard/Magisk"
1577 | mkdir -p "/sdcard/Magisk"
1578 | EXTENSION_ZIP="/sdcard/Magisk/magisk-extension-$MAGISK_VER.gxp"
1579 | rm -rf "$EXTENSION_ZIP"
1580 | cp "$TMPDIR/gxp.zip" "$EXTENSION_ZIP" || abortc light_red "$text_grant_inter_access_permission"
1581 | echo "- $text_saved_magisk_gxp_to"
1582 | echo " $EXTENSION_ZIP"
1583 | clean_flash
1584 | echo "- $text_done"
1585 |
1586 | }
1587 |
1588 |
1589 |
1590 |
1591 | install_magisk(){
1592 | GEARLOCK=false
1593 |
1594 | echo "******************************"
1595 | echo " Magisk installer"
1596 | echo "******************************"
1597 |
1598 | first_setup
1599 |
1600 | echo "- $text_mount_rw_system"
1601 | mount_rw_system
1602 | $IS_SYSTEM_MOUNT || abortc "light_red" "! $text_failed_mount_system"
1603 |
1604 | umount -l /system/bin
1605 | umount -l /system/bin/*
1606 |
1607 | echo "- $text_setup"
1608 | rm -rf "$MAGISKCORE"
1609 | mkdir -p "$MAGISKCORE"
1610 | chown root:root "$MAGISKCORE"
1611 | chmod 750 "$MAGISKCORE"
1612 |
1613 | setup_magisk_env
1614 |
1615 |
1616 | echo "- $text_install Magisk loader..."
1617 | rm -rf $MAGISKCORE/overlay.sh
1618 | echo "$overlay_loader" >"$MAGISKCORE/overlay.sh"
1619 | rm -rf "/system/etc/init/magisk.rc"
1620 | echo "$magiskloader" >"/system/etc/init/magisk.rc"
1621 | rm -rf "$MAGISKCORE/loadpolicy.sh"
1622 | echo "$shloadpolicy" >"$MAGISKCORE/loadpolicy.sh"
1623 | echo "- $text_mount_ro_system"
1624 | mount_ro_system
1625 |
1626 | if [ ! "$build_name" == "Custom" ]; then
1627 | STUB_MAGISK_APK="$(find /data/user_de/0/*/dyn/current.apk -type f 2>/dev/null)"
1628 | echo "- $text_install_app..."
1629 | if [ -z "$STUB_MAGISK_APK" ]; then
1630 | pm uninstall com.topjohnwu.magisk &>/dev/null
1631 | pm install "$APKFILE" &>/dev/null || echo "* $text_install_app_sug"
1632 | else
1633 | echo "$STUB_MAGISK_APK" | while read magisk_dyn; do
1634 | cat "$APKFILE" >"$magisk_dyn"
1635 | done
1636 | fi
1637 | mkdir -p "/sdcard/Magisk"
1638 | rm -rf "/sdcard/Magisk/Magisk.apk"
1639 | cp "$APKFILE" "/sdcard/Magisk/Magisk.apk"
1640 | echo "- $text_saved_magisk_apk_to /sdcard/Magisk/Magisk.apk"
1641 | fi
1642 | clean_flash
1643 | echo "- $text_done"
1644 | }
1645 |
1646 |
1647 |
1648 |
1649 | uninstall_magisk(){
1650 | echo "******************************"
1651 | echo " Magisk uninstaller"
1652 | echo "******************************"
1653 | need_root_access
1654 | FOUND_MAGISK=false
1655 | SYSTEMLESS=true
1656 | FILE_LIST1="
1657 | /data/ghome/gearboot/overlay/magisk
1658 | /data/ghome/gearboot/overlay/rusty-magisk
1659 | /data/ghome/.local/magisk
1660 | "
1661 |
1662 | for file in $FILE_LIST1; do
1663 | test -d $file && FOUND_MAGISK=true
1664 | done
1665 |
1666 | FILE_LIST2="
1667 | /system/ghome/gearboot/overlay/rusty-magisk
1668 | /system/ghome/gearboot/overlay/magisk
1669 | /system/ghome/.local/magisk
1670 | /magisk
1671 | /system/etc/magisk
1672 | "
1673 |
1674 | for file in $FILE_LIST2; do
1675 | test -d $file && FOUND_MAGISK=true && SYSTEMLESS=false
1676 | done
1677 |
1678 | $FOUND_MAGISK || abortc light_red "$text_uninstall_fail"
1679 |
1680 | if [ "$SYSTEMLESS" == "false" ]; then
1681 | echo "- $text_mount_rw_system"
1682 | mount_rw_system
1683 | $IS_SYSTEM_MOUNT || abortc "light_red" "! $text_failed_mount_system"
1684 |
1685 | MAGISKCOREDIR=/magisk
1686 | [ ! -d "/magisk" ] && MAGISKCOREDIR=/system/etc/magisk
1687 |
1688 | rm -rf "$MAGISKCOREDIR/.rw" 2>/dev/null
1689 | touch "$MAGISKCOREDIR/.rw" 2>/dev/null || abortc light_red "$text_system_not_writeable"
1690 | rm -rf "$MAGISKCOREDIR/.rw" 2>/dev/null
1691 |
1692 | fi
1693 |
1694 | echo "- $text_uninstalling_magisk..."
1695 |
1696 | for fun in $FILE_LIST1 $FILE_LIST2 /system/etc/init/magisk.rc; do
1697 | rm -rf "$fun"
1698 | done
1699 |
1700 | if $REMOVE_MAGISK_DATA; then
1701 |
1702 | ADDOND=/system/addon.d/99-magisk.sh
1703 | if [ -f $ADDOND ]; then
1704 | rm -f "/$ADDOND"
1705 | fi
1706 | echo "- $text_rm_magisk_files"
1707 | rm -rf \
1708 | /cache/*magisk* /cache/unblock /data/*magisk* /data/cache/*magisk* /data/property/*magisk* \
1709 | /data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh /data/adb/*magisk* \
1710 | /data/adb/post-fs-data.d /data/adb/service.d /data/adb/modules* \
1711 | /data/unencrypted/magisk /metadata/magisk /persist/magisk /mnt/vendor/persist/magisk /data/.magisk_binary /magisk \
1712 | /data/ghome/unins/Magisk_* /system/ghome/unins/Magisk_*
1713 |
1714 | if [ "$SYSTEMLESS" == "false" ]; then
1715 | echo "- $text_mount_ro_system"
1716 | mount_ro_system
1717 | fi
1718 | cd /
1719 | echo "********************************************"
1720 | warn_reboot
1721 | echo "********************************************"
1722 | (sleep 8; /system/bin/reboot)&
1723 | fi
1724 | echo "- $text_done"
1725 |
1726 | }
1727 |
1728 |
1729 | unsu(){
1730 | clear
1731 | ui_print " ";
1732 | echo "******************************"
1733 | ui_print "unSU Script";
1734 | ui_print "by osm0sis @ xda-developers"; #keep credit
1735 | echo "******************************"
1736 | echo "- $text_mount_rw_system"
1737 | mount_rw_system
1738 | $IS_SYSTEM_MOUNT || abortc "light_red" "! $text_failed_mount_system"
1739 |
1740 | mount --bind /system /system
1741 |
1742 | rm -rf "/system/.rw" 2>/dev/null
1743 | touch "/system/.rw" 2>/dev/null || { umount -l /system; abortc light_red "$text_system_not_writeable"; }
1744 | rm -rf "/system/.rw" 2>/dev/null
1745 |
1746 |
1747 | if [ -e /data/su ]; then
1748 | ui_print "Removing phh's SuperUser...";
1749 | rm -rf /data/app/me.phh.superuser* /data/data/me.phh.superuser* /data/su;
1750 | bootmsg=1;
1751 | fi;
1752 |
1753 |
1754 | if [ -e /cache/su.img -o -e /data/su.img ]; then
1755 | ui_print "Removing SuperSU Systemless (su.img)...";
1756 | umount /su;
1757 | rm -rf /cache/su.img /data/su.img /data/adb/suhide;
1758 | bootmsg=1;
1759 | supersu=1;
1760 | fi;
1761 |
1762 | bindsbin=$(dirname `find /data -name supersu_is_here | head -n1`);
1763 | if [ -e "$bindsbin" ]; then
1764 | ui_print "Removing SuperSU Systemless (BINDSBIN at $bindsbin)...";
1765 | rm -rf $bindsbin /data/app/eu.chainfire.suhide* /data/user*/*/eu.chainfire.suhide*;
1766 | bootmsg=1;
1767 | supersu=1;
1768 | fi;
1769 |
1770 | if [ -e /system/bin/.ext/.su ]; then
1771 | ui_print "Removing SuperSU...";
1772 | mount -o rw,remount /system;
1773 |
1774 | rm -rf /system/.pin /system/.supersu \
1775 | /system/app/Superuser.apk /system/app/SuperSU \
1776 | /system/bin/.ext /system/bin/app_process_init \
1777 | /system/etc/.installed_su_daemon /system/etc/install-recovery.sh /system/etc/init.d/99SuperSUDaemon \
1778 | /system/lib/libsupol.so /system/lib64/libsupol.so /system/su.d \
1779 | /system/xbin/daemonsu /system/xbin/su /system/xbin/sugote /system/xbin/sugote-mksh /system/xbin/supolicy;
1780 |
1781 | mv -f /system/bin/app_process32_original /system/bin/app_process32;
1782 | mv -f /system/bin/app_process64_original /system/bin/app_process64;
1783 | mv -f /system/bin/install-recovery_original.sh /system/bin/install-recovery.sh;
1784 |
1785 | cd /system/bin;
1786 | if [ -e app_process64 ]; then
1787 | ln -sf app_process64 app_process;
1788 | elif [ -e app_process32 ]; then
1789 | ln -sf app_process32 app_process;
1790 | fi;
1791 | supersu=1;
1792 | fi;
1793 |
1794 | if [ "$supersu" ]; then
1795 | rm -rf /cache/.supersu /cache/SuperSU.apk \
1796 | /data/.supersu /data/SuperSU.apk \
1797 | /data/app/eu.chainfire.supersu* /data/user*/*/eu.chainfire.supersu*;
1798 | fi;
1799 |
1800 | if [ -e /system/bin/su -a "$(strings /system/xbin/su | grep koush)" ]; then
1801 | ui_print "Removing Koush's SuperUser...";
1802 | mount -o rw,remount /system;
1803 |
1804 | rm -rf /system/app/Superuser.apk /system/bin/su \
1805 | /system/etc/.has_su_daemon /system/etc/.installed_su_daemon /system/xbin/su \
1806 | /cache/su /cache/Superuser.apk /cache/install-recovery-sh \
1807 | /data/app/com.koushikdutta.superuser* /data/user*/*/com.koushikdutta.superuser*;
1808 | fi;
1809 |
1810 | if [ -e /system/addon.d/51-addonsu.sh ]; then
1811 | ui_print "Removing LineageOS addonsu...";
1812 | mount -o rw,remount /system;
1813 | rm -rf /system/addon.d/51-addonsu.sh /system/bin/su \
1814 | /system/etc/init/superuser.rc /system/xbin/su;
1815 | fi;
1816 |
1817 | if [ -e /system/bin/su -o -e /system/xbin/su ]; then
1818 | ui_print "Removing ROM su binary...";
1819 | mount -o rw,remount /system;
1820 | rm -rf /system/bin/su /system/xbin/su;
1821 | fi;
1822 | umount -l /system
1823 | echo "- $text_mount_ro_system"
1824 | mount_ro_system
1825 | }
1826 |
1827 | download_magisk_apk(){
1828 | if [ "$install_offline" != "true" ]; then
1829 |
1830 |
1831 | echo "- Downloading Magisk APK..."
1832 | rm -rf "$DLPATH/app.tmp"
1833 | rm -rf "$DLPATH/app.apk"
1834 | mirror_git="https://gh.api.99988866.xyz/"
1835 |
1836 |
1837 | wget -O "$DLPATH/app.tmp" "$URL" 2>/dev/null && mv -f "$DLPATH/app.tmp" "$DLPATH/app.apk" 2>/dev/null
1838 | [ -f "$DLPATH/app.apk" ] || wget -O "$DLPATH/app.tmp" "$mirror_git$URL" 2>/dev/null && mv -f "$DLPATH/app.tmp" "$DLPATH/app.apk" 2>/dev/null
1839 | [ -f "$DLPATH/app.apk" ] || abortc none "! Cannot download Magisk APK"
1840 | APKFILE="$DLPATH/app.apk"
1841 | fi
1842 | rm -rf "$DLPATH/util_functions.sh"; unzip -oj "$APKFILE" 'assets/util_functions.sh' -d "$DLPATH" &>/dev/null
1843 | MAGISK_VERINFO="$( . $DLPATH/util_functions.sh; echo "$MAGISK_VER $MAGISK_VER_CODE"; )"
1844 | MAGISK_VER="$(echo "$MAGISK_VERINFO" | awk '{ print $1 }')"
1845 | MAGISK_VER_CODE="$(echo "$MAGISK_VERINFO" | awk '{ print $2 }')"
1846 | [ -z "$MAGISK_VER" -o -z "$MAGISK_VER_CODE" ] && abortc light_red "This APK is not Magisk app"
1847 | cp -af "$APKFILE" "$DLPATH/save/$MAGISK_VER($MAGISK_VER_CODE)"
1848 | }
1849 |
1850 |
1851 | install_option_process(){
1852 | clear
1853 |
1854 | ( download_magisk_apk
1855 | install_option_method
1856 | )
1857 | }
1858 |
1859 | install_option_method(){
1860 | MINIMAL_MAGISK=false
1861 | while true; do
1862 | clear
1863 | pd light_cyan "- Magisk build: $MAGISK_VER($MAGISK_VER_CODE)"
1864 | nomethod=false
1865 | print_method
1866 | read method
1867 | case "$method" in
1868 | 1)
1869 | install_command="install_magisk"
1870 | ;;
1871 | 2)
1872 | patch_ramdisk_method
1873 | ;;
1874 | 3)
1875 | gearlock_method
1876 | ;;
1877 | 4)
1878 | install_command="update_magiskbin"
1879 | ;;
1880 | "m")
1881 | if [ "$MAGISK_VER_CODE" -lt "23010" ]; then
1882 | if $MINIMAL_MAGISK; then
1883 | MINIMAL_MAGISK=false
1884 | else
1885 | MINIMAL_MAGISK=true
1886 | fi
1887 | fi
1888 | nomethod=true
1889 | ;;
1890 | 0)
1891 | exit 0
1892 | ;;
1893 | *)
1894 | nomethod=true
1895 | ;;
1896 | esac
1897 | $nomethod || break
1898 | done
1899 | $nomethod || { clear; $install_command "$RAMDISK"; }
1900 |
1901 | }
1902 |
1903 | ramdisk_direct_install(){
1904 | CONTINUE=1
1905 | echo -n "$text_find_ramdisk_auto ? "
1906 | read autom
1907 | if [ "$autom" == "Y" -o "$autom" == "y" ]; then
1908 | ( find_ramdisk_image
1909 | patch_ramdisk "$RAMDISK" "true" )
1910 | test "$?" == 0 && CONTINUE=0
1911 | umount -l /dev/os_disk_*
1912 | echo "Unmount all disks..."
1913 | elif ! [ "$autom" == "N" -o "$autom" == "n" ]; then
1914 | exit
1915 | fi
1916 | if [ "$CONTINUE" == "1" ]; then
1917 | VAR_OSROOT="$(cat $DISKINFO/blockdev)"
1918 | VAR_RAMDISK="$(cat $DISKINFO/ramdisk)"
1919 | RAMDISK="$VAR_RAMDISK"
1920 | if [ "$VAR_OSROOT" ] && [ "$VAR_RAMDISK" ]; then
1921 | ( echo -n "${text_use_current_ramdisk_info}? "
1922 | read opt
1923 | if [ "$opt" == "Y" -o "$opt" == "y" ]; then
1924 | mount_disk
1925 | ( patch_ramdisk "$RAMDISK" "true" )
1926 | ERR_CODE=$?
1927 | umount_disk
1928 | exit $ERR_CODE
1929 | elif ! [ "$opt" == "N" -o "$opt" == "n" ]; then
1930 | exit
1931 | else
1932 | exit 1
1933 | fi )
1934 | if [ "$?" == "1" ]; then
1935 | table_list
1936 | patch_ramdisk "$RAMDISK" "true"
1937 | umount_disk
1938 | fi
1939 | else
1940 | table_list
1941 | patch_ramdisk "$RAMDISK" "true"
1942 | umount_disk
1943 | fi
1944 | fi
1945 | }
1946 |
1947 | ramdisk_direct_uninstall(){
1948 | CONTINUE=1
1949 | echo -n "$text_find_ramdisk_auto ? "
1950 | read autom
1951 | if [ "$autom" == "Y" -o "$autom" == "y" ]; then
1952 | ( find_ramdisk_image
1953 | unpatch_ramdisk "$RAMDISK" "true" )
1954 | test "$?" == 0 && CONTINUE=0
1955 | umount -l /dev/os_disk_*
1956 | echo "Unmount all disks..."
1957 | elif ! [ "$autom" == "N" -o "$autom" == "n" ]; then
1958 | exit
1959 | fi
1960 | if [ "$CONTINUE" == "1" ]; then
1961 | VAR_OSROOT="$(cat $DISKINFO/blockdev)"
1962 | VAR_RAMDISK="$(cat $DISKINFO/ramdisk)"
1963 | RAMDISK="$VAR_RAMDISK"
1964 | if [ "$VAR_OSROOT" ] && [ "$VAR_RAMDISK" ]; then
1965 | ( echo -n "${text_use_current_ramdisk_info}? "
1966 | read opt
1967 | if [ "$opt" == "Y" -o "$opt" == "y" ]; then
1968 | mount_disk
1969 | ( unpatch_ramdisk "$RAMDISK" "true" )
1970 | ERR_CODE=$?
1971 | umount_disk
1972 | exit $ERR_CODE
1973 | elif ! [ "$opt" == "N" -o "$opt" == "n" ]; then
1974 | exit
1975 | else
1976 | exit 1
1977 | fi )
1978 | if [ "$?" == "1" ]; then
1979 | table_list
1980 | unpatch_ramdisk "$RAMDISK" "true"
1981 | umount_disk
1982 | fi
1983 | else
1984 | table_list
1985 | unpatch_ramdisk "$RAMDISK" "true"
1986 | umount_disk
1987 | fi
1988 | fi
1989 | }
1990 |
1991 |
1992 | patch_ramdisk_method(){
1993 | RAMDISK=""
1994 | print_ramdisk_method
1995 | read c
1996 | case "$c" in
1997 | 1)
1998 | need_root_access
1999 | install_command="ramdisk_direct_install"
2000 | ;;
2001 | 2)
2002 | echo "$text_enter_path_ramdisk"
2003 | p none "> "
2004 | read RAMDISK
2005 | install_command="patch_ramdisk"
2006 | ;;
2007 | *)
2008 | nomethod=true
2009 | ;;
2010 | esac
2011 | }
2012 |
2013 | gearlock_method(){
2014 | RAMDISK=""
2015 | print_gxp_method
2016 | read c
2017 | case "$c" in
2018 | 1)
2019 | need_root_access
2020 | install_command="install_magisk_gearlock"
2021 | ;;
2022 | 2)
2023 |
2024 | install_command="build_gxp"
2025 | ;;
2026 | *)
2027 | nomethod=true
2028 | ;;
2029 | esac
2030 | }
2031 |
2032 |
2033 |
2034 | install_option(){
2035 | clear
2036 | print_menu_install
2037 | read build
2038 | install_magisk=true
2039 | install_offline=false
2040 | MINIMAL_MAGISK=false
2041 | APKFILE="$DLPATH/magisk.apk"
2042 | case $build in
2043 | 1)
2044 | build_name="Canary"
2045 | URL="$canary_magisk_link"
2046 | ;;
2047 | 2)
2048 | build_name="Alpha"
2049 | URL="$alpha_magisk_link"
2050 | ;;
2051 | 3)
2052 | build_name="Canary"
2053 | URL="$canary_v23001_magisk_link"
2054 | ;;
2055 | 4)
2056 | build_name="Stable"
2057 | URL="$stable_magisk_link"
2058 | ;;
2059 | 5)
2060 | build_name="Canary"
2061 | URL="https://github.com/TheHitMan7/Magisk-Files/blob/master/channel/app-release.apk?raw=true"
2062 | ;;
2063 | "e")
2064 | echo -n "[URL]: "
2065 | read URL
2066 | [ -z "$URL" ] && install_magisk=false
2067 | ;;
2068 | "a")
2069 | build_name="Alpha"
2070 | install_offline=true
2071 | ;;
2072 | "x")
2073 | build_name="Custom"
2074 | install_offline=true
2075 | echo "$text_enter_magisk_apk"
2076 | p none "$text_example: "; pd gray "/sdcard/Magisk.apk"
2077 | p none "> "
2078 | read custom_magisk_apk
2079 | APKFILE="$custom_magisk_apk"
2080 | [ ! -f "$APKFILE" ] && abortc light_red "Magisk APK does not exist"
2081 | ;;
2082 | "z")
2083 | install_offline=true
2084 | list_apk
2085 | ;;
2086 |
2087 | *)
2088 | install_magisk=false
2089 | ;;
2090 | esac
2091 |
2092 | if [ "$install_magisk" == "true" ]; then
2093 | clear
2094 | install_option_process
2095 | fi
2096 |
2097 |
2098 |
2099 | }
2100 |
2101 | uninstall_option(){
2102 | clear
2103 | pd gray "=============================================="
2104 | echo " Uninstall Magisk"
2105 | pd gray "=============================================="
2106 | echo " 1 - $text_uninstall_magisk_in"
2107 | echo " 2 - $text_restore_original_ramdisk"
2108 | echo -n "[$text_choice]: "
2109 | read c
2110 | case "$c" in
2111 | 1)
2112 | ( need_root_access; p none "$text_warn_uninstall_magisk "
2113 | read uni
2114 | if [ "$uni" == "y" -o "$uni" == "Y" ]; then
2115 | p none "$text_ask_keep_modules "
2116 | REMOVE_MAGISK_DATA=true
2117 | read uni2
2118 | [ "$uni2" == "y" -o "$uni2" == "Y" ] && REMOVE_MAGISK_DATA=false
2119 | clear
2120 | uninstall_magisk
2121 | fi )
2122 | ;;
2123 | 2)
2124 | unpatch_ramdisk_method
2125 | ;;
2126 | esac
2127 | }
2128 |
2129 | unpatch_ramdisk_method(){
2130 | print_unpatch_ramdisk
2131 | read c
2132 | case "$c" in
2133 | 1)
2134 | ( need_root_access; clear; ramdisk_direct_uninstall )
2135 | ;;
2136 | 2)
2137 | echo "$text_enter_path_ramdisk"
2138 | echo -n "> "
2139 | read RAMDISK
2140 | clear
2141 | ( unpatch_ramdisk "$RAMDISK" )
2142 | ;;
2143 | esac
2144 | }
2145 |
2146 |
2147 |
2148 | try_mount_it(){
2149 | echo -e "Mounting ${BGREEN}${VAR_OSROOT}${RC} to ${BPURPLE}${OSROOT}${RC}"
2150 | mount -o ro "$VAR_OSROOT" "$OSROOT"
2151 | mount -t ext4 "$VAR_OSROOT" "$OSROOT"
2152 | mount -o rw,remount "$OSROOT" && IS_MOUNT=true
2153 | mount.ntfs "$VAR_OSROOT" "$OSROOT" && IS_MOUNT=true
2154 | $IS_MOUNT || echo -e "${BRED}$text_cannot_mount_part${RC}"
2155 | }
2156 |
2157 | try_umount_it(){
2158 | if [ "$GEARROOT" ]; then
2159 | for block in $GEARROOT; do
2160 | if [ "$block" != "/system" ]; then
2161 | echo -ne "Unmount ${BPURPLE}${block}${RC}... "
2162 | umount -l "$block" && echo -e "${BGREEN}SUCCESS!${RC}" || echo -e "${BRED}FAILED!${RC}"
2163 | fi
2164 | done
2165 | fi
2166 | }
2167 |
2168 |
2169 | mount_disk(){
2170 | IS_MOUNT=false
2171 | [ -z "$OSROOT" ] && OSROOT=/dev/os_disk
2172 | umount -l "$OSROOT"
2173 | rm -rf "$OSROOT"
2174 | mkdir "$OSROOT"
2175 | GEARROOT="$(mount | grep "^${VAR_OSROOT}" | awk '{ print $3 }')"
2176 | try_mount_it
2177 | if [ "$IS_MOUNT" == "false" ]; then
2178 | try_umount_it
2179 | try_mount_it
2180 | fi
2181 | }
2182 |
2183 | umount_disk(){
2184 | echo -ne "Unmount ${BPURPLE}/dev/os_disk${RC}... "
2185 | umount -l /dev/os_disk && echo -e "${BGREEN}SUCCESS!${RC}" || echo -e "${BRED}FAILED!${RC}"
2186 | }
2187 |
2188 | table_blockdev(){
2189 | echo " ------- Partition Table -------"
2190 | BLOCKDEVS="$(/system/bin/blkid -s LABEL -s TYPE | grep -v loop | grep -v "/sr" | awk 'NF')"
2191 | #BLOCKDEVS="/dev/block/example"
2192 | echo "$BLOCKDEVS" | nl -s "]. "
2193 | echo " 0]. Exit table"
2194 | IS_MOUNT=false
2195 | while true; do
2196 | echo -ne "+ $text_enter_part >>"
2197 | read -r c
2198 | VAR_OSROOT="$(echo "$BLOCKDEVS" | sed -n "$c p" 2>/dev/null | cut -d : -f1)"
2199 | OSROOT=/dev/os_disk
2200 | if [ "$c" == "0" ]; then
2201 | exit
2202 | elif [ -z "$c" ] || [ -z "$VAR_OSROOT" ]; then
2203 | echo -e "${RED}! $text_wrong_input ...${RC}"
2204 | else
2205 | # mount the partition for us
2206 | mount_disk
2207 | $IS_MOUNT && break
2208 | fi
2209 | done
2210 | }
2211 |
2212 | find_ramdisk_image(){
2213 | RAMDISK=""
2214 | BLOCKDEVS="$(blkid | grep -v loop | grep -v "/sr" | awk 'NF' | cut -d : -f1)"
2215 | BIMGVAR="$(cmdline BOOT_IMAGE)"
2216 | SRCVAR="$(cmdline SRC)"
2217 | [ -z "$SRCVAR" ] && SRCVAR="$(dirname "$BIMGVAR")"
2218 | [ "$SRCVAR" == "." ] && SRCVAR="android"
2219 | count=0
2220 | RAMDISK="/gearlock/gearroot/$SRCVAR/ramdisk.img"
2221 | if [ ! -f "$RAMDISK" ]; then
2222 | unset RAMDISK
2223 | for VAR_OSROOT in $BLOCKDEVS; do
2224 | count="$(($count + 1))"
2225 | OSROOT="/dev/os_disk_$count"
2226 | mount_disk
2227 | TARGET_ROOT="$OSROOT/$SRCVAR"
2228 | if [ -d "$TARGET_ROOT" ] && [ -f "$TARGET_ROOT/findme" ] && [ -f "$TARGET_ROOT/initrd.img" ] && [ -f "$TARGET_ROOT/ramdisk.img" ] && file "$TARGET_ROOT/ramdisk.img" | grep -q " gzip "; then
2229 | RAMDISK="$TARGET_ROOT/ramdisk.img"
2230 | break;
2231 | fi
2232 | done
2233 | fi
2234 | [ -z "$RAMDISK" ] && abortc light_red "$text_cannot_detect_target_ramdisk"
2235 | echo -e "- Target ramdisk: ${BGREEN}${RAMDISK}${RC}"
2236 | }
2237 |
2238 |
2239 | table_ramdisk(){
2240 | SELECTED_RAMDISK=false
2241 | test -f $DISKINFO/blockdev || rm -rf $DISKINFO/blockdev
2242 | echo -n "$VAR_OSROOT" >$DISKINFO/blockdev
2243 | echo "------- CHOICE RAMDISK -------:"
2244 | LIST_OS="$(find "$OSROOT" -mindepth 2 -maxdepth 2 -name "$chkFile" 2>/dev/null)"
2245 | [ -z "$LIST_OS" ] && pd light_red " No ramdisk!" || echo "$LIST_OS" | nl -s "]. "
2246 | echo " r]. Re-mount partition"
2247 | echo " 0]. Exit table"
2248 | while true; do
2249 | echo -ne "$text_enter_ramdisk >>"
2250 | read -r c
2251 | VAR_RAMDISK=$(echo "$LIST_OS" | sed -n "$c p" 2>/dev/null | cut -d : -f1)
2252 | if [ "$c" == "0" ]; then
2253 | exit
2254 | elif [ "$c" == r ]; then
2255 | break
2256 | elif [ -z "$c" ] || [ -z "$VAR_OSROOT" ]; then
2257 | echo -e "${RED}! $text_wrong_input ...${RC}"
2258 | elif file "$VAR_RAMDISK" | grep -q " gzip "; then
2259 | echo -e "- Target ramdisk: ${BGREEN}${VAR_RAMDISK}${RC}"
2260 | test -f $DISKINFO/ramdisk || rm -rf $DISKINFO/ramdisk
2261 | echo -n "$VAR_RAMDISK" >$DISKINFO/ramdisk
2262 | RAMDISK="$VAR_RAMDISK"
2263 | echo -e "- $text_saved_ramdisk_info ${BGREEN}/data/adb/diskinfo${RC}"
2264 | SELECTED_RAMDISK=true
2265 | break
2266 | else
2267 | echo -n "${RED}! $text_unsupport_ramdisk_format${RC}"
2268 | fi
2269 | done
2270 | }
2271 |
2272 |
2273 | mount_fail_pick_again(){
2274 | echo -e "${RED}! $text_cannot_mount_part${RC}"
2275 | sleep 1
2276 | table_blockdev
2277 | }
2278 |
2279 | bluestacks_fix(){ (
2280 | MODDIR=/data/adb/modules/bluestacks-fix
2281 | MODDIR2=/data/adb/modules_update/bluestacks-fix
2282 | mkdir -p $MODDIR
2283 | mkdir -p $MODDIR2
2284 | echo "MAGISKTMP=\$(magisk --path) || MAGISKTMP=/sbin
2285 | MIRROR_SYSTEM=\"\$MAGISKTMP/.magisk/mirror/system\"
2286 | test ! -d \"\$MIRROR_SYSTEM/android/system\" && exit
2287 | mount --bind \"\$MIRROR_SYSTEM/android/system\" \"\$MIRROR_SYSTEM\"">$MODDIR2/post-fs-data.sh
2288 | MODPROP="id=bluestacks-fix
2289 | name=Bluestacks System Fix
2290 | version=v1.0
2291 | versionCode=10000
2292 | author=HuskyDG
2293 | description=Fix the incorrect Bluestacks system partition that breaks Magisk modules"
2294 | echo "$MODPROP" >$MODDIR/module.prop
2295 | echo "$MODPROP" >$MODDIR2/module.prop
2296 | echo -n >$MODDIR/update
2297 | pd light_green "$text_added_bs_module"
2298 | ) 2>/dev/null
2299 | }
2300 |
2301 |
2302 | table_list(){
2303 | RESET_DISKINFO="$1"
2304 | while true; do
2305 | clear
2306 | mkdir -p "$DISKINFO"
2307 | BLOCKDEV="$(cat $DISKINFO/blockdev)"
2308 | VAR_RAMDISK="$(cat $DISKINFO/ramdisk)"
2309 | if [ -z "$BLOCKDEV" ]; then
2310 | table_blockdev
2311 | else
2312 | VAR_OSROOT="$BLOCKDEV"
2313 | echo -ne "Mount this device block?: ${BPURPLE}${BLOCKDEV}${RC} ? "; read m
2314 | if [ "$m" == "Y" -o "$m" == "y" ]; then
2315 | mount_disk
2316 | $IS_MOUNT || mount_fail_pick_again
2317 | else
2318 | table_blockdev
2319 | fi
2320 | fi
2321 |
2322 | chkFile="ramdisk.img"
2323 | #test_if_ramdisk
2324 | # find Android x86 folder
2325 |
2326 | if $IS_MOUNT; then
2327 | table_ramdisk
2328 | fi
2329 | $SELECTED_RAMDISK && break
2330 | done
2331 | }
2332 |
2333 | list_apk(){
2334 | while true; do
2335 | clear
2336 | pd light_cyan "$text_select_magisk_app"
2337 | LIST_APK="$(cd "$DLPATH/save" && find * -prune -type f)"
2338 | echo "$LIST_APK" | nl -s "]. "
2339 | echo "----------"
2340 | echo " 0]. Exit here"
2341 | echo "$text_guide_rm_magisk_app"
2342 | echo -n "[$text_choice]: "
2343 | read -r capk
2344 | if [ "$capk" == 0 ]; then
2345 | exit
2346 | elif [ ! -z "$capk" ] && [ -f "$DLPATH/save/$(echo "$LIST_APK" | sed -n "$capk p" 2>/dev/null | cut -d : -f1)" ]; then
2347 | APKFILE="$DLPATH/save/$(echo "$LIST_APK" | sed -n "$capk p" 2>/dev/null | cut -d : -f1)"
2348 | break
2349 | elif [ "$(echo "$capk" | awk '{ print $1 }')" == "rm" ]; then
2350 | rm -rf "$DLPATH/save/$(echo "$LIST_APK" | sed -n "$(echo -n "$capk" | awk '{ print $2 }') p" 2>/dev/null | cut -d : -f1)"
2351 | else
2352 | echo -en "${RED}! $text_wrong_input ...${RC}"; read
2353 | fi
2354 | done
2355 |
2356 | }
2357 |
2358 |
2359 | main(){
2360 | clear
2361 | print_menu
2362 | read option
2363 | no_turn_back=false
2364 | case $option in
2365 | 1)
2366 | ( install_option )
2367 | ;;
2368 | 2)
2369 | uninstall_option
2370 | ;;
2371 | 3)
2372 | rm -rf "$DLPATH/fmm.apk"
2373 | cp "$MYPATH/libmm.so" "$DLPATH/fmm.apk"
2374 | pm install "$DLPATH/fmm.apk" &>/dev/null && pd light_green "$text_success_mm" || pd light_red "$text_cannot_mm"
2375 | ;;
2376 | 4)
2377 | (need_root_access; unsu)
2378 | ;;
2379 | 0)
2380 | exit 0
2381 | ;;
2382 | *)
2383 | no_turn_back=true
2384 | ;;
2385 | esac
2386 | $no_turn_back || turn_back
2387 | }
2388 |
2389 | install_option_dd(){
2390 | download_magisk_apk
2391 | case "$AGV3" in
2392 | "system")
2393 | (need_root_access; install_magisk)
2394 | ;;
2395 | "ramdisk")
2396 | (need_root_access; ramdisk_direct_install)
2397 | ;;
2398 | "ramdisk-patch")
2399 | (patch_ramdisk "$AGV4")
2400 | ;;
2401 | "export-gxp")
2402 | ( build_gxp )
2403 | ;;
2404 | *)
2405 | install_option_method
2406 | ;;
2407 | esac
2408 | }
2409 |
2410 |
2411 |
2412 |
2413 |
2414 | APKFILE="$DLPATH/magisk.apk"
2415 | if [ "$AGV1" != "noexec" ]; then
2416 | if [ "$AGV1" == "option" ]; then
2417 | case "$AGV2" in
2418 | "install")
2419 | install_option;
2420 | ;;
2421 |
2422 | "install:alpha")
2423 | build_name="Alpha"
2424 | URL="$alpha_magisk_link"
2425 | install_option_dd
2426 | ;;
2427 | "install:canary")
2428 | build_name="Canary"
2429 | URL="$canary_magisk_link"
2430 | install_option_dd
2431 | ;;
2432 | "install:stable")
2433 | build_name="Stable"
2434 | URL="$stable_magisk_link"
2435 | install_option_dd
2436 | ;;
2437 | "install:offline")
2438 | build_name="Alpha"
2439 | install_offline=true
2440 | install_option_dd
2441 | ;;
2442 | "install:custom")
2443 | build_name="Custom"
2444 | install_offline=true
2445 | APKFILE="$AGV5"
2446 | install_option_dd
2447 | ;;
2448 | "install:"*)
2449 | echo "Invaild Magisk build. Available build: canary, alpha, stable"
2450 | ;;
2451 | "uninstall")
2452 | uninstall_option
2453 | ;;
2454 | *)
2455 | open_main
2456 | ;;
2457 |
2458 | esac
2459 | else
2460 | open_main
2461 | fi
2462 | fi; clean_flash 2>/dev/null; true
--------------------------------------------------------------------------------
/libbusybox.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/libbusybox.so
--------------------------------------------------------------------------------
/libgxp.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/libgxp.so
--------------------------------------------------------------------------------
/libmkshrc.so:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2010, 2012, 2013, 2014
2 | # Thorsten Glaser
3 | # This file is provided under the same terms as mksh.
4 | #-
5 | # Minimal /system/etc/mkshrc for Android
6 | #
7 | # Support: https://launchpad.net/mksh
8 |
9 |
10 | AGVARR="$@"
11 | SCRIPT="$0"
12 | AGV1="$1"
13 | AGV2="$2"
14 | AGV3="$3"
15 | export MYSCRIPT="$(realpath "$0")" 2>/dev/null
16 | if [ "$MYSCRIPT" ]; then
17 | export MYPATH="${MYSCRIPT%/*}"
18 | cmds="$SCRIPT $AGVARR"
19 | fi
20 | priv_dir=/data/data/io.github.huskydg.magiskonnox
21 |
22 |
23 | p(){
24 | COLOR=$1;TEXT="$2";escape="$1"
25 | [ "$COLOR" == "black" ] && escape="0;30"
26 | [ "$COLOR" == "red" ] && escape="0;31"
27 | [ "$COLOR" == "green" ] && escape="0;32"
28 | [ "$COLOR" == "orange" ] && escape="0;33"
29 | [ "$COLOR" == "blue" ] && escape="0;34"
30 | [ "$COLOR" == "purple" ] && escape="0;35"
31 | [ "$COLOR" == "cyan" ] && escape="0;36"
32 | [ "$COLOR" == "light_gray" ] && escape="0;37"
33 | [ "$COLOR" == "gray" ] && escape="1;30"
34 | [ "$COLOR" == "light_red" ] && escape="1;31"
35 | [ "$COLOR" == "light_green" ] && escape="1;32"
36 | [ "$COLOR" == "yellow" ] && escape="1;33"
37 | [ "$COLOR" == "light_blue" ] && escape="1;34"
38 | [ "$COLOR" == "light_purple" ] && escape="1;35"
39 | [ "$COLOR" == "light_cyan" ] && escape="1;36"
40 | [ "$COLOR" == "white" ] && escape="1;37"
41 | [ "$COLOR" == "none" ] && escape="0"
42 | code="\033[${escape}m"
43 | end_code="\033[0m"
44 | echo -en "$code$TEXT$end_code"
45 | }
46 |
47 |
48 |
49 | RC='\033[0m' RED='\033[0;31m' BRED='\033[1;31m' GRAY='\033[1;30m' BLUE='\033[0;34m' BBLUE='\033[1;34m' CYAN='\033[0;34m' CYAN='\033[1;34m' WHITE='\033[1;37m' GREEN='\033[0;32m' BGREEN='\033[1;32m' YELLOW='\033[1;33m' PURPLE='\033[0;35m' BPURPLE='\033[1;35m' ORANGE='\033[0;33m'
50 |
51 | pd(){
52 | p "$1" "$2"; echo
53 | }
54 |
55 | DLPATH="$priv_dir/magisk"
56 |
57 | export OLDPATH="$PATH"
58 |
59 |
60 | ( cd "$priv_dir"
61 |
62 | if [ ! -d "$DLPATH" ]; then
63 | rm -rf "$DLPATH" 2>/dev/null
64 | mkdir -p "$DLPATH" 2>/dev/null
65 | fi
66 |
67 |
68 |
69 | link(){ (
70 | agv1="$1"; agv2="$2"
71 | [ ! -f "$DLPATH/$agv2" ] && rm -rf "$DLPATH/$agv2" 2>/dev/null
72 | ln -s "$(which "$agv1")" "$DLPATH/$agv2" 2>/dev/null
73 | ) }
74 |
75 | link "libapp.so" "magisk.apk"
76 | link "libbusybox.so" "busybox"
77 | link "liblegacy.so" "legacy.zip"
78 | link "libbash.so" "menu"
79 | link "libgxp.so" "gearlock_extension.zip"
80 |
81 | )
82 |
83 | export PATH="$DLPATH/bin:$DLPATH:$PATH"
84 |
85 |
86 | alias inmagisk='"$DLPATH/busybox" sh -o standalone "$DLPATH/menu" option "$@"'
87 | alias m='inmagisk "$@"'
88 |
89 |
90 | magiskhide(){ (
91 | VAR_ARRAY="$@"
92 | MAGISK_VERSION="$(magisk -V)" || exit 1
93 | MAGISKHIDE="--denylist"
94 | [ "$MAGISK_VERSION" -lt "23010" ] && MAGISKHIDE="magiskhide"
95 | magisk $MAGISKHIDE "$@"
96 | ) }
97 |
98 | denylist(){ ( magiskhide "$@"; ) }
99 |
100 | help(){
101 | echo "$(inmagisk help)
102 |
103 | MagiskHide / DenyList ConFig
104 | usage: magiskhide [option]...
105 | or: denylist [option]...
106 | shortcut for \"magisk --denylist\" if Magisk version is 23010+"
107 | }
108 |
109 | p none "Type "; p light_purple "m"; p none " to open "; pd light_green "Magisk Installer Script";
110 | p none "Website: "; pd light_green "http://github.com/HuskyDG/MagiskOnNox"
111 |
--------------------------------------------------------------------------------
/libmm.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/libmm.so
--------------------------------------------------------------------------------
/libzip.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/code871/MagiskOnEmu/900a989ebeb6031d38f9e1f226151df7a27719ee/libzip.so
--------------------------------------------------------------------------------