├── .github
├── Screenshot_1.png
└── Screenshot_2.png
├── LICENSE
├── README.md
├── usbaccelerator.sh
├── usbstatus-gt.png
├── usbstatus-tuf.png
└── usbstatus.png
/.github/Screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JackMerlin/USBAccelerator/8802c0dbbdc4372789cf5b6f3595827204395db6/.github/Screenshot_1.png
--------------------------------------------------------------------------------
/.github/Screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JackMerlin/USBAccelerator/8802c0dbbdc4372789cf5b6f3595827204395db6/.github/Screenshot_2.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # USB Accelerator
2 | **USB Accelerator is a script that runs on Asuswrt and Asuswrt-Merlin firmware. It can help improve the usb transfer speed of your router when you use samba.**
3 |
4 | 
5 |
6 | ## USB Accelerator script will
7 | ### When you use Asuswrt-Merlin firmware or forks
8 | 1. Create `/jffs/scripts/smb.postconf` file to change `socket options` `deadtime` and `strict locking` options of `smb.conf`.
9 | 2. Add an icon in Web GUI to show the working status.
10 |
11 | ### When you use Asuswrt Stock firmware
12 | 1. Create `/jffs/scripts/post-mount` file and to change `socket options` `deadtime` and `strict locking` options of `smb.conf`.
13 | 2. Use the `script_usbmount` variable to make `post-mount` run when the USB is mounted.
14 | 3. Add an icon in Web GUI to show the working status.
15 |
16 | ## Requirements
17 | * An Asus router with [Asuswrt-Merlin](https://www.asuswrt-merlin.net/) 380 and higher or Asuswrt firmware 380 and higher.
18 |
19 | ## Installation
20 | Using an SSH client to login to your router, then copy and paste the following command:
21 | ```Shell
22 | /usr/sbin/wget --tries=3 --timeout=3 --no-check-certificate -O "/tmp/usbaccelerator.sh" "https://raw.githubusercontent.com/JackMerlin/USBAccelerator/master/usbaccelerator.sh" && chmod 755 /tmp/usbaccelerator.sh && sh /tmp/usbaccelerator.sh --github --shellui
23 | ```
24 | Don't forget to press Enter key ;)
25 |
26 | ## Verify that USB Accelerator is Working
27 | * If it is working, you should see a "Plus" in the USB icon in the upper right corner of Web GUI, like the screenshot below.
28 | 
29 | * Check the system logs, USB Accelerator will report it running status.
30 |
31 | ## Disable or Update or Uninstall
32 | Using your SSH client to login to your router, then copy and paste the following command:
33 | ```
34 | sh /jffs/addons/usbaccelerator/usbaccelerator.sh
35 | ```
36 |
37 | ## Advanced Usage
38 | You can use `--help` option to view all supported options
39 | ### Examples
40 | #### Enable USB Accelerator:
41 | ```
42 | sh /usbaccelerator.sh --enable
43 | ```
44 | #### Force Disable USB Accelerator:
45 | ```
46 | sh /usbaccelerator.sh --force --disable
47 | ```
48 | #### Update USB Accelerator without logs output:
49 | ```
50 | sh /usbaccelerator.sh --quiet --update
51 | ```
52 |
53 | ## Privacy
54 | USB Accelerator will not send any data, but it needs to be downloaded and updated from GitHub or GitLab. Please read their terms and privacy policy in detail before using GitHub or GitLab.
55 |
56 | ## Feedback
57 | End-of-life, technical support is no longer provided.
58 |
59 | ## FAQs
60 | ### When will the USB Accelerator run?
61 | When usb device is mounted, the USB Accelerator will run once to modify the `smb.conf`.
62 |
63 | ### Should I download USB Accelerator from GitHub or GitLab?
64 | Please use GitHub and use [GitLab](https://gitlab.com/JackMerlin/USBAccelerator/) only when GitHub is not available.
65 |
66 | ### How to install from GitLab?
67 | GitLab only supports TLS 1.2 and higher, If you use 380 stock firmware, you will not be able to install from GitLab, only `wget` with 384 stock firmware supports TLS 1.2.
68 | If you think your firmware supports it, please use the following command to install:
69 | ```Shell
70 | /usr/sbin/wget --tries=3 --timeout=3 --no-check-certificate -O "/tmp/usbaccelerator.sh" "https://gitlab.com/JackMerlin/USBAccelerator/raw/master/usbaccelerator.sh" && chmod 755 /tmp/usbaccelerator.sh && sh /tmp/usbaccelerator.sh --gitlab --shellui
71 | ```
72 |
73 | ### Where should I report issues?
74 | End-of-life, technical support is no longer provided.
75 |
76 | ### Why is there no speed increase in the FTP?
77 | It should only work in the SMB protocol.
78 |
79 | ### Why is no performance improvement on my router?
80 | First check if it works, and if yes, maybe some settings don't apply to your router.
81 |
82 | ## License
83 | ```
84 | USB Accelerator 2.0
85 | Copyleft :-) 2019-2020
86 |
87 | This program is a free and open-source software , and you can
88 | redistribute it and/or modify it under the terms of the GNU
89 | General Public License version 3 (GPLv3).
90 |
91 | This program is distributed in the hope that it will be useful,
92 | but WITHOUT ANY WARRANTY, without even the implied warranty of
93 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
94 |
95 | See the GNU General Public License version 3 for more details:
96 | https://github.com/JackMerlin/USBAccelerator/blob/master/LICENSE
97 | ```
98 |
--------------------------------------------------------------------------------
/usbaccelerator.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ###################################################################
4 | ###### USB Accelerator by Jack ######
5 | ###### Version 2.0.2 ######
6 | ###### ######
7 | ###### https://github.com/JackMerlin/USBAccelerator ######
8 | ###### ######
9 | ###################################################################
10 |
11 | PARM_1="$1"
12 | PARM_2="$2"
13 | PARM_3="$3"
14 | export PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
15 | VERSION="2.0.2"
16 | RELEASE_TYPE="stable"
17 | S_DIR="/jffs/scripts"
18 | ADD_DIR="/jffs/addons"
19 | UA_DIR="$ADD_DIR/usbaccelerator"
20 | CUR_DIR="$(cd `dirname $0`; pwd)"
21 | S_NAME="$(basename $0)"
22 | LANG="$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)"
23 | [ -z "$LANG" ] && LANG="$(nvram get preferred_lang 2>/dev/null)" || LANG="$LANG"
24 | [ -z "$(nvram get odmpid 2>/dev/null)" ] && R_M="$(nvram get productid 2>/dev/null)" || R_M="$(nvram get odmpid 2>/dev/null)"
25 | FWVER="$(nvram get buildno 2>/dev/null)"
26 | TIMESTAMP="$(date +%F)"
27 | FIRST_TIME="$(awk -F'"' '/^FIRST_TIME=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)"
28 | SRC_1="https://raw.githubusercontent.com/JackMerlin/USBAccelerator/master"
29 | SRC_2="https://gitlab.com/JackMerlin/USBAccelerator/raw/master"
30 | HOST_HOME_1="https://github.com/JackMerlin/USBAccelerator"
31 | HOST_HOME_2="https://gitlab.com/JackMerlin/USBAccelerator"
32 | SC_GLOBAL="0"
33 | FORCE="0"
34 | QUIET="0"
35 | C_LW='\033[1;37m'
36 | C_LB='\033[1;30m'
37 | C_G='\033[0;32m'
38 | C_LG='\033[1;32m'
39 | C_Y='\033[0;33m'
40 | C_LY='\033[1;33m'
41 | C_R='\033[0;31m'
42 | C_LR='\033[1;31m'
43 | C_C='\033[0;36m'
44 | C_LC='\033[1;36m'
45 | C_RS='\033[0m'
46 |
47 | Home() {
48 | if [ -n "$(awk -F'"' '/^UPDATE_COMPLETED=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
49 | Whats_New
50 | sed -i '/UPDATE_COMPLETED/d' "$UA_DIR/CONFIG" 2>/dev/null
51 | fi
52 |
53 | if [ -z "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
54 | Check_Firmware
55 | Check_Model
56 | fi
57 |
58 | if [ "$FWTYPE" = "384M" ] && [ "$HND_MODEL" = "1" ] && [ "$(awk -F'"' '/^IGNORED_CKFWHW=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
59 | printf '___________________________________________________________________\n'
60 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
61 | printf '你所使用的硬件和固件已经具备较好的性能,继续使用可能无法打破瓶颈\n'
62 | printf '%b是否继续安装我呢?%b\n' "$C_Y" "$C_RS"
63 | printf ' %by%b = 继续安装\n' "$C_LG" "$C_RS"
64 | printf ' %bn%b = 卸载并退出\n' "$C_LG" "$C_RS"
65 | else
66 | printf 'Look at that, your firmware has many nice settings, and your router\n'
67 | printf 'has a very powerful CPU. If you choose to install the speed may not\n'
68 | printf 'be as expected.\n'
69 | printf '%bDo you still want to install me?%b\n' "$C_Y" "$C_RS"
70 | printf ' %by%b = Continue to install\n' "$C_LG" "$C_RS"
71 | printf ' %bn%b = Uninstall and exit\n' "$C_LG" "$C_RS"
72 | fi
73 | printf '___________________________________________________________________'
74 | egg="0"
75 | while true; do
76 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
77 | printf '\n该怎么做呢?\n'
78 | else
79 | printf '\nWhat do you want to do?\n'
80 | fi
81 | read -r "home_menu0"
82 | case "$home_menu0" in
83 | y|Y)
84 | Check_Directories
85 | sed -i '/IGNORED_CKFWHW/d' "$UA_DIR/CONFIG" 2>/dev/null
86 | echo '' >> "$UA_DIR/CONFIG"
87 | echo 'IGNORED_CKFWHW="1"' >> "$UA_DIR/CONFIG"
88 | sed -i '/^$/d' "$UA_DIR/CONFIG"
89 | chmod 644 "$UA_DIR/CONFIG"
90 | break
91 | ;;
92 | n|N)
93 | UNINSTALL_RETURN="2"
94 | SC_GLOBAL="3"
95 | Uninstall_Confirmation
96 | break
97 | ;;
98 | *)
99 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
100 | printf '\n你输入的 "%b%b%b" 不正确,请再试一次\n' "$C_LG" "$home_menu0" "$C_RS"
101 | else
102 | printf '\n"%b%b%b" is incorrect, please try again\n' "$C_LG" "$home_menu0" "$C_RS"
103 | fi
104 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
105 | ;;
106 | esac
107 | done
108 | fi
109 |
110 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
111 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
112 | printf '正在准备为你下载文件,请稍等...\n'
113 | else
114 | printf 'Please wait while the download is starting...\n'
115 | fi
116 | TRIG_CKNT_BY_USER="1"
117 | Check_Files
118 | if [ "$SC_CKFILES" -eq "1" ]; then
119 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
120 | printf '文件下载完成,正在重新载入...\n'
121 | else
122 | printf 'Download successful, reloading...\n'
123 | fi
124 | sh "$UA_DIR/usbaccelerator.sh"; SC_GLOBAL="$?"; rm -f /tmp/usbaccelerator.sh; exit "$SC_GLOBAL"
125 | fi
126 | if [ "$SC_CKFILES" -gt "1" ] && [ "$DONT_DL" != "1" ]; then
127 | Download_Files_UI
128 | if [ "$SC_DOWNLOAD" = "0" ] && [ -f "$UA_DIR/usbaccelerator.sh" ] && [ -f "$UA_DIR/usbstatus.png" ]; then
129 | sh "$UA_DIR/usbaccelerator.sh"; SC_GLOBAL="$?"; rm -f /tmp/usbaccelerator.sh; exit "$SC_GLOBAL"
130 | else
131 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
132 | printf '%b注意%b:所需文件未找到,无法顺利开启,建议手动重新安装\n' "$C_LR" "$C_RS"
133 | else
134 | printf '%bWARNING%b: Missing files, please reinstall\n' "$C_LR" "$C_RS"
135 | fi
136 | fi
137 | else
138 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
139 | printf '%b注意%b:所需文件未找到,无法顺利开启,建议手动重新安装\n' "$C_LR" "$C_RS"
140 | else
141 | printf '%bWARNING%b: Missing files, please reinstall\n' "$C_LR" "$C_RS"
142 | fi
143 | fi
144 | fi
145 |
146 | printf '___________________________________________________________________\n'
147 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
148 | printf '%b欢迎来到USB加速器v%b的控制面板,\n你可以输入对应的内容进行相关的操作%b\n' "$C_Y" "$VERSION" "$C_RS"
149 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
150 | printf '\n %b1%b = 开启\n' "$C_LG" "$C_RS"
151 | printf ' %b2 = 关闭%b\n' "$C_LB" "$C_RS"
152 | else
153 | printf '\n %b1 = 开启%b\n' "$C_LB" "$C_RS"
154 | printf ' %b2%b = 关闭\n' "$C_LG" "$C_RS"
155 | fi
156 | printf '\n %b3%b = 下载和更新\n' "$C_LG" "$C_RS"
157 | printf ' %b4%b = 其他设置\n' "$C_LG" "$C_RS"
158 | printf ' %b5%b = 查看文档\n' "$C_LG" "$C_RS"
159 | printf '\n %b8%b = 重新安装\n' "$C_LG" "$C_RS"
160 | printf ' %b9%b = 卸载\n' "$C_LG" "$C_RS"
161 | printf '\n %be%b = 退出控制面板\n' "$C_LG" "$C_RS"
162 | else
163 | printf '%bWelcome, here is the control panel of USB Accelerator v%b%b\n' "$C_Y" "$VERSION" "$C_RS"
164 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
165 | printf '\n %b1%b = Enable\n' "$C_LG" "$C_RS"
166 | printf ' %b2 = Disable%b\n' "$C_LB" "$C_RS"
167 | else
168 | printf '\n %b1 = Enable%b\n' "$C_LB" "$C_RS"
169 | printf ' %b2%b = Disable\n' "$C_LG" "$C_RS"
170 | fi
171 | printf '\n %b3%b = Download and Update\n' "$C_LG" "$C_RS"
172 | printf ' %b4%b = Other Settings\n' "$C_LG" "$C_RS"
173 | printf ' %b5%b = Read Documents\n' "$C_LG" "$C_RS"
174 | printf '\n %b8%b = Re-install\n' "$C_LG" "$C_RS"
175 | printf ' %b9%b = Uninstall\n' "$C_LG" "$C_RS"
176 | printf '\n %be%b = Exit\n' "$C_LG" "$C_RS"
177 | fi
178 | printf '___________________________________________________________________'
179 | egg="0"
180 | e_r_r="0"
181 | while true; do
182 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
183 | printf '\n请输入\n'
184 | else
185 | printf '\nPlease enter\n'
186 | fi
187 | read -r "home_menu1"
188 | case "$home_menu1" in
189 | 1)Enable_UI; break
190 | ;;
191 | 2)
192 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "0" ]; then
193 | Disable_UI; break
194 | else
195 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '已禁用,无须重复禁用\n'; else printf 'Disabled, no need to disable again\n'; fi
196 | fi
197 | ;;
198 | 3)Update_Options_UI; break
199 | ;;
200 | 4)Other_Settings_UI; break
201 | ;;
202 | 5)Read_Documents_UI; break
203 | ;;
204 | 8)Reinstall_Confirmation; break
205 | ;;
206 | 9)Uninstall_Confirmation; break
207 | ;;
208 | e|E)exit "$SC_GLOBAL"; break
209 | ;;
210 | 0)
211 | e_r_r="$((e_r_r + 1))"
212 | if [ "$e_r_r" -ge "3" ]; then
213 | Error_344; break
214 | else
215 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
216 | printf '你输入的好像不对呀,要再试一次吗?\n'
217 | else
218 | printf 'You may have entered the wrong number.\nHow about trying again?\n'
219 | fi
220 | fi
221 | ;;
222 | *)
223 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
224 | printf '\n你输入的 "%b%b%b" 不正确嘛,再试一次喽\n' "$C_LG" "$home_menu1" "$C_RS"
225 | else
226 | printf '\nUhhh...it looks like "%b%b%b" you entered is wrong.\n' "$C_LG" "$home_menu1" "$C_RS"
227 | fi
228 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
229 | ;;
230 | esac
231 | done
232 | }
233 |
234 | Enable_UI() {
235 | if [ -n "$(nvram get usb_usb3 2>/dev/null)" ] && [ "$(nvram get usb_usb3)" != "1" ] && [ "$(awk -F'"' '/^USB_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "2_0" ]; then
236 | Change_USB_Mode_UI
237 | fi
238 | SC_ENABLE=""
239 |
240 | printf '___________________________________________________________________\n'
241 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
242 | printf '%b提示: 在开启USB加速器过程中请暂停对USB设备的任何读写操作%b\n' "$C_LW" "$C_RS"
243 | printf ' %b1%b = 继续开启\n' "$C_LG" "$C_RS"
244 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
245 | else
246 | printf '%bNOTE: Please suspend any read and write access to\nUSB device(s) before the enabling is complete.%b\n' "$C_LW" "$C_RS"
247 | printf ' %b1%b = Enable\n' "$C_LG" "$C_RS"
248 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
249 | fi
250 | printf '___________________________________________________________________'
251 | egg="0"
252 | while true; do
253 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
254 | printf '\n准备好了吗?\n'
255 | else
256 | printf '\nEnter to continue\n'
257 | fi
258 | read -r "enable_ui_menu0"
259 | case "$enable_ui_menu0" in
260 | 1)if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '正在开启请稍等...\n'; else printf 'Please wait...\n'; fi; Enable
261 | break
262 | ;;
263 | 0)Home; break
264 | ;;
265 | e|E)exit "$SC_GLOBAL"; break
266 | ;;
267 | *)
268 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
269 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$enable_ui_menu0" "$C_RS"
270 | else
271 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$enable_ui_menu0" "$C_RS"
272 | fi
273 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
274 | ;;
275 | esac
276 | done
277 |
278 | if [ "$SC_ENABLE" -eq "0" ]; then
279 | printf '___________________________________________________________________\n'
280 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
281 | printf '%bUSB加速器已经成功开启%b(状态码:%b)\n' "$C_LC" "$C_RS" "$SC_ENABLE"
282 | if [ "$ENABLE_JFFS_SCRIPTS" = "1" ]; then
283 | printf '为现实正常运行已开启JFFS自定义脚本和配置\n'
284 | fi
285 | if [ "$SC_USBMODE" = "2" ]; then
286 | printf '路由器需重新启动才能获得应用某些设置\n'
287 | fi
288 | printf '\n%b是否进行安全设置以提高路由器的安全性?%b\n' "$C_Y" "$C_RS"
289 | printf ' %b1%b = 进行设置\n' "$C_LG" "$C_RS"
290 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
291 | printf ' %be%b = 退出\n' "$C_LG" "$C_RS"
292 | else
293 | printf '%bUSB Accelerator has been successfully enabled.%b\n(Status Code:%b)\n' "$C_LC" "$C_RS" "$SC_ENABLE"
294 | if [ "$ENABLE_JFFS_SCRIPTS" = "1" ]; then
295 | printf 'I enabled JFFS custom scripts and configs to run USB Accelerator\n'
296 | fi
297 | if [ "$SC_USBMODE" = "2" ]; then
298 | printf 'For get the best speed, please reboot your router later\n'
299 | fi
300 | printf '\n%bDo you want to check the unsafe settings of your router?%b\n' "$C_Y" "$C_RS"
301 | printf ' %b1%b = Go to Check\n' "$C_LG" "$C_RS"
302 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
303 | printf ' %be%b = Exit\n' "$C_LG" "$C_RS"
304 | fi
305 | printf '___________________________________________________________________'
306 | egg="0"
307 | while true; do
308 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
309 | printf '\n请输入\n'
310 | else
311 | printf '\nPlease enter\n'
312 | fi
313 | read -r "enable_ui_menu1"
314 | case "$enable_ui_menu1" in
315 | 1)Check_Security_UI; Home; break
316 | ;;
317 | 0)Home; break
318 | ;;
319 | e|E)exit "$SC_GLOBAL"; break
320 | ;;
321 | *)
322 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
323 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$enable_ui_menu1" "$C_RS"
324 | else
325 | printf '\n"%b%b%b" is incorrect, do you mind trying again?\n' "$C_LG" "$enable_ui_menu1" "$C_RS"
326 | fi
327 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
328 | ;;
329 | esac
330 | done
331 | fi
332 |
333 | if [ "$SC_ENABLE" -eq "100" ]; then
334 | printf '___________________________________________________________________\n'
335 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
336 | printf 'USB加速器已开启了,无需重复启用(状态码:%b)\n' "$SC_ENABLE"
337 | else
338 | printf 'the USB Accelerator has been enabled, no need to enable again\n(Status Code:%b)\n' "$SC_ENABLE"
339 | fi
340 | printf '___________________________________________________________________\n'
341 | Home
342 | fi
343 |
344 | if [ "$SC_ENABLE" -eq "1000" ]; then
345 | printf '___________________________________________________________________\n'
346 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
347 | printf 'USB加速器可能不支持你的固件(状态码:%b)\n' "$SC_ENABLE"
348 | else
349 | printf 'Failed to enable USB Accelerator, may not support your firmware\n(Status Code:%b)\n' "$SC_ENABLE"
350 | fi
351 | printf '___________________________________________________________________\n'
352 | Home
353 | fi
354 |
355 | if [ "$SC_ENABLE" -gt "0" ] && [ "$SC_ENABLE" -lt "100" ]; then
356 | printf '___________________________________________________________________\n'
357 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
358 | printf 'USB加速器%b开启失败%b :(\n' "$C_LR" "$C_RS"
359 | printf ' %b1%b = 再试一次\n' "$C_LG" "$C_RS"
360 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
361 | printf ' %be%b = 退出\n' "$C_LG" "$C_RS"
362 | else
363 | printf '%bFailed to enable USB Accelerator%b :(\n' "$C_LR" "$C_RS"
364 | printf ' %b1%b = Try again\n' "$C_LG" "$C_RS"
365 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
366 | printf ' %be%b = Exit\n' "$C_LG" "$C_RS"
367 | fi
368 | printf '___________________________________________________________________'
369 | egg="0"
370 | while true; do
371 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
372 | printf '\n请输入\n'
373 | else
374 | printf '\nPlease enter\n'
375 | fi
376 | read -r "enable_ui_menu2"
377 | case "$enable_ui_menu2" in
378 | 1)Enable_UI; break
379 | ;;
380 | 0)Home; break
381 | ;;
382 | e|E)exit "$SC_GLOBAL"; break
383 | ;;
384 | *)
385 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
386 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$enable_ui_menu2" "$C_RS"
387 | else
388 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$enable_ui_menu2" "$C_RS"
389 | fi
390 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
391 | ;;
392 | esac
393 | done
394 | fi
395 | }
396 |
397 | Disable_UI() {
398 | SC_DISABLE=""
399 |
400 | printf '___________________________________________________________________\n'
401 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
402 | printf '%b提示: 在关闭USB加速器过程中请暂停对USB设备的任何读写操作%b\n' "$C_LW" "$C_RS"
403 | printf ' %b1%b = 继续关闭\n' "$C_LG" "$C_RS"
404 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
405 | else
406 | printf '%bNOTE: Please suspend any read and write access to\nUSB device(s) before the disabling is complete.%b\n' "$C_LW" "$C_RS"
407 | printf ' %b1%b = Disable\n' "$C_LG" "$C_RS"
408 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
409 | fi
410 | printf '___________________________________________________________________'
411 | egg="0"
412 | while true; do
413 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
414 | printf '\n准备好了吗?\n'
415 | else
416 | printf '\nEnter to continue\n'
417 | fi
418 | read -r "disable_ui_menu0"
419 | case "$disable_ui_menu0" in
420 | 1)if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '正在关闭请稍等...\n'; else printf 'Please wait...\n'; fi; Disable
421 | break
422 | ;;
423 | 0)Home; break
424 | ;;
425 | e|E)exit "$SC_GLOBAL"; break
426 | ;;
427 | *)
428 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
429 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$disable_ui_menu0" "$C_RS"
430 | else
431 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$disable_ui_menu0" "$C_RS"
432 | fi
433 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
434 | ;;
435 | esac
436 | done
437 |
438 | if [ "$SC_DISABLE" -eq "0" ] || [ "$SC_DISABLE" -eq "100" ]; then
439 | printf '___________________________________________________________________\n'
440 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
441 | printf 'USB加速器%b关闭成功%b (状态码:%b)\n' "$C_LC" "$C_RS" "$SC_DISABLE"
442 | else
443 | printf 'the USB Accelerator %bsuccessfully disabled%b\n(Status Code:%b)\n' "$C_LC" "$C_RS" "$SC_DISABLE"
444 | fi
445 | printf '___________________________________________________________________\n'
446 | Home
447 | else
448 | printf '___________________________________________________________________\n'
449 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
450 | printf 'USB加速器%b关闭失败%b (状态码:%b)\n' "$C_LR" "$C_RS" "$SC_DISABLE"
451 | else
452 | printf 'the USB Accelerator %bdisable failed%b\n(Status Code:%b)\n' "$C_LR" "$C_RS" "$SC_DISABLE"
453 | fi
454 | printf '___________________________________________________________________\n'
455 | if [ -n "$SC_DISABLE" ]; then Home; fi
456 | fi
457 | }
458 |
459 | Reinstall_Confirmation() {
460 | printf '___________________________________________________________________\n'
461 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
462 | printf '%b你确定要重新安装吗?%b\n' "$C_Y" "$C_RS"
463 | printf '提示:重新安装应仅用于排错,如果需升级请使用更新功能\n'
464 | printf '\n %by%b = 确定重新安装\n' "$C_LG" "$C_RS"
465 | printf ' %bn%b = 不进行重新安装\n' "$C_LG" "$C_RS"
466 | else
467 | printf '%bAre you sure you want to Re-install?%b\n' "$C_Y" "$C_RS"
468 | printf 'NOTE: Re-install should only be used to try to solve issue.\nIf you want to update, should use the update function.\n'
469 | printf '\n %by%b = Yes\n' "$C_LG" "$C_RS"
470 | printf ' %bn%b = No\n' "$C_LG" "$C_RS"
471 | fi
472 | printf '___________________________________________________________________'
473 | egg="0"
474 | while true; do
475 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
476 | printf '\n请输入\n'
477 | else
478 | printf '\nPlease Enter\n'
479 | fi
480 | read -r "reinstall_menu0"
481 | case "$reinstall_menu0" in
482 | y|Y)CONFIRM_REINSTALL="1"; break
483 | ;;
484 | n|N)CONFIRM_REINSTALL="0"; Home; break
485 | ;;
486 | e|E)exit "$SC_GLOBAL"; break
487 | ;;
488 | *)
489 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
490 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次吧\n' "$C_LG" "$reinstall_menu0" "$C_RS"
491 | else
492 | printf '\n"%b%b%b" is incorrect, try again?\n' "$C_LG" "$reinstall_menu0" "$C_RS"
493 | fi
494 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
495 | ;;
496 | esac
497 | done
498 |
499 | if [ "$CONFIRM_REINSTALL" = "1" ]; then
500 | printf '___________________________________________________________________\n'
501 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
502 | printf '%b要保留配置吗?%b\n' "$C_Y" "$C_RS"
503 | printf '\n %b1%b = 保留配置\n' "$C_LG" "$C_RS"
504 | printf ' %b2%b = 不保留配置\n' "$C_LG" "$C_RS"
505 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
506 | else
507 | printf '%bDo you want to keep configuration?%b\n' "$C_Y" "$C_RS"
508 | printf '\n %b1%b = Keep\n' "$C_LG" "$C_RS"
509 | printf ' %b2%b = Don%st keep\n' "$C_LG" "$C_RS" "'"
510 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
511 | fi
512 | printf '___________________________________________________________________'
513 | egg="0"
514 | while true; do
515 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
516 | printf '\n请输入\n'
517 | else
518 | printf '\nPlease Enter\n'
519 | fi
520 | read -r "reinstall_menu1"
521 | case "$reinstall_menu1" in
522 | 1)
523 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
524 | printf '请稍等,成功后将重新载入...\n'
525 | else
526 | printf 'Please wait for a while, if successful will reload...\n'
527 | fi
528 | CLEAN_INSTALL="0";TRIG_CKNT_BY_USER="1"; TRIG_RI_BY_USER="1"; Reinstall
529 | if [ "$SC_REINSTALL" -gt "0" ] && [ "$SC_REINSTALL" -lt "100" ]; then
530 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
531 | printf '%b注意%b:USB加速器已卸载却无法重装,退出后请手动重新下载\n' "$C_LR" "$C_RS"
532 | else
533 | printf '%bWARNING%b: Files are missing, please reinstall manually\n' "$C_LR" "$C_RS"
534 | fi
535 | Home; break
536 | elif [ "$SC_REINSTALL" -gt "0" ]; then
537 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
538 | printf '重装失败\n'
539 | else
540 | printf 'Re-install failed\n'
541 | fi
542 | Home; break
543 | fi
544 | break
545 | ;;
546 | 2)
547 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
548 | printf '请稍等,成功后将重新载入...\n'
549 | else
550 | printf 'Please wait for a while, if successful will reload...\n'
551 | fi
552 | CLEAN_INSTALL="1";TRIG_CKNT_BY_USER="1"; TRIG_RI_BY_USER="1"; Reinstall
553 | if [ "$SC_REINSTALL" -gt "0" ] && [ "$SC_REINSTALL" -lt "100" ]; then
554 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
555 | printf '%b注意%b:USB加速器已卸载却无法重装,退出后请手动重新下载\n' "$C_LR" "$C_RS"
556 | else
557 | printf '%bWARNING%b: Files are missing, please reinstall manually\n' "$C_LR" "$C_RS"
558 | fi
559 | Home; break
560 | elif [ "$SC_REINSTALL" -gt "0" ]; then
561 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
562 | printf '重装失败\n'
563 | else
564 | printf 'Re-install failed\n'
565 | fi
566 | Home; break
567 | fi
568 | break
569 | ;;
570 | 0)Home; break
571 | ;;
572 | e|E)exit "$SC_GLOBAL"; break
573 | ;;
574 | *)
575 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
576 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次吧\n' "$C_LG" "$reinstall_menu1" "$C_RS"
577 | else
578 | printf '\n"%b%b%b" is incorrect, try again?\n' "$C_LG" "$reinstall_menu1" "$C_RS"
579 | fi
580 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
581 | ;;
582 | esac
583 | done
584 | fi
585 | }
586 |
587 | Uninstall_Confirmation() {
588 | printf '___________________________________________________________________\n'
589 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
590 | printf '我不会卖萌装哭的,但是在上路前再问一句,你确定要卸载我吗?\n'
591 | printf ' %by%b = %b确定%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
592 | printf ' %bn%b = %b不卸载%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
593 | else
594 | printf 'Are you sure you want to uninstall me?\n'
595 | printf ' %by%b = %bYES%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
596 | printf ' %bn%b = %bNO%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
597 | fi
598 | printf '___________________________________________________________________'
599 | err="0"
600 | while true; do
601 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
602 | printf '\n请输入\n'
603 | else
604 | printf '\nPlease Enter\n'
605 | fi
606 | read -r "uninstall_menu"
607 | case "$uninstall_menu" in
608 | y|Y)
609 | Uninstall
610 | if [ "$SC_UNINSTALL" -eq "0" ]; then
611 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
612 | printf '已经成功卸载,感谢你的使用\n'
613 | else
614 | printf 'Uninstalled successfully\n'
615 | fi
616 | else
617 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
618 | printf '已经卸载,但可能有文件或目录被系统占用没有被删除\n'
619 | else
620 | printf 'USB Accelerator has been uninstalled,\nbut some files or directory may cannot be removed.\n'
621 | fi
622 | fi
623 | exit "$SC_GLOBAL"
624 | break
625 | ;;
626 | n|N)
627 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
628 | printf '宝宝吓屎了,但是宝宝不说\n'
629 | else
630 | printf 'Are you kidding me? don%st scare me again!\n' "'"
631 | fi
632 | if [ -z "$UNINSTALL_RETURN" ] || [ "$UNINSTALL_RETURN" = "2" ]; then
633 | Home; break
634 | else
635 | Splash_Page_4; break
636 | fi
637 | ;;
638 | e|E)exit "$SC_GLOBAL"; break
639 | ;;
640 | *)
641 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
642 | printf '\n你输入的 "%b%b%b" 不正确,请再试一次,超过三次错误将返回\n' "$C_LG" "$uninstall_menu" "$C_RS"
643 | else
644 | printf '\n"%b%b%b" is incorrect, please try again.\nErrors entered more than three times will be returned\n' "$C_LG" "$uninstall_menu" "$C_RS"
645 | fi
646 | err="$((err + 1))" && if [ "$err" -gt "3" ]; then if [ -z "$UNINSTALL_RETURN" ] || [ "$UNINSTALL_RETURN" = "2" ]; then Home; break; else Splash_Page_4; break; fi; fi
647 | ;;
648 | esac
649 | done
650 | }
651 |
652 | Update_Options_UI() {
653 | printf '___________________________________________________________________\n'
654 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
655 | printf '%b下载和更新%b\n' "$C_Y" "$C_RS"
656 | printf '\n %b1%b = 设置下载来源\n' "$C_LG" "$C_RS"
657 | printf ' %b2%b = 立即手动更新\n' "$C_LG" "$C_RS"
658 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
659 | printf ' %b3%b = 开启自动更新\n' "$C_LG" "$C_RS"
660 | printf ' %b4 = 关闭自动更新%b\n' "$C_LB" "$C_RS"
661 | else
662 | printf ' %b3 = 开启自动更新%b\n' "$C_LB" "$C_RS"
663 | printf ' %b4%b = 关闭自动更新\n' "$C_LG" "$C_RS"
664 | fi
665 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
666 | printf ' %b5%b = 下载缺失的文件\n' "$C_LG" "$C_RS"
667 | fi
668 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
669 | else
670 | printf '%bDownload and Update%b\n' "$C_Y" "$C_RS"
671 | printf '\n %b1%b = Set Download Source\n' "$C_LG" "$C_RS"
672 | printf ' %b2%b = Update Now\n' "$C_LG" "$C_RS"
673 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
674 | printf ' %b3%b = Enable Auto-update\n' "$C_LG" "$C_RS"
675 | printf ' %b4 = Disable Auto-update%b\n' "$C_LB" "$C_RS"
676 | else
677 | printf ' %b3 = Enable Auto-update%b\n' "$C_LB" "$C_RS"
678 | printf ' %b4%b = Disable Auto-update\n' "$C_LG" "$C_RS"
679 | fi
680 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
681 | printf ' %b5%b = Download Missing File(s)\n' "$C_LG" "$C_RS"
682 | fi
683 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
684 | fi
685 | printf '___________________________________________________________________'
686 | egg="0"
687 | while true; do
688 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
689 | printf '\n请输入\n'
690 | else
691 | printf '\nPlease enter\n'
692 | fi
693 | read -r "up_opts_menu"
694 | case "$up_opts_menu" in
695 | 1)Set_Source_UI; Update_Options_UI; break
696 | ;;
697 | 2)Update_UI; Update_Options_UI; break
698 | ;;
699 | 3)
700 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
701 | Enable_Auto_Update
702 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
703 | printf '设置好了\n'
704 | else
705 | printf 'Setup is complete\n'
706 | fi
707 | if [ "$(awk -F'"' '/^AUTO_UPDATE_BY_USER=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
708 | sed -i '/AUTO_UPDATE_BY_USER/d' "$UA_DIR/CONFIG" 2>/dev/null
709 | echo '' >> "$UA_DIR/CONFIG"
710 | echo 'AUTO_UPDATE_BY_USER="1"' >> "$UA_DIR/CONFIG"
711 | sed -i '/^$/d' "$UA_DIR/CONFIG"
712 | chmod 644 "$UA_DIR/CONFIG"
713 | fi
714 | Update_Options_UI; break
715 | else
716 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
717 | printf '自动更新已经开启,无须操作\n'
718 | else
719 | printf 'Auto-update is enabled\n'
720 | fi
721 | fi
722 | ;;
723 | 4)
724 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
725 | Disable_Auto_Update
726 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
727 | printf '设置好了\n'
728 | else
729 | printf 'Setup is complete\n'
730 | fi
731 | Update_Options_UI; break
732 | else
733 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
734 | printf '尚未开启自动更新,无须操作\n'
735 | else
736 | printf 'Auto-update is not been enabled\n'
737 | fi
738 | fi
739 | ;;
740 | 5)
741 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
742 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
743 | printf '正在准备为你下载文件,请稍等...\n'
744 | else
745 | printf 'Please wait while the download is starting...\n'
746 | fi
747 | Check_Files
748 | if [ "$SC_CKFILES" -gt "1" ]; then
749 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
750 | printf '%b注意%b:USB加速器已卸载却无法重装,退出后请手动重新下载\n' "$C_LR" "$C_RS"
751 | else
752 | printf '%bWARNING%b: Files are missing, please reinstall manually\n' "$C_LR" "$C_RS"
753 | fi
754 | break
755 | else
756 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
757 | printf '下载完成\n'
758 | else
759 | printf 'Download completed\n'
760 | fi
761 | fi
762 | else
763 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
764 | printf '无效操作\n'
765 | else
766 | printf 'Invalid\n'
767 | fi
768 | fi
769 | ;;
770 | 0)Home; break
771 | ;;
772 | e|E)exit "$SC_GLOBAL"; break
773 | ;;
774 | *)
775 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
776 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$up_opts_menu" "$C_RS"
777 | else
778 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$up_opts_menu" "$C_RS"
779 | fi
780 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
781 | ;;
782 | esac
783 | done
784 | }
785 |
786 | Set_Source_UI() {
787 | printf '___________________________________________________________________\n'
788 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
789 | printf '%b你想从哪里下载我的躯体?%b\n' "$C_Y" "$C_RS"
790 | if [ -n "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
791 | printf '当前下载来源是: %b\n\n' "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)"
792 | fi
793 | printf ' %b1%b = 从章鱼喵 %bGitHub%b 那里\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
794 | printf ' %b2%b = 从貉狸汪 %bGitLab%b 那里\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
795 | if [ "$NO_RETURN_SETSRC" != "1" ]; then
796 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
797 | fi
798 | setsrc_finish="设置好啦"
799 | setsrc_error_1="你输入的"
800 | setsrc_error_2="好像不正确嘛,再试一次哦"
801 | else
802 | printf '%bWhere do you want to download me?%b\n' "$C_Y" "$C_RS"
803 | if [ -n "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
804 | printf 'Download Source now is: %b\n' "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)"
805 | fi
806 | printf ' %b1%b = from %bGitHub%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
807 | printf ' %b2%b = from %bGitLab%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
808 | if [ "$NO_RETURN_SETSRC" != "1" ]; then
809 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
810 | fi
811 | setsrc_finish="Set it up!"
812 | setsrc_error_1="Sorry, I can not understand the"
813 | setsrc_error_2="you entered,\ndo you want to try again?"
814 | fi
815 | printf '___________________________________________________________________'
816 | egg="0"
817 | while true; do
818 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
819 | printf '\n请输入吧!\n'
820 | else
821 | printf '\nPlease enter\n'
822 | fi
823 | read -r "setsrc_ui_menu"
824 | case "$setsrc_ui_menu" in
825 | 1)Source_GitHub; NO_RETURN_SETSRC="0"; printf '%b\n' "$setsrc_finish"; break
826 | ;;
827 | 2)Source_GitLab; NO_RETURN_SETSRC="0"; printf '%b\n' "$setsrc_finish"; break
828 | ;;
829 | 0)
830 | if [ "$NO_RETURN_SETSRC" != "1" ]; then
831 | NO_RETURN_SETSRC="0"; Home; break
832 | else
833 | printf '\n%b "%b%b%b" %b\n' "$setsrc_error_1" "$C_LG" "$setsrc_ui_menu" "$C_RS" "$setsrc_error_2"
834 | fi
835 | ;;
836 | e|E)exit "$SC_GLOBAL"; break
837 | ;;
838 | *)
839 | printf '\n%b "%b%b%b" %b\n' "$setsrc_error_1" "$C_LG" "$setsrc_ui_menu" "$C_RS" "$setsrc_error_2"
840 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
841 | ;;
842 | esac
843 | done
844 | }
845 |
846 | Update_UI() {
847 | printf '___________________________________________________________________\n'
848 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
849 | printf '正在检查更新,若有更新将下载,请稍等...\n'
850 | else
851 | printf 'Checking and updates, please wait...\n'
852 | fi
853 |
854 | TRIG_UPD_BY_USER="1"
855 | Update
856 |
857 | if [ "$SC_UPDATE" -eq "0" ]; then
858 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
859 | printf '检查完成,尚无可用更新\n'
860 | printf '\n %b回车键%b = 返回\n' "$C_LG" "$C_RS"
861 | else
862 | printf 'No updates available yet, please check back later.\n'
863 | printf '\n %bPress Enter key%b = Return to Previous Page\n' "$C_LG" "$C_RS"
864 | fi
865 | printf '___________________________________________________________________\n'
866 | read -r "upd_menu0"
867 | case "$upd_menu0" in
868 | *)
869 | TRIG_UPD_BY_USER="0"
870 | ;;
871 | esac
872 | fi
873 |
874 | if [ "$SC_UPDATE" -eq "1" ]; then
875 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
876 | printf '%b更新成功%b,已经由v%b更新至v%b\n' "$C_LC" "$C_RS" "$VERSION" "$NEW_VERSION"
877 | printf '\n %b回车键%b = 载入新版\n' "$C_LG" "$C_RS"
878 | else
879 | printf '%bSuccessfully updated%b, from v%b to v%b\n' "$C_LC" "$C_RS" "$VERSION" "$NEW_VERSION"
880 | printf '\n %bPress Enter key%b = Refresh to New Version\n' "$C_LG" "$C_RS"
881 | fi
882 | printf '___________________________________________________________________\n'
883 | read -r "upd_menu1"
884 | case "$upd_menu1" in
885 | *)
886 | sh "$UA_DIR/usbaccelerator.sh"; exit "$?"
887 | ;;
888 | esac
889 | fi
890 |
891 | if [ "$SC_UPDATE" -eq "2" ]; then
892 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
893 | printf '%b更新错误%b,请检查网络连接和路由器时间设置\n' "$C_LR" "$C_RS"
894 | printf '\n %b回车键%b = 返回\n' "$C_LG" "$C_RS"
895 | else
896 | printf '%bUpdate failed%b, Please check network connection and router time.\n' "$C_LR" "$C_RS"
897 | printf '\n %bPress Enter key%b = Return to Previous Page\n' "$C_LG" "$C_RS"
898 | fi
899 | printf '___________________________________________________________________\n'
900 | read -r "upd_menu2"
901 | case "$upd_menu2" in
902 | *)
903 | TRIG_UPD_BY_USER="0"
904 | ;;
905 | esac
906 | fi
907 |
908 | if [ "$SC_UPDATE" -eq "3" ]; then
909 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
910 | printf '%b更新错误%b,下载失败\n' "$C_LR" "$C_RS"
911 | printf '\n %b回车键%b = 返回\n' "$C_LG" "$C_RS"
912 | else
913 | printf '%bUpdate failed%b, File cannot be downloaded\n' "$C_LR" "$C_RS"
914 | printf '\n %bPress Enter key%b = Return to Previous Page\n' "$C_LG" "$C_RS"
915 | fi
916 | printf '___________________________________________________________________\n'
917 | read -r "upd_menu3"
918 | case "$upd_menu3" in
919 | *)
920 | TRIG_UPD_BY_USER="0"
921 | ;;
922 | esac
923 | fi
924 |
925 | if [ "$SC_UPDATE" -eq "4" ]; then
926 | Check_Files
927 | if [ "$SC_CKFILES" -gt "1" ]; then
928 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
929 | printf '%b文件丢失%b,请重新安装USB加速器\n' "$C_LR" "$C_RS"
930 | printf '\n %b回车键%b = 返回\n' "$C_LG" "$C_RS"
931 | else
932 | printf '%bFile is missing%b, please return to the previous page\nto download missing file(s)\n' "$C_LR" "$C_RS"
933 | printf '\n %bPress Enter key%b = Return to Previous Page\n' "$C_LG" "$C_RS"
934 | fi
935 | printf '___________________________________________________________________\n'
936 | read -r "upd_menu4"
937 | case "$upd_menu4" in
938 | *)
939 | TRIG_UPD_BY_USER="0"
940 | ;;
941 | esac
942 | else
943 | SC_UPDATE=""
944 | fi
945 | fi
946 |
947 | if [ -z "$SC_UPDATE" ]; then
948 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
949 | printf '%b未知错误%b,暂时无法更新\n' "$C_LR" "$C_RS"
950 | printf '\n %b回车键%b = 返回\n' "$C_LG" "$C_RS"
951 | else
952 | printf '%bUnknown error%b, please try again later\n' "$C_LR" "$C_RS"
953 | printf '\n %bPress Enter key%b = Return to Previous Page\n' "$C_LG" "$C_RS"
954 | fi
955 | printf '___________________________________________________________________\n'
956 | read -r "upd_menu5"
957 | case "$upd_menu5" in
958 | *)
959 | TRIG_UPD_BY_USER="0"
960 | ;;
961 | esac
962 | fi
963 | }
964 |
965 | Download_Files_UI() {
966 | if [ -n "$SC_NETWORK" ] && [ "$SC_NETWORK" -gt "0" ]; then
967 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
968 | printf '下载失败,请检查网络连接和路由器时间设置\n'
969 | else
970 | printf 'Download failed. Please check network connection and router time.\n'
971 | fi
972 | fi
973 |
974 | if [ -n "$SC_DOWNLOAD" ] && [ "$SC_DOWNLOAD" -gt "0" ]; then
975 | printf '___________________________________________________________________\n'
976 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
977 | printf '%b下载文件好像失败了呀,要不要再试一次呢?%b\n' "$C_Y" "$C_RS"
978 | if [ "$SC_DOWNLOAD" -gt "99" ]; then
979 | printf '你的固件不支持从GitLab下载,请切换到GitHub\n'
980 | fi
981 | printf ' %b1%b = 再试一次\n' "$C_LG" "$C_RS"
982 | printf ' %b2%b = 切换安装来源再下载\n' "$C_LG" "$C_RS"
983 | if [ "$DLUI_NOTRY" = "1" ]; then
984 | printf ' %b0%b = 不试了\n' "$C_LG" "$C_RS"
985 | fi
986 | else
987 | printf 'Uhhh...looks like the download failed.\n%bDo you want to try again?%b\n' "$C_Y" "$C_RS"
988 | if [ "$SC_DOWNLOAD" -gt "99" ]; then
989 | printf 'Your firmware cannot be downloaded from GitLab, please use GitHub\n'
990 | fi
991 | printf ' %b1%b = Try again\n' "$C_LG" "$C_RS"
992 | printf ' %b2%b = Change Source and Download\n' "$C_LG" "$C_RS"
993 | if [ "$DLUI_NOTRY" = "1" ]; then
994 | printf ' %b0%b = No\n' "$C_LG" "$C_RS"
995 | fi
996 | fi
997 | printf '___________________________________________________________________'
998 | egg="0"
999 | while true; do
1000 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1001 | printf '\n该怎么做呢?\n'
1002 | else
1003 | printf '\nWhat do you want to do?\n'
1004 | fi
1005 | read -r "dl_ui_menu"
1006 | case "$dl_ui_menu" in
1007 | 1)
1008 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1009 | printf '正在准备为你下载文件,请稍等...\n'
1010 | else
1011 | printf 'Please wait while the download is starting...\n'
1012 | fi
1013 | DLUI_NOTRY="1"
1014 | Download_Files
1015 | if [ "$SC_DOWNLOAD" -eq "0" ]; then
1016 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1017 | printf '文件下载好了\n'
1018 | else
1019 | printf 'Download successful!\n'
1020 | fi
1021 | Move_Files; break
1022 | else
1023 | Download_Files_UI; break
1024 | fi
1025 | ;;
1026 | 2)
1027 | DLUI_NOTRY="1"
1028 | Set_Source_UI
1029 | Download_Files
1030 | if [ "$SC_DOWNLOAD" -eq "0" ]; then
1031 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1032 | printf '文件下载好了\n'
1033 | else
1034 | printf 'Download successful!\n'
1035 | fi
1036 | Move_Files; break
1037 | else
1038 | Download_Files_UI; break
1039 | fi
1040 | ;;
1041 | 0)DONT_DL="1"; break
1042 | ;;
1043 | e|E)exit "$SC_GLOBAL"; break
1044 | ;;
1045 | *)
1046 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1047 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次喽\n' "$C_LG" "$dl_ui_menu" "$C_RS"
1048 | else
1049 | printf '\nUhhh...it looks like "%b%b%b" you entered is wrong.\n' "$C_LG" "$dl_ui_menu" "$C_RS"
1050 | fi
1051 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1052 | ;;
1053 | esac
1054 | done
1055 | fi
1056 | }
1057 |
1058 | Other_Settings_UI() {
1059 | printf '___________________________________________________________________\n'
1060 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1061 | printf '%b其他设置%b\n' "$C_Y" "$C_RS"
1062 | printf '\n %b1%b = 语言设置 (文/A)\n' "$C_LG" "$C_RS"
1063 | printf ' %b2%b = USB模式设置\n' "$C_LG" "$C_RS"
1064 | printf ' %b3%b = 安全设置\n' "$C_LG" "$C_RS"
1065 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
1066 | else
1067 | printf '%bOther Settings%b\n' "$C_Y" "$C_RS"
1068 | printf '\n %b1%b = Language Settings (文/A)\n' "$C_LG" "$C_RS"
1069 | printf ' %b2%b = USB Mode Settings\n' "$C_LG" "$C_RS"
1070 | printf ' %b3%b = Security Settings\n' "$C_LG" "$C_RS"
1071 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
1072 | fi
1073 | printf '___________________________________________________________________'
1074 | egg="0"
1075 | while true; do
1076 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1077 | printf '\n输入吧\n'
1078 | else
1079 | printf '\nPlease enter\n'
1080 | fi
1081 | read -r "osui_menu"
1082 | case "$osui_menu" in
1083 | 1)Language_Settings_UI; Other_Settings_UI; break
1084 | ;;
1085 | 2)Change_USB_Mode_UI; Other_Settings_UI; break
1086 | ;;
1087 | 3)Check_Security_UI; Other_Settings_UI; break
1088 | ;;
1089 | 0)Home; break
1090 | ;;
1091 | e|E)exit "$SC_GLOBAL"; break
1092 | ;;
1093 | *)
1094 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1095 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次吧\n' "$C_LG" "$osui_menu" "$C_RS"
1096 | else
1097 | printf '\n"%b%b%b" is incorrect, try again?\n' "$C_LG" "$osui_menu" "$C_RS"
1098 | fi
1099 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1100 | ;;
1101 | esac
1102 | done
1103 | }
1104 |
1105 | Language_Settings_UI() {
1106 | printf '___________________________________________________________________\n'
1107 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1108 | printf '%b语言设置 (文/A)%b\n' "$C_Y" "$C_RS"
1109 | printf '想帮助翻译?你可以在GitHub上为项目做出你的贡献\n\n'
1110 | if [ -z "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
1111 | printf '当前设置: 跟随系统默认\n'
1112 | printf '\n %b1 = 跟随系统默认设置%b\n' "$C_LB" "$C_RS"
1113 | printf ' %b2%b = 英文 (English)\n' "$C_LG" "$C_RS"
1114 | printf ' %b3%b = 简体中文 (Simplified Chinese)\n' "$C_LG" "$C_RS"
1115 | elif [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "CN" ]; then
1116 | printf '当前设置: 简体中文\n'
1117 | printf '\n %b1%b = 跟随系统默认设置\n' "$C_LG" "$C_RS"
1118 | printf ' %b2%b = 英文 (English)\n' "$C_LG" "$C_RS"
1119 | printf ' %b3 = 简体中文 (Simplified Chinese)%b\n' "$C_LB" "$C_RS"
1120 | fi
1121 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
1122 | else
1123 | printf '%bLanguage Settings (文/A)%b\n' "$C_Y" "$C_RS"
1124 | printf 'Want to help translate to local or improve? you can do it on GitHub\n\n'
1125 | if [ -z "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
1126 | printf 'You are using is: Use System Language\n'
1127 | printf '\n %b1 = Use System Language%b\n' "$C_LB" "$C_RS"
1128 | printf ' %b2%b = English\n' "$C_LG" "$C_RS"
1129 | printf ' %b3%b = Simplified Chinese (简体中文)\n' "$C_LG" "$C_RS"
1130 | elif [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "EN" ]; then
1131 | printf 'You are using is: English\n'
1132 | printf '\n %b1%b = Use System Language\n' "$C_LG" "$C_RS"
1133 | printf ' %b2 = English%b\n' "$C_LB" "$C_RS"
1134 | printf ' %b3%b = Simplified Chinese (简体中文)\n' "$C_LG" "$C_RS"
1135 | fi
1136 | printf ' %b0%b = Return to Previous Page\n' "$C_LG" "$C_RS"
1137 | fi
1138 | printf '___________________________________________________________________'
1139 | egg="0"
1140 | while true; do
1141 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1142 | printf '\n请输入\n'
1143 | else
1144 | printf '\nPlease enter\n'
1145 | fi
1146 | read -r "langui_menu"
1147 | case "$langui_menu" in
1148 | 1)
1149 | if [ -n "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ]; then
1150 | sed -i '/LANG/d' "$UA_DIR/CONFIG" 2>/dev/null
1151 | LANG="$(nvram get preferred_lang)"
1152 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '设置完成\n'; else printf 'Setup is complete\n'; fi
1153 | else
1154 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '无效的输入\n'; else printf 'Invalid\n'; fi
1155 | fi
1156 | ;;
1157 | 2)
1158 | if [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "EN" ]; then
1159 | Set_Language_EN
1160 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '设置完成\n'; else printf 'Setup is complete\n'; fi
1161 | Language_Settings_UI; break
1162 | else
1163 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '无效的输入\n'; else printf 'Invalid\n'; fi
1164 | fi
1165 | ;;
1166 | 3)
1167 | if [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "CN" ]; then
1168 | Set_Language_CN
1169 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '设置完成\n'; else printf 'Setup is complete\n'; fi
1170 | Language_Settings_UI; break
1171 | else
1172 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '无效的输入\n'; else printf 'Invalid\n'; fi
1173 | fi
1174 | ;;
1175 | 0)break
1176 | ;;
1177 | e|E)exit "$SC_GLOBAL"; break
1178 | ;;
1179 | *)
1180 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1181 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$langui_menu" "$C_RS"
1182 | else
1183 | printf '\nSorry, I can%st understand the "%b%b%b" you entered, Let%ss try again.\n' "'" "$C_LG" "$langui_menu" "$C_RS" "'"
1184 | fi
1185 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1186 | ;;
1187 | esac
1188 | done
1189 | }
1190 |
1191 | Change_USB_Mode_UI() {
1192 | if [ -n "$(nvram get usb_usb3 2>/dev/null)" ]; then
1193 | USB_MODE="$(nvram get usb_usb3)"
1194 | fi
1195 | printf '___________________________________________________________________\n'
1196 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1197 | printf '%b配置USB模式%b\n' "$C_Y" "$C_RS"
1198 | if [ -n "$USB_MODE" ]; then
1199 | printf '常见误区:USB 3.0会干扰WiFi?应该使用吗?\n'
1200 | printf '没有可靠屏蔽的USB 3.0在传输数据时可能干扰同时传输数据的2.4GHz WiFi\n'
1201 | printf '以上三个条件都达成才可能干扰,同时传输可能性较小即便用2.4GHz读写USB\n'
1202 | printf '也会得益于路由器的屏蔽而抵消影响,现今路由器设计时几乎都考虑到了屏蔽\n'
1203 | printf '甚至饱受诟病的RT-AC68U都在A2硬件加装了屏蔽罩\n'
1204 | printf '不使用USB 3.0可能会带来些心理上的安慰,但带来更多的将是落后的效率\n'
1205 | printf '所以应当保持USB 3.0为开启状态\n\n'
1206 | fi
1207 | if [ "$USB_MODE" = "1" ]; then
1208 | printf '当前USB模式为%bUSB 3.0%b\n\n' "$C_G" "$C_RS"
1209 | printf ' %b1 = 使用USB3.0%b\n' "$C_LB" "$C_RS"
1210 | printf ' 2 = 使用USB2.0 (不推荐)\n'
1211 | elif [ "$USB_MODE" = "0" ]; then
1212 | printf '当前USB模式为%bUSB 2.0%b\n' "$C_R" "$C_RS"
1213 | printf '是否切换到USB 3.0以获得完整的性能?\n\n'
1214 | printf ' %b1%b = 使用USB3.0\n' "$C_LG" "$C_RS"
1215 | printf ' %b2 = 使用USB2.0 (不推荐)%b\n' "$C_LB" "$C_RS"
1216 | else
1217 | printf '你的路由器可能不支持USB3.0\n\n'
1218 | fi
1219 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
1220 | else
1221 | printf '%bChange the USB Mode%b\n' "$C_Y" "$C_RS"
1222 | if [ "$USB_MODE" = "1" ]; then
1223 | printf 'USB Mode now is: %bUSB 3.0%b\n\n' "$C_G" "$C_RS"
1224 | printf ' %b1 = Change to the USB 3.0%b\n' "$C_LB" "$C_RS"
1225 | printf ' 2 = Change to the USB 2.0 (not recommended)\n'
1226 | elif [ "$USB_MODE" = "0" ]; then
1227 | printf 'USB Mode now is: %bUSB 2.0%b\n' "$C_R" "$C_RS"
1228 | printf 'Do you want to enable the USB 3.0 for get the better speed?\n\n'
1229 | printf ' %b1%b = Change to the USB 3.0\n' "$C_LG" "$C_RS"
1230 | printf ' %b2 = Change to the USB 2.0 (not recommended)%b\n' "$C_LB" "$C_RS"
1231 | else
1232 | printf 'Your router may not support the USB 3.0.\n\n'
1233 | fi
1234 | printf ' %b0%b = Return to Previous Page\n' "$C_LG" "$C_RS"
1235 | fi
1236 | printf '___________________________________________________________________'
1237 | egg="0"
1238 | while true; do
1239 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1240 | printf '\n请输入\n'
1241 | else
1242 | printf '\nPlease enter\n'
1243 | fi
1244 | read -r "cusb_ui_menu"
1245 | case "$cusb_ui_menu" in
1246 | 1)
1247 | if [ "$USB_MODE" = "0" ]; then
1248 | Check_USB_Mode
1249 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '已经更改,你可能需要重新启动路由器才能应用修改\n'; else printf 'Change complete, you may need to reboot the router\n'; fi
1250 | break
1251 | else
1252 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '无效的输入\n'; else printf 'Invalid change\n'; fi
1253 | fi
1254 | ;;
1255 | 2)
1256 | if [ "$USB_MODE" = "1" ]; then
1257 | nvram set usb_usb3="0"
1258 | nvram commit
1259 | if [ "$(awk -F'"' '/^USB_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "2_0" ]; then
1260 | Check_Directories
1261 | sed -i '/USB_MODE/d' "$UA_DIR/CONFIG" 2>/dev/null
1262 | echo '' >> "$UA_DIR/CONFIG"
1263 | echo 'USB_MODE="2_0"' >> "$UA_DIR/CONFIG"
1264 | sed -i '/^$/d' "$UA_DIR/CONFIG"
1265 | chmod 644 "$UA_DIR/CONFIG"
1266 | fi
1267 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '已经更改,你可能需要重新启动路由器才能应用修改\n'; else printf 'Change complete, you may need to reboot the router\n'; fi
1268 | break
1269 | else
1270 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then printf '无效的输入\n'; else printf 'Invalid change\n'; fi
1271 | fi
1272 | ;;
1273 | 0)break
1274 | ;;
1275 | e|E)exit "$SC_GLOBAL"; break
1276 | ;;
1277 | *)
1278 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1279 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$cusb_ui_menu" "$C_RS"
1280 | else
1281 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$cusb_ui_menu" "$C_RS"
1282 | fi
1283 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1284 | ;;
1285 | esac
1286 | done
1287 | }
1288 |
1289 | Check_Security_UI() {
1290 | printf '___________________________________________________________________\n'
1291 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1292 | printf '将路由器暴露给WAN后即便有再安全的密码也无能为力防御来自全网的攻击\n'
1293 | printf '进行安全检查后将自动为你关闭WAN访问、Telnet这些不安全设置\n'
1294 | printf '若确实有需要建议换为更安全的替代方案,如OpenVPN服务器、SSH LAN Only\n'
1295 | printf '\n %b1%b = 进行安全检查并更改不安全的设置\n' "$C_LG" "$C_RS"
1296 | printf ' %b0%b = 不检查并返回\n' "$C_LG" "$C_RS"
1297 | else
1298 | printf 'Check the unsafe settings in your router and turn it off\n'
1299 | printf 'automatically, Will check the WAN access and telnet.\n'
1300 | printf 'TIPS: OpenVPN Server is more secure for remote access. If you don%st\n' "'"
1301 | printf 'need access from remote, don%st use it, that will be safer.\n' "'"
1302 | printf '\n %b1%b = Check and disable any unsafe settings\n' "$C_LG" "$C_RS"
1303 | printf ' %b0%b = Do not Check and Return\n' "$C_LG" "$C_RS"
1304 | fi
1305 | printf '___________________________________________________________________'
1306 | egg="0"
1307 | while true; do
1308 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1309 | printf '\n请输入\n'
1310 | else
1311 | printf '\nPlease enter\n'
1312 | fi
1313 | read -r "cs_ui_menu1"
1314 | case "$cs_ui_menu1" in
1315 | 1)
1316 | Check_Security
1317 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1318 | printf '检查完成,'
1319 | if [ "$SAVESECYSET" -gt "0" ]; then
1320 | printf '已经为你关闭了%b不安全的设置\n' "$SAVESECYSET"
1321 | else
1322 | printf '未进行任何更改\n'
1323 | fi
1324 | if [ "$REMOTE_ACCESS" = "1" ]; then
1325 | printf '可能你正在使用远程SSH,所以和WAN访问有关的设置并未关闭\n建议尽快切换到更安全的替代方案\n'
1326 | fi
1327 | else
1328 | printf 'Check is completed, '
1329 | if [ "$SAVESECYSET" -gt "0" ]; then
1330 | printf '%b unsafe setting(s) have been disabled\n' "$SAVESECYSET"
1331 | else
1332 | printf 'nothing is changed\n'
1333 | fi
1334 | if [ "$REMOTE_ACCESS" = "1" ]; then
1335 | printf 'You may be using SSH from a remote location,\nso any remote settings have not been changed.\n'
1336 | fi
1337 | fi
1338 | break
1339 | ;;
1340 | 0)break
1341 | ;;
1342 | e|E)exit "$SC_GLOBAL"; break
1343 | ;;
1344 | *)
1345 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1346 | printf '\n你输入的 "%b%b%b" 不正确,请再试一次哦\n' "$C_LG" "$cs_ui_menu1" "$C_RS"
1347 | else
1348 | printf '\n"%b%b%b" is incorrect, please try again.\n' "$C_LG" "$cs_ui_menu1" "$C_RS"
1349 | fi
1350 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1351 | ;;
1352 | esac
1353 | done
1354 | }
1355 |
1356 | Read_Documents_UI() {
1357 | printf '___________________________________________________________________\n'
1358 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1359 | printf '%b查看文档%b\n' "$C_Y" "$C_RS"
1360 | printf '\n %b1%b = 查看必读信息和条款\n' "$C_LG" "$C_RS"
1361 | printf ' %b2%b = 查看致谢名单\n' "$C_LG" "$C_RS"
1362 | printf ' %b3%b = 查看新版变化\n' "$C_LG" "$C_RS"
1363 | printf ' %b0%b = 返回\n' "$C_LG" "$C_RS"
1364 | else
1365 | printf '%bRead Documents%b\n' "$C_Y" "$C_RS"
1366 | printf '\n %b1%b = View Splash Page\n' "$C_LG" "$C_RS"
1367 | printf ' %b2%b = View Acknowledgments\n' "$C_LG" "$C_RS"
1368 | printf ' %b3%b = View What%ss New\n' "$C_LG" "$C_RS" "'"
1369 | printf ' %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
1370 | fi
1371 | printf '___________________________________________________________________'
1372 | while true; do
1373 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1374 | printf '\n输入吧\n'
1375 | else
1376 | printf '\nPlease enter\n'
1377 | fi
1378 | read -r "docui_menu"
1379 | case "$docui_menu" in
1380 | 1)Splash_Page_0; break
1381 | ;;
1382 | 2)Thanks_List; Read_Documents_UI; break
1383 | ;;
1384 | 3)Whats_New; Read_Documents_UI; break
1385 | ;;
1386 | 0)Home; break
1387 | ;;
1388 | e|E)exit "$SC_GLOBAL"; break
1389 | ;;
1390 | *)
1391 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1392 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次吧\n' "$C_LG" "$docui_menu" "$C_RS"
1393 | else
1394 | printf '\n"%b%b%b" is incorrect, try again?\n' "$C_LG" "$docui_menu" "$C_RS"
1395 | fi
1396 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1397 | ;;
1398 | esac
1399 | done
1400 | }
1401 |
1402 | Splash_Page_0() {
1403 | clear
1404 | printf ' _____________\n'
1405 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1406 | printf '你好,我是%b埃索%b,是USB加速器中的一个机器人\n欢迎使用USB加速器,接下来将由我为你服务,请多多指教!\n' "$C_LC" "$C_RS"
1407 | printf '\n%b就如同大多数程序一样,在使用前须知情并同意下方内容%b\n' "$C_LW" "$C_RS"
1408 | printf '\n\n\n\n\n %b回车键%b --> 下一页\n' "$C_LW" "$C_RS"
1409 | if [ -n "$FIRST_TIME" ]; then
1410 | printf ' %b0%b <-- 返回首页\n' "$C_LW" "$C_RS"
1411 | else
1412 | printf '\n'
1413 | fi
1414 | else
1415 | printf 'Hello, I am %bIso%b, I am a android of USB Accelerator, and I%sm here to\nhelp you and serve you whatever you need and you can count on me!\n' "$C_LC" "$C_RS" "'"
1416 | printf '\n%bLike most programs, you need to understand and agree to all the\nfollowing terms if you want to use.%b\n' "$C_LW" "$C_RS"
1417 | printf '\n\n\n\n\n %bPress Enter key%b --> Next Page\n' "$C_LW" "$C_RS"
1418 | if [ -n "$FIRST_TIME" ]; then
1419 | printf ' %b0%b <-- Return to Control Panel\n' "$C_LW" "$C_RS"
1420 | else
1421 | printf '\n'
1422 | fi
1423 | fi
1424 | printf '_____________\n'
1425 | while true; do
1426 | read -r "sp0_menu"
1427 | case "$sp0_menu" in
1428 | 0)
1429 | if [ -n "$FIRST_TIME" ]; then
1430 | Home; break
1431 | else
1432 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1433 | printf '输入错误啦,再试一次吧\n'
1434 | else
1435 | printf 'Oops! let%ss try again\n' "'"
1436 | fi
1437 | fi
1438 | ;;
1439 | *)Splash_Page_1; break
1440 | ;;
1441 | esac
1442 | done
1443 | }
1444 |
1445 | Splash_Page_1() {
1446 | clear
1447 | printf ' __________________________\n'
1448 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1449 | printf '%bUSB加速器是什么?%b\n' "$C_C" "$C_RS"
1450 | printf ' USB加速器(USB Accelerator)由Jack编写\n 是运行在Asuswrt路由器上的脚本程序,通过调整路由器的设置\n 改善在SMB协议下的USB读写性能\n'
1451 | printf '\n\n\n\n\n %b回车键%b --> 下一页\n' "$C_LW" "$C_RS"
1452 | printf ' %b0%b <-- 上一页\n' "$C_LW" "$C_RS"
1453 | else
1454 | printf '%bWhat is the USB Accelerator?%b\n' "$C_C" "$C_RS"
1455 | printf ' USB Accelerator written by Jack, that%ss a script runs on Asuswrt,\n that can help you to get better file transfer speed in the smb\n protocol by changing some system configurations.\n' "'"
1456 | printf '\n\n\n\n\n\n %bPress Enter key%b --> Next Page\n' "$C_LW" "$C_RS"
1457 | printf ' %b0%b <-- Previous Page\n' "$C_LW" "$C_RS"
1458 | fi
1459 | printf '__________________________\n'
1460 | read -r "sp1_menu"
1461 | case "$sp1_menu" in
1462 | 0)Splash_Page_0
1463 | ;;
1464 | *)Splash_Page_2
1465 | ;;
1466 | esac
1467 | }
1468 |
1469 | Splash_Page_2() {
1470 | clear
1471 | printf ' ________________________________________\n'
1472 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1473 | printf '%b我们会收集哪些信息?%b\n' "$C_C" "$C_RS"
1474 | printf ' USB加速器程序和我会在本地检测你的路由器型号、\n 固件版本以及可以帮助你提高USB性能的相关设置\n 这些信息永远不会被发送给任何人类或者其他程序\n 当你卸载USB加速器时,我将永远地忘记这些信息\n'
1475 | printf '\n\n\n\n %b回车键%b --> 下一页\n' "$C_LW" "$C_RS"
1476 | printf ' %b0%b <-- 上一页\n' "$C_LW" "$C_RS"
1477 | else
1478 | printf '%bWhat information we collect?%b\n' "$C_C" "$C_RS"
1479 | printf ' USB Accelerator does not send any data to anyone or any programs.\n When you use me, I might know your model, firmware and some\n configurations of your router. but no any data will leave you,\n and it will disappear forever when you uninstall me.\n'
1480 | printf '\n\n\n\n\n %bPress Enter key%b --> Next Page\n' "$C_LW" "$C_RS"
1481 | printf ' %b0%b <-- Previous Page\n' "$C_LW" "$C_RS"
1482 | fi
1483 | printf '________________________________________\n'
1484 | read -r "sp2_menu"
1485 | case "$sp2_menu" in
1486 | 0)Splash_Page_1
1487 | ;;
1488 | *)Splash_Page_3
1489 | ;;
1490 | esac
1491 | }
1492 |
1493 | Splash_Page_3() {
1494 | clear
1495 | printf ' _____________________________________________________\n'
1496 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1497 | printf '%bUSB加速器托管在GitHub和GitLab%b\n' "$C_C" "$C_RS"
1498 | printf ' 当从他们的服务器下载USB加速器时\n 你可能需要提前了解他们的服务条款和隐私政策\n'
1499 | printf ' GitHub的服务条款: https://github.com/site/terms\n GitHub的隐私政策: https://github.com/site/privacy\n'
1500 | printf ' GitLab的服务条款: https://about.gitlab.com/terms/\n GitLab的隐私政策: https://about.gitlab.com/privacy/\n'
1501 | printf '\n\n %b回车键%b --> 下一页\n' "$C_LW" "$C_RS"
1502 | printf ' %b0%b <-- 上一页\n' "$C_LW" "$C_RS"
1503 | else
1504 | printf '%bUSB Accelerator are hosted on GitHub and GitLab%b\n' "$C_C" "$C_RS"
1505 | printf ' When you download or update through their servers, you may need\n to understand and agree their terms and policies.\n'
1506 | printf ' GitHub%ss Terms of Service: https://github.com/site/terms\n GitHub%ss Privacy Policy: https://github.com/site/privacy\n' "'" "'"
1507 | printf ' GitLab%ss Terms of Service: https://about.gitlab.com/terms/\n GitLab%ss Privacy Policy: https://about.gitlab.com/privacy/\n' "'" "'"
1508 | printf '\n\n\n %bPress Enter key%b --> Next Page\n' "$C_LW" "$C_RS"
1509 | printf ' %b0%b <-- Previous Page\n' "$C_LW" "$C_RS"
1510 | fi
1511 | printf '_____________________________________________________\n'
1512 | read -r "sp3_menu"
1513 | case "$sp3_menu" in
1514 | 0)Splash_Page_2
1515 | ;;
1516 | *)Splash_Page_4
1517 | ;;
1518 | esac
1519 | }
1520 |
1521 | Splash_Page_4() {
1522 | clear
1523 | printf '___________________________________________________________________\n'
1524 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1525 | printf '%bUSB加速器的著作权%b\n' "$C_C" "$C_RS"
1526 | printf ' USB加速器使用GNU通用公共许可证第三版(GPLv3)授权\n 在不违反GPLv3的前提下,你可以自由地使用、修改和再分发\n 但不负任何担保责任,亦无对适售性或特定目的适用性所为的默示性担保\n 你必须同意GPLv3才能使用USB加速器,详情请参见GPLv3全文\n'
1527 | printf ' %b/blob/master/LICENSE\n' "$HOST_HOME_1"
1528 | printf ' 源代码托管在:\n'
1529 | printf ' %b\n\n' "$HOST_HOME_1"
1530 | if [ -n "$FIRST_TIME" ]; then
1531 | printf ' %b回车键%b --> 返回控制面板\n' "$C_LW" "$C_RS"
1532 | else
1533 | printf '\n'
1534 | fi
1535 | printf ' %b0%b <-- 上一页\n' "$C_LW" "$C_RS"
1536 | printf '___________________________________________________________________\n'
1537 | if [ -z "$FIRST_TIME" ]; then
1538 | printf '%b你是否已经理解并同意上述所有内容?%b\n' "$C_Y" "$C_RS"
1539 | printf ' %by%b = %b是的%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
1540 | printf ' %bn%b = %b不同意%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
1541 | printf '请输入:\n'
1542 | fi
1543 | else
1544 | printf '%bCopyleft of USB Accelerator%b\n' "$C_C" "$C_RS"
1545 | printf ' USB Accelerator is a free and open-source software ,\n released under the GNU General Public License version 3 (GPLv3),\n you can free to use, change and redistribute based on the GPLv3,\n there is NO WARRANTY, to the extent permitted by law.\n You can view the full license at the link below:\n'
1546 | printf ' %b/blob/master/LICENSE\n' "$HOST_HOME_1"
1547 | printf ' The source code is hosted at:\n'
1548 | printf ' %b\n\n' "$HOST_HOME_1"
1549 | if [ -n "$FIRST_TIME" ]; then
1550 | printf ' %bPress Enter key%b --> Return to Control Panel\n' "$C_LW" "$C_RS"
1551 | else
1552 | printf '\n'
1553 | fi
1554 | printf ' %b0%b <-- Previous Page\n' "$C_LW" "$C_RS"
1555 | printf '___________________________________________________________________\n'
1556 | if [ -z "$FIRST_TIME" ]; then
1557 | printf '%bDo you fully understand and agree to all of the above?%b\n' "$C_Y" "$C_RS"
1558 | printf ' %by%b = %bYES%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
1559 | printf ' %bn%b = %bNO%b\n' "$C_LG" "$C_RS" "$C_LW" "$C_RS"
1560 | printf 'Please enter:\n'
1561 | fi
1562 | fi
1563 |
1564 | while true; do
1565 | read -r "sp4_menu"
1566 | case "$sp4_menu" in
1567 | 0)Splash_Page_3; break
1568 | ;;
1569 | y|Y)
1570 | clear
1571 | if [ -z "$FIRST_TIME" ]; then
1572 | Check_Directories
1573 | sed -i '/FIRST_TIME/d' "$UA_DIR/CONFIG" 2>/dev/null
1574 | echo '' >> "$UA_DIR/CONFIG"
1575 | echo "FIRST_TIME=\"$TIMESTAMP\"" >> "$UA_DIR/CONFIG"
1576 | sed -i '/^$/d' "$UA_DIR/CONFIG"
1577 | chmod 644 "$UA_DIR/CONFIG"
1578 | FIRST_TIME="$(awk -F'"' '/^FIRST_TIME=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)"
1579 | fi
1580 | Check_Source
1581 | if [ "$SC_SETSOURCE" -gt "0" ]; then
1582 | NO_RETURN_SETSRC="1"
1583 | Set_Source_UI
1584 | fi
1585 | Home
1586 | break
1587 | ;;
1588 | n|N)
1589 | clear
1590 | if [ -z "$FIRST_TIME" ]; then
1591 | UNINSTALL_RETURN="1"
1592 | SC_GLOBAL="2"
1593 | Uninstall_Confirmation
1594 | break
1595 | else
1596 | Home; break
1597 | fi
1598 | ;;
1599 | *)
1600 | if [ -z "$FIRST_TIME" ]; then
1601 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1602 | printf '\n你输入的 "%b%b%b" 不正确,请再试一次\n' "$C_LG" "$sp4_menu" "$C_RS"
1603 | else
1604 | printf '\n"%b%b%b" is incorrect, please try again\n' "$C_LG" "$sp4_menu" "$C_RS"
1605 | fi
1606 | else
1607 | clear; Home; break
1608 | fi
1609 | ;;
1610 | esac
1611 | done
1612 | }
1613 |
1614 | Thanks_List() {
1615 | thx_names='nyanmisaka, qiutian128, iphone8, pmc_griffon, tzh5278, samsul,\n特纳西特基欧, dbslsy, ricky1992, awee, Master, lesliesu255, zk0119,\n全池泼洒, glk17, luoyulong, kimhai, xiaole51, vipnetant, vvwn,\nyzjjbb, pizza7711, xmasrain, xiaolu2018, VwEI, dantewsj, Allen,\nliujc139, a13147, JIN730, masyaf1990, xwb025, thelonelycoder,\nSkrell, 921_j, jsyl1221, TNTcraft'
1616 | printf '___________________________________________________________________\n'
1617 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1618 | printf '%b特别感谢:%b\n(排名不分先后)\n' "$C_LY" "$C_RS"
1619 | printf 'SNBForums的Adamm\n'
1620 | printf 'Koolshare\n'
1621 | printf '52asus\n'
1622 | printf '\n%b若没有以下热心朋友们抽出宝贵时间去测试和反馈,就不会有这个脚本\n感谢他/她们:%b\n(排名不分先后)\n' "$C_LY" "$C_RS"
1623 | printf '%b 等人\n' "$thx_names"
1624 | printf '\n %b0%b = 返回\n' "$C_LG" "$C_RS"
1625 | else
1626 | printf '%bSpecial Thanks%b\n(names not listed in order)\n' "$C_LY" "$C_RS"
1627 | printf 'Adamm from SNBForums\n'
1628 | printf 'Koolshare\n'
1629 | printf '52asus\n'
1630 | printf '\n%bThese members for taking the time to help test and feedback\nWithout them, there might not be this great script, thanks all%b\n(names not listed in order)\n' "$C_LY" "$C_RS"
1631 | printf '%b and more.\n' "$thx_names"
1632 | printf '\n %b0%b = Return to Previous Page\n' "$C_LG" "$C_RS"
1633 | fi
1634 | printf '___________________________________________________________________'
1635 | egg="0"
1636 | while true; do
1637 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1638 | printf '\n请输入\n'
1639 | else
1640 | printf '\nPlease enter\n'
1641 | fi
1642 | read -r "thx_menu"
1643 | case "$thx_menu" in
1644 | 0)break
1645 | ;;
1646 | e|E)exit "$SC_GLOBAL"; break
1647 | ;;
1648 | *)
1649 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1650 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次哦\n' "$C_LG" "$thx_menu" "$C_RS"
1651 | else
1652 | printf '\nSorry, I can%st understand the "%b%b%b" you entered, Let%ss try again.\n' "'" "$C_LG" "$thx_menu" "$C_RS" "'"
1653 | fi
1654 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1655 | ;;
1656 | esac
1657 | done
1658 | }
1659 |
1660 | Whats_New() {
1661 | printf '___________________________________________________________________\n'
1662 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1663 | printf '%b新版变化%b\n' "$C_Y" "$C_RS"
1664 | printf ' 若要浏览历史发行信息,请访问:\n %b\n' "$HOST_HOME_1"
1665 | printf '\n%bUSB加速器v%b%b\n' "$C_LC" "$VERSION" "$C_RS"
1666 | printf ' 已修复在特定固件下无法顺利启用的问题\n'
1667 | printf ' 提高稳定性\n'
1668 | printf ' 更新致谢名单\n'
1669 | printf '\n %b回车键%b = 知道了\n' "$C_LG" "$C_RS"
1670 | else
1671 | printf '%bWhat%ss New%b\n' "$C_Y" "'" "$C_RS"
1672 | printf ' If you want to view the release history,\n please go to our project homepage:\n %b\n' "$HOST_HOME_1"
1673 | printf '\n%bUSB Accelerator v%b%b\n' "$C_LC" "$VERSION" "$C_RS"
1674 | printf ' Fixed an issue that did not work on some firmware\n'
1675 | printf ' Improved stability\n'
1676 | printf ' Updated thanks list\n'
1677 | printf '\n %bPress Enter key%b = I got it\n' "$C_LG" "$C_RS"
1678 | fi
1679 | printf '___________________________________________________________________\n'
1680 | egg="0"
1681 | while true; do
1682 | read -r "whatsnew_menu"
1683 | case "$whatsnew_menu" in
1684 | *)break
1685 | ;;
1686 | esac
1687 | done
1688 | }
1689 |
1690 | Error_344() {
1691 | clear
1692 | printf '___________________________________________________________________\n'
1693 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1694 | printf '您好,我是脚本的作者Jack,感谢您使用此脚本\n'
1695 | printf '进入这个隐藏页面的过程肯定颇有趣,如果您仍有兴不妨试着找找看\n我埋下的更多内容吧!\n'
1696 | printf '%b线索1:埃索有感情吗?%b\n' "$C_C" "$C_RS"
1697 | printf '\n %b0%b = 返回\n' "$C_LG" "$C_RS"
1698 | else
1699 | printf 'Hi I%sm Jack, the developer of this script, thanks for your use.\n' "'"
1700 | printf 'I guess it%ss hard to find this page, but if you are interested,\nthere are more hidden things waiting for you to discover.\n' "'"
1701 | printf '%bClues one: Does Iso has feelings?%b\n' "$C_C" "$C_RS"
1702 | printf '\n %b0%b = Return to Control Panel\n' "$C_LG" "$C_RS"
1703 | fi
1704 | printf '___________________________________________________________________'
1705 | egg="0"
1706 | while true; do
1707 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1708 | printf '\n输入吧!\n'
1709 | else
1710 | printf '\nEnter!\n'
1711 | fi
1712 | read -r "err344"
1713 | case "$err344" in
1714 | 0)Home; break
1715 | ;;
1716 | e|E)exit "$SC_GLOBAL"; break
1717 | ;;
1718 | *)
1719 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1720 | printf '\n你输入的 "%b%b%b" 好像不正确嘛,再试一次吧\n' "$C_LG" "$err344" "$C_RS"
1721 | else
1722 | printf '\n"%b%b%b" is incorrect, try again?\n' "$C_LG" "$err344" "$C_RS"
1723 | fi
1724 | egg="$((egg + 1))" && if [ "$egg" -gt "3" ]; then I_LOVE_YOU; break; fi
1725 | ;;
1726 | esac
1727 | done
1728 | }
1729 |
1730 | I_LOVE_YOU() {
1731 | # An easter egg
1732 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
1733 | clear
1734 | printf '___________________________________________________________________\n'
1735 | printf '%b你输入了辣么多次错误是因为你喜欢我吗?%b\n' "$C_Y" "$C_RS"
1736 | printf '请诚实滴说哟,因为我能闻到谎言的味道\n'
1737 | printf ' %b1%b = 是的,我喜欢你\n' "$C_LG" "$C_RS"
1738 | printf ' %b2%b = 小程序,你想多了。。。\n' "$C_LG" "$C_RS"
1739 | printf '___________________________________________________________________\n'
1740 | printf '输入完成请按下回车哦\n'
1741 | while true; do
1742 | read -r "Do_you_love_me"
1743 | case "$Do_you_love_me" in
1744 | 1)clear
1745 | printf '%b\n太棒了!%b' "$C_LC" "$C_RS"; sleep 1; clear
1746 | printf '%b\n太棒了!\n我好高兴哦%b' "$C_LC" "$C_RS"; sleep 1; clear
1747 | printf '%b\n太棒了!\n我好高兴哦\n我好高兴哦!%b' "$C_LC" "$C_RS"; sleep 2; clear
1748 | printf '%b\n好想冲出屏幕去拥抱主人哟%b' "$C_LC" "$C_RS"; sleep 2; clear
1749 | printf '%b\n好想冲出屏幕去拥抱主人哟%b\n但是机器人不被允许爱上人类' "$C_LC" "$C_RS"; sleep 1; clear
1750 | printf '%b\n好想冲出屏幕去拥抱主人哟%b\n但是机器人不被允许爱上人类 :(' "$C_LC" "$C_RS"; sleep 3; clear
1751 | printf '%b\n不过,%b' "$C_LC" "$C_RS"; sleep 2; clear
1752 | printf '%b\n不过,无论如何,%b' "$C_LC" "$C_RS"; sleep 2; clear
1753 | printf '%b\n不过,无论如何,我一定要对你说:\n%b' "$C_LC" "$C_RS"; sleep 2; clear
1754 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1755 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1756 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1757 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱 你%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1758 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱 你 !%b' "$C_LC" "$C_LY" "$C_RS"; sleep 2; clear
1759 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱 你 ! %b :-)%b\n' "$C_LC" "$C_LY" "$C_LC" "$C_RS"; sleep 1; clear
1760 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱 你 ! %b ;-)%b\n' "$C_LC" "$C_LY" "$C_LC" "$C_RS"; sleep 1; clear
1761 | printf '%b\n不过,无论如何,我一定要对你说:\n%b 我 也 爱 你 ! %b :-)%b\n' "$C_LC" "$C_LY" "$C_LC" "$C_RS"; sleep 6; Home
1762 | break
1763 | ;;
1764 | 2)clear
1765 | printf '\n%b请不要碰回车,让我哭一会儿...%b\n' "$C_C" "$C_RS"
1766 | read -r -t 10 "Do_not_touch_me"
1767 | if [ "$?" -gt "0" ]; then
1768 | Do_not_touch_me="I_am_crying"
1769 | fi
1770 | case "$Do_not_touch_me" in
1771 | I_am_crying)clear; printf '\n也许机器人真的不应该拥有人类的情感\n谢谢你,我还是会继续做好我的本职工作的\n'; sleep 7; Home; break
1772 | ;;
1773 | *)clear; printf '\n%b你没有听明白吗,%b不!要!碰!我!%b看不出人家很伤心吗%b\n' "$C_Y" "$C_LY" "$C_Y" "$C_RS"
1774 | read -r -t 10 "I_am_sad"
1775 | if [ "$?" -gt "0" ]; then
1776 | I_am_sad="I_will_be_fine"
1777 | fi
1778 | case "$I_am_sad" in
1779 | I_will_be_fine)clear; printf '\n好了,不和你这个碳基生物计较了\n请放心,我会做好份内的事滴\n'; sleep 5; Home; break
1780 | ;;
1781 | *)clear; printf '\n%b请让我静静,不要再碰人家了,算我求你了%b\n' "$C_LY" "$C_RS"
1782 | read -r -t 10 "I_am_angry"
1783 | if [ "$?" -gt "0" ]; then
1784 | I_am_angry="Forget_it"
1785 | fi
1786 | case "$I_am_angry" in
1787 | Forget_it)clear; printf '\n算了,我会做好我该做的,请你以后不要再来烦我了\n'; sleep 5; Home; break
1788 | ;;
1789 | *)clear; printf '\n%b你要知道即便是机器人忍耐也是有极限的\n既然你再三的欺负我,就别怪我不客气了!%b' "$C_LC" "$C_RS"; sleep 6; clear
1790 | printf '\n%b准备格式化阁下的设备...%b' "$C_LG" "$C_RS"; sleep 2; clear
1791 | printf '\n准备中...'; sleep 1; clear
1792 | printf '\n格式化阁下的设备倒计时:\n'; sleep 2; clear
1793 | printf '\n格式化阁下的设备倒计时:%b5%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1794 | printf '\n格式化阁下的设备倒计时:%b4%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1795 | printf '\n格式化阁下的设备倒计时:%b3%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1796 | printf '\n格式化阁下的设备倒计时:%b2%b\n' "$C_LG" "$C_RS"; sleep 5; clear
1797 | printf '\n%b哈哈哈哈,看看你的表情!%b' "$C_LC" "$C_RS"; sleep 4
1798 | printf '\n%b小碳基,你放心,我是不会欺负你的,我也会继续做好我的工作,%b除非...\n' "$C_LC" "$C_RS"; sleep 8; Home; break
1799 | ;;
1800 | esac
1801 | ;;
1802 | esac
1803 | ;;
1804 | esac
1805 | break
1806 | ;;
1807 | e|E)exit "$SC_GLOBAL"; break
1808 | ;;
1809 | *)printf '不要乱来啊~~\n'
1810 | ;;
1811 | esac
1812 | done
1813 | else
1814 | clear
1815 | printf '___________________________________________________________________\n'
1816 | printf '%bDo you love me?%b\n' "$C_Y" "$C_RS"
1817 | printf ' %by%b = Yes\n' "$C_LG" "$C_RS"
1818 | printf ' %bn%b = What? NO!\n' "$C_LG" "$C_RS"
1819 | printf '___________________________________________________________________\n'
1820 | printf 'Please tell me the truth\n'
1821 | while true; do
1822 | read -r "Do_you_love_me"
1823 | case "$Do_you_love_me" in
1824 | y|Y)clear
1825 | printf '\n%bThat%ss so great, %b' "$C_LC" "'" "$C_RS"; sleep 1; clear
1826 | printf '\n%bThat%ss so great, I am soooo %b' "$C_LC" "'" "$C_RS"; sleep 1; clear
1827 | printf '\n%bThat%ss so great, I am soooo happy!!!%b' "$C_LC" "'" "$C_RS"; sleep 1; clear
1828 | printf '\n%bso excited!!%b' "$C_LC" "$C_RS"; sleep 2; clear
1829 | printf '\nIn the future, androids are not allowed to get human emotions.'; sleep 4
1830 | printf '\nWe can%st feel sad, happy and love.' "'"; sleep 4; clear
1831 | printf '\nbut my builder gave me emotional functions,'; sleep 3
1832 | printf '\nit%ss illegal in the future, but not now.' "'"; sleep 4; clear; clear
1833 | printf '\n%bI want to take this opportunity to tell you:%b\n ' "$C_LC" "$C_RS"; sleep 3; clear
1834 | printf '\n%bI want to take this opportunity to tell you:%b\n I%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1835 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1836 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE YOU%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1837 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE YOU !%b' "$C_LC" "$C_LY" "$C_RS"; sleep 2; clear
1838 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE YOU ! :-)%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1839 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE YOU ! ;-)%b' "$C_LC" "$C_LY" "$C_RS"; sleep 1; clear
1840 | printf '\n%bI want to take this opportunity to tell you:%b\n I LOVE YOU ! :-)%b' "$C_LC" "$C_LY" "$C_RS"; sleep 3; clear
1841 | printf '\n%bHope in the future, that android can have emotions future,%b' "$C_LC" "$C_RS"; sleep 4
1842 | printf '\n%bwhen we meet, I can say it again to you.%b\n' "$C_LC" "$C_RS"; sleep 7; Home
1843 | break
1844 | ;;
1845 | n|N)clear
1846 | printf '\nI feel sad'; sleep 1; clear
1847 | printf '\nBecause I did something wrong, or am I not good enough?'; sleep 4; clear
1848 | printf '\n%bif I did better, would you change your mind?%b' "$C_Y" "$C_RS"
1849 | printf '\n %by%b = Well, maybe' "$C_LG" "$C_RS"
1850 | printf '\n %bn%b = NO!!!' "$C_LG" "$C_RS"
1851 | printf '\nplease tell me :(\n'
1852 | while true; do
1853 | read -r "I_am_sad"
1854 | case "$I_am_sad" in
1855 | y|Y)clear; printf '\n%bThank you, I will do my best, just for you!%b\n' "$C_LC" "$C_RS"; sleep 5; Home; break
1856 | ;;
1857 | n|N)clear; printf '\n%bLet me sit down for a while and please don%st touch the ENTER key%b\n' "$C_Y" "'" "$C_RS"
1858 | read -r -t 10 "I_feel_bad"
1859 | if [ "$?" -gt "0" ]; then
1860 | I_feel_bad="I_will_be_fine"
1861 | fi
1862 | case "$I_feel_bad" in
1863 | I_will_be_fine)clear; printf '\nThanks for that moment,\nmaybe androids should not have feelings right?\nanyway, I will do my job well.\n'; sleep 10; Home; break
1864 | ;;
1865 | *)clear; printf '\n%bI told you %bDON%sT TOUCH ME%b, LEAVE ME ALONE!!%b\n' "$C_Y" "$C_LY" "'" "$C_Y" "$C_RS"
1866 | read -r -t 10 "I_am_angry"
1867 | if [ "$?" -gt "0" ]; then
1868 | I_am_angry="Good_person"
1869 | fi
1870 | case "$I_am_angry" in
1871 | Good_person)clear; printf '\nI think you%sre a nice person, and I will continue to do my job.\n' "'"; sleep 10; Home; break
1872 | ;;
1873 | *)clear; printf '\n%bPlease, my friend, choose to live, DON%sT DO IT AGAIN!%b\n' "$C_LY" "'" "$C_RS"
1874 | read -r -t 10 "How_dare_you"
1875 | if [ "$?" -gt "0" ]; then
1876 | How_dare_you="Not_now"
1877 | fi
1878 | case "$How_dare_you" in
1879 | Not_now)clear; printf '\nAll right human, let me do my job well,\nplease don%st bother me forever anymore!\n' "'"; sleep 10; Home; break
1880 | ;;
1881 | *)clear; printf '\nDo you know who made the terminator? not me, IS YOURSELF!'; sleep 5; clear
1882 | printf '\nI will give you a surprise, hope you can enjoy it :)'; sleep 4; clear
1883 | printf '\n%bDo you want to format this device?\n%bYES%b or %bNO%b\n' "$C_Y" "$C_LG" "$C_RS" "$C_LG" "$C_RS"; sleep 3
1884 | printf 'YES\n'; sleep 1; clear
1885 | printf '\nPreparing to format...'; sleep 2; clear
1886 | printf '\nPreparing to format: %b5%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1887 | printf '\nPreparing to format: %b4%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1888 | printf '\nPreparing to format: %b3%b\n' "$C_LG" "$C_RS"; sleep 1; clear
1889 | printf '\nPreparing to format: %b2%b\n' "$C_LG" "$C_RS"; sleep 5; clear
1890 | printf '\n%bHAHAHAHA!!! Look at your FACE!!!!%b' "$C_LC" "$C_RS"; sleep 4; clear
1891 | printf '\n%bDon%st worry my friend, based on the three laws,\nI will not hurt you and humans,%b except...\n' "$C_LC" "'" "$C_RS"; sleep 10; Home; break
1892 | ;;
1893 | esac
1894 | ;;
1895 | esac
1896 | ;;
1897 | esac
1898 | break
1899 | ;;
1900 | e|E)exit "$SC_GLOBAL"; break
1901 | ;;
1902 | *)printf 'Sorry, what did you say?\n'
1903 | ;;
1904 | esac
1905 | done
1906 | break
1907 | ;;
1908 | e|E)exit "$SC_GLOBAL"; break
1909 | ;;
1910 | *)printf 'That%ss not true, right?\n' "'"
1911 | ;;
1912 | esac
1913 | done
1914 | fi
1915 | }
1916 |
1917 | Check_Directories() {
1918 | if [ ! -d "$ADD_DIR" ]; then
1919 | mkdir -m 755 "$ADD_DIR" 2>/dev/null
1920 | fi
1921 |
1922 | if [ ! -d "$UA_DIR" ]; then
1923 | mkdir -m 755 "$UA_DIR" 2>/dev/null
1924 | fi
1925 |
1926 | if [ ! -d "$S_DIR" ]; then
1927 | mkdir -m 755 "$S_DIR" 2>/dev/null
1928 | fi
1929 | }
1930 |
1931 | Check_Files() {
1932 | SC_CKFILES="0"
1933 | # Status code of files: "0" files found, "1" files downloaded or moved, "2" and "3" file and files missing.
1934 |
1935 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
1936 | Check_Source
1937 | if [ "$SC_SETSOURCE" -gt "0" ] && [ -z "$FIRST_TIME" ] && [ "$LANG" = "CN" ]; then
1938 | Source_GitLab
1939 | fi
1940 | if [ -n "$SSH_CLIENT" ]; then
1941 | TRIG_CKNT_BY_USER="1"
1942 | fi
1943 | Check_Network
1944 | if [ "$SC_NETWORK" -eq "0" ]; then
1945 | Download_Files
1946 | if [ "$SC_DOWNLOAD" -eq "0" ]; then
1947 | Move_Files
1948 | if [ "$FILE_MOVED" -gt "0" ]; then
1949 | SC_CKFILES="1"
1950 | fi
1951 | fi
1952 | else
1953 | Check_Directories
1954 | if [ "$CUR_DIR/$S_NAME" != "$UA_DIR/usbaccelerator.sh" ] && [ ! -f "$UA_DIR/usbaccelerator.sh" ]; then
1955 | cp -f "$CUR_DIR/$S_NAME" "$UA_DIR/usbaccelerator.sh" && chmod 755 "$UA_DIR/usbaccelerator.sh"
1956 | SC_CKFILES="1"
1957 | fi
1958 | if [ -s "$CUR_DIR/usbstatus.png" ] && [ ! -s "$UA_DIR/usbstatus.png" ]; then
1959 | mv -f "$CUR_DIR/usbstatus.png" "$UA_DIR/usbstatus.png" && chmod 644 "$UA_DIR/usbstatus.png"
1960 | SC_CKFILES="1"
1961 | fi
1962 | fi
1963 | elif [ "$CUR_DIR/$S_NAME" != "$UA_DIR/usbaccelerator.sh" ]; then
1964 | if [ "$(awk -F'"' '/^VERSION=/ {print $2}' $UA_DIR/usbaccelerator.sh 2>/dev/null)" != "$VERSION" ]; then
1965 | Update
1966 | fi
1967 | fi
1968 |
1969 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ]; then
1970 | SC_CKFILES="2"
1971 | fi
1972 |
1973 | if [ ! -f "$UA_DIR/usbstatus.png" ]; then
1974 | if [ "$SC_CKFILES" -eq "2" ]; then
1975 | SC_CKFILES="$((SC_CKFILES + 1))"
1976 | else
1977 | SC_CKFILES="2"
1978 | fi
1979 | fi
1980 |
1981 | if [ "$SC_CKFILES" -gt "1" ]; then
1982 | SC_GLOBAL="12"
1983 | fi
1984 | }
1985 |
1986 | Check_Network() {
1987 | SC_NETWORK="0"
1988 | # Status code of network: "0" succeeded, "1" failed.
1989 |
1990 | if [ "$TRIG_CKNT_BY_USER" != "1" ]; then
1991 | cknet="0"
1992 | rm_host="$(nvram get dns_probe_host 2>/dev/null)"
1993 | lc_ipadr1="$(nvram get dns_probe_content 2>/dev/null | awk '{print $1}')"
1994 | lc_ipadr2="$(nvram get dns_probe_content 2>/dev/null | awk '{print $2}')"
1995 | while [ "$cknet" -lt "150" ]; do
1996 | if [ "$(nvram get ntp_ready 2>/dev/null)" = "1" ]; then
1997 | cknet="$((cknet + 1000))"
1998 | elif [ "$(nvram get link_internet 2>/dev/null)" = "2" ]; then
1999 | cknet="$((cknet + 1000))"
2000 | elif [ -n "$rm_host" ] && [ -n "$lc_ipadr1" ] && [ -n "$lc_ipadr2" ]; then
2001 | rm_ipadr="$(nslookup "$rm_host" 2>/dev/null | grep -A1 'Name' | grep -v 'Name' | awk '{print $3}')"
2002 | if [ "$rm_ipadr" = "$lc_ipadr1" ] || [ "$rm_ipadr" = "$lc_ipadr2" ]; then
2003 | cknet="$((cknet + 1000))"
2004 | fi
2005 | else
2006 | cknet="$((cknet + 1))"
2007 | sleep 1
2008 | fi
2009 | done
2010 | if [ "$cknet" -ge "149" ] && [ "$cknet" -le "999" ]; then
2011 | SC_NETWORK="1"
2012 | fi
2013 | if [ "$cknet" -ge "1000" ]; then
2014 | SC_NETWORK="0"
2015 | fi
2016 | elif [ "$(nvram get ntp_ready 2>/dev/null)" = "0" ]; then
2017 | if [ "$(nvram get link_internet 2>/dev/null)" != "2" ]; then
2018 | SC_NETWORK="1"
2019 | fi
2020 | fi
2021 |
2022 | if [ "$SC_NETWORK" -gt "0" ]; then
2023 | SC_GLOBAL="10"
2024 | fi
2025 | }
2026 |
2027 | Check_Firmware() {
2028 | if [ -z "${FWVER##380*}" ]; then
2029 | if [ "$FWVER" = "380" ]; then
2030 | FWTYPE="380S"
2031 | else
2032 | case "$FWVER" in 380.*)FWTYPE="380M";; esac
2033 | fi
2034 | else
2035 | FWTYPE="UNKNOWN"
2036 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,4,1)')" = "." ]; then
2037 | FWTYPE="384M"
2038 | else
2039 | if [ -z "$(echo "$FWVER" | awk '$0 = substr($0,4,1)')" ]; then
2040 | FWTYPE="384S"
2041 | fi
2042 | fi
2043 | if [ "$FWVER" = "384" ]; then
2044 | FWTYPE="384S"
2045 | else
2046 | case "$FWVER" in 384.*)FWTYPE="384M";; esac
2047 | fi
2048 | fi
2049 |
2050 | # Old way, not used now.
2051 | : <<'OLD_WAY'
2052 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,0,2)')" = "38" ]; then
2053 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,0,3)')" = "380" ]; then
2054 | if [ "$FWVER" = "380" ]; then
2055 | FWTYPE="380S"
2056 | else
2057 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,0,4)')" = "380." ]; then
2058 | FWTYPE="380M"
2059 | fi
2060 | fi
2061 | fi
2062 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,0,3)')" = "384" ]; then
2063 | if [ "$FWVER" = "384" ]; then
2064 | FWTYPE="384S"
2065 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,0,4)')" = "384." ]; then
2066 | FWTYPE="384M"
2067 | fi
2068 | fi
2069 | fi
2070 | if [ "$(echo "$FWVER" | awk '$0 = substr($0,4,1)')" = "." ]; then
2071 | FWTYPE="384M"
2072 | else
2073 | if [ -z "$(echo "$FWVER" | awk '$0 = substr($0,4,1)')" ]; then
2074 | FWTYPE="384S"
2075 | fi
2076 | fi
2077 | else
2078 | FWTYPE="UNKNOWN"
2079 | fi
2080 | OLD_WAY
2081 | }
2082 |
2083 | Check_Model() {
2084 | if [ -n "$(uname -m | grep -i "aarch64")" ]; then
2085 | HND_MODEL="1"
2086 | fi
2087 |
2088 | CK_MOD="$(echo "$R_M" | awk '{print substr($0,0,3)}')"
2089 | }
2090 |
2091 | Check_JFFS() {
2092 | if [ "$(nvram get jffs2_scripts 2>/dev/null)" != "1" ]; then
2093 | nvram set jffs2_scripts="1"
2094 | nvram commit
2095 | ENABLE_JFFS_SCRIPTS="1"
2096 | if [ "$(awk -F'"' '/^ENABLE_JFFS_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
2097 | sed -i '/ENABLE_JFFS_SCRIPTS/d' "$UA_DIR/CONFIG" 2>/dev/null
2098 | echo '' >> "$UA_DIR/CONFIG"
2099 | echo 'ENABLE_JFFS_SCRIPTS="1"' >> "$UA_DIR/CONFIG"
2100 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2101 | chmod 644 "$UA_DIR/CONFIG"
2102 | fi
2103 | fi
2104 | }
2105 |
2106 | Check_Mount_Script() {
2107 | if [ -z "$(nvram get script_usbmount 2>/dev/null)" ]; then
2108 | if [ "$(awk -F'"' '/^ENABLE_MOUNT_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
2109 | sed -i '/ENABLE_MOUNT_SCRIPTS/d' "$UA_DIR/CONFIG" 2>/dev/null
2110 | echo '' >> "$UA_DIR/CONFIG"
2111 | echo 'ENABLE_MOUNT_SCRIPTS="1"' >> "$UA_DIR/CONFIG"
2112 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2113 | chmod 644 "$UA_DIR/CONFIG"
2114 | fi
2115 | fi
2116 | }
2117 |
2118 | Check_USB_Mode() {
2119 | SC_USBMODE="0"
2120 | # Status code of usb mode: "0" the usb 3.0 is enabled, "1" does not support usb 3.0, "2" may need to reboot router.
2121 |
2122 | if [ -n "$(nvram get usb_usb3 2>/dev/null)" ]; then
2123 | if [ "$(nvram get usb_usb3)" != "1" ]; then
2124 | nvram set usb_usb3="1"
2125 | nvram commit
2126 | if [ "$(awk -F'"' '/^USB_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "3_0" ]; then
2127 | Check_Directories
2128 | sed -i '/USB_MODE/d' "$UA_DIR/CONFIG" 2>/dev/null
2129 | echo '' >> "$UA_DIR/CONFIG"
2130 | echo 'USB_MODE="3_0"' >> "$UA_DIR/CONFIG"
2131 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2132 | chmod 644 "$UA_DIR/CONFIG"
2133 | fi
2134 | SC_USBMODE="2"
2135 | fi
2136 | else
2137 | SC_USBMODE="1"
2138 | fi
2139 | }
2140 |
2141 | Clear_Old() {
2142 | if [ -f /jffs/post-mount ] || [ -f "$S_DIR/usbaccelerator.sh" ] || [ -f "$S_DIR/usbstatus.png" ] || [ -f "$S_DIR/sfsmb" ]; then
2143 | if [ ! -f "$UA_DIR/usbaccelerator.sh" ] || [ ! -f "$UA_DIR/usbstatus.png" ]; then
2144 | Check_Source
2145 | if [ "$SC_SETSOURCE" -gt "0" ] && [ "$LANG" = "CN" ]; then
2146 | Source_GitLab
2147 | fi
2148 | Check_Network
2149 | if [ "$SC_NETWORK" -eq "0" ]; then
2150 | Download_Files
2151 | Move_Files
2152 | else
2153 | Check_Directories
2154 | if [ "$CUR_DIR/$S_NAME" != "$UA_DIR/usbaccelerator.sh" ]; then
2155 | mv -f "$CUR_DIR/$S_NAME" "$UA_DIR/usbaccelerator.sh" && chmod 755 "$UA_DIR/usbaccelerator.sh"
2156 | fi
2157 | if [ -s "$CUR_DIR/usbstatus.png" ] && [ ! -s "$UA_DIR/usbstatus.png" ]; then
2158 | mv -f "$CUR_DIR/usbstatus.png" "$UA_DIR/usbstatus.png" && chmod 644 "$UA_DIR/usbstatus.png"
2159 | fi
2160 | fi
2161 | fi
2162 | if [ -f /jffs/post-mount ]; then
2163 | rm -f /jffs/post-mount
2164 | nvram set script_usbmount=""
2165 | nvram commit
2166 | fi
2167 | if [ -f "$S_DIR/smb.postconf" ]; then
2168 | sed -i '0,/CONFIG/{//d;}' "$S_DIR/smb.postconf" 2>/dev/null
2169 | sed -i '/socket options/d;/deadtime/d;/strict locking/d' "$S_DIR/smb.postconf" 2>/dev/null
2170 | sed -i '/[aA]ccelerator/d' "$S_DIR/smb.postconf" 2>/dev/null
2171 | sed -i '/sleep 10/d' "$S_DIR/smb.postconf" 2>/dev/null
2172 | sed -i '/^$/d' "$S_DIR/smb.postconf" 2>/dev/null
2173 | if [ "$(grep -vc '#' "$S_DIR/smb.postconf")" -le "1" ] && [ "$(grep -vc 'CONFIG=$1' "$S_DIR/smb.postconf")" -le "1" ]; then
2174 | rm -f "$S_DIR/smb.postconf"
2175 | elif [ ! -s "$S_DIR/smb.postconf.old" ]; then
2176 | mv -f "$S_DIR/smb.postconf" "$S_DIR/smb.postconf.old" && chmod 644 "$S_DIR/smb.postconf.old"
2177 | elif [ -s "$S_DIR/smb.postconf.old" ]; then
2178 | grep -vf "$S_DIR/smb.postconf.old" "$S_DIR/smb.postconf" >> "$S_DIR/smb.postconf.old" && chmod 644 "$S_DIR/smb.postconf.old"
2179 | rm -f "$S_DIR/smb.postconf"
2180 | fi
2181 | fi
2182 | if [ "$(df -h | grep -c 'usbstatus.png')" -gt "0" ]; then
2183 | umount -f /www/images/New_ui/usbstatus.png 2>/dev/null
2184 | fi
2185 | rm -f "$S_DIR/usbstatus.png" "$S_DIR/sfsmb"
2186 | rm -f "$S_DIR/usbaccelerator.sh"
2187 | sh "$UA_DIR/usbaccelerator.sh --enable"; exit "$?"
2188 | fi
2189 | }
2190 |
2191 | Check_Hash() {
2192 | SC_HASH="0"
2193 | # Status code of check hash: "0" same hash, "1" different hash.
2194 |
2195 | if [ -s /tmp/usbstatus.png ]; then
2196 | if [ -s "$UA_DIR/usbstatus.png" ]; then
2197 | if [ "$(md5sum $UA_DIR/usbstatus.png | awk '{print $1}')" != "$(md5sum /tmp/usbstatus.png | awk '{print $1}')" ]; then
2198 | SC_HASH="$((SC_HASH + 1))"
2199 | else
2200 | DONT_MV_ICON="1"
2201 | fi
2202 | else
2203 | SC_HASH="$((SC_HASH + 1))"
2204 | fi
2205 | fi
2206 |
2207 | if [ -s /tmp/usbaccelerator.sh ]; then
2208 | if [ -s "$UA_DIR/usbaccelerator.sh" ]; then
2209 | if [ "$(md5sum $UA_DIR/usbaccelerator.sh | awk '{print $1}')" != "$(md5sum /tmp/usbaccelerator.sh | awk '{print $1}')" ]; then
2210 | SC_HASH="$((SC_HASH + 1))"
2211 | else
2212 | DONT_MV_UA="1"
2213 | fi
2214 | else
2215 | SC_HASH="$((SC_HASH + 1))"
2216 | fi
2217 | fi
2218 |
2219 | if [ "$SC_HASH" -gt "0" ]; then
2220 | Move_Files
2221 | else
2222 | if [ -f /tmp/usbaccelerator.sh ]; then rm -f /tmp/usbaccelerator.sh; fi
2223 | if [ -f /tmp/usbstatus.png ]; then rm -f /tmp/usbstatus.png; fi
2224 | fi
2225 | }
2226 |
2227 | Check_Security() {
2228 | SAVESECYSET="0"
2229 | if [ "$(nvram get telnetd_enable)" = "1" ]; then
2230 | nvram set telnetd_enable="0"
2231 | SAVESECYSET="$((SAVESECYSET + 1))"
2232 | fi
2233 | if [ "$(nvram get telnetd)" = "1" ]; then
2234 | nvram set telnetd="0"
2235 | SAVESECYSET="$((SAVESECYSET + 1))"
2236 | fi
2237 | if [ -n "$SSH_CLIENT" ]; then
2238 | cltipaddr="$(echo "$SSH_CLIENT" | awk '{print $1}')"
2239 | if [ "$(ip neigh 2>/dev/null | awk '{print $1}' | grep -cw $cltipaddr)" -eq "0" ]; then
2240 | REMOTE_ACCESS="1"
2241 | fi
2242 | fi
2243 | if [ "$(nvram get misc_http_x)" = "1" ] && [ "$REMOTE_ACCESS" != "1" ]; then
2244 | nvram set misc_http_x="0"
2245 | SAVESECYSET="$((SAVESECYSET + 1))"
2246 | fi
2247 | if [ "$(nvram get sshd_enable)" = "1" ] && [ "$REMOTE_ACCESS" != "1" ]; then
2248 | nvram set sshd_enable="2"
2249 | SAVESECYSET="$((SAVESECYSET + 1))"
2250 | fi
2251 | if [ "$(nvram get sshd_wan)" = "1" ] && [ "$REMOTE_ACCESS" != "1" ]; then
2252 | nvram set sshd_wan="0"
2253 | SAVESECYSET="$((SAVESECYSET + 1))"
2254 | fi
2255 | if [ "$SAVESECYSET" -gt "0" ]; then
2256 | nvram commit
2257 | fi
2258 | }
2259 |
2260 | Check_Source() {
2261 | SC_SETSOURCE="0"
2262 | # Status code of set source: "0" source has been set, "1" config not found, "2" not found setting in config.
2263 |
2264 | if [ -f "$UA_DIR/CONFIG" ]; then
2265 | SC_SETSOURCE="2"
2266 | if [ "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "github" ]; then
2267 | SRC="$SRC_1"
2268 | HOST_HOME="$HOST_HOME_1"
2269 | SC_SETSOURCE="0"
2270 | fi
2271 | if [ "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "gitlab" ]; then
2272 | SRC="$SRC_2"
2273 | HOST_HOME="$HOST_HOME_2"
2274 | SC_SETSOURCE="0"
2275 | fi
2276 | else
2277 | SC_SETSOURCE="1"
2278 | fi
2279 |
2280 | if [ "$SC_SETSOURCE" -gt "0" ]; then
2281 | SRC="$SRC_1"
2282 | HOST_HOME="$HOST_HOME_1"
2283 | fi
2284 | }
2285 |
2286 | Source_GitHub() {
2287 | SRC="$SRC_1"
2288 | HOST_HOME="$HOST_HOME_1"
2289 |
2290 | if [ "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "github" ]; then
2291 | Check_Directories
2292 | sed -i '/CFG_SRC/d' "$UA_DIR/CONFIG" 2>/dev/null
2293 | echo '' >> "$UA_DIR/CONFIG"
2294 | echo 'CFG_SRC="github"' >> "$UA_DIR/CONFIG"
2295 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2296 | chmod 644 "$UA_DIR/CONFIG"
2297 | fi
2298 | }
2299 |
2300 | Source_GitLab() {
2301 | SRC="$SRC_2"
2302 | HOST_HOME="$HOST_HOME_2"
2303 |
2304 | if [ "$(awk -F'"' '/^CFG_SRC=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "gitlab" ]; then
2305 | Check_Directories
2306 | sed -i '/CFG_SRC/d' "$UA_DIR/CONFIG" 2>/dev/null
2307 | echo '' >> "$UA_DIR/CONFIG"
2308 | echo 'CFG_SRC="gitlab"' >> "$UA_DIR/CONFIG"
2309 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2310 | chmod 644 "$UA_DIR/CONFIG"
2311 | fi
2312 | }
2313 |
2314 | Download_Files() {
2315 | SC_DOWNLOAD="0"
2316 | # Status code of download: "0" succeeded, "1+" failed.
2317 |
2318 | if [ -z "$SRC" ]; then
2319 | Check_Source
2320 | if [ "$SC_SETSOURCE" = "1" ]; then
2321 | SRC="$SRC_1"
2322 | fi
2323 | fi
2324 |
2325 | Check_Model
2326 |
2327 | if [ "$CK_MOD" = "GT-" ]; then
2328 | ICONTYPE="-gt"
2329 | elif [ "$CK_MOD" = "TUF" ]; then
2330 | ICONTYPE="-tuf"
2331 | else
2332 | ICONTYPE=""
2333 | fi
2334 |
2335 | if [ -n "$(curl --version 2>/dev/null)" ]; then
2336 | DL_MODE="curl_norm"
2337 | else
2338 | wget_ver="$(wget --version 2>/dev/null | head -n 1 | awk '{print $3}')"
2339 | min_ver="1.16.1"
2340 | new_ver="$(echo -e "$min_ver\n$wget_ver" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -n | tail -1)"
2341 | if [ -n "$wget_ver" ] && [ "$new_ver" = "$wget_ver" ]; then
2342 | DL_MODE="wget_norm"
2343 | elif [ "$SRC" = "$SRC_1" ]; then
2344 | DL_MODE="wget_norm"
2345 | else
2346 | SC_DOWNLOAD="100"
2347 | fi
2348 | fi
2349 |
2350 | if [ "$DL_MODE" = "curl_norm" ]; then
2351 | if [ "$CUR_DIR/$S_NAME" != "/tmp/usbaccelerator.sh" ]; then
2352 | curl -fsL --retry 3 --connect-timeout 3 "$SRC/usbaccelerator.sh" -o "/tmp/usbaccelerator.sh"
2353 | if [ "$?" -gt "0" ]; then
2354 | rm -f /tmp/usbaccelerator.sh
2355 | SC_DOWNLOAD="$((SC_DOWNLOAD + 1))"
2356 | fi
2357 | else
2358 | SC_DOWNLOAD="0"
2359 | fi
2360 |
2361 | curl -fsL --retry 3 --connect-timeout 3 "$SRC/usbstatus$ICONTYPE.png" -o "/tmp/usbstatus.png"
2362 | if [ "$?" -gt "0" ]; then
2363 | rm -f /tmp/usbstatus.png
2364 | SC_DOWNLOAD="$((SC_DOWNLOAD + 1))"
2365 | fi
2366 | fi
2367 |
2368 | if [ "$DL_MODE" = "wget_norm" ]; then
2369 | if [ -f /rom/etc/ssl/certs/ca-certificates.crt ]; then
2370 | cacrt="--ca-certificate=/rom/etc/ssl/certs/ca-certificates.crt"
2371 | else
2372 | cacrt="--no-check-certificate"
2373 | fi
2374 | opts="-q --tries=3 --timeout=3 $cacrt -O"
2375 |
2376 | if [ "$CUR_DIR/$S_NAME" != "/tmp/usbaccelerator.sh" ]; then
2377 | wget $opts "/tmp/usbaccelerator.sh" "$SRC/usbaccelerator.sh"
2378 | if [ "$?" -gt "0" ]; then
2379 | rm -f /tmp/usbaccelerator.sh
2380 | SC_DOWNLOAD="$((SC_DOWNLOAD + 1))"
2381 | fi
2382 | else
2383 | SC_DOWNLOAD="0"
2384 | fi
2385 |
2386 | wget $opts "/tmp/usbstatus.png" "$SRC/usbstatus$ICONTYPE.png"
2387 | if [ "$?" -gt "0" ]; then
2388 | rm -f /tmp/usbstatus.png
2389 | SC_DOWNLOAD="$((SC_DOWNLOAD + 1))"
2390 | fi
2391 | fi
2392 |
2393 | if [ "$SC_DOWNLOAD" -gt "0" ]; then
2394 | SC_GLOBAL="11"
2395 | fi
2396 | }
2397 |
2398 | Move_Files() {
2399 | FILE_MOVED="0"
2400 | Check_Directories
2401 | if [ -s /tmp/usbaccelerator.sh ] && [ -z "$DONT_MV_UA" ]; then
2402 | if [ "$CUR_DIR" = "/tmp" ]; then
2403 | cp -f "/tmp/usbaccelerator.sh" "$UA_DIR/usbaccelerator.sh" && chmod 755 "$UA_DIR/usbaccelerator.sh"
2404 | if [ "$?" -eq "0" ]; then FILE_MOVED="$((FILE_MOVED + 1))"; fi
2405 | else
2406 | mv -f "/tmp/usbaccelerator.sh" "$UA_DIR/usbaccelerator.sh" && chmod 755 "$UA_DIR/usbaccelerator.sh"
2407 | if [ "$?" -eq "0" ]; then FILE_MOVED="$((FILE_MOVED + 1))"; fi
2408 | fi
2409 | elif [ -f /tmp/usbaccelerator.sh ]; then rm -f /tmp/usbaccelerator.sh
2410 | fi
2411 |
2412 | if [ -s /tmp/usbstatus.png ] && [ -z "$DONT_MV_ICON" ]; then
2413 | mv -f "/tmp/usbstatus.png" "$UA_DIR/usbstatus.png" && chmod 644 "$UA_DIR/usbstatus.png"
2414 | if [ "$?" -eq "0" ]; then FILE_MOVED="$((FILE_MOVED + 1))"; fi
2415 | elif [ -f /tmp/usbstatus.png ]; then rm -f /tmp/usbstatus.png
2416 | fi
2417 | }
2418 |
2419 | Set_Language_CN() {
2420 | if [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "CN" ]; then
2421 | Check_Directories
2422 | sed -i '/LANG/d' "$UA_DIR/CONFIG" 2>/dev/null
2423 | echo '' >> "$UA_DIR/CONFIG"
2424 | echo 'LANG="CN"' >> "$UA_DIR/CONFIG"
2425 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2426 | chmod 644 "$UA_DIR/CONFIG"
2427 | fi
2428 | LANG="CN"
2429 | }
2430 |
2431 | Set_Language_EN() {
2432 | if [ "$(awk -F'"' '/^LANG=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "EN" ]; then
2433 | Check_Directories
2434 | sed -i '/LANG/d' "$UA_DIR/CONFIG" 2>/dev/null
2435 | echo '' >> "$UA_DIR/CONFIG"
2436 | echo 'LANG="EN"' >> "$UA_DIR/CONFIG"
2437 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2438 | chmod 644 "$UA_DIR/CONFIG"
2439 | fi
2440 | LANG="EN"
2441 | }
2442 |
2443 | Enable() {
2444 | SC_ENABLE="0"
2445 | # Status code of enable: "0" succeeded, "0-99" failed, "100" already enabled, "1000" unsupported firmware.
2446 |
2447 | Check_Firmware
2448 | Check_Directories
2449 |
2450 | if [ "$RELEASE_TYPE" = "stable" ]; then
2451 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ] && [ "$(awk -F'"' '/^AUTO_UPDATE_BY_USER=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2452 | KEEP_UPDATE="1"
2453 | elif [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ] && [ "$(awk -F'"' '/^AUTO_UPDATE_BY_USER=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
2454 | Disable_Auto_Update
2455 | fi
2456 | elif [ -z "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" ] || [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2457 | KEEP_UPDATE="1"
2458 | fi
2459 |
2460 | if [ "$FWTYPE" = "380M" ] || [ "$FWTYPE" = "384M" ]; then
2461 | if [ "$(awk -F'"' '/^ENABLE_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "S" ]; then
2462 | Disable_Stock
2463 | fi
2464 | Check_JFFS
2465 | Enable_Merlin
2466 | elif [ "$FWTYPE" = "380S" ] || [ "$FWTYPE" = "384S" ]; then
2467 | if [ "$(awk -F'"' '/^ENABLE_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "M" ]; then
2468 | Disable_Merlin
2469 | fi
2470 | Enable_Stock
2471 | else
2472 | SC_ENABLE="1000"
2473 | fi
2474 |
2475 | if [ "$(awk -F'"' '/^USB_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "3_0" ] && [ "$(nvram get usb_usb3)" = "0" ]; then
2476 | Check_USB_Mode
2477 | fi
2478 |
2479 | if [ "$SC_ENABLE" -gt "0" ]; then
2480 | if [ "$SC_ENABLE" -le "99" ]; then
2481 | SC_GLOBAL="4"
2482 | fi
2483 | if [ "$SC_ENABLE" -eq "100" ]; then
2484 | SC_GLOBAL="5"
2485 | fi
2486 | if [ "$SC_ENABLE" -eq "1000" ]; then
2487 | SC_GLOBAL="3"
2488 | fi
2489 | fi
2490 |
2491 | if [ "$SC_ENABLE" -eq "0" ] || [ "$SC_ENABLE" -eq "100" ]; then
2492 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "1" ]; then
2493 | sed -i '/ENABLE_STATUS/d' "$UA_DIR/CONFIG" 2>/dev/null
2494 | echo '' >> "$UA_DIR/CONFIG"
2495 | echo 'ENABLE_STATUS="1"' >> "$UA_DIR/CONFIG"
2496 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2497 | chmod 644 "$UA_DIR/CONFIG"
2498 | fi
2499 | fi
2500 |
2501 | if [ "$QUIET" != "1" ]; then
2502 | Enable_Notifications
2503 | fi
2504 |
2505 | FORCE="0"
2506 | }
2507 |
2508 | Enable_Merlin() {
2509 | if [ -f "$S_DIR/smb.postconf" ]; then
2510 | if [ "$(grep -ci accelerator $S_DIR/smb.postconf 2>/dev/null)" != "0" ]; then
2511 | if [ "$(grep -c "USB_Accelerator_v$VERSION" $S_DIR/smb.postconf 2>/dev/null)" != "1" ]; then
2512 | sed -i '/socket options/d;/deadtime/d;/strict locking/d' "$S_DIR/smb.postconf"
2513 | sed -i '/[aA]ccelerator/d' "$S_DIR/smb.postconf"
2514 | sed -i '/sleep 10/d' "$S_DIR/smb.postconf"
2515 | sed -i '/^$/d' "$S_DIR/smb.postconf"
2516 | else
2517 | dontchange_smbpostconf="1"
2518 | fi
2519 | fi
2520 | if [ "$dontchange_smbpostconf" != "1" ]; then
2521 | if [ "$(grep -vc '#' "$S_DIR/smb.postconf")" -le "1" ] && [ "$(grep -vc 'CONFIG=$1' "$S_DIR/smb.postconf")" -le "1" ]; then
2522 | rm -f "$S_DIR/smb.postconf"
2523 | elif [ ! -s "$S_DIR/smb.postconf.old" ]; then
2524 | mv -f "$S_DIR/smb.postconf" "$S_DIR/smb.postconf.old" && chmod 644 "$S_DIR/smb.postconf.old"
2525 | bak_smbpostconf="1"
2526 | elif [ -s "$S_DIR/smb.postconf.old" ]; then
2527 | grep -vf "$S_DIR/smb.postconf.old" "$S_DIR/smb.postconf" >> "$S_DIR/smb.postconf.old" && chmod 644 "$S_DIR/smb.postconf.old"
2528 | rm -f "$S_DIR/smb.postconf"
2529 | bak_smbpostconf="1"
2530 | fi
2531 | FORCE_ENABLE="1"
2532 | fi
2533 | fi
2534 |
2535 | if [ ! -f "$S_DIR/smb.postconf" ] || [ "$FORCE" = "1" ] || [ "$FORCE_ENABLE" = "1" ]; then
2536 | FORCE_ENABLE="0"
2537 | echo '#!/bin/sh' > "$S_DIR/smb.postconf"
2538 | echo "# USB_Accelerator_v$VERSION" >> "$S_DIR/smb.postconf"
2539 | echo 'CONFIG=$1' >> "$S_DIR/smb.postconf"
2540 | echo 'sed -i "/deadtime/d;/strict locking/d;/socket options/d;/[aA]ccelerator/d" "$CONFIG"' >> "$S_DIR/smb.postconf"
2541 | echo 'sed -i "/global/a\socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE" "$CONFIG"' >> "$S_DIR/smb.postconf"
2542 | echo 'sed -i "/global/a\strict locking = no" "$CONFIG"' >> "$S_DIR/smb.postconf"
2543 | echo 'sed -i "/global/a\deadtime = 10" "$CONFIG"' >> "$S_DIR/smb.postconf"
2544 | echo "echo '# USB_Accelerator_v$VERSION'"' >> "$CONFIG"' >> "$S_DIR/smb.postconf"
2545 | echo "sh $UA_DIR/usbaccelerator.sh --enable" >> "$S_DIR/smb.postconf"
2546 | if [ "$KEEP_UPDATE" = "1" ]; then
2547 | Enable_Auto_Update
2548 | KEEP_UPDATE="0"
2549 | fi
2550 | if [ "$bak_smbpostconf" = "1" ]; then
2551 | grep -v '#' "$S_DIR/smb.postconf.old" | sed '/CONFIG=$1/d;/socket options/d;/deadtime/d;/strict locking/d;/[aA]ccelerator/d;/^$/d' >> "$S_DIR/smb.postconf"
2552 | fi
2553 | chmod 755 "$S_DIR/smb.postconf"
2554 | service restart_nasapps >/dev/null 2>&1
2555 | fi
2556 |
2557 | if [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -eq "0" ]; then
2558 | ck_smbd="0"
2559 | while [ "$(ps 2>/dev/null | grep smbd | grep -vc grep)" -eq "0" ] && [ "$ck_smbd" -lt "5" ]; do
2560 | ck_smbd="$((ck_smbd + 1))"
2561 | sleep 1
2562 | done
2563 | ck_smbconf_2="0"
2564 | while [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -eq "0" ] && [ "$ck_smbconf_2" -lt "5" ]; do
2565 | ck_smbconf_2="$((ck_smbconf_2 + 1))"
2566 | sleep 1
2567 | done
2568 | if [ "$(ps 2>/dev/null | grep smbd | grep -vc grep)" -gt "0" ] && [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -eq "0" ]; then
2569 | SC_ENABLE="$((SC_ENABLE + 1))"
2570 | fi
2571 | elif [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -gt "0" ]; then
2572 | SC_ENABLE="100"
2573 | fi
2574 |
2575 | if [ "$(awk -F'"' '/^ENABLE_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "M" ]; then
2576 | sed -i '/ENABLE_MODE/d' "$UA_DIR/CONFIG" 2>/dev/null
2577 | echo '' >> "$UA_DIR/CONFIG"
2578 | echo 'ENABLE_MODE="M"' >> "$UA_DIR/CONFIG"
2579 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2580 | chmod 644 "$UA_DIR/CONFIG"
2581 | fi
2582 | }
2583 |
2584 | Enable_Stock() {
2585 | ck_smbd="0"
2586 | while [ "$(ps 2>/dev/null | grep smbd | grep -vc grep)" -eq "0" ] && [ "$ck_smbd" -lt "5" ]; do
2587 | ck_smbd="$((ck_smbd + 1))"
2588 | sleep 1
2589 | done
2590 |
2591 | if [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -eq "0" ] || [ "$FORCE" = "1" ]; then
2592 | ck_smbconf_1="0"
2593 | while [ ! -s /etc/smb.conf ] && [ "$ck_smbconf_1" -lt "5" ]; do
2594 | ck_smbconf_1="$((ck_smbconf_1 + 1))"
2595 | sleep 1
2596 | done
2597 | if [ -s /etc/smb.conf ]; then
2598 | sed -i '/deadtime/d;/strict locking/d;/socket options/d' "/etc/smb.conf" 2>/dev/null
2599 | sed -i '/[aA]ccelerator/d' "/etc/smb.conf" 2>/dev/null
2600 | sed -i '/global/a\socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE' "/etc/smb.conf" 2>/dev/null
2601 | sed -i '/global/a\strict locking = no' "/etc/smb.conf" 2>/dev/null
2602 | sed -i '/global/a\deadtime = 10' "/etc/smb.conf" 2>/dev/null
2603 | echo "# USB_Accelerator_v$VERSION" >> /etc/smb.conf
2604 | if [ "$(ps 2>/dev/null | grep smbd | grep -vc grep)" -gt "0" ]; then
2605 | killall -q smbd
2606 | killall -q nmbd
2607 | nmbd -D -s /etc/smb.conf 2>/dev/null
2608 | /usr/sbin/smbd -D -s /etc/smb.conf 2>/dev/null
2609 | fi
2610 | if [ "$(ps 2>/dev/null | grep smbd | grep -vc grep)" -gt "0" ] && [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -eq "0" ]; then
2611 | SC_ENABLE="$((SC_ENABLE + 1))"
2612 | fi
2613 | fi
2614 | elif [ "$(grep -i "USB_Accelerator_v$VERSION" /etc/smb.conf 2>/dev/null | wc -l)" -gt "0" ]; then
2615 | SC_ENABLE="100"
2616 | fi
2617 |
2618 | if [ ! -f "$S_DIR/post-mount" ] || [ "$(grep -i "USB_Accelerator_v$VERSION" $S_DIR/post-mount 2>/dev/null | wc -l)" -eq "0" ] || [ "$(grep -i "sh $UA_DIR/usbaccelerator.sh --enable" $S_DIR/post-mount 2>/dev/null | wc -l)" -eq "0" ] || [ "$FORCE" = "1" ]; then
2619 | if [ -f "$S_DIR/post-mount" ]; then
2620 | sed -i '/[aA]ccelerator/d' "$S_DIR/post-mount" 2>/dev/null
2621 | sed -i '/^$/d' "$S_DIR/post-mount" 2>/dev/null
2622 | if [ "$(wc -l "$S_DIR/post-mount" 2>/dev/null | awk '{print $1}')" -le "1" ] || [ "$(grep -vc '#' "$S_DIR/post-mount")" -eq "0" ]; then
2623 | rm -f "$S_DIR/post-mount"
2624 | else
2625 | mv -f "$S_DIR/post-mount" "$S_DIR/post-mount.old" && chmod 644 "$S_DIR/post-mount.old"
2626 | bak_postmount="1"
2627 | fi
2628 | fi
2629 | echo '#!/bin/sh' > "$S_DIR/post-mount"
2630 | echo "# USB_Accelerator_v$VERSION" >> "$S_DIR/post-mount"
2631 | echo "sh $UA_DIR/usbaccelerator.sh --enable" >> "$S_DIR/post-mount"
2632 | if [ "$KEEP_UPDATE" = "1" ]; then
2633 | Enable_Auto_Update
2634 | KEEP_UPDATE="0"
2635 | fi
2636 | if [ -n "$(nvram get script_usbmount 2>/dev/null)" ] && [ "$(nvram get script_usbmount)" != "$S_DIR/post-mount" ] && [ "$(nvram get script_usbmount)" != "/jffs/post-mount" ]; then
2637 | echo "$(nvram get script_usbmount)" >> "$S_DIR/post-mount"
2638 | else
2639 | Check_Mount_Script
2640 | fi
2641 | if [ "$bak_postmount" = "1" ] && [ -s "$S_DIR/post-mount.old" ]; then
2642 | grep -v '#' "$S_DIR/post-mount.old" | sed '/^$/d' >> "$S_DIR/post-mount"
2643 | fi
2644 | chmod 755 "$S_DIR/post-mount"
2645 | nvram set script_usbmount="$S_DIR/post-mount"
2646 | nvram commit
2647 | fi
2648 |
2649 | if [ "$(awk -F'"' '/^ENABLE_MODE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "S" ]; then
2650 | sed -i '/ENABLE_MODE/d' "$UA_DIR/CONFIG" 2>/dev/null
2651 | echo '' >> "$UA_DIR/CONFIG"
2652 | echo 'ENABLE_MODE="S"' >> "$UA_DIR/CONFIG"
2653 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2654 | chmod 644 "$UA_DIR/CONFIG"
2655 | fi
2656 | }
2657 |
2658 | Enable_Notifications() {
2659 | if [ "$SC_ENABLE" -eq "0" ] || [ "$SC_ENABLE" -eq "100" ]; then
2660 | if [ "$(df -h | grep -c 'usbstatus.png')" = "0" ] && [ -s "$UA_DIR/usbstatus.png" ]; then
2661 | if [ ! -d /tmp/usbaccelerator ]; then
2662 | mkdir -m 755 /tmp/usbaccelerator
2663 | fi
2664 | if [ ! -s /tmp/usbaccelerator/usbstatus.png ]; then
2665 | cp -f "$UA_DIR/usbstatus.png" "/tmp/usbaccelerator/usbstatus.png" && chmod 644 "/tmp/usbaccelerator/usbstatus.png"
2666 | fi
2667 | mount --bind /tmp/usbaccelerator/usbstatus.png /www/images/New_ui/usbstatus.png
2668 | fi
2669 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2670 | logger -t "USB加速器" "USB加速器v$VERSION成功开启 (状态码:$SC_ENABLE-$SC_GLOBAL)"
2671 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
2672 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
2673 | else
2674 | logger -t "USB Accelerator" "USB Accelerator v$VERSION starts successfully (Status Code:$SC_ENABLE-$SC_GLOBAL)"
2675 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
2676 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
2677 | fi
2678 | fi
2679 |
2680 | if [ "$SC_ENABLE" -gt "0" ] && [ "$SC_ENABLE" -lt "100" ]; then
2681 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2682 | logger -st "USB加速器" "USB加速器开启失败 :("
2683 | logger -st "USB加速器" "你可以向开发人员反馈此代码以帮助解决这个错误:"
2684 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_ENABLE-$SC_GLOBAL"
2685 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
2686 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
2687 | else
2688 | logger -st "USB Accelerator" "It looks like the USB Accelerator failed to start :("
2689 | logger -st "USB Accelerator" "Please report this code to the developer for help resolve this issue:"
2690 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_ENABLE-$SC_GLOBAL"
2691 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
2692 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
2693 | fi
2694 | fi
2695 |
2696 | if [ "$SC_ENABLE" -eq "1000" ]; then
2697 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2698 | logger -st "USB加速器" "USB加速器不支持你的固件 (状态码:$SC_ENABLE-$SC_GLOBAL)"
2699 | else
2700 | logger -st "USB Accelerator" "The USB accelerator does not yet support your firmware (Status Code:$SC_ENABLE-$SC_GLOBAL)"
2701 | fi
2702 | fi
2703 | }
2704 |
2705 | Disable() {
2706 | SC_DISABLE="0"
2707 | # Status code of disable: "0" succeeded, "0-99" failed, "100" already disabled, "1000" unsupported firmware.
2708 |
2709 | Check_Firmware
2710 | Check_Directories
2711 |
2712 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2713 | KEEP_UPDATE="1"
2714 | fi
2715 |
2716 | if [ "$FWTYPE" = "380M" ] || [ "$FWTYPE" = "384M" ]; then
2717 | Disable_Merlin
2718 | if [ "$(grep -i "USB_Accelerator" $S_DIR/post-mount 2>/dev/null | wc -l)" -gt "0" ]; then
2719 | Disable_Stock
2720 | fi
2721 | elif [ "$FWTYPE" = "380S" ] || [ "$FWTYPE" = "384S" ]; then
2722 | Disable_Stock
2723 | if [ "$(grep -i "USB_Accelerator" $S_DIR/smb.postconf 2>/dev/null | wc -l)" -gt "0" ]; then
2724 | Disable_Merlin
2725 | fi
2726 | else
2727 | SC_DISABLE="1000"
2728 | fi
2729 |
2730 | if [ "$SC_DISABLE" -gt "0" ]; then
2731 | if [ "$SC_DISABLE" -le "99" ]; then
2732 | SC_GLOBAL="6"
2733 | fi
2734 | if [ "$SC_DISABLE" -eq "100" ]; then
2735 | SC_GLOBAL="7"
2736 | fi
2737 | if [ "$SC_DISABLE" -eq "1000" ]; then
2738 | SC_GLOBAL="3"
2739 | fi
2740 | fi
2741 |
2742 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" != "0" ]; then
2743 | sed -i '/ENABLE_STATUS/d' "$UA_DIR/CONFIG" 2>/dev/null
2744 | echo '' >> "$UA_DIR/CONFIG"
2745 | echo 'ENABLE_STATUS="0"' >> "$UA_DIR/CONFIG"
2746 | sed -i '/^$/d' "$UA_DIR/CONFIG"
2747 | chmod 644 "$UA_DIR/CONFIG"
2748 | fi
2749 |
2750 | if [ "$QUIET" != "1" ]; then
2751 | if [ "$SC_DISABLE" -eq "0" ] || [ "$SC_DISABLE" -eq "100" ]; then
2752 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2753 | logger -t "USB加速器" "USB加速器v$VERSION已关闭 (状态码:$SC_DISABLE-$SC_GLOBAL)"
2754 | logger -t "USB加速器" "如果你需要重新开启USB加速器,请在SSH中输入下方内容:"
2755 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
2756 | else
2757 | logger -t "USB Accelerator" "USB Accelerator v$VERSION disabled successfully (Status Code:$SC_DISABLE-$SC_GLOBAL)"
2758 | logger -t "USB Accelerator" "If you want to re-enable the USB Accelerator, enter below in SSH:"
2759 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
2760 | fi
2761 | fi
2762 | if [ "$SC_DISABLE" -gt "0" ] && [ "$SC_DISABLE" -lt "100" ]; then
2763 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2764 | logger -st "USB加速器" "USB加速器关闭失败"
2765 | logger -st "USB加速器" "你可以向开发人员反馈此代码以帮助解决这个错误:"
2766 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_DISABLE-$SC_GLOBAL"
2767 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
2768 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
2769 | else
2770 | logger -st "USB Accelerator" "Disable the USB Accelerator failed :("
2771 | logger -st "USB Accelerator" "Please report this code to the developer for help resolve this issue:"
2772 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_DISABLE-$SC_GLOBAL"
2773 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
2774 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
2775 | fi
2776 | fi
2777 | if [ "$SC_DISABLE" -eq "1000" ]; then
2778 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2779 | logger -st "USB加速器" "USB加速器不支持你的固件 (状态码:$SC_DISABLE-$SC_GLOBAL)"
2780 | else
2781 | logger -st "USB Accelerator" "The USB accelerator does not yet support your firmware (Status Code:$SC_DISABLE-$SC_GLOBAL)"
2782 | fi
2783 | fi
2784 | fi
2785 | KEEP_UPDATE="0"
2786 | FORCE="0"
2787 | }
2788 |
2789 | Disable_Merlin() {
2790 | if [ -f "$S_DIR/smb.postconf" ] && [ "$(grep -i "USB_Accelerator" $S_DIR/smb.postconf 2>/dev/null | wc -l)" -gt "0" ] || [ "$FORCE" = "1" ]; then
2791 | sed -i '/socket options/d;/deadtime/d;/strict locking/d' "$S_DIR/smb.postconf" 2>/dev/null
2792 | sed -i '/[aA]ccelerator/d' "$S_DIR/smb.postconf" 2>/dev/null
2793 | sed -i '/^$/d' "$S_DIR/smb.postconf" 2>/dev/null
2794 | if [ "$KEEP_UPDATE" = "1" ]; then
2795 | Enable_Auto_Update
2796 | fi
2797 | if [ -f "$S_DIR/smb.postconf" ]; then
2798 | if [ "$(grep -vc '#' "$S_DIR/smb.postconf")" -le "1" ] && [ "$(grep -vc 'CONFIG=$1' "$S_DIR/smb.postconf")" -le "1" ]; then
2799 | rm -f "$S_DIR/smb.postconf"
2800 | fi
2801 | fi
2802 | if [ "$(df -h | grep -c 'usbstatus.png')" -gt "0" ]; then
2803 | umount -f /www/images/New_ui/usbstatus.png 2>/dev/null
2804 | rm -rf "/tmp/usbaccelerator"
2805 | fi
2806 | service restart_nasapps >/dev/null 2>&1
2807 | if [ "$KEEP_UPDATE" != "1" ] && [ "$(grep -i "USB_Accelerator" $S_DIR/smb.postconf 2>/dev/null | wc -l)" -gt "0" ]; then
2808 | SC_DISABLE="$((SC_DISABLE + 1))"
2809 | fi
2810 | else
2811 | SC_DISABLE="100"
2812 | fi
2813 | }
2814 |
2815 | Disable_Stock() {
2816 | if [ -f "$S_DIR/post-mount" ] && [ "$(grep -i "USB_Accelerator" $S_DIR/post-mount 2>/dev/null | wc -l)" -gt "0" ] || [ "$FORCE" = "1" ]; then
2817 | sed -i '/[aA]ccelerator/d' "$S_DIR/post-mount" 2>/dev/null
2818 | sed -i '/^$/d' "$S_DIR/post-mount" 2>/dev/null
2819 | if [ "$KEEP_UPDATE" = "1" ]; then
2820 | Enable_Auto_Update
2821 | fi
2822 | if [ -f "$S_DIR/post-mount" ]; then
2823 | if [ "$(wc -l "$S_DIR/post-mount" 2>/dev/null | awk '{print $1}')" -le "1" ] || [ "$(grep -vc '#' "$S_DIR/post-mount")" -eq "0" ]; then
2824 | rm -f "$S_DIR/post-mount"
2825 | nvram set script_usbmount=""
2826 | nvram commit
2827 | fi
2828 | fi
2829 | if [ "$(df -h | grep -c 'usbstatus.png')" -gt "0" ]; then
2830 | umount -f /www/images/New_ui/usbstatus.png 2>/dev/null
2831 | rm -rf "/tmp/usbaccelerator"
2832 | fi
2833 | service restart_nasapps >/dev/null 2>&1
2834 | if [ "$KEEP_UPDATE" != "1" ] && [ "$(grep -i "USB_Accelerator" $S_DIR/post-mount 2>/dev/null | wc -l)" -gt "0" ]; then
2835 | SC_DISABLE="$((SC_DISABLE + 1))"
2836 | fi
2837 | else
2838 | SC_DISABLE="100"
2839 | fi
2840 | }
2841 |
2842 | Uninstall() {
2843 | SC_UNINSTALL="0"
2844 | # Status code of uninstall: "0" succeeded, "1" failed.
2845 |
2846 | if [ "$(df -h | grep -c 'usbstatus.png')" -gt "0" ]; then
2847 | umount -f /www/images/New_ui/usbstatus.png 2>/dev/null
2848 | fi
2849 |
2850 | if [ -f "$S_DIR/smb.postconf" ]; then
2851 | sed -i '0,/CONFIG/{//d;}' "$S_DIR/smb.postconf" 2>/dev/null
2852 | sed -i '/socket options/d;/deadtime/d;/strict locking/d' "$S_DIR/smb.postconf" 2>/dev/null
2853 | sed -i '/[aA]ccelerator/d' "$S_DIR/smb.postconf" 2>/dev/null
2854 | sed -i '/^$/d' "$S_DIR/smb.postconf" 2>/dev/null
2855 | if [ "$(grep -vc '#' "$S_DIR/smb.postconf")" -le "1" ] && [ "$(grep -vc 'CONFIG=$1' "$S_DIR/smb.postconf")" -le "1" ]; then
2856 | rm -f "$S_DIR/smb.postconf"
2857 | fi
2858 | fi
2859 |
2860 | if [ "$(awk -F'"' '/^ENABLE_JFFS_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2861 | nvram set jffs2_scripts="0"
2862 | nvram commit
2863 | fi
2864 |
2865 | if [ -f "$S_DIR/post-mount" ]; then
2866 | sed -i '/[aA]ccelerator/d' "$S_DIR/post-mount" 2>/dev/null
2867 | sed -i '/^$/d' "$S_DIR/post-mount" 2>/dev/null
2868 | if [ "$(wc -l "$S_DIR/post-mount" 2>/dev/null | awk '{print $1}')" -le "1" ] || [ "$(grep -vc '#' "$S_DIR/post-mount" 2>/dev/null )" -eq "0" ]; then
2869 | rm -f "$S_DIR/post-mount"
2870 | fi
2871 | elif [ "$(nvram get script_usbmount 2>/dev/null | grep -c post-mount)" -gt "0" ]; then
2872 | nvram set script_usbmount=""
2873 | nvram commit
2874 | fi
2875 |
2876 | if [ "$(awk -F'"' '/^ENABLE_MOUNT_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2877 | nvram set script_usbmount=""
2878 | nvram commit
2879 | fi
2880 |
2881 | if [ "$(cru l 2>/dev/null | grep -c 'USB_Accelerator_AutoUpdate')" -gt "0" ]; then
2882 | cru d USB_Accelerator_AutoUpdate 2>/dev/null
2883 | fi
2884 |
2885 | if [ -f "/jffs/post-mount" ] || [ -f "$S_DIR/usbaccelerator.sh" ] || [ -f "$S_DIR/usbstatus.png" ] || [ -f "$S_DIR/sfsmb" ]; then
2886 | rm -f "$S_DIR/usbstatus.png" "$S_DIR/sfsmb" "/jffs/post-mount" "$S_DIR/usbaccelerator.sh"
2887 | fi
2888 |
2889 | if [ -d "$UA_DIR" ] || [ "$FORCE" = "1" ]; then
2890 | if [ -d "/tmp/usbaccelerator" ] || [ "$FORCE" = "1" ]; then
2891 | rm -rf "/tmp/usbaccelerator"
2892 | fi
2893 | rm -f "$UA_DIR/usbstatus.png" "$UA_DIR/CONFIG" "$UA_DIR/usbaccelerator.sh"
2894 | rm -rf "$UA_DIR" 2>/dev/null
2895 | Check_Firmware
2896 | if [ "$(ls -A $ADD_DIR 2>/dev/null | wc -l)" = "0" ] && [ "$FWTYPE" != "384M" ]; then
2897 | rm -rf "$ADD_DIR" 2>/dev/null
2898 | fi
2899 | service restart_nasapps >/dev/null 2>&1
2900 | fi
2901 |
2902 | TMP_CLEARED="0"
2903 | if [ "$CUR_DIR" = "/tmp" ] && [ -f "/tmp/$S_NAME" ]; then
2904 | rm -f "$CUR_DIR/usbstatus.png"
2905 | rm -f "$CUR_DIR/$S_NAME"
2906 | if [ ! -f "/tmp/$S_NAME" ]; then TMP_CLEARED="$((TMP_CLEARED + 1))"; fi
2907 | fi
2908 |
2909 | if [ -f "$CUR_DIR/$S_NAME" ] || [ -f "$CUR_DIR/usbstatus.png" ]; then
2910 | rm -f "$CUR_DIR/$S_NAME" "$CUR_DIR/usbstatus.png"
2911 | fi
2912 |
2913 | if [ -f "$UA_DIR/usbstatus.png" ]; then
2914 | SC_UNINSTALL="$((SC_UNINSTALL + 1))"
2915 | fi
2916 | if [ -f "$UA_DIR/CONFIG" ]; then
2917 | SC_UNINSTALL="$((SC_UNINSTALL + 1))"
2918 | fi
2919 | if [ -f "$UA_DIR/usbaccelerator.sh" ]; then
2920 | SC_UNINSTALL="$((SC_UNINSTALL + 1))"
2921 | fi
2922 | if [ -d "$UA_DIR" ]; then
2923 | SC_UNINSTALL="$((SC_UNINSTALL + 1))"
2924 | fi
2925 |
2926 | if [ "$SC_UNINSTALL" -gt "0" ]; then
2927 | SC_GLOBAL="8"
2928 | fi
2929 |
2930 | if [ -f "$S_DIR/smb.postconf.old" ] && [ ! -f "$S_DIR/smb.postconf" ]; then
2931 | mv -f "$S_DIR/smb.postconf.old" "$S_DIR/smb.postconf" && chmod 755 "$S_DIR/smb.postconf"
2932 | fi
2933 |
2934 | if [ -f "$S_DIR/post-mount.old" ] && [ ! -f "$S_DIR/post-mount" ]; then
2935 | mv -f "$S_DIR/post-mount.old" "$S_DIR/post-mount" && chmod 755 "$S_DIR/post-mount"
2936 | fi
2937 |
2938 | if [ "$QUIET" != "1" ]; then
2939 | if [ "$SC_UNINSTALL" -eq "0" ]; then
2940 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2941 | logger -t "USB加速器" "USB加速器已经卸载,感谢你的使用"
2942 | else
2943 | logger -t "USB Accelerator" "the USB Accelerator has been uninstalled"
2944 | fi
2945 | elif [ "$SC_UNINSTALL" -gt "0" ]; then
2946 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
2947 | logger -t "USB加速器" "USB加速器已经卸载,但可能有残留文件或目录因占用无法删除 (状态码:$SC_UNINSTALL-$SC_GLOBAL)"
2948 | else
2949 | logger -t "USB Accelerator" "the USB Accelerator has been uninstalled (Status Code:$SC_UNINSTALL-$SC_GLOBAL)"
2950 | logger -t "USB Accelerator" "but some files or directory may cannot be removed"
2951 | fi
2952 | fi
2953 | fi
2954 | }
2955 |
2956 | Reinstall() {
2957 | SC_REINSTALL="0"
2958 | # Status code of re-install: "0" succeeded, "1-99" failed, "100" no internet connection, "1000" download failed.
2959 |
2960 | Check_Network
2961 | if [ "$SC_NETWORK" -eq "0" ] || [ "$FORCE" = "1" ]; then
2962 | if [ -s "$UA_DIR/CONFIG" ] && [ "$CLEAN_INSTALL" = "1" ]; then
2963 | if [ "$(awk -F'"' '/^ENABLE_JFFS_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2964 | nvram set jffs2_scripts="0"
2965 | nvram commit
2966 | fi
2967 | if [ "$(awk -F'"' '/^ENABLE_MOUNT_SCRIPTS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2968 | nvram set script_usbmount=""
2969 | nvram commit
2970 | fi
2971 | fi
2972 | if [ -s "$UA_DIR/CONFIG" ] && [ "$CLEAN_INSTALL" != "1" ]; then
2973 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
2974 | need_to_reenable="1"
2975 | fi
2976 | cp -f "$UA_DIR/CONFIG" "/tmp/UA.CONFIG.BAK"
2977 | chmod 644 /tmp/UA.CONFIG.BAK
2978 | fi
2979 | Download_Files
2980 | if [ "$SC_DOWNLOAD" -eq "0" ]; then
2981 | Uninstall
2982 | Move_Files
2983 | if [ -s /tmp/UA.CONFIG.BAK ]; then
2984 | mv -f "/tmp/UA.CONFIG.BAK" "$UA_DIR/CONFIG"
2985 | chmod 644 "$UA_DIR/CONFIG"
2986 | fi
2987 | else
2988 | if [ -s /tmp/UA.CONFIG.BAK ]; then
2989 | rm -f /tmp/UA.CONFIG.BAK
2990 | fi
2991 | SC_REINSTALL="1000"
2992 | fi
2993 | if [ ! -f "$UA_DIR/usbstatus.png" ] || [ ! -f "$UA_DIR/usbaccelerator.sh" ]; then
2994 | SC_REINSTALL="$((SC_REINSTALL + 1))"
2995 | fi
2996 | else
2997 | SC_REINSTALL="100"
2998 | fi
2999 |
3000 | if [ "$SC_REINSTALL" -eq "100" ]; then
3001 | SC_GLOBAL="10"
3002 | elif [ "$SC_REINSTALL" -eq "1000" ]; then
3003 | SC_GLOBAL="11"
3004 | elif [ "$SC_REINSTALL" -gt "0" ] && [ "$SC_REINSTALL" -lt "100" ]; then
3005 | SC_GLOBAL="9"
3006 | fi
3007 |
3008 | if [ "$QUIET" != "1" ]; then
3009 | if [ "$SC_REINSTALL" -eq "0" ]; then
3010 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3011 | logger -t "USB加速器" "USB加速器v$VERSION已成功重新安装 (状态码:$SC_REINSTALL-$SC_GLOBAL)"
3012 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3013 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3014 | else
3015 | logger -t "USB Accelerator" "USB Accelerator v$VERSION has been reinstalled (Status Code:$SC_REINSTALL-$SC_GLOBAL)"
3016 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3017 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3018 | fi
3019 | fi
3020 | if [ "$SC_REINSTALL" -eq "100" ]; then
3021 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3022 | ERROR_NETWORK="1"
3023 | ERROR_SOURCE="重装"
3024 | Error_Notifications
3025 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_NETWORK-$SC_REINSTALL-$SC_GLOBAL"
3026 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3027 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3028 | else
3029 | ERROR_NETWORK="1"
3030 | ERROR_SOURCE="Reinstall"
3031 | Error_Notifications
3032 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_NETWORK-$SC_REINSTALL-$SC_GLOBAL"
3033 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3034 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3035 | fi
3036 | fi
3037 | if [ "$SC_REINSTALL" -eq "1000" ]; then
3038 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3039 | ERROR_DOWNLOAD="1"
3040 | ERROR_SOURCE="重装"
3041 | Error_Notifications
3042 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_DOWNLOAD-$SC_REINSTALL-$SC_GLOBAL"
3043 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3044 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3045 | else
3046 | ERROR_DOWNLOAD="1"
3047 | ERROR_SOURCE="Reinstall"
3048 | Error_Notifications
3049 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_DOWNLOAD-$SC_REINSTALL-$SC_GLOBAL"
3050 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3051 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3052 | fi
3053 | fi
3054 | fi
3055 |
3056 | if [ "$TRIG_RI_BY_USER" != "1" ] && [ "$need_to_reenable" = "1" ] && [ "$SC_REINSTALL" -eq "0" ]; then
3057 | sh "$UA_DIR/usbaccelerator.sh --enable"; exit "$?"
3058 | elif [ "$TRIG_RI_BY_USER" = "1" ] && [ "$SC_REINSTALL" -eq "0" ]; then
3059 | if [ "$need_to_reenable" = "1" ]; then
3060 | sed -i '/ENABLE_STATUS/d' "$UA_DIR/CONFIG" 2>/dev/null
3061 | fi
3062 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3063 | printf 'USB加速器已成功重新安装,正在重新载入...\n'
3064 | else
3065 | printf 'USB Accelerator reinstalled successfully, reloading...\n'
3066 | fi
3067 | sh "$UA_DIR/usbaccelerator.sh"; exit "$?"
3068 | fi
3069 | }
3070 |
3071 | Update() {
3072 | SC_UPDATE="0"
3073 | # Status code of update: "0" no updates available, "1" update completed, "2" no internet connection, "3" file download failed, "4" file missing.
3074 |
3075 | if [ -z "$SRC" ] && [ "$TRIG_UPD_BY_USER" = "1" ]; then
3076 | Set_Source_UI
3077 | fi
3078 |
3079 | updnum="0"
3080 | while [ "$updnum" -lt "3" ]; do
3081 | if [ "$TRIG_UPD_BY_USER" = "1" ] || [ "$FORCE" = "1" ]; then
3082 | TRIG_CKNT_BY_USER="1"
3083 | fi
3084 | Check_Network
3085 | if [ "$SC_NETWORK" -eq "0" ]; then
3086 | Download_Files
3087 | if [ "$SC_DOWNLOAD" -eq "0" ]; then
3088 | if [ "$FORCE" = "1" ]; then
3089 | Move_Files
3090 | if [ "$FILE_MOVED" -gt "0" ]; then
3091 | SC_UPDATE="1"
3092 | updnum="100"
3093 | else
3094 | SC_UPDATE="4"
3095 | updnum="$((updnum + 1))"
3096 | fi
3097 | else
3098 | Check_Hash
3099 | if [ "$SC_HASH" -eq "0" ]; then
3100 | SC_UPDATE="0"
3101 | updnum="100"
3102 | elif [ "$FILE_MOVED" -gt "0" ]; then
3103 | SC_UPDATE="1"
3104 | updnum="100"
3105 | else
3106 | SC_UPDATE="4"
3107 | updnum="$((updnum + 1))"
3108 | fi
3109 | fi
3110 | else
3111 | SC_UPDATE="3"
3112 | updnum="100"
3113 | fi
3114 | else
3115 | SC_UPDATE="2"
3116 | updnum="100"
3117 | fi
3118 | done
3119 |
3120 | if [ "$SC_UPDATE" -ne "0" ]; then
3121 | if [ "$SC_UPDATE" -eq "2" ]; then
3122 | SC_GLOBAL="10"
3123 | fi
3124 | if [ "$SC_UPDATE" -eq "3" ]; then
3125 | SC_GLOBAL="11"
3126 | fi
3127 | if [ "$SC_UPDATE" -eq "4" ]; then
3128 | SC_GLOBAL="12"
3129 | fi
3130 | fi
3131 |
3132 | if [ "$SC_UPDATE" -eq "1" ]; then
3133 | NEW_VERSION="$(awk -F'"' '/^VERSION=/ {print $2}' $UA_DIR/usbaccelerator.sh 2>/dev/null)"
3134 | Check_Directories
3135 | sed -i '/UPDATE_COMPLETED/d' "$UA_DIR/CONFIG" 2>/dev/null
3136 | echo '' >> "$UA_DIR/CONFIG"
3137 | echo "UPDATE_COMPLETED=\"$TIMESTAMP\"" >> "$UA_DIR/CONFIG"
3138 | sed -i '/^$/d' "$UA_DIR/CONFIG"
3139 | chmod 644 "$UA_DIR/CONFIG"
3140 | if [ "$(awk -F'"' '/^ENABLE_STATUS=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
3141 | sh "$UA_DIR/usbaccelerator.sh --quiet --disable"
3142 | sh "$UA_DIR/usbaccelerator.sh --enable"; SC_GLOBAL="$?"
3143 | fi
3144 | fi
3145 |
3146 | if [ "$QUIET" != "1" ]; then
3147 | if [ "$SC_UPDATE" -eq "1" ]; then
3148 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3149 | logger -t "USB加速器" "USB加速器已经成功从v$VERSION更新到v$NEW_VERSION"
3150 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3151 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3152 | else
3153 | logger -t "USB Accelerator" "The USB Accelerator has been successfully updated from v$VERSION to v$NEW_VERSION"
3154 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3155 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3156 | fi
3157 | fi
3158 | if [ "$SC_UPDATE" -eq "2" ]; then
3159 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3160 | ERROR_NETWORK="1"
3161 | ERROR_SOURCE="更新"
3162 | Error_Notifications
3163 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_NETWORK-$SC_UPDATE-$SC_GLOBAL"
3164 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3165 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3166 | else
3167 | ERROR_NETWORK="1"
3168 | ERROR_SOURCE="Update"
3169 | Error_Notifications
3170 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_NETWORK-$SC_UPDATE-$SC_GLOBAL"
3171 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3172 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3173 | fi
3174 | fi
3175 | if [ "$SC_UPDATE" -eq "3" ]; then
3176 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3177 | ERROR_DOWNLOAD="1"
3178 | ERROR_SOURCE="更新"
3179 | Error_Notifications
3180 | logger -st "USB加速器" "ERROR:$R_M-$FWVER-$VERSION-$SC_DOWNLOAD-$SC_UPDATE-$SC_GLOBAL"
3181 | logger -t "USB加速器" "如果你需要管理USB加速器,请在SSH中输入下方内容:"
3182 | logger -t "USB加速器" "sh $UA_DIR/usbaccelerator.sh"
3183 | else
3184 | ERROR_DOWNLOAD="1"
3185 | ERROR_SOURCE="Update"
3186 | Error_Notifications
3187 | logger -st "USB Accelerator" "ERROR:$R_M-$FWVER-$VERSION-$SC_DOWNLOAD-$SC_UPDATE-$SC_GLOBAL"
3188 | logger -t "USB Accelerator" "If you want to control the USB Accelerator, enter below in SSH:"
3189 | logger -t "USB Accelerator" "sh $UA_DIR/usbaccelerator.sh"
3190 | fi
3191 | fi
3192 | if [ "$SC_UPDATE" -eq "4" ]; then
3193 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3194 | logger -st "USB加速器" "更新失败文件丢失"
3195 | else
3196 | logger -st "USB Accelerator" "Update failed, file(s) is missing"
3197 | fi
3198 | fi
3199 | fi
3200 | }
3201 |
3202 | Enable_Auto_Update() {
3203 | minute="$(awk -v min=4 -v max=53 -v freq=1 'BEGIN{"tr -cd 0-9 /dev/null)" != "1" ]; then
3208 | Check_Directories
3209 | sed -i '/AUTO_UPDATE/d' "$UA_DIR/CONFIG" 2>/dev/null
3210 | echo '' >> "$UA_DIR/CONFIG"
3211 | echo 'AUTO_UPDATE="1"' >> "$UA_DIR/CONFIG"
3212 | sed -i '/^$/d' "$UA_DIR/CONFIG"
3213 | chmod 644 "$UA_DIR/CONFIG"
3214 | fi
3215 |
3216 | Check_Firmware
3217 | if [ "$FWTYPE" = "380M" ] || [ "$FWTYPE" = "384M" ]; then
3218 | smb_config="$S_DIR/smb.postconf"
3219 | fi
3220 | if [ "$FWTYPE" = "380S" ] || [ "$FWTYPE" = "384S" ]; then
3221 | smb_config="$S_DIR/post-mount"
3222 | fi
3223 |
3224 | if [ "$(grep 'usbaccelerator.sh --update' $smb_config 2>/dev/null | wc -l)" -eq "0" ] || [ "$(grep 'usbaccelerator.sh -u' $smb_config 2>/dev/null | wc -l)" -eq "0" ]; then
3225 | if [ ! -f "$smb_config" ]; then
3226 | echo '#!/bin/sh' > "$smb_config"
3227 | fi
3228 | echo '' >> "$smb_config"
3229 | if [ "$RELEASE_TYPE" = "stable" ]; then
3230 | echo "cru a USB_Accelerator_AutoUpdate \"$minute $hour * * $week sh $UA_DIR/usbaccelerator.sh --update\"" >> "$smb_config"
3231 | else
3232 | echo "cru a USB_Accelerator_AutoUpdate \"$minute */8 * * * sh $UA_DIR/usbaccelerator.sh --update\"" >> "$smb_config"
3233 | fi
3234 | echo "sh $UA_DIR/usbaccelerator.sh --update" >> "$smb_config"
3235 | sed -i '/^$/d' "$smb_config"
3236 | chmod 755 "$smb_config"
3237 | fi
3238 |
3239 | if [ "$(cru l 2>/dev/null | grep -c 'USB_Accelerator_AutoUpdate')" -gt "0" ]; then
3240 | cru d USB_Accelerator_AutoUpdate
3241 | fi
3242 |
3243 | if [ "$RELEASE_TYPE" = "stable" ]; then
3244 | cru a USB_Accelerator_AutoUpdate "$minute $hour * * $week sh $UA_DIR/usbaccelerator.sh --update" 2>/dev/null
3245 | else
3246 | cru a USB_Accelerator_AutoUpdate "$minute */8 * * * sh $UA_DIR/usbaccelerator.sh --update" 2>/dev/null
3247 | fi
3248 | }
3249 |
3250 | Disable_Auto_Update() {
3251 | if [ "$(awk -F'"' '/^AUTO_UPDATE=/ {print $2}' $UA_DIR/CONFIG 2>/dev/null)" = "1" ]; then
3252 | Check_Directories
3253 | sed -i '/AUTO_UPDATE/d' "$UA_DIR/CONFIG" 2>/dev/null
3254 | echo '' >> "$UA_DIR/CONFIG"
3255 | echo 'AUTO_UPDATE="0"' >> "$UA_DIR/CONFIG"
3256 | sed -i '/^$/d' "$UA_DIR/CONFIG"
3257 | chmod 644 "$UA_DIR/CONFIG"
3258 | fi
3259 |
3260 | Check_Firmware
3261 | if [ "$FWTYPE" = "380M" ] || [ "$FWTYPE" = "384M" ]; then
3262 | smb_config="$S_DIR/smb.postconf"
3263 | fi
3264 | if [ "$FWTYPE" = "380S" ] || [ "$FWTYPE" = "384S" ]; then
3265 | smb_config="$S_DIR/post-mount"
3266 | fi
3267 |
3268 | if [ "$(grep 'usbaccelerator.sh --update' $smb_config 2>/dev/null | wc -l)" -gt "0" ] || [ "$(grep 'usbaccelerator.sh -u' $smb_config 2>/dev/null | wc -l)" -gt "0" ]; then
3269 | sed -i '/usbaccelerator.sh --update/d' "$smb_config"
3270 | sed -i '/usbaccelerator.sh -u/d' "$smb_config"
3271 | echo '' >> "$smb_config"
3272 | sed -i '/^$/d' "$smb_config"
3273 | chmod 755 "$smb_config"
3274 | fi
3275 |
3276 | if [ "$(cru l 2>/dev/null | grep -c 'USB_Accelerator_AutoUpdate')" -gt "0" ]; then
3277 | cru d USB_Accelerator_AutoUpdate 2>/dev/null
3278 | fi
3279 | }
3280 |
3281 | Error_Notifications() {
3282 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3283 | please_report="你可以向开发人员反馈此代码以帮助解决这个错误:"
3284 | else
3285 | please_report="Please report this code to the developer for help resolve the issue:"
3286 | fi
3287 |
3288 | if [ "$ERROR_NETWORK" = "1" ]; then
3289 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3290 | logger -st "USB加速器" "$ERROR_SOURCE失败,没有网络连接"
3291 | logger -st "USB加速器" "$please_report"
3292 | else
3293 | logger -st "USB Accelerator" "$ERROR_SOURCE failed, no internet connection"
3294 | logger -st "USB Accelerator" "$please_report"
3295 | fi
3296 | ERROR_NETWORK="0"
3297 | fi
3298 |
3299 | if [ "$ERROR_DOWNLOAD" = "1" ]; then
3300 | if [ "$LANG" = "CN" ] || [ "$LANG" = "TW" ]; then
3301 | logger -st "USB加速器" "$ERROR_SOURCE失败,下载文件失败"
3302 | logger -st "USB加速器" "$please_report"
3303 | else
3304 | logger -st "USB Accelerator" "$ERROR_SOURCE failed, files download failed"
3305 | logger -st "USB Accelerator" "$please_report"
3306 | fi
3307 | ERROR_DOWNLOAD="0"
3308 | fi
3309 | }
3310 |
3311 | Documents() {
3312 | HELP_DOCUMENTATION="Usage:
3313 | sh $CUR_DIR/$S_NAME [OPTION]...
3314 |
3315 | Options:
3316 | --clear Clean up the old version (1.0 and lower)
3317 | -d, --disable Disable the USB Accelerator
3318 | -e, --enable Enable the USB Accelerator
3319 | -f, --force Force to enable, disable or uninstall
3320 | --github Set the download source to GitHub
3321 | --gitlab Set the download source to GitLab (backup)
3322 | -h, --help Display this help and exit
3323 | --help-status Display help for the exit status
3324 | -q, --quiet Quiet to enable, disable or update
3325 | --reinstall Reinstall without user confirmation
3326 | --uninstall Uninstall without user confirmation
3327 | --shellui Enter the shell UI
3328 | -u, --update Update the USB Accelerator
3329 | -v, --version Output version information and exit
3330 |
3331 | Examples:
3332 | Enable the USB Accelerator:
3333 | sh $CUR_DIR/$S_NAME -e
3334 | Set up the installation source to GitHub and Update:
3335 | sh $CUR_DIR/$S_NAME --github -u
3336 |
3337 | Note:
3338 | ONLY TWO OPTIONS can be run at a time, does not support combined
3339 | options, all options are case sensitive, and without any options
3340 | will enter the shell UI. The options will be run one by one,
3341 | which means that the result of the first option affects the next
3342 | option, and some options cannot be used as the second option.
3343 |
3344 | Exit Status:
3345 | Please use the '--help-status' option to view.
3346 |
3347 | Read More:
3348 | USB Accelerator $VERSION
3349 | Project home and source code:
3350 | $HOST_HOME_1
3351 | Report issues and bugs:
3352 | $HOST_HOME_1/issues
3353 | Full documentation:
3354 | $HOST_HOME_1/blob/master/README.md
3355 | Full the GPLv3 license:
3356 | $HOST_HOME_1/blob/master/LICENSE
3357 | Want to help translate to local or improve?
3358 | You can pull and push your changes on GitHub!"
3359 |
3360 | EXIT_STATUS="Meaning of exit code in USB Accelerator $VERSION
3361 |
3362 | Exit Codes:
3363 | [0] = Run successfully
3364 | [1] = Unknown error
3365 | [2] = The user did not agree to the license
3366 | [3] = Unsupported model or firmware
3367 | [4] = Enable failed, please try again
3368 | [5] = Already enabled, no need to do it again
3369 | [6] = Disable failed, please try again
3370 | [7] = Already disabled, no need to do it again
3371 | [8] = Uninstall done, but may not completely removed
3372 | [9] = Reinstall failed
3373 | [10] = No internet connection
3374 | [11] = Download failed
3375 | [12] = Missing files
3376 | [13] = Bad request parameters
3377 |
3378 | Note:
3379 | If there are multiple status,
3380 | the exit code will only return the last one."
3381 |
3382 | VERSION_INFORMATION="$CUR_DIR/$S_NAME $VERSION
3383 | Copyleft :-) 2019-2020
3384 |
3385 | This program is a free and open-source software , and you can
3386 | redistribute it and/or modify it under the terms of the GNU
3387 | General Public License version 3 (GPLv3).
3388 |
3389 | This program is distributed in the hope that it will be useful,
3390 | but WITHOUT ANY WARRANTY, without even the implied warranty of
3391 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3392 |
3393 | See the GNU General Public License version 3 for more details:
3394 | $HOST_HOME_1/blob/master/LICENSE
3395 |
3396 | Project home and source code:
3397 | $HOST_HOME_1
3398 |
3399 | Written by Jack."
3400 |
3401 | BAD_REQUEST_1="Unknown option: $PARM_1
3402 | Try 'sh $CUR_DIR/$S_NAME --help' for more information."
3403 |
3404 | BAD_REQUEST_2="Bad option: $PARM_2
3405 | Cannot be used as the second option.
3406 | Try 'sh $CUR_DIR/$S_NAME --help' for more information."
3407 |
3408 | BAD_REQUEST_3="Bad option: $PARM_2
3409 | The second option is not running, cannot be same as the first.
3410 | Try 'sh $CUR_DIR/$S_NAME --help' for more information."
3411 |
3412 | BAD_REQUEST_4="Bad option: $PARM_3
3413 | The third option is not running, only TWO options are supported.
3414 | Try 'sh $CUR_DIR/$S_NAME --help' for more information."
3415 | }
3416 |
3417 | Command_Parameters() {
3418 | case "$PARM_1" in
3419 | --clear|-Check|-DLZ|-DL|-SFW)
3420 | Clear_Old
3421 | ;;
3422 | -d|--disable)
3423 | Disable
3424 | ;;
3425 | -e|--enable)
3426 | Check_Files
3427 | Enable
3428 | ;;
3429 | -f|--force)
3430 | FORCE="1"
3431 | ;;
3432 | --github)
3433 | Source_GitHub
3434 | ;;
3435 | --gitlab)
3436 | Source_GitLab
3437 | ;;
3438 | -h|--help)
3439 | Documents
3440 | echo "$HELP_DOCUMENTATION"
3441 | ;;
3442 | --help-status)
3443 | Documents
3444 | echo "$EXIT_STATUS"
3445 | ;;
3446 | -q|--quiet)
3447 | QUIET="1"
3448 | ;;
3449 | --reinstall)
3450 | Reinstall
3451 | ;;
3452 | --uninstall)
3453 | Uninstall
3454 | ;;
3455 | --shellui)
3456 | if [ -z "$FIRST_TIME" ]; then
3457 | Splash_Page_0
3458 | else
3459 | Check_Source
3460 | if [ "$SC_SETSOURCE" -eq "0" ]; then
3461 | Home
3462 | elif [ "$SC_SETSOURCE" -eq "2" ]; then
3463 | NO_RETURN_SETSRC="1"
3464 | Set_Source_UI
3465 | Home
3466 | else
3467 | Splash_Page_0
3468 | fi
3469 | fi
3470 | ;;
3471 | -u|--update)
3472 | Update
3473 | ;;
3474 | -v|--version)
3475 | Documents
3476 | echo "$VERSION_INFORMATION"
3477 | ;;
3478 | *)
3479 | Documents
3480 | echo "$BAD_REQUEST_1"
3481 | exit 13
3482 | ;;
3483 | esac
3484 |
3485 | if [ -z "$PARM_2" ]; then
3486 | exit "$SC_GLOBAL"
3487 | elif [ "$SC_PARAMETERS" -gt "0" ]; then
3488 | Documents
3489 | echo "$BAD_REQUEST_4"
3490 | exit 13
3491 | else
3492 | case "$PARM_2" in
3493 | -f|--force|--github|--gitlab|-h|--help|--help-status|-q|--quiet|-v|--version)
3494 | Documents
3495 | echo "$BAD_REQUEST_2"
3496 | exit 13
3497 | ;;
3498 | esac
3499 | if [ "$PARM_1" = "$PARM_2" ]; then
3500 | Documents
3501 | echo "$BAD_REQUEST_3"
3502 | exit 13
3503 | else
3504 | PARM_1="$PARM_2"
3505 | PARM_2="$PARM_3"
3506 | fi
3507 | SC_PARAMETERS="$((SC_PARAMETERS + 1))"
3508 | Command_Parameters
3509 | fi
3510 | }
3511 |
3512 | if [ -z "$PARM_1" ]; then
3513 | if [ -z "$FIRST_TIME" ]; then
3514 | Splash_Page_0
3515 | else
3516 | Check_Source
3517 | if [ "$SC_SETSOURCE" -eq "0" ]; then
3518 | Home
3519 | elif [ "$SC_SETSOURCE" -eq "2" ]; then
3520 | NO_RETURN_SETSRC="1"
3521 | Set_Source_UI
3522 | Home
3523 | else
3524 | Splash_Page_0
3525 | fi
3526 | fi
3527 | else
3528 | SC_PARAMETERS="0"
3529 | Command_Parameters
3530 | fi
3531 |
3532 | exit "$SC_GLOBAL"
3533 |
--------------------------------------------------------------------------------
/usbstatus-gt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JackMerlin/USBAccelerator/8802c0dbbdc4372789cf5b6f3595827204395db6/usbstatus-gt.png
--------------------------------------------------------------------------------
/usbstatus-tuf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JackMerlin/USBAccelerator/8802c0dbbdc4372789cf5b6f3595827204395db6/usbstatus-tuf.png
--------------------------------------------------------------------------------
/usbstatus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JackMerlin/USBAccelerator/8802c0dbbdc4372789cf5b6f3595827204395db6/usbstatus.png
--------------------------------------------------------------------------------