Codebase list sakis3g / 804bcea
Imported Upstream version 0.2.0e Devon Kearns 11 years ago
161 changed file(s) with 21607 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # This file lists contributors to Sakis3G All-in-one script
1
2 ==Ideas==
3 * Josua Dietze.
4 * Arturas Sleinius.
5 * Tasos Gropalis.
6
7
8 ==Patches==
9 * Josua Dietze: Identified and fixed a regression issue, introduced by 0.1.2, that was preventing correct tty device detection on several modems. Proposed fix was included in 0.1.3.
10 * Emanuele Bovisio: Identified and fixed an issue with older wvdial versions. Proposed fix was included in 0.2.0c.
11 * Hartmut Giessmann: Identified and fixed an issue with certain UTF-8 translations not being used if locale was specified in lowercase. Proposed patch was included in 0.2.0d.
12
13
14 ==Translators==
15 * Hartmut Giessmann: German translation. Included since 0.2.0d.
16 * Jean-Pierre VAISSIERE: French translation. Included since 0.2.0e.
17
18
19 ==Wiki editors==
20 None so far.
21
22
23 ==Testers==
24 * Josua Dietze.
25 * Jean-Pierre VAISSIERE.
26 * Arturas Sleinius.
27 * Peder Norgaard.
28 * Luikki.
29 * Monty’s SoupCatcher.
30 * Tasos Gropalis.
31
32
33 ==Operator updates==
34 * Arturas Sleinius (Omnitel Lithuania).
35 * Don (1und1 Germany).
36 * Luikki (ZON, Clix Portugal).
37 * Monty’s SoupCatcher (T-Mobile, Vodafone, O2 United Kingdom).
38 * Sébastien Abilla (Orange French Caraibes).
39 * Vasco Santos (TMN Portugal).
40 * Rafael Estevez (IndosatM2, 3 Indonesia).
41 * Stefanix (ToT Thailand)
42
43
44 ==Modem information/feedback==
45 * Dimitrios Tsolakis (Huawei E170).
46 * Jean-Pierre VAISSIERE (GBC PL68).
47 * Arturas Sleinius (ZTE MF633).
48 * Luikki (ZTE MF627).
49 * Monty’s SoupCatcher (Huawei E160).
50 * Tasos Gropalis (Huawei E1692).
51
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
2
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
4 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Library General Public License instead.) You can apply it to
18 your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
26
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
31
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
37
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
41
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
48
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
54
55 The precise terms and conditions for copying, distribution and
56 modification follow.
57
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
70
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
77
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
85
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
88
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
93
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
96
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
101
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
112
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
122
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
127
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
132
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
136
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
140
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
147
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
153
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
164
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
170
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
178
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
187
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
195
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
208
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
213
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
224
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
227
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
235
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281 How to Apply These Terms to Your New Programs
282
283 If you develop a new program, and you want it to be of the greatest
284 possible use to the public, the best way to achieve this is to make it
285 free software which everyone can redistribute and change under these terms.
286
287 To do so, attach the following notices to the program. It is safest
288 to attach them to the start of each source file to most effectively
289 convey the exclusion of warranty; and each file should have at least
290 the "copyright" line and a pointer to where the full notice is found.
291
292 <one line to give the program's name and a brief idea of what it does.>
293 Copyright (C) <year> <name of author>
294
295 This program is free software; you can redistribute it and/or modify
296 it under the terms of the GNU General Public License as published by
297 the Free Software Foundation; either version 2 of the License, or
298 (at your option) any later version.
299
300 This program is distributed in the hope that it will be useful,
301 but WITHOUT ANY WARRANTY; without even the implied warranty of
302 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303 GNU General Public License for more details.
304
305 You should have received a copy of the GNU General Public License
306 along with this program; if not, write to the Free Software
307 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
308
309
310 Also add information on how to contact you by electronic and paper mail.
311
312 If the program is interactive, make it output a short notice like this
313 when it starts in an interactive mode:
314
315 Gnomovision version 69, Copyright (C) year name of author
316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 This is free software, and you are welcome to redistribute it
318 under certain conditions; type `show c' for details.
319
320 The hypothetical commands `show w' and `show c' should show the appropriate
321 parts of the General Public License. Of course, the commands you use may
322 be called something other than `show w' and `show c'; they could even be
323 mouse-clicks or menu items--whatever suits your program.
324
325 You should also get your employer (if you work as a programmer) or your
326 school, if any, to sign a "copyright disclaimer" for the program, if
327 necessary. Here is a sample; alter the names:
328
329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
332 <signature of Ty Coon>, 1 April 1989
333 Ty Coon, President of Vice
334
335 This General Public License does not permit incorporating your program into
336 proprietary programs. If your program is a subroutine library, you may
337 consider it more useful to permit linking proprietary applications with the
338 library. If this is what you want to do, use the GNU Library General
339 Public License instead of this License.
0 0.2.0e 2010/07/09
1
2 * New functionality:
3 o French translation is now available for those using a unicode fr_FR
4 locale.
5 * Modified functionality:
6 o Debug output now includes name of function, emitting debug message,
7 as well.
8 * Fixed the following issues:
9 o TRANSLATION variable is now properly taken into account.
10 o BAUD=MAX, BAUD=MIN and BAUD=DEFAULT now work properly.
11 o Disassembling Sakis3G script, back into its contents, should now be
12 possible even for distributions shipping a "tar" version prior to
13 1.20.
14 o Script now queries modem, about network it is registered to, using
15 proper AT-command. This should eliminate cases where querying modem
16 resulted into it unregistering network instead (like Huawei E1820).
17 o Fixed a regression issue, introduced by 0.2.0d, which resulted into
18 user being asked twice about driver to be used. This affected only
19 users of old kernels, or users of new devices (i.e. users who's
20 kernel was not recognizing USB IDs).
21 * Embedded Usb-ModeSwitch:
22 o Upgraded to version 1.1.3.
23 o Device database upgraded to 2010-06-23 version.
24 * Operators' database:
25 o Modified following networks:
26 + 23402: O2 (UK): Added one more APN.
27 + 23410: O2 (UK): Added one more APN.
28 + 23411: O2 (UK): Added one more APN.
29 + 23415: Vodafone (UK): Added "new PAYG" APN.
30 o Added the following networks:
31 + 51001: IndosatM2 (Indonesia).
32 + 51089: 3 (Indonesia).
33 + 52015: ToT (Thailand).
34
35 0.2.0d 2010/06/07
36
37 * New functionality:
38 o German translation is now available for those using a unicode en_DE
39 locale.
40 o Script now offers manual network selection whenever modem fails to
41 automatically register one.
42 o Configuration variable PREPARE was introduced, allowing custom AT
43 commands to be sent to modem before any other command is issued.
44 o Configuration variable BAUD was introduced, allowing to explicitly
45 set baud rate "pppd" and/or "wvdial" should use. Consult
46 documentation for more information.
47 o Switch "--guruplug" was introduced, instructing script to attempt
48 utilizing leds, found on GuruPlug devices, for indicating progress,
49 errors and success.
50 * Modified functionality:
51 o Script does not anymore wait for modem to register a network,
52 before forcing network specified by FORCE_ISP variable.
53 * Fixed the following issues:
54 o DCOP based versions of "kdialog" now work better (still far from
55 being perfect). Users of such a "kdialog" version, who still face
56 problems, are encouraged to:
57 + Either install and use "zenity" (--zenity switch), or
58 + Use a text-mode UI through "konsole" (--konsole switch).
59 o "nostorage" switch now works as it should. First attempts to unbind
60 usb_storage from device, before attempting to globally unload
61 module. This should fix cases with:
62 + kernels having usb_storage built-in and not as a module,
63 + users having other usb_storage devices mounted which prevent
64 module from unloading.
65 o In cases where operator name is extracted by SIM, first byte is
66 properly considered a flag and not part of the name. This should
67 prevent a non-printable character being displayed before operator's
68 name.
69 o Fixed an issue which prevented some cdc_acm driven devices from
70 working with some kernel versions.
71 o Progress bar should now ascend in a more consistent way.
72 o Text within dialog boxes does not anymore erratically wraps when a
73 translation for current locale exists, still selected UI does not
74 allow translations.
75 o Script will now display translated text even if "UTF8" sub-string
76 of locale used, is typed in lowercase.
77 o Fixed an issue which was resulting into both:
78 + Root instances of script being unable to access X display
79 from which they were initiated,
80 + File "$HOME/-n" and/or "/root/-n" being created and never
81 being deleted.
82 * Icons embedded in script had been on diet.
83 * Changelog file is now human readable (like this: "sakis3g Changelog").
84 * Operators' database:
85 o Modified following networks:
86 + 24004: Sweden 3G: Corrected Tele2 APN.
87 + 24005: Sweden 3G: Corrected Tele2 APN.
88 + 24007: Tele2 (Sweden): APN corrected.
89 + 26803: Optimus (Portugal): Added "Clix" APN.
90
91 0.2.0c 2010/05/14
92
93 * Modified functionality:
94 o APN_USER and APN_PASS variables now override corresponding values
95 loaded from operator database. This would allow using custom APN
96 username and password for misconfigured APNs.
97 * Fixed the following issues:
98 o Helper now obeys 1st "Exit" request, without a second one required.
99 o Script should now work with older wvdial versions as well.
100 * Operators' database:
101 o Modified following networks:
102 + 23430: T-Mobile (United Kingdom): Added "Virgin" APN.
103 + 23802: Telenor (Denmark): Added "BiBoB" APN.
104 o Added the following networks:
105 + 23402: O2 (United Kingdom)
106 + 23410: O2 (United Kingdom)
107 + 23411: O2 (United Kingdom)
108 + 23415: Vodafone (United Kingdom)
109 + 23420: 3 (United Kingdom)
110 + 23431: Virgin (United Kingdom)
111 + 23432: Virgin (United Kingdom)
112 + 23433: Orange (United Kingdom)
113 + 23434: Orange (United Kingdom)
114 + 23801: TDC (Denmark)
115 + 23806: 3 DK (Denmark)
116 + 23806: OiSTER (Denmark)
117 + 23820: Telia (Denmark)
118 + 23830: Telia (Denmark)
119
120 0.2.0b 2010/05/04
121
122 Fixed the following issues:
123 * Better parsing of lsusb output.
124 * Improved compatibility for shell environments without FUNCNAME
125 environment variable support.
126 * Removed --keep-tite argument when invoking dialog.
127
128 0.2.0a 2010/05/02
129
130 Fixed the following issues:
131 * Fixed an issue on systems which provide /proc/bus/usb/devices. Issue had
132 been preventing devices from being properly parsed.
133 * Fixed an issue prevent script to work with shells not providing FUNCNAME
134 environment variable.
135 * Fixed an issue where script was incorrectly following wrong HAL storage
136 polling proccess. Issue had been resulting into script waiting for a
137 useless period of 20 seconds.
138 * Fixed an issue with devices offering more than one storage interfaces
139 after being switched. Employed solution should be revised in the future.
140 * Script now waits for 20 seconds for tty node to get created by driver.
141 * Usb-ModeSwitch is now always called with the -I argument. This should
142 prevent Usb-ModeSwitch from getting blocked for some devices.
143 * Renamed "/ChangeLog" file to "/Changelog"
144
145 0.2.0 2010/04/28
146
147 Sakis3G script version 0.2.0 is written from scratch and is not derived from
148 0.1.3 (now called legacy) series.
149
150 * Examples, user guides, instructions and documentation for legacy version,
151 are not applicable to 0.2.0 series.
152 * Modified functionality:
153 o Drastically improved workflow and device selection procedure,
154 allowing even more USB modems to work with Sakis3G script.
155 o Permanently dropped dependency to sharutils/uudecode. Script now
156 depends on bunzip2 and tar instead.
157 o 9menu binary is not anymore embedded in script, still can be used
158 if "--9menu" or "--legacy" switches are specified.
159 o Menu, presented by user interface, now has more options.
160 o Removed "replacedefaultroute" from pppd arguments since several
161 pppd versions do not recognize it. Script anyway fixes routing
162 table, unless newly introduced "--nofix" switch is set.
163 o You no longer need to provide connection details, again, when using
164 "reconnect" argument, while connected.
165 o Several command line arguments and variables are now obsolete or
166 replaced. Consult documentation for more details.
167 o Setting environment variables, before invoking script, is not
168 anymore encouraged. Instead, they can now be supplied as arguments
169 or within configuration files. Consult documentation for more
170 details.
171 o Employed a workaround for "gksu" versions which do not respect
172 arguments containing whitespace characters.
173 o Employed a workaround for modems not properly displaying operator's
174 name. Name is read from operator's database, if an entry exists.
175 o Improved method of acquiring access to a running X session, when
176 invoked with root privileges.
177 o Kernel module loading/unloading is now safer and cleaner. Script
178 now attempts to unload module only when it refuses to unbind from
179 device.
180 o Script should now be able to utilize even more USB modems (and not
181 just option.ko handled ones).
182 o Modems can now be recognized and setup according to the model name
183 they report, and not by their USB IDs.
184 o Script can now understand whether pppd or wvdial succeeded, or
185 failed, into getting connected, and success is not determined upon
186 timeouts.
187 o Improved desktop shortcut creation method.
188 o Several, less important, modifications.
189 * New functionality:
190 o A more sophisticated concept for command line arguments has been
191 introduced for those wishing to max out possibilities.
192 o Command line arguments, environment variables and user input are
193 now sanitized before being used. This should reduce risk of a
194 malicious user passing specially crafted values.
195 o Several new configuration variables are now introduced, allowing
196 better overall control over performed actions.
197 o Connection information is now available, while connection is still
198 running.
199 o Configurations file(s) are now possible. Consult documentation for
200 more information.
201 o Script can now discover available/best fitted kernel module(s) for
202 a USB modem.
203 o Script can now create character device nodes, within /dev
204 directory, when system did not already.
205 o Script now takes care of not becoming "stalled" when a broken USB
206 device blocks access to USB bus.
207 o Script now exclusively locks "org.freedesktop.Hal.Device.Storage"
208 before switching a device, unless "--nohal" switch is set. This
209 improves stability by reducing simultaneous operations to storage
210 and modem interfaces of a USB device.
211 o Script now utilizes "avoid_reset_quirk" available in recent kernels.
212 o Script now checks for mandatory dependencies being present in PATH,
213 before proceeding with execution.
214 o Script now instructs pppd to use file /etc/ppp/peers/sakis3g, if
215 file exists and pppd is used for connection.
216 o Script now offers a UI for selecting and setting up nearby
217 Bluetooth devices, to be used as modems.
218 o When operator is not found within embedded operators' database,
219 script attempts to fetch last APN, modem was used with, by querying
220 modem.
221 o Subscribers to virtual operators are now presented their operator's
222 name instead of network's name. This is possible by reading service
223 provider's name from SIM card, if modem permits it.
224 o Script can now use "zenity", for becoming a "background process"
225 reachable through an icon in notification area, when "helper"
226 command line argument is used.
227 o It is now possible to keep "secret" a modem from HAL by using
228 "--nohalinform" switch.
229 o It is now possible to request for storage part of a USB device
230 being "eliminated", using "--nostorage" switch, which might improve
231 stability on some devices.
232 o It is now possible to construct a binary free version of script,
233 suitable for all architects. However, binary free version depends
234 on a working Usb-ModeSwitch installation, for setting up switchable
235 USB devices.
236 o It is now possible to disassemble script, back to its ingredients,
237 by using "disassemble" command line argument.
238 o Script can now switch devices, not found within embedded
239 Usb-ModeSwitch device database, if appropriate file is found within
240 /etc/usb_modeswitch.d directory.
241 o Script now embeds man pages, accessible using "man" command line
242 argument.
243 o Script now allows UTF-8 translations, so that localized versions
244 appear in the future. A translation is currently available only for
245 Greek language.
246 o Several, less important, newly introduced functionality.
247 * User interface:
248 o Sakis3G now has its own Tux icon. Icon is used when creating
249 desktop shortcut, unless an operator logo is available and user
250 selects that one instead.
251 o Script can now use anyone of "kdialog", "zenity", "Xdialog",
252 "9menu", "whiptail" and "dialog" for displaying user interface.
253 + If none of them is available, script can resemble an
254 elementary text-mode user interface through shell builtin
255 functions, if "--interactive" switch is set.
256 o Balloon notifications can now appear, when "--balloons" switch is
257 set, using libnotify.
258 o All options available through user interface, are available as
259 command line arguments as well. The opposite statement is not true.
260 o Translations are not used when:
261 + using "Xdialog" or "9menu" as user interface.
262 + displaying OSD messages.
263 + Switch "--notranslate" is set.
264 * Embedded Usb-ModeSwitch:
265 o Upgraded to version 1.1.2alpha.
266 o Device database upgraded to 2010-04-18 version.
267 o It is now possible to compile it for your platform, by using
268 "recompile" command line argument, or by selecting equivalent UI
269 option.
270 o It is now possible to directly reach embedded Usb-ModeSwitch
271 binary, by using "usb_modeswitch" command line argument.
272 * Operators' database:
273 o Entries available in legacy version were migrated to 0.2.0 version.
274 o You can now connect to any operator, even if not found within
275 operators' database. You just need to know APN details.
276 o It is not anymore possible/required to add operators by modifying
277 script.
278 o Modified following networks:
279 + 20201: Cosmote (Greece): Included an extra APN.
280 + 20209: Wind (Greece): Added "Q" APN.
281 + 20210: Wind (Greece): Added "Q" APN.
282 + 26202: Vodafone (Germany): Added "1und1" APN.
283 + 26204: Vodafone (Germany): Added "1und1" APN.
284 + 26209: Vodafone (Germany): Added "1und1" APN.
285 + 26801: Vodafone (Portugal): Added "ZON" APN.
286 o Added the following operators:
287 + 23430: T-Mobile (United Kingdom)
288 + 23802: Telenor (Denmark)
289 + 34001: Orange (French Caraibes)
290
291 ================================================================================
292 Changes below refer to legacy version and should not be considered applicable
293 to latest Sakis3G script version, except operator information.
294 ================================================================================
295
296 0.1.3g 2010/02/24
297
298 Upgraded to Usb-ModeSwitch device database that was released on 2010/02/03.
299
300 0.1.3f 2010/02/14
301
302 Added support for the following 85 networks:
303
304 * 21601: pannon (Hungary)
305 * 21630: T-Mobile (Hungary)
306 * 21670: Vodafone (Hungary)
307 * 21890: BH Mobile (Bosnia & Herzegovina)
308 * 22001: Telenor (Serbia)
309 * 22003: mts (Serbia)
310 * 22005: VIP (Serbia)
311 * 22601: Vodafone (Romania)
312 * 22603: COSMOTE (Romania)
313 * 22610: Orange (Romania)
314 * 22801: Swisscom (Switzerland)
315 * 22802: Sunrise (Switzerland)
316 * 22803: Orange (Switzerland)
317 * 23001: T-Mobile (Czech Republic)
318 * 23002: O2 (Czech Republic)
319 * 23003: Vodafone (Czech Republic)
320 * 23101: Orange (Slovakia)
321 * 23102: T-Mobile (Slovakia)
322 * 23104: T-Mobile (Slovakia)
323 * 24001: Telia (Sweden)
324 * 24002: 3 (Sweden)
325 * 24004: Sweden 3G (Sweden)
326 * 24005: Sweden 3G (Sweden)
327 * 24006: Telenor (Sweden)
328 * 24007: Tele2 (Sweden)
329 * 24008: Telenor (Sweden)
330 * 24201: Telenor (Norway)
331 * 24202: N COM (Norway)
332 * 24204: Network (Norway)
333 * 24205: Network (Norway)
334 * 24403: DNA (Finland)
335 * 24405: Elisa (Finland)
336 * 24421: Saunalahti (Finland)
337 * 24491: Sonera (Finland)
338 * 24701: LMT (Latvia)
339 * 24702: TELE2 (Latvia)
340 * 25001: MTS (Russia)
341 * 25002: Megafon (Russia)
342 * 25003: NCC (Russia)
343 * 25005: ETK (Russia)
344 * 25012: BWC (Russia)
345 * 25016: NTC (Russia)
346 * 25020: Tele2 (Russia)
347 * 25028: Beeline (Russia)
348 * 25035: Motiv (Russia)
349 * 25039: U-tel (Russia)
350 * 25099: Beeline (Russia)
351 * 25501: MTC (Ukraine)
352 * 25502: Beeline (Ukraine)
353 * 25503: Kyivstar (Ukraine)
354 * 25506: Life (Ukraine)
355 * 25507: Utel (Ukraine)
356 * 25701: VELCOM (Belarus)
357 * 25702: MTS (Belarus)
358 * 25703: Life (Belarus)
359 * 25901: Orange (Moldova)
360 * 25902: MOLDCELL (Moldova)
361 * 25904: Eventis (Moldova)
362 * 26001: Plus (Poland)
363 * 26002: ERA (Poland)
364 * 26003: Orange (Poland)
365 * 26006: Play Mobile (Poland)
366 * 27801: VODAFONE (Malta)
367 * 27821: GO Mobile (Malta)
368 * 29340: MOBITEL (Slovenia)
369 * 29341: SI MOBIL (Slovenia)
370 * 29701: ProMonte (Montenegro)
371 * 29702: T-Mobile (Montenegro)
372 * 29703: m:tel (Montenegro)
373 * 33402: TELCEL (Mexico)
374 * 33403: Movistar (Mexico)
375 * 50501: Telstra (Australia)
376 * 50502: Optus (Australia)
377 * 50503: Vodafone (Australia)
378 * 50506: 3 (Australia)
379 * 53000: Telecom (New Zealand)
380 * 53001: Vodafone (New Zealand)
381 * 53005: Telecom (New Zealand)
382 * 60400: Meditel (Morocco)
383 * 60401: IAM (Morocco)
384 * 65501: Voda (South Africa)
385 * 65507: Cell C (South Africa)
386 * 65510: MTN (South Africa)
387 * 71606: Movistar (Peru)
388 * 71610: Claro (Peru)
389
390 0.1.3e 2010/02/11
391
392 Script now utilizes modems that while not advertising their GSM capabilities,
393 they still provide their IMEI number (which indicates GSM functionality).
394 0.1.3d 2010/02/10
395
396 * Updated settings for operators:
397 o 20205: Vodafone (Greece): Added prepay (CU) APN.
398 * Added support for operators:
399 o 20404: Vodafone (Netherlands)
400 o 20408: KPN (Netherlands)
401 o 20412: Telfort (Netherlands)
402 o 20416: T-Mobile (Netherlands)
403 o 20420: Orange (Netherlands)
404 o 20601: Proximus (Belgium)
405 o 20610: Mobistar (Belgium)
406 o 20620: Base (Belgium)
407 o 27001: LUXGSM (Luxembourg)
408 o 27077: Tango (Luxembourg)
409 o 27099: Orange (Luxembourg)
410
411 0.1.3c 2010/02/07
412
413 * Added support for operators:
414 o 20801: Orange (France)
415 o 20810: SFR (France)
416 o 20811: SFR (France)
417 o 20820: Bouygtel (France)
418 o 20821: Bouygtel (France)
419 o 21401: Vodafone (Spain)
420 o 21403: Orange (Spain)
421 o 21404: YOIGO (Spain)
422 o 21406: Vodafone (Spain)
423 o 21407: Movistar (Spain)
424 o 21408: Euskaltel (Spain)
425 o 21409: Orange (Spain)
426 o 21416: Telecable (Spain)
427 o 21417: R móbil (Spain)
428 o 21418: Ono (Spain)
429 o 21419: Simyo (Spain)
430 o 28001: Cytamobile Vodafone (Cyprus)
431 o 28010: MTN (Cyprus)
432 * Fixed following issues:
433 o Now checking if /usr/lib/kde4/libexec/kdesu is available if no
434 other graphical su is found. This will allow using graphical su
435 on KDE4 systems.
436
437 0.1.3b 2010/02/05
438
439 * Upgraded to Usb-ModeSwitch device database that was released on
440 2010/02/03.
441 * Fixed the following issues:
442 o Notification appearing after connecting with "toggle" argument, now
443 also displays operator name.
444 o Whenever script awaits network logon (usually after supplying PIN),
445 instead of querying modem every one second for a maximum of 15
446 seconds (15 tries, one second difference), now queries every four
447 seconds for a maximum of 20 seconds (5 tries, 4 seconds difference).
448 This may help some modems.
449 o When Xterm window appears to prompt user for PIN number, all
450 required information are not read from scratch anymore. This
451 eliminates issues where environment is not passed to child process
452 and accelerates overall operation.
453 o When Xterm window appears to prompt user for PIN number, while
454 DEBUG variable is SET, user has to press Ctrl+C for window to
455 vanish.
456 o Script does not anymore jump to an existing X session of user that
457 invoked it, if user invoked it from a tty console.
458 o If called from udevd, now properly captures access to X DISPLAY :0.
459 + Uses xauth to gain access, if not having already, and drops
460 access when exiting, if it had not access before.
461 + Only does so, if only one non-root user currently has an X
462 session running.
463 o Some initialization stuff is skipped when invoked with a
464 "don't-really-do-anything" argument like "help", "status",
465 "version".
466 o Script now makes sure PATH includes /bin, /usr/bin, /sbin and
467 /usr/sbin before proceeding.
468 o Timestamp information, when running with DEBUG set, now only
469 displays time information, skipping date part.
470
471 0.1.3 2010/02/04
472
473 This version is an "emergency" release which fixes regression issues introduced
474 by 0.1.2.
475
476 * Improved udev integration.
477 * Added logposition configuration variable which indicates log file that
478 should be used when running as a udev rule.
479 * A "debug" method now takes care of displaying debug output when DEBUG
480 variable is set. Displays PID and timestamp along with message. Also
481 reduced script size for 5KB.
482 * Fixed the following issues:
483 o Josua Dietze provided a bug report and a patch for serial device
484 autodetection procedure which fixes a regression issue, introduced
485 by 0.1.2, preventing many modems from having their correct tty
486 device chosen.
487 o Fixed a regression issue, introduced by 0.1.2, which required a
488 modem to be connected even when executing with the "help" argument.
489 o When first using script, 9menu interface does not any more appear
490 as "Unnamed window".
491 o Configuration variable "debug" is now renamed to "DEBUG". This
492 allows for method "debug" to be defined.
493
494 0.1.2 2010/02/01
495
496 * Added better serial tty detection. This method will allow more unknown
497 modems to work.
498 * Added support for user defined modems. To use a user defined modem,
499 USBMODEM variable must contain USB IDs in "XXXX:XXXX" hex form.
500 o If a specific driver is also required, USBDRIVER variable can be
501 used and should contain the module required to be loaded.
502 o Examples:
503 + By exporting variables:
504 $ export USBMODEM=1199:68a3
505 $ export USBDRIVER=sierra
506 $ sakis3g connect
507 + Or, in command line:
508 $ USBMODEM=1199:68a3 \
509 > USBDRIVER=sierra \
510 > sakis3g connect
511 + Or, by editting this script and place them below MYVERSION
512 variable (especially if using sudo for getting root
513 privileges).
514 o When no known/switched modem is found, and USBMODEM variable is not
515 set, 9menu users are presented a list of currently connected USB
516 devices to choose their modem from.
517 * An embedded 9menu binary is now included in script.
518 If:
519 o prefer_osd and stick_to_console are NOT set, and
520 o an X DISPLAY IS detected, and
521 o uudecode IS present, then
522 embedded 9menu binary is utilized.
523 * Script now works flawlessly on LiveCD images that do not provide writable
524 home directories.
525 * Added support for the following operators:
526 o 70401: Claro (Guatemala)
527 o 70402: Tigo (Guatemala)
528 * Added support for the following modems:
529 o 1c9e:f000 GBC PL68
530 * Fixed the following issues:
531 o Drastically improved workflow to avoid executing same things twice
532 or more. Overral operation is now faster.
533 o Does not any more randomly pickup a modem when more than one modems
534 are available. 9menu users are provided a list of modems to choose
535 from. OSD and command line users must provide its name or USB
536 IDs as an extra command line argument. Argument must be long enough
537 to distinguish just one modem.
538 + Example:
539 # If two ZTE modems are connected, then doing "sakis3g
540 connect ZTE" will fail, while "sakis3g connect MF636"
541 will work (if they are not both of the same model).
542 o Supported modems are not any more detected twice as both their
543 official name and as their SWITCHED equivalent.
544 o If more than one modems are connected, does not any more silently
545 proceed with second one, if first one failed to connect for
546 whatever reason.
547 o Moved several parts, of autogenerated part, in the first part.
548 Released around 130 KB, given current device database of
549 Usb-ModeSwitch.
550 o Fixed a long existing issue preventing some switchable devices from
551 being properly switched. Was providing wrong configuration file to
552 Usb-ModeSwitch. Affected devices are a subset of devices with IDs:
553 05c6:1000 and 19d2:2000.
554 o Setting stick_to_console does not any more imply alwayssudo. You
555 must explicitly set alwayssudo for sudo to be used.
556 o Less output should now appear when debug or VERBOSE are not set.
557 o User is now notified if tty device is occupied by another process.
558 This will help users understand whether their modemmanager is
559 messing with their ports.
560 o Unknown, switched and user-defined modems are all now given a 10
561 seconds period to settle connection with driver. This increases
562 time required to connect, but sets more unsupported modems usable.
563 o When debug variable is set, output is now more rich during modem
564 switching.
565 o Large pack of comments found on top part of script are now more
566 readable.
567 o Added copyright notices:
568 + when called with the "help" argument.
569 + on 9menu interface, before connecting.
570
571 0.1.1 2010/01/25
572
573 * Now using fresh 1.1.0 version of Usb-ModeSwitch and 2010/01/24 device
574 database.
575 * Added support for operators offering more than one APNs.
576 o FORCE_APN variable must be set if operator provides more than one
577 APNs, or if requires subscriber number to be included in username
578 or password for ppp connection.
579 * VERXOSD option is renamed to VERBOSE and is now turned off by default.
580 * Added support for operators:
581 o 22201: TIM (Italy)
582 o 22210: Vodafone (Italy)
583 o 22288: WIND (Italy)
584 o 22299: Tre (Italy)
585 o 26202: Vodafone (Germany)
586 o 26207: O2 (Germany)
587 o 26216: Vistream (Germany)
588 o 28601: Vodafone (Portugal)
589 o 28603: Optimus (Portugal)
590 o 28606: TMN (Portugal)
591 o 70802: Tigo (Honduras)
592 * Fixed the following issues:
593 o Script now waits for network logon even for SIM cards that do not
594 need PIN number.
595 o Script does not any more switch modem if called with the "help" or
596 "status" arguments.
597
598 0.1.0 2010/01/20
599
600 * Added progress bar functionality for xosd (osd_cat) users.
601 * Added support for the following operators:
602 o 20209: Wind (Greece)
603 o 23201: Mobilkom/A1 (Austria)
604 o 23203: T-Mobile AT (Austria)
605 o 23205: Orange AT (Austria)
606 o 23207: T-Mobile AT (Austria)
607 o 23210: Drei AT (Austria)
608 o 26201: T-Mobile D1 (Germany)
609 o 26203: E-Plus (Germany)
610 o 26205: E-Plus (Germany)
611 o 26206: T-Mobile D1 (Germany)
612 o 26277: E-Plus (Germany)
613 o 27602: VODAFONE (Albania)
614 * Fixed the following issues:
615 o If "option" driver fails to create devices, it removes it before
616 attempting with driver specified by modem configuration.
617 o Chown operations now do not also define group.
618 o Desktop shortcut is now chmoded to 744.
619 o After supplying PIN number to modem, script now waits for network
620 logon prior to continuing.
621
622 0.0.9 2010/01/15
623
624 Fixed the following issues:
625
626 * Ironic messages appearing when cleaning up files in "/tmp", do not appear
627 any more.
628 * Added wait interval support for devices requiring it (only Huawei E170
629 and family so far).
630
631 0.0.8 2010/01/14
632
633 * Added experimental support for modems:
634 o 12d1:1003: Huawei E170 E220 E230 E270 E870
635 * Fixed the following issues:
636 o Does not mess with HAL for unknown modems.
637 o Now uses a combination of UID/EUID/USER for determining if root or
638 not. Not all shells set all three of them.
639
640 0.0.7 2010/01/13
641
642 * If no gksu/kdesu is found, switches to normal su. Sudo is now used only
643 when no X display is found, or when stick_to_console is set, or when
644 alwayssudo is set.
645 * Fixed the following issues:
646 o Script had been checking for pppd/wvdial existence, prior to being
647 root.
648 o Script now checks for "chat" existence before proceeding.
649 o Now relies on UID, instead of EUID for determining being root or
650 not.
651
652 0.0.6 2010/01/12
653
654 * Added xosd support. xosd is used if neither 9menu nor aosd_cat are
655 installed. It is more popular among distributions. If xosd is also not
656 found, fallbacks to terminal.
657 * Fixed the following issues:
658 o Calls to "which" redirect stderr output to /dev/null. This should
659 eliminate spamming occuring on some configurations.
660 o When "gksu" is not present, checks if "kdesu" exists, and uses that
661 one instead. This should prevent it from using "su" on KDE
662 environments.
663
664 0.0.5 2010/01/10
665
666 * Added HAL support (fallbacks to previous method if HAL is not available):
667 o /dev/tty* device is determined by accessing HAL devices.
668 o HAL is updated of modem capabilities if not already set. This
669 should make modem device appear on hal-aware programs.
670 * Added command line argument "setup", which only setups modem(s):
671 o Switches modem (if not switched).
672 o Loads kernel driver (if not loaded).
673 o Updates HAL for modem capabilities (if not already aware).
674 Using this argument, can be used as udev rule for setting up device
675 and allow use by other applications.
676 * Now uses option driver and if still no serial devices appear, the one on
677 config is used instead.
678 * Fixed the following bugs:
679 o Now makes sure it has root privileges before invoking
680 usb_modeswitch.
681 o If modem gets disconnected, while 9menu is running, it scans if
682 other usable hardware is present. If not, aborts like it used to do.
683
684 0.0.4 2010/01/09
685
686 Updated so that includes newer 1.0.7 version of Usb_ModeSwitch.
687
688 0.0.3 2010/01/04
689
690 * Sakis3G now embeds whole Usb_ModeSwitch 2009/12/28 database. This makes
691 clear to whom, one should refer if facing problems. Issue a "sakis3g
692 connect" from a terminal and watch for messages appearing. If your modem
693 gets properly switched, you should contact Sakis3G author. If modem does
694 not get switched, is probably a new device and you should contact
695 Usb_ModeSwitch forums for further troubleshooting instructions.
696 * Sakis3G now utilizes devices on Usb_ModeSwitch device list with default
697 initialization strings, even if not supported by Sakis3G itself. To
698 identify whether your modem is used like this, issue "sakis3g help".
699 If SWITCHED_MODEM is identified as present hardware, then your modem is
700 used with default values (and may not work).
701 * Sakis3G now detects tty devices appearing from the USB Bus that your
702 modem is attached on, autodetecting appropriate tty device. This should
703 handle cases where other devices, USB or not, create /dev/tty* nodes,
704 leading to the wrong node being selected. If you still have wrong
705 /dev/tty* node selected, try using another USB port. Try "lsusb -t" to
706 see what else devices reside on the same USB bus as your modem.
707
708 0.0.2 2010/01/02
709
710 Initial version published to celebrate blog creation. Only author's equipment
711 and operators are supported.
712
713 * Added comments and instructions within shell script, to increase
714 reusability.
715
716 0.0.1 Can't remember
717
718 Made initially by the author to allow family members to use 3G connections, and
719 easier installation accross different home PCs.
0 Introduction
1 ------------
2
3 This is the source tarball of Sakis3G script. While granted the
4 the "script" title, it actually cheats big time. Scope of Sakis3G
5 is to finally provide a single self-contained shell script to end
6 user, capable to connect him/her through 3G/UMTS/GPRS. Thus, the
7 "script" title.
8
9 Official site: http://www.sakis3g.org/
10
11
12 License
13 -------
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of
18 the License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details:
24
25 http://www.gnu.org/licenses/gpl.txt
26
27 Above statement includes additional charges you may receive from
28 your operator by using this program, defects to your SIM card
29 including but not limited to being PIN blocked, defects on your
30 hardware, 3G service abuse ban etc. USE WITH CARE. Author of this
31 program or authors of any of its dependencies have no responsibi-
32 lity for what may happen to you.
33
34 Author is not related in any way with any of the companies, being
35 operators or modem manufacturers, other than being a customer to
36 some of them. Logos and trademarks mentioned by this package
37 belong to their respective owners.
38
39 This program, in order to remain as self-contained as possible,
40 includes original source packages of some of its dependencies.
41 You should consult their respective COPYING and README files to
42 identify terms under which they are redistributed by Sakis3G.
43
44
45 Scope
46 -----
47
48 Scope of this work is to provide an as small as possible single
49 file which could enable a user to use his 3G USB modem. It does
50 not, in anyway, attempt to be a complete replacement to fully
51 featured solutions or distribution specific methodologies, used
52 for utilizing such devices. Instead, it is supposed to provide:
53
54 - An as small as possible solution to those unlucky enough
55 to have no internet connection, other than their 3G USB
56 modem. They can use this script to initially bring their
57 connection up, and then install all required software.
58 - An alternative solution when anything else has failed.
59 - A small footprint solution for environments and distri-
60 butions that need to keep their profile low.
61
62
63 Package Contents
64 ----------------
65
66 This package contains Sakis3G sources, along with:
67 - Unmodified Usb-ModeSwitch sources.
68 - Unmodified Usb-ModeSwitch device database.
69
70 You can replace contents of their respective directories with
71 more recent -suitable- versions, as long as you mention version
72 and origin of your own supplied versions wherever/whenever you
73 redistribute Sakis3G, either "compiled" or in "source" form and
74 as long as you respect license requirements of Sakis3G and any
75 one of its dependencies mentioned above.
76
77
0 scripts/compile
0 ../usb-modeswitch-data/COPYING
0
1 History of USB-ModeSwitch
2 =========================
3
4 Version 1.1.3, 2010/06/21
5 Added delay option to separate multiple message transfers by millisecs;
6 fixed (possibly dangerous) sloppy string handling (thanks to Christophe
7 Fergeau); added "clear_halt" for response endpoint; small additions in
8 Makefile (install with -D); changes in option handling (NO MORE DEFAULT
9 CONFIG FILE!) and help text; symlink feature in wrapper can now cope
10 with devices providing more than one interrupt port; wrapper now ignores
11 package manager leftovers in config folder; replaced bash-specific syntax
12 in wrapper; changed ZTE skipping (if existing rules are found) to warning
13 Version 1.1.2, 2010/04/18
14 Added support for two additional bulk messages; wrapper handles special
15 ZTE case; generalized driver loading, new parameter "DriverModule" and
16 "DriverIDPath"; new wrapper facility to add symlink pointing to interrupt
17 port (used in rule file from data pack >= 20100418)
18 Version 1.1.1, 2010/03/17
19 Attention: old usb_modeswitch.conf renamed to usb_modeswitch.setup!
20 Add separate config file for wrapper (global settings for switching and
21 logging); add config file option to disable driver loading; handling of
22 kernel attribute AVOID_RESET_QUIRK added; bug fixed in SonyMode (reported
23 by "no-0n3"); bug fixed in SuccessCheck logic; minor flow alignments and
24 fixes; new devices
25 Version 1.1.0, 2010/01/24
26 Attention: wrapper script location changed, uninstall old versions!
27 Major fixes in the wrapper script (stabilizing and time-saving);
28 back to unified installation, defaults to "integrated" approach;
29 new -D parameter to enable "integrated" behaviour; bugs fixed in
30 success check; man file included (borrowed from the Debian package);
31 C code and binary works with the compat library from libusb-1.0;
32 some new devices
33 Version 1.0.7, 2010/01/06
34 Bug fixed for Sony mode, thanks to Marco Chiaranda; fix for parameter
35 substitution in newer udev versions, fix for bad bug in wrapper script
36 practically disabling automatic mode
37 Version 1.0.6, 2009/12/21
38 New "GCT Mode", fixes for device quirks (NXP Dragonfly), fix for multiple
39 Huawei devices, cleanups, loads of new devices in config file and database,
40 minor tcl script changes
41 Version 1.0.5, 2009/08/26
42 More changes and fixes regarding success check; "--version" option;
43 config "database" updated
44 Version 1.0.4, 2009/08/23
45 Success check bugs (and others) fixed
46 Version 1.0.3, 2009/08/20
47 Success check improved; experimental system integration (fully automated),
48 optional; new parameter "TargetProductList" needed for this; other
49 necessary small adaptations; more devices
50 Version 1.0.2, 2009/06/10
51 Output bugs fixed
52 Version 1.0.1, 2009/06/08
53 Added output of descriptor strings for further identification
54 Version 1.0.0, 2009/06/01
55 Attention: possible incompatibilities for command line control!
56 On/off flags don't require arguments anymore (-H, -S, -O, -d, -R,
57 -n, new: -I), meaning "-R 0" does a reset like "-R 1" or "-R";
58 long option names changed to standard format (e.g. --HuaweiMode to
59 --huawei-mode); added device inquiry, for future help with device
60 identification; catch error -19 as possible success; send and response
61 endpoints now autoselected (consequently NeedResponse is back);
62 new devices
63 Version 0.9.7, 2009/04/15
64 Updated SonyMode, MD 400 now stable; automatic default endpoint
65 detection from Andrew Bird
66 Version 0.9.7beta, 2009/03/15
67 Major code clean up, optional success control (both suggested
68 by Daniel Cooper), new devices
69 Version 0.9.6, 2009/01/08
70 Special modes added for Sierra and Sony Ericsson, new devices
71 Version 0.9.5, 2008/10/27
72 New options for USB tuning (jokedst), lots of new devices, clean up
73 Version 0.9.4, 2008/06/09
74 Compat fix for libusb on FreeBSD quirks, more devices
75 Version 0.9.4beta2, 2008/03/19
76 Successful udev device release fix
77 Version 0.9.4beta, 2008/03/16
78 Multiple device support
79 Version 0.9.3, 2008/03/09
80 More devices, no changes from beta version
81 Version 0.9.3beta, 2007/12/30
82 New TargetClass parameter for recent Option firmware (Paul Hardwick), more
83 devices
84 Version 0.9.2, 2007/11/02
85 New Huawei mode (code from Miroslav Bobovsky, added by Denis Sutter), more
86 devices
87 Version 0.9.1beta, 2007/09/04 (jokedst)
88 Added command line parsing, cleaned up config stuff, doc updates
89 Version 0.9beta, 2007/08/15
90 Name change from "icon_switch", parameter file and generalizing
91 Version 0.2, 2006/09/25
92 Code cleaning, more messages
93 Version 0.1, 2006/09/24
94 (as "icon_switch") Just very basic functionality ...
0 PROG = usb_modeswitch
1 VERS = 1.1.3
2 CC = gcc
3 CFLAGS += -Wall -l usb
4 RM = /bin/rm -f
5 OBJS = usb_modeswitch.c
6 PREFIX = $(DESTDIR)/usr
7 ETCDIR = $(DESTDIR)/etc
8 UDEVDIR = $(DESTDIR)/lib/udev
9 SBINDIR = $(PREFIX)/sbin
10 MANDIR = $(PREFIX)/share/man/man1
11
12 .PHONY: clean
13
14 all: $(PROG)
15
16 $(PROG): $(OBJS)
17 $(CC) -o $(PROG) $(OBJS) $(CFLAGS) $(LDFLAGS)
18
19 clean:
20 $(RM) usb_modeswitch
21
22 install: all
23 install -D --mode=755 usb_modeswitch $(SBINDIR)/usb_modeswitch
24 install -D --mode=755 usb_modeswitch.tcl $(UDEVDIR)/usb_modeswitch
25 install -D --mode=644 usb_modeswitch.conf $(ETCDIR)/usb_modeswitch.conf
26 install -D --mode=644 usb_modeswitch.1 $(MANDIR)/usb_modeswitch.1
27
28
29 uninstall:
30 $(RM) $(SBINDIR)/usb_modeswitch
31 $(RM) $(UDEVDIR)/usb_modeswitch
32 $(RM) $(ETCDIR)/usb_modeswitch.conf
33 $(RM) $(MANDIR)/usb_modeswitch.1
34
35 .PHONY: clean install uninstall
36
0 README for USB_ModeSwitch
1
2 For up-to-date and more detailed information (plus a friendly forum) visit
3 http://www.draisberghof.de/usb_modeswitch
4
5
6 What it is
7 ==========
8
9 USB_ModeSwitch is (surprise!) a small mode switching tool for controlling
10 "flip flop" (multiple mode) USB gear.
11
12 Several new USB devices (especially high-speed WAN stuff, based on cell phone
13 chipsets containing that feature) have their MS Windows drivers onboard; when
14 plugged in for the first time they act like a flash storage and start
15 installing the driver from there.
16 After installation (and on every consecutive plugging) the driver switches the
17 mode internally, the storage device vanishes (in most cases), and a new device
18 (like an USB modem) shows up. Modem maker "Option" calls that feature "ZeroCD
19 (TM)".
20
21 In the beginning, nothing of this was documented in any form and there was
22 hardly any Linux support available.
23 On the good side, most of the known devices work out of the box in all modes
24 with the available Linux modules like "usb-storage" or serial USB drivers.
25 That leaves only the problem of the mode-switching from storage to whatever
26 the thing is supposed to do.
27
28 Fortunately there are things like human intelligence, USB sniffing programs and
29 "libusb". It is possible to eavesdrop the communication of the MS Windows
30 driver, to isolate the command or action that does the switching, and to replay
31 the same thing with Linux.
32
33 USB-ModeSwitch eases the pain considerably by taking just the important para-
34 meters from a configuration file and doing all the initialization and communi-
35 cation stuff, with heavy help from "libusb".
36 It is mainly used automatically - via udev events and rules - to do the switch
37 without any user interaction. But it can also be run as a command line tool,
38 usually when trying to make it work with unknown devices.
39
40 We have already collected a wide range of information on how to switch all
41 sorts of devices. If you run into a new one that is unknown yet, don't despair:
42 we can find out what you need to do!
43
44
45 How to install
46 ==============
47
48 !! You need the usb-modeswitch-data package from the same source as this !!
49
50 If you have an earlier version installed, de-installation is recommended ("make
51 uninstall"). The wrapper script location changed in 1.1.0, old ones might be
52 orphaned in /usr/sbin.
53
54 Important: you need "tcl" for the wrapper script to work; if you enter "tclsh"
55 and you get a "%" prompt, you are set (to exit type "exit"). The "tcl" package
56 is part of all distributions I know.
57
58 To install, unpack and in the new directory use this line at the shell (as root):
59
60 > make install
61
62 This installs a wrapper script, a global config file, the binary and a man page.
63
64 Install the data package as well, and you are set already; if your device is
65 known, you should be able to just plug it and use it. If it doesn't work we'll
66 find out why.
67
68
69 For manual use just run "make". Work with the command line interface or
70 with a setup file. You can use any file and give its path with the "-c"
71 parameter.
72 The file named "device_reference.txt" that you can find in this package is
73 a device and configuration reference containing most known devices; you can
74 use it as a base to create your own configuration file.
75 It's heavily commented and should tell you what to do.
76
77 Run "usb-modeswitch -h" to list the command line parameters. If any of them
78 except -W and -q are used, the default config file in /etc is NOT read.
79 See also the provided man page.
80
81 To run the program use it from the source folder or put it somewhere into your
82 path (preferably "/sbin" or "/usr/sbin").
83
84 Note: manual use is intended for testing and analyzing !
85
86 Once your new device is switching fine you can add a rule entry to the rules
87 file to let udev run usb-modeswitch as soon as the default IDs are found
88 (when the device is plugged). Then add your new setup file to
89 "/etc/usb_modeswitch.d". But don't forget to report your success !!
90
91 ##########
92 Important: libusb programs - like this tool - need to be run as root!
93 ##########
94
95
96
97 Known working hardware, Troubleshooting
98 =======================================
99
100 Please see the homepage. Read carefully.
101 For support use ONLY the forum.
102
103
104
105 Contribute
106 ==========
107
108 USB-ModeSwitch comes quite handy for experimenting with your own hardware if
109 not supported yet. You could try this approach:
110
111 Note the device's Vendor and Product ID from /proc/bus/usb/devices (or from the
112 output of lsusb); the assigned driver is usually "usb-storage". Then try spying
113 on the USB communication to the device with the same ID inside M$ Windoze. I
114 recommend this tool:
115 "SniffUSB" (http://benoit.papillault.free.fr/usbsnoop/index.php.en).
116
117 PLEASE post any improvements, new device information and/or bug reports to the
118 forum (see above) or send it to the author (see below)!
119
120
121 Whodunit
122 ========
123
124 Copyright 2007, 2008, 2009, 2010 Josua Dietze (mail to "usb_admin"
125 at the domain "draisberghof.de" or write a personal message through the forum
126 to "Josh"; NO SUPPORT QUESTIONS VIA E-MAIL, use the forum!)
127
128 Command line parsing, decent usage/config output and handling, advanced options
129 and bugfixes:
130 Joakim Wennergren (jokedst) (gmail.com)
131
132 TargetClass parameter implementation to support new Option devices/firmware:
133 Paul Hardwick (http://www.pharscape.org)
134
135 Created with initial help from:
136 "usbsnoop2libusb.pl" by Timo Lindfors
137 (http://iki.fi/lindi/usb/usbsnoop2libusb.pl)
138
139 Config file parsing stuff borrowed from:
140 Guillaume Dargaud (http://www.gdargaud.net/Hack/SourceCode.html)
141
142 Hexstr2bin function borrowed from:
143 Jouni Malinen (http://hostap.epitest.fi/wpa_supplicant, from "common.c")
144
145 Code, fixes and ideas from:
146 Aki Makkonen
147 Denis Sutter
148 Lucas Benedicic
149 Roman Laube
150 Luigi Iotti
151 Vincent Teoh
152 Tommy Cheng
153 Daniel Cooper
154 Andrew Bird
155 Yaroslav Levandovskiy
156 Sakis Dimopoulos
157 Steven Fernandez
158 Christophe Fergeau
159
160 Device information contributors are named in the "device_reference.txt" file.
161
162
163 Legal
164 =====
165
166 This program is free software; you can redistribute it and/or modify it under
167 the terms of the GNU General Public License as published by the Free Software
168 Foundation; either version 2 of the License, or (at your option) any later
169 version.
170
171 This program is distributed in the hope that it will be useful, but WITHOUT ANY
172 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
173 PARTICULAR PURPOSE. See the GNU General Public License for more details:
174
175 http://www.gnu.org/licenses/gpl.txt
176
177 Or find it as the file COPYING in this folder.
178
179
180
181
182 Last revised: 2010-06-21, Josua Dietze
0 # Device and Configuration Reference
1 #
2 # Last modified: 2010-06-21
3 #
4 # Collection of configurations for usb_modeswitch, a mode switching
5 # tool for controlling flip flop (multiple mode) USB devices
6 #
7 # Detailed instructions and a friendly forum on the homepage:
8 # http://www.draisberghof.de/usb_modeswitch
9 #
10 # You may want to check for a newer version of this file at:
11 # http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.setup
12
13
14 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
15 #
16 # Important! This file is just a reference! Use the data package!
17 #
18 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
19
20
21 # In order to activate a device included here you might remove the
22 # comment signs (";") from the respective entry.
23 #
24 # It is rather recommended to copy device information to a different
25 # file, to ease editing work and oversight and to avoid possible
26 # conflicts by activating multiple entries.
27 # There is no guarantee that this file is free of any errors!
28 #
29 # The actual entries are further down, after the command reference.
30
31
32 # For custom settings:
33 # Numbers can be decimal or hexadecimal, MessageStrings MUST be
34 # hexadecimal without prepended "0x". Digits 9-16 in the known
35 # MessageStrings are arbitrary; I set them to "12345678"
36
37 # What it all means (short command line flags appended):
38 #
39 #
40 # * DefaultVendor -v <hex number>
41 # * DefaultProduct -p <hex number>
42 #
43 # This is the ID the USB device shows after having been plugged in.
44 # The program needs this; if not found -> no action.
45 #
46 #
47 # * TargetVendor -V <hex number>
48 # * TargetProduct -P <hex number>
49 #
50 # These are the IDs of the USB device after successful mode switching.
51 # They are optional, but I recommend to provide them for better analysis.
52 # You definitely need them if you enable CheckSuccess (see below)
53 #
54 #
55 # * TargetProductList (file only) <comma separated hex strings>
56 #
57 # Like TargetProduct, but more than one possibility. Only used in automated
58 # config files (in /etc/usb_modeswitch.d).
59 #
60 #
61 # * TargetClass -C <hex number>
62 #
63 # Some weird devices don't change IDs. They only switch the device class.
64 # If the device has the target class -> no action (and vice versa)
65 #
66 #
67 # * MessageEndpoint -m <hex number>
68 #
69 # A kind of address inside the interface to which the "message"
70 # (the sequence that does the actual switching) is directed.
71 # Starting from version 0.9.7 the MessageEndpoint is autodetected
72 # if not given
73 #
74 #
75 # * MessageContent -M <hex string>
76 #
77 # A hex string containing the "message" sequence; it will be
78 # sent as a USB bulk transfer
79 #
80 #
81 # * MessageContent2, ...3 -2/-3 <hex string>
82 #
83 # Additional "messages". Use with "NeedResponse"!
84 #
85 #
86 # * MessageDelay -w <milliseconds>
87 #
88 # Waiting time between message transfers. Only for multiple
89 # message transfers
90 #
91 #
92 # * ResponseEndpoint -r <hex number>
93 # * NeedResponse <0/1> -n
94 #
95 # Some devices were reported to require receiving the response of the
96 # bulk transfer to do the switching properly. Usually not needed.
97 # Starting from version 1.0.0 the ResponseEndpoint is autodetected
98 # if not given
99 #
100 #
101 # * DetachStorageOnly <0/1> -d
102 #
103 # Some devices just need to be detached from the usb-storage
104 # driver to initiate the mode switching. Using this feature
105 # instead of removing the whole usbstorage module keeps other
106 # storage devices working.
107 #
108 #
109 # * HuaweiMode <0/1> -H
110 #
111 # Some Huawei devices can be switched by a special control
112 # message.
113 #
114 #
115 # * SierraMode <0/1> -S
116 #
117 # Some Sierra devices can be switched by a special control
118 # message.
119 #
120 #
121 # * SonyMode <0/1> -O
122 #
123 # Some Sony-Ericsson devices can be switched by a special control
124 # message. This is experimental and might not have a stable result
125 #
126 #
127 # * ResetUSB <0/1> -R
128 #
129 # Some devices need a rougher treatment. If the switching seems
130 # to do something (run udevmonitor), but your system does not reflect
131 # it, try this somewhat brutal method to do a reset after switching.
132 # Mind that if your device switched OK before, this will probably set
133 # it back to storage mode ...
134 #
135 #
136 # * Interface -i <hex number>
137 # * Configuration -u <hex number>
138 # * AltSetting -a <hex number>
139 #
140 # More USB parameter to help with tricky devices and for doing lots
141 # of cruel experiments ...
142 #
143 ## Note:
144 ## AltSetting/Configuration changes and ResetUSB are executed after all
145 ## other steps and can be combined or used on their own (e.g. a reset
146 ## might have the same effect as a manual replug)
147 #
148 #
149 # * InquireDevice <0|1> -I (disables inquiry)
150 #
151 # The standard since 1.0.0 is to do a SCSI inquiry on the default device
152 # before other actions. This might be a future way to identify a device
153 # without ambiguities. If it causes trouble with your device, just disable.
154 #
155 #
156 # * CheckSuccess -s <number>
157 #
158 # Check continuously if the switch succeeded for max <number> seconds.
159 # First, an interface access test: most devices vanish after
160 # switching and can't be accessed anymore.
161 # Second, a recount of target devices: one more than at the initial
162 # count, at the same bus with a higher device number -> device
163 # switched fine.
164 # It's safe to give a higher value than needed; checking stops as
165 # soon as the target device is found
166 #
167 #
168 # * NoDriverLoading <0|1> (no command line parameter)
169 #
170 # The binary tells the wrapper script NOT to check for and initiate
171 # binding of the serial driver after switching.
172 # Mostly useful for non-modem devices
173 #
174 #
175 # -> All other entries are just ignored <-
176
177 # Additional command line flags:
178 #
179 # Verbose output -W
180 # No output at all -q
181 # Other config file -c <file>
182
183 # For filling in all this information for an unknown device,
184 # see instructions and links on the homepage:
185 # http://www.draisberghof.de/usb_modeswitch
186 #
187 # If you find working codes and configurations, please contribute
188 # them!
189
190
191 #######################################################
192 # Option GlobeSurfer Icon (aka "Vodafone EasyBox")
193 #
194 # The message SHOULD be the same for all Option devices
195
196 ;DefaultVendor= 0x05c6
197 ;DefaultProduct= 0x1000
198
199 ;TargetVendor= 0x0af0
200 ;TargetProduct= 0x6600
201
202 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
203
204
205 #######################################################
206 # Option GlobeSurfer Icon 7.2
207 #
208 # Contributor: The Pharscape Forum
209
210 ;DefaultVendor= 0x05c6
211 ;DefaultProduct= 0x1000
212
213 ;TargetVendor= 0x0af0
214 ;TargetProduct= 0x6901
215
216 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
217
218
219 ########################################################
220 # Option GlobeTrotter GT MAX 3.6 (aka "T-Mobile Web'n'walk Card Compact II")
221 #
222 # Contributor: Bernd Holzmüller
223
224 ;DefaultVendor= 0x05c6
225 ;DefaultProduct= 0x1000
226
227 ;TargetVendor= 0x0af0
228 ;TargetProduct= 0x6600
229
230 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
231
232 # ResponseEndpoint=0x84
233
234 ;NeedResponse=1
235
236
237 ########################################################
238 # Option GlobeTrotter GT MAX "7.2 Ready"
239 #
240 # Contributors: Lucas Benedicic, Morgwai Kotarbinski
241
242 ;DefaultVendor= 0x05c6
243 ;DefaultProduct= 0x1000
244
245 ;TargetVendor= 0x0af0
246 ;TargetProduct= 0x6701
247
248 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
249
250
251 ########################################################
252 # Option GlobeTrotter EXPRESS 7.2 (aka "T-Mobile wnw Express II")
253 #
254 # Contributor: Fridtjof Busse
255
256 ;DefaultVendor= 0x05c6
257 ;DefaultProduct= 0x1000
258
259 ;TargetVendor= 0x0af0
260 ;TargetProduct= 0x6701
261
262 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
263
264 # Response reading needed according to one (1) report
265 ;NeedResponse=1
266
267
268 #######################################################
269 # Option GlobeSurfer Icon 7.2, new firmware (HSO driver)
270 #
271 # Vendor/ProductID don't change when switching, only the device
272 # class does. Most new Option devices work with this. Just adapt IDs!
273 # HSO driver support is available at Pharscape (www.pharscape.org)
274 #
275 # Contributor: Paul Hardwick
276
277 ;DefaultVendor= 0x0af0
278 ;DefaultProduct= 0x6911
279
280 ;TargetClass= 0xff
281
282 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
283
284
285 ########################################################
286 # Option iCON 210
287 # PROLiNK PHS100 (various looks)
288 # Hyundai Mobile MB-810
289 #
290 # One report of switching with DetachStorageOnly. Needs at least
291 # a second to settle before binding to usbserial
292 #
293 # Contributor: wahlm, Peter Kraker, Pakdhetimin Sekum
294
295 ;DefaultVendor= 0x1e0e
296 ;DefaultProduct= 0xf000
297
298 ;TargetVendor= 0x1e0e
299 ;TargetProduct= 0x9000
300
301 ;MessageContent="555342431234567800000000000006bd000000020000000000000000000000"
302
303 ;NeedResponse=1
304
305
306 #######################################################
307 # Option iCON 225 HSDPA
308 #
309 # New Firmware. HSO driver support is available at Pharscape (www.pharscape.org)
310 #
311 # Contributor: Matti Viljanen
312
313 ;DefaultVendor= 0x0af0
314 ;DefaultProduct= 0x6971
315
316 ;TargetClass= 0xff
317
318 ;MessageContent="555342431223456780100000080000601000000000000000000000000000000"
319
320
321 #######################################################
322 # Option GlobeTrotter HSUPA Modem (aka "T-Mobile Web'n'walk Card Compact III')
323 #
324 # New Firmware. HSO driver support is available at Pharscape (www.pharscape.org)
325 #
326 # Contributor: Gerold Gruber
327
328 ;DefaultVendor= 0x0af0
329 ;DefaultProduct= 0x7011
330
331 ;TargetClass= 0xff
332
333 ;MessageContent="55534243785634120100000080000601000000000000000000000000000000"
334
335
336 ######################################################
337 # Option iCON 401
338 #
339 # HSO driver
340 #
341 # Contributor: Vincent Teoh
342
343 ;DefaultVendor= 0x0af0
344 ;DefaultProduct= 0x7401
345
346 ;TargetClass= 0xff
347
348 ;MessageContent="55534243785634120100000080000601000000000000000000000000000000"
349
350 ;NeedResponse=1
351
352
353 ########################################################
354 # Vodafone K3760 (made by Option, HSO driver)
355 #
356 # Contributor: The Solutor
357
358 ;DefaultVendor= 0x0af0
359 ;DefaultProduct= 0x7501
360
361 ;TargetClass= 0xff
362
363 ;MessageContent="55534243785634120100000080000601000000000000000000000000000000"
364
365
366 ########################################################
367 # AT&T USBConnect Quicksilver (made by Option, HSO driver)
368 #
369 # Contributor: sissie from Bullteam
370
371 ;DefaultVendor= 0x0af0
372 ;DefaultProduct= 0xd033
373
374 ;TargetClass= 0xff
375
376 ;MessageContent="55534243785634120100000080000601000000000000000000000000000000"
377
378
379 ########################################################
380 # Huawei devices
381 #
382 # Contributor: Hans Kurent, Denis Sutter, Vincent Teoh
383
384 ;DefaultVendor= 0x12d1
385 ;DefaultProduct= 0x1003
386
387 ;TargetClass= 0xff
388
389 ;HuaweiMode=1
390
391
392 ########################################################
393 # Huawei E169
394 #
395 # Contributor: Dale Lane
396
397 ;DefaultVendor= 0x12d1
398 ;DefaultProduct= 0x1001
399
400 ;TargetClass= 0xff
401
402 # choose one of these:
403 ;DetachStorageOnly=1
404 ;HuaweiMode=1
405
406
407 ########################################################
408 # Huawei E180
409 #
410 # Contributor: Tom Dawahare
411
412 ;DefaultVendor= 0x12d1
413 ;DefaultProduct= 0x1414
414
415 ;TargetClass= 0xff
416
417 ;HuaweiMode=1
418
419
420 ########################################################
421 # Huawei E630
422 #
423 # There seem to be modem-only variants around - no storage,
424 # no switching
425 #
426 # Contributor: Joakim Wenrgren
427
428 ;DefaultVendor= 0x1033
429 ;DefaultProduct= 0x0035
430
431 ;TargetVendor= 0x12d1
432 ;TargetProduct= 0x1003
433
434 ;HuaweiMode=1
435
436
437 ########################################################
438 # ZTE MF620 (aka "Onda MH600HS")
439 #
440 # Probably works with DetachStorageOnly too
441 #
442 # Contributor: Flávio Moringa and others
443
444 ;DefaultVendor= 0x19d2
445 ;DefaultProduct= 0x2000
446
447 ;TargetVendor= 0x19d2
448 ;TargetProductList="0001"
449
450 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
451 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
452
453 ;NeedResponse=1
454
455
456 ########################################################
457 # ZTE MF622 (aka "Onda MDC502HS"), MF100 and others
458 #
459 # Contributor: andylog
460
461 ;DefaultVendor= 0x19d2
462 ;DefaultProduct= 0x2000
463
464 ;TargetVendor= 0x19d2
465 ;TargetProduct= 0x0002
466
467 ;MessageContent="5553424312345678240000008000061b000000020000000000000000000000"
468 ;MessageContent2="55534243f8f993882000000080000a85010101180101010101000000000000"
469
470 ;NeedResponse=1
471
472
473 ########################################################
474 # ZTE MF628
475 #
476 # Captured with "usbmon". Has a micro SD slot which can be
477 # activated alternatively
478 #
479 # Contributor: Alvaro Lopes <alvieboy at alvie dot com>
480
481 ;DefaultVendor= 0x19d2
482 ;DefaultProduct= 0x2000
483
484
485 # To modem mode:
486
487 ;TargetVendor= 0x19d2
488 ;TargetProduct= 0x0015
489
490 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
491 ;MessageContent2="55534243876543212000000080000a85010101180101010101000000000000"
492
493 ;NeedResponse=1
494
495 # To SD slot mode:
496
497 ;TargetVendor= 0x05c6
498 ;TargetProduct= 0x2001
499
500 ;MessageContent="55534243123456782000000080000a86010101180101010101000000000000"
501
502 ;NeedResponse=1
503
504
505 ########################################################
506 # ZTE MF622 (aka "Onda MDC502HS")
507 # ZTE MF626
508 # ZTE MF628+ (tested version from Telia / Sweden)
509 # ZTE MF633
510 # ZTE MF636 (aka "Telstra / BigPond 7.2 Mobile Card")
511 # ZTE MF637
512 #
513 # Contributor: Joakim Wennergren and others
514
515 ;DefaultVendor= 0x19d2
516 ;DefaultProduct= 0x2000
517
518 ;TargetVendor= 0x19d2
519 ;TargetProduct= 0x0031
520
521 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
522 ;MessageContent2="5553424312345678000000000000061b000000030000000000000000000000"
523
524 ;NeedResponse=1
525
526
527 ########################################################
528 # ZTE MF638 (aka "Onda MDC525UP")
529 #
530 # Contributor: andylog
531
532 ;DefaultVendor= 0x19d2
533 ;DefaultProduct= 0x2000
534
535 ;TargetVendor= 0x19d2
536 ;TargetProduct= 0x0037
537
538 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
539 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
540
541 ;NeedResponse=1
542
543
544 ########################################################
545 # ZTE AC8710
546 # ZTE AC2726
547 # and others
548 #
549 # Many new ZTE devices use this sequence. There are
550 # several ID combinations; check your default
551 #
552 # Contributor: Michael Khurtsiya, Amit Pundir and others
553
554 ;DefaultVendor= 0x19d2
555 ;DefaultProduct= 0xfff5
556
557 ;TargetVendor= 0x19d2
558 ;TargetProduct= 0xffff
559
560 # No. 2
561
562 ;DefaultVendor= 0x19d2
563 ;DefaultProduct= 0xfff6
564
565 ;TargetVendor= 0x19d2
566 ;TargetProduct= 0xfff1
567
568 # No. 3
569
570 ;DefaultVendor= 0x19d2
571 ;DefaultProduct= 0xfff5
572
573 ;TargetVendor= 0x19d2
574 ;TargetProduct= 0xfff1
575
576 ;MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"
577
578
579 ########################################################
580 # ZTE AC2710 (EVDO)
581 #
582 # Contributor: Wasim Baig
583
584 ;DefaultVendor= 0x19d2
585 ;DefaultProduct= 0xfff5
586
587 ;TargetVendor= 0x19d2
588 ;TargetProduct= 0xffff
589
590 ;MessageContent="5553424312345678c00000008000069f010000000000000000000000000000"
591
592 # Just for information: try it with the message from the AC8710 ...
593
594
595 ########################################################
596 # ZTE 6535-Z
597 #
598 # Contributor: David Taillandier
599
600 ;DefaultVendor= 0x19d2
601 ;DefaultProduct= 0x2000
602
603 ;TargetVendor= 0x19d2
604 ;TargetProduct= 0x0052
605
606 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
607 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
608
609 ;NeedResponse=1
610
611
612 ########################################################
613 # ONDA MT503HS
614 #
615 # Contributor: Lucio Asnaghi a.k.a. kRAkEn/gORe
616
617 ;DefaultVendor= 0x19d2
618 ;DefaultProduct= 0x2000
619
620 ;TargetVendor= 0x19d2
621 ;TargetProduct= 0x0002
622
623 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
624 ;MessageContent2="55534243876543212000000080000a85010101180101010101000000000000"
625
626 ;NeedResponse=1
627
628
629 ########################################################
630 # ONDA MT505UP (most likely a ZTE model)
631 #
632 # Contributor: Alex Scortegagna
633
634 ;DefaultVendor= 0x19d2
635 ;DefaultProduct= 0x2000
636
637 ;TargetVendor= 0x19d2
638 ;TargetProduct= 0x0002
639
640 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
641 ;MessageContent2="55534243876543210000010080000a28000000001c00002000000000000000"
642
643 ;NeedResponse=1
644
645
646 ########################################################
647 # Novatel Wireless Ovation MC950D HSUPA
648 # Novatel Wireless Merlin XU950D
649 # Novatel Wireless Ovation 930D
650 #
651 # Contributor: Razvan Dragomirescu, Mike Kirk
652
653 ;DefaultVendor= 0x1410
654 ;DefaultProduct= 0x5010
655
656 ;TargetVendor= 0x1410
657 ;TargetProduct= 0x4400
658
659 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
660 ;NeedResponse=1
661
662
663 ########################################################
664 # Novatel U727 USB modem
665 #
666 # Modem only versions (no switching required) are around.
667 #
668 # Contributor: Chris Thielen
669
670 ;DefaultVendor= 0x1410
671 ;DefaultProduct= 0x5010
672
673 ;TargetVendor= 0x1410
674 ;TargetProduct= 0x4100
675
676 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
677 ;NeedResponse=1
678
679
680 ########################################################
681 # Novatel MC990D
682 #
683 # Contributor: Joakim Wennergren
684
685 ;DefaultVendor= 0x1410
686 ;DefaultProduct= 0x5020
687
688 ;Interface= 5
689
690 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
691 ;NeedResponse=1
692
693
694 ########################################################
695 # Novatel U760 USB modem
696 #
697 # Contributor: Richard Laager
698
699 ;DefaultVendor= 0x1410
700 ;DefaultProduct= 0x5030
701
702 ;TargetVendor= 0x1410
703 ;TargetProduct= 0x6000
704
705 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
706 ;NeedResponse=1
707
708
709 ########################################################
710 # Alcatel One Touch X020 (aka OT-X020, aka MBD-100HU, aka Nuton 3.5G), works with Emobile D11LC
711 # Alcatel One Touch X030 (aka OT-X030, aka Nuton NT36HD)
712 #
713 # Contributor: Aleksandar Samardzic, Marcelo Fernandez
714
715 ;DefaultVendor= 0x1c9e
716 ;DefaultProduct= 0x1001
717
718 ;TargetVendor= 0x1c9e
719 ;TargetProduct= 0x6061
720
721 ;MessageContent="55534243123456780000000000000606f50402527000000000000000000000"
722
723
724 ########################################################
725 # Alcatel X200/X060S
726
727 ;DefaultVendor= 0x1bbb
728 ;DefaultProduct= 0xf000
729
730 ;TargetVendor= 0x1bbb
731 ;TargetProduct= 0x0000
732
733 ;MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
734
735
736 ########################################################
737 # AnyDATA ADU-500A, ADU-510A, ADU-510L, ADU-520A
738 #
739 # This ID gets an "Option" treatment by newer kernels.
740 # Use module option "option_zero_cd=2" with usb-storage.
741 # A kernel patch to fix the problem is pending
742 #
743 # Contributor: Vladimir Poluektov, Gabriel Smolar
744
745 ;DefaultVendor= 0x05c6
746 ;DefaultProduct= 0x1000
747
748 ;TargetVendor= 0x16d5
749 ;TargetProduct= 0x6502
750
751 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
752 ;NeedResponse=1
753
754
755 ########################################################
756 # BandLuxe C120
757 #
758 # Reportedly needs several switch calls in a certain order. See
759 # http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=71
760 # This might be a case to try the new ResetUSB function
761 #
762 # Contributor: Alexander Czigler
763
764 ;DefaultVendor= 0x1a8d
765 ;DefaultProduct= 0x1000
766
767 ;TargetVendor= 0x1a8d
768 ;TargetProduct= 0x1002
769
770 ;MessageContent="55534243123456781200000080000603000000020000000000000000000000"
771
772 ;NeedResponse=1
773
774
775 ########################################################
776 # Solomon S3Gm-660
777 #
778 # Same notes apply as with the BandLuxe C120 above
779 #
780 # Contributor: Alexander Czigler
781
782 ;DefaultVendor= 0x1dd6
783 ;DefaultProduct= 0x1000
784
785 ;TargetVendor= 0x1dd6
786 ;TargetProduct= 0x1002
787
788 ;MessageContent="55534243123456781200000080000603000000020000000000000000000000"
789
790 ;NeedResponse=1
791
792
793 ########################################################
794 # C-motech D-50 (aka "CDU-680")
795 #
796 # Interesting notes about the device in the forum post at
797 # http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=69
798 #
799 # Contributor: Alexander Czigler
800
801 ;DefaultVendor= 0x16d8
802 ;DefaultProduct= 0x6803
803
804 ;TargetVendor= 0x16d8
805 ;TargetProduct= 0x680a
806
807 ;MessageContent="555342431234567824000000800008ff524445564348470000000000000000"
808
809
810 ########################################################
811 # C-motech CGU-628 (aka "Franklin Wireless CGU-628A" aka "4G Systems XS Stick W12")
812 #
813 # Contributor: Mathias Picker
814
815 ;DefaultVendor= 0x16d8
816 ;DefaultProduct= 0xf000
817
818 ;TargetVendor= 0x16d8
819 ;TargetProduct= 0x6006
820
821 ;MessageContent="55534243d85dd88524000000800008ff524445564348470000000000000000"
822
823
824 ########################################################
825 # Toshiba G450
826 #
827 # Contributor: Mijail Anton
828
829 ;DefaultVendor= 0x0930
830 ;DefaultProduct= 0x0d46
831
832 ;TargetVendor= 0x0930
833 ;TargetProduct= 0x0d45
834
835 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
836
837 ;NeedResponse=1
838
839
840 ########################################################
841 # UTStarcom UM175 (distributor "Alltel")
842 #
843 # Contributor: Mark A. Ziesemer
844
845 ;DefaultVendor= 0x106c
846 ;DefaultProduct= 0x3b03
847
848 ;TargetVendor= 0x106c
849 ;TargetProduct= 0x3715
850
851 ;MessageContent="555342431234567824000000800008ff024445564348470000000000000000"
852
853
854 ########################################################
855 # Hummer DTM5731
856 #
857 # Contributor: "paul"
858
859 ;DefaultVendor= 0x1ab7
860 ;DefaultProduct= 0x5700
861
862 ;TargetVendor= 0x1ab7
863 ;TargetProduct= 0x5731
864
865 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
866
867 ;NeedResponse=1
868
869
870 ########################################################
871 # A-Link 3GU
872 #
873 # Contributor: A-Link Europe Ltd.
874
875 ;DefaultVendor= 0x1e0e
876 ;DefaultProduct= 0xf000
877
878 ;TargetVendor= 0x1e0e
879 ;TargetProduct= 0x9200
880
881 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
882
883 ;NeedResponse=1
884
885
886 ########################################################
887 # Sierra Wireless Compass 597
888 #
889 # Contributor: Vincent Teoh
890
891 ;DefaultVendor= 0x1199
892 ;DefaultProduct= 0x0fff
893
894 ;TargetVendor= 0x1199
895 ;TargetProduct= 0x0023
896
897 ;SierraMode=1
898
899
900 ########################################################
901 # Sierra Wireless AirCard 881U (most likely 880U too)
902 #
903 # Contributor: Vincent Teoh
904
905 ;DefaultVendor= 0x1199
906 ;DefaultProduct= 0x0fff
907
908 ;TargetVendor= 0x1199
909 ;TargetProduct= 0x6856
910
911 ;SierraMode=1
912
913
914 ########################################################
915 # Sony Ericsson MD400
916 #
917 # Special procedure, takes around 25 secs. on the whole
918
919 ;DefaultVendor= 0x0fce
920 ;DefaultProduct= 0xd0e1
921
922 ;TargetClass= 0x02
923
924 ;SonyMode=1
925 ;Configuration=2
926
927
928 ########################################################
929 # LG LDU-1900D EV-DO (Rev. A)
930 #
931 # Recommended init command: ATE0V1&D2&C1S0=0
932 #
933 # Contributor: Jérôme Oufella
934
935 ;DefaultVendor= 0x1004
936 ;DefaultProduct= 0x1000
937
938 ;MessageContent="55534243123456780000000000000aff554d53434847000000000000000000"
939
940
941 ########################################################
942 # Samsung SGH-Z810 USB (with microSD card)
943 #
944 # This ID gets a wrong "Option" treatment by newer kernels
945 # from 2.6.29 to 2.6.31
946 # Use module option "option_zero_cd=2" with usb-storage.
947 # Problem fixed in 2.6.32
948 #
949 # Contributor: A Friend
950
951 ;DefaultVendor= 0x05c6
952 ;DefaultProduct= 0x1000
953
954 ;TargetVendor= 0x04e8
955 ;TargetProduct= 0x6601
956
957 ;MessageContent="55534243123456780000000000000616000000000000000000000000000000"
958
959
960 ########################################################
961 # MobiData MBD-200HU
962 #
963 # Contributor: Stefan Olejnik
964
965 ;DefaultVendor= 0x1c9e
966 ;DefaultProduct= 0xf000
967
968 ;TargetVendor= 0x1c9e
969 ;TargetProduct= 0x9000
970
971 ;MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
972
973
974 ########################################################
975 # ST Mobile Connect HSUPA USB Modem
976 #
977 # Use /dev/ttyUSB2 for connecting
978 #
979 # Contributor: Vincent Teoh
980
981 ;DefaultVendor= 0x1c9e
982 ;DefaultProduct= 0xf000
983
984 ;TargetVendor= 0x1c9e
985 ;TargetProduct= 0x9063
986
987 ;MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
988
989
990 ########################################################
991 # MyWave SW006 Sport Phone/Modem Combination
992 #
993 # Has a card reader too, working fine
994 #
995 # Contributor: Aaron Guidazzi
996
997 ;DefaultVendor= 0x1c9e
998 ;DefaultProduct= 0x9200
999
1000 ;TargetVendor= 0x1c9e
1001 ;TargetProduct= 0x9202
1002
1003 ;MessageContent="55534243123456780000000000000606f50402527000000000000000000000"
1004
1005
1006 ########################################################
1007 # Cricket A600
1008 #
1009 # Switches to ACM device. Might need a ResetUSB after switching - or not
1010 #
1011 # Contributor: Jeffrey Hoogland
1012
1013 ;DefaultVendor= 0x1f28
1014 ;DefaultProduct= 0x0021
1015
1016 ;TargetVendor= 0x1f28
1017 ;TargetProduct= 0x0020
1018
1019 ;MessageContent="555342431234567824000000800108df200000000000000000000000000000"
1020
1021 # Afterwards (optional): "usb_modeswitch -v 0x1f28 -p 0x0020 -R"
1022
1023
1024 ########################################################
1025 # EpiValley SEC-7089 (featured by Alegro and Starcomms / iZAP)
1026 #
1027 # Contributor: Chris Wright
1028
1029 ;DefaultVendor= 0x1b7d
1030 ;DefaultProduct= 0x0700
1031
1032 ;TargetVendor= 0x1b7d
1033 ;TargetProduct= 0x0001
1034
1035 ;MessageContent="555342431234567824000000800008FF05B112AEE102000000000000000000"
1036
1037
1038 ########################################################
1039 # Samsung U209
1040 #
1041 # Has a modem and a storage device after switching
1042 #
1043 # Contributor: Arif Ahmed
1044
1045 ;DefaultVendor= 0x04e8
1046 ;DefaultProduct= 0xf000
1047
1048 ;TargetVendor= 0x04e8
1049 ;TargetProduct= 0x6601
1050
1051 ;MessageContent="55534243123456780000000000000616000000000000000000000000000000"
1052
1053
1054 ########################################################
1055 # Huawei E270+ (HSPA+ modem)
1056 # Huawei E1762
1057 # Huawei E1820
1058 #
1059 # Contributor: Paranoid Paranoia
1060
1061 ;DefaultVendor= 0x12d1
1062 ;DefaultProduct= 0x1446
1063
1064 ;TargetVendor= 0x12d1
1065 ;TargetProduct= 0x14ac
1066
1067 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1068
1069
1070 ########################################################
1071 # Huawei E1550
1072 # Huawei E1750
1073 #
1074 # Contributor: Anders Blomdell, Ahmed Soliman
1075
1076 ;DefaultVendor= 0x12d1
1077 ;DefaultProduct= 0x1446
1078
1079 ;TargetVendor= 0x12d1
1080 ;TargetProduct= 0x1001
1081
1082 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1083
1084
1085 ########################################################
1086 # ZTE K3520-Z
1087 #
1088 # Contributor: Paul McDermott
1089
1090 ;DefaultVendor= 0x19d2
1091 ;DefaultProduct= 0x2000
1092
1093 ;TargetVendor= 0x19d2
1094 ;TargetProduct= 0x0055
1095
1096 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1097 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
1098
1099 ;NeedResponse=1
1100
1101
1102 ########################################################
1103 # MobiData MBD-200HU (aka 4G XS Stick W10/W14, aka Micromax MMX 300G,
1104 # aka ChinaBird CBCPL68)
1105 #
1106 # Contributor: Chris
1107
1108 ;DefaultVendor= 0x1c9e
1109 ;DefaultProduct= 0xf000
1110
1111 ;TargetVendor= 0x1c9e
1112 ;TargetProduct= 0x9603
1113
1114 ;MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
1115
1116
1117 ########################################################
1118 # D-Link DWM-162-U5, Micromax MMX 300c
1119 #
1120 # Contributor: Zhang Le
1121
1122 ;DefaultVendor= 0x05c6
1123 ;DefaultProduct= 0x2001
1124
1125 ;TargetVendor= 0x1e0e
1126 ;TargetProductList="ce16,cefe"
1127
1128 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1129
1130 ;NeedResponse=1
1131
1132
1133 ########################################################
1134 # Novatel MC760 3G
1135 #
1136 # Contributor: Matt Roberds
1137
1138 ;DefaultVendor= 0x1410
1139 ;DefaultProduct= 0x5031
1140
1141 ;TargetVendor= 0x1410
1142 ;TargetProduct= 0x6002
1143
1144 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1145
1146 ;NeedResponse=1
1147
1148
1149 ########################################################
1150 # ZTE MF110 (Variant)
1151 #
1152 # Contributor: Moritz Grosse-Wentrup
1153
1154 ;DefaultVendor= 0x19d2
1155 ;DefaultProduct= 0x0053
1156
1157 ;TargetVendor= 0x19d2
1158 ;TargetProduct= 0x0031
1159
1160 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1161 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
1162
1163 ;NeedResponse=1
1164
1165
1166 ########################################################
1167 # Philips TalkTalk (NXP Semiconductors "Dragonfly")
1168 #
1169
1170 ;DefaultVendor= 0x0471
1171 ;DefaultProduct= 0x1237
1172
1173 ;TargetVendor= 0x0471
1174 ;TargetProduct= 0x1234
1175
1176 ;MessageContent="5553424312345678000000000000061b000000030000000000000000000000"
1177
1178 ;NeedResponse=1
1179
1180
1181 ########################################################
1182 # HuaXing E600 (NXP Semiconductors "Dragonfly")
1183 #
1184 # Contributor: Emfox Zhou
1185
1186 ;DefaultVendor= 0x0471
1187 ;DefaultProduct= 0x1237
1188
1189 ;TargetVendor= 0x0471
1190 ;TargetProduct= 0x1206
1191
1192 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1193
1194 ;NeedResponse=1
1195
1196 ;Configuration=2
1197
1198
1199 ########################################################
1200 # ZTE K3565
1201 #
1202
1203 ;DefaultVendor= 0x19d2
1204 ;DefaultProduct= 0x2000
1205
1206 ;TargetVendor= 0x19d2
1207 ;TargetProduct= 0x0063
1208
1209 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1210
1211 ;NeedResponse=1
1212
1213
1214 ########################################################
1215 # Motorola 802.11 bg WLAN (TER/GUSB3-E)
1216 #
1217 # Contributor: Prashad Prashant
1218
1219 ;DefaultVendor= 0x148f
1220 ;DefaultProduct= 0x2578
1221
1222 ;TargetVendor= 0x148f
1223 ;TargetProduct= 0x9021
1224
1225 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1226
1227 ;NeedResponse=1
1228
1229
1230 ########################################################
1231 # Huawei E1612
1232 #
1233 # Contributor: Genar Codina
1234
1235 ;DefaultVendor= 0x12d1
1236 ;DefaultProduct= 0x1446
1237
1238 ;TargetVendor= 0x12d1
1239 ;TargetProduct= 0x1406
1240
1241 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1242
1243
1244 ########################################################
1245 # Huawei E1690
1246 # Huawei E1692
1247 # Huawei E1762
1248 #
1249 # Contributor: Carolin Latze and others
1250
1251 ;DefaultVendor= 0x12d1
1252 ;DefaultProduct= 0x1446
1253
1254 ;TargetVendor= 0x12d1
1255 ;TargetProduct= 0x140c
1256
1257 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1258
1259
1260 ########################################################
1261 # C-motech CHU-629S
1262 #
1263
1264 ;DefaultVendor= 0x16d8
1265 ;DefaultProduct= 0x700a
1266
1267 ;TargetClass=0xff
1268
1269 ;MessageContent="55534243123456782400000080000dfe524445564348473d4e444953000000"
1270
1271
1272 ########################################################
1273 # Sagem F@ST 9520-35-GLR
1274 #
1275 # Contributor: Yaroslav Levandovskiy
1276
1277 ;DefaultVendor= 0x1076
1278 ;DefaultProduct= 0x7f40
1279
1280 ;TargetVendor= 0x1076
1281 ;TargetProduct= 0x7f00
1282
1283 ;GCTMode=1
1284
1285
1286 ########################################################
1287 # Nokia CS-15
1288 #
1289 # Contributor: Antti Turunen
1290
1291 ;DefaultVendor= 0x0421
1292 ;DefaultProduct= 0x0610
1293
1294 ;TargetVendor= 0x0421
1295 ;TargetProduct= 0x0612
1296
1297 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1298
1299 ;NeedResponse=1
1300
1301
1302 ########################################################
1303 # Huawei K3765
1304 #
1305 # Contributor: Felix Schwarz
1306
1307 ;DefaultVendor= 0x12d1
1308 ;DefaultProduct= 0x1520
1309
1310 ;TargetVendor= 0x12d1
1311 ;TargetProduct= 0x1465
1312
1313 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1314
1315
1316 ########################################################
1317 # Huawei K4505
1318 #
1319 # Contributor: Nikolaos Koutsianas
1320
1321 ;DefaultVendor= 0x12d1
1322 ;DefaultProduct= 0x1521
1323
1324 ;TargetVendor= 0x12d1
1325 ;TargetProduct= 0x1464
1326
1327 ;MessageContent="55534243123456780000000000000011060000000000000000000000000000"
1328
1329
1330 #########################################
1331 # Vodafone MD950 (Wisue Technology)
1332 #
1333 # Contributor: Bob Williams
1334
1335 ;DefaultVendor= 0x0471
1336 ;DefaultProduct= 0x1210
1337
1338 # The report said that giving the target IDs prevented
1339 # the device from switching. Got to try it out ...
1340
1341 #TargetVendor= 0x1dbc
1342 #TargetProduct= 0x0005
1343
1344 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1345
1346 ;NeedResponse=1
1347
1348
1349 ########################################################
1350 # Siptune LM-75 ("LinuxModem")
1351 #
1352 # Contributor: Antti Turunen
1353
1354 ;DefaultVendor= 0x05c6
1355 ;DefaultProduct= 0xf000
1356
1357 ;TargetVendor= 0x05c6
1358 ;TargetProduct= 0x9000
1359
1360 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1361
1362
1363 ########################################################
1364 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 1)
1365 #
1366 # WLAN devices from Linux kernel
1367
1368 ;DefaultVendor= 0x0ace
1369 ;DefaultProduct= 0x2011
1370
1371 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1372
1373 ;NeedResponse=1
1374
1375
1376 ########################################################
1377 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 2)
1378 #
1379 # WLAN devices from Linux kernel
1380
1381 ;DefaultVendor= 0x0ace
1382 ;DefaultProduct= 0x20ff
1383
1384 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1385
1386 ;NeedResponse=1
1387
1388
1389 ########################################################
1390 # Vertex Wireless 100 Series
1391 #
1392 # Contributor: Reinis Danne
1393
1394 ;DefaultVendor= 0x05c6
1395 ;DefaultProduct= 0x1000
1396
1397 ;TargetVendor= 0x1fe7
1398 ;TargetProduct= 0x0100
1399
1400 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1401
1402 ;NeedResponse=1
1403
1404
1405 ########################################################
1406 # AVM Fritz!Wlan USB Stick N
1407 #
1408
1409 ;DefaultVendor= 0x057c
1410 ;DefaultProduct= 0x84ff
1411
1412 ;TargetVendor= 0x057c
1413 ;TargetProduct= 0x8401
1414
1415 ;MessageContent="5553424312345678000000000000061b000000ff0000000000000000000000"
1416
1417
1418 ########################################################
1419 # InfoCert Business Key (SmartCard/Reader emulation)
1420 #
1421 # Contributor: Bicio
1422
1423 ;DefaultVendor= 0x072f
1424 ;DefaultProduct= 0x100d
1425
1426 ;TargetVendor= 0x072f
1427 ;TargetProduct= 0x90cc
1428
1429 ;MessageContent="01b0000000000000000000000000000000000000000000000000000000000000"
1430
1431
1432 ########################################################
1433 # UTStarcom UM185E (distributor "Alltel")
1434 #
1435 # Contributor: Jason Smith
1436
1437 ;DefaultVendor= 0x106c
1438 ;DefaultProduct= 0x3b06
1439
1440 ;TargetVendor= 0x106c
1441 ;TargetProduct= 0x3717
1442
1443 ;MessageContent="555342431234567824000000800008ff020000000000000000000000000000
1444
1445
1446 ########################################################
1447 # ZTE AC581
1448 #
1449 # Contributor: Alberto Maurizi
1450
1451 ;DefaultVendor= 0x19d2
1452 ;DefaultProduct= 0x0026
1453
1454 ;TargetVendor= 0x19d2
1455 ;TargetProduct= 0x0094
1456
1457 ;MessageContent="5553424312345678240000008000061b000000020000000000000000000000"
1458
1459 ;NeedResponse=1
1460
1461
1462 ########################################################
1463 # Huawei U7510 / U7517
1464 #
1465 # Contributor: Isaac Salgado
1466
1467 ;DefaultVendor= 0x12d1
1468 ;DefaultProduct= 0x101e
1469
1470 ;TargetClass=0xff
1471
1472 ;MessageContent="55534243123456780600000080000601000000000000000000000000000000"
1473
1474
1475 ########################################################
1476 # Beceem BCSM250
1477 #
1478 # Contributor: Alexander Gordeev
1479
1480 ;DefaultVendor= 0x198f
1481 ;DefaultProduct=0xbccd
1482
1483 ;TargetVendor= 0x198f
1484 ;TargetProduct= 0x0220
1485
1486 MessageContent="555342431234567824000000800006bc626563240000000000000000000000"
1487
1488
1489 ########################################################
1490 # LG HDM-2100 (EVDO Rev.A USB modem)
1491 #
1492 # Contributor: Jérôme Oufella
1493
1494 ;DefaultVendor= 0x1004
1495 ;DefaultProduct=0x607f
1496
1497 ;TargetVendor= 0x1004
1498 ;TargetProduct= 0x6114
1499
1500 ;MessageContent="1201100102000040041014610000010200018006000100001200"
1501
1502
1503 ########################################################
1504 # Kyocera W06K CDMA modem
1505 #
1506 # Contributor: Ying-Hung Lo
1507
1508 ;DefaultVendor= 0x0482
1509 ;DefaultProduct=0x024d
1510
1511 ;Configuration=2
1512
1513
1514 ########################################################
1515 # Digicom 8E4455
1516 #
1517 # Contributor: Alberto Ciampini
1518
1519 ;DefaultVendor= 0x1266
1520 ;DefaultProduct=0x1000
1521
1522 ;TargetVendor= 0x1266
1523 ;TargetProduct= 0x1009
1524
1525 ;MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
1526 ;MessageContent2="5553424387654321000000000000061b000000020000000000000000000000"
1527
1528 ;NeedResponse=1
1529
1530
1531 ########################################################
1532 # Sony Ericsson MD300
1533 #
1534 # Contributor: Betavine Project
1535
1536 ;DefaultVendor= 0x0fce
1537 ;DefaultProduct=0xd0cf
1538
1539 ;TargetClass=0x02
1540
1541 ;DetachStorageOnly=1
1542 ;Configuration=3
1543
1544
1545 ########################################################
1546 # Franklin Wireless U210
1547 #
1548 # Contributor: Adam J. Porter
1549
1550 ;DefaultVendor= 0x1fac
1551 ;DefaultProduct=0x0130
1552
1553 ;TargetVendor= 0x1fac
1554 ;TargetProduct= 0x0131
1555
1556 ;CheckSuccess=20
1557
1558 ;MessageContent="555342431234567824000000800108df200000000000000000000000000000"
1559
1560
1561 ########################################################
1562 # Alcatel X220L, X215S
1563 #
1564 # Contributor: John Watt
1565
1566 ;DefaultVendor= 0x1bbb
1567 ;DefaultProduct= 0xf000
1568
1569 ;TargetVendor= 0x1bbb
1570 ;TargetProduct= 0x0017
1571
1572 ;MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
1573
1574
1575 ########################################################
1576 # ZTE MF112
1577 #
1578 # Contributors: Akos Ladanyi, John Talbut
1579
1580 ;DefaultVendor= 0x19d2
1581 ;DefaultProduct= 0x0103
1582
1583 ;TargetVendor= 0x19d2
1584 ;TargetProduct= 0x0031
1585
1586 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1587 ;MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
1588
1589 ;NeedResponse=1
1590
1591
1592 ########################################################
1593 # Olivetti Olicard 100 and others
1594 #
1595 # Contributor: Nils Radke
1596
1597 ;DefaultVendor= 0x0b3c
1598 ;DefaultProduct= 0xc700
1599
1600 ;TargetVendor= 0x0b3c
1601 ;TargetProductList="c000,c001,c002"
1602
1603 ;MessageContent="5553424312345678000000000000061b000000030000000000000000000000"
1604
1605 ;NeedResponse=1
1606
1607
1608 ########################################################
1609 # ZTE MF110 (Variant)
1610 #
1611 # Contributor: uusrlnx
1612
1613 ;DefaultVendor= 0x19d2
1614 ;DefaultProduct= 0x0083
1615
1616 ;TargetVendor= 0x19d2
1617 ;TargetProduct= 0x0124
1618
1619 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1620
1621 ;NeedResponse=1
1622
1623
1624 ########################################################
1625 # ZTE MU351
1626
1627 ;DefaultVendor= 0x19d2
1628 ;DefaultProduct= 0x0003
1629
1630 ;TargetClass=0xff
1631
1632 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1633
1634 ;NeedResponse=1
1635
1636
1637 ########################################################
1638 # LG L-05A
1639
1640 ;DefaultVendor= 0x1004
1641 ;DefaultProduct= 0x613a
1642
1643 ;TargetVendor= 0x1004
1644 ;TargetProduct= 0x6124
1645
1646 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1647
1648 ;NeedResponse=1
1649
1650
1651 ########################################################
1652 # LG LUU-2100TI (aka AT&T USBConnect Turbo)
1653 #
1654 # Contributor: Chris Jager
1655
1656 ;DefaultVendor= 0x1004
1657 ;DefaultProduct= 0x613f
1658
1659 ;TargetVendor= 0x1004
1660 ;TargetProduct= 0x6141
1661
1662 ;MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
1663
1664 ;NeedResponse=1
1665
1666
1667 ########################################################
1668 # LG KP500 Cookie Phone - UNTESTED! Please report!
1669 #
1670 # Contributor: Oliver Mattos
1671
1672 ;DefaultVendor= 0x1004
1673 ;DefaultProduct=0x607f
1674
1675 ;TargetVendor= 0x1004
1676 ;TargetProduct= 0x6000
1677
1678 ;MessageContent="555342431234567803000000800006f1022000000000000000000000000000"
1679 ;MessageContent2="555342438765432103000000800006f1010100000000000000000000000000"
1680
1681 ;NeedResponse=1
1682
1683
1684 ########################################################
1685 # Royaltek Q110 - UNCONFIRMED!
1686
1687 ;DefaultVendor= 0x1266
1688 ;DefaultProduct= 0x1000
1689
1690 ;TargetVendor= 0x1266
1691 ;TargetProduct= 0x1009
1692
1693 ;MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
1694 ;MessageContent2="5553424387654321000000000000061b000000020000000000000000000000"
1695
1696 ;NeedResponse=1
1697
1698
1699 ########################################################
1700 # Rogers Rocket Stick (a Sony Ericsson device)
1701
1702 ;DefaultVendor= 0x0fce
1703 ;DefaultProduct= 0xd103
1704
1705 ;TargetClass= 0x02
1706
1707 ;SonyMode=1
1708
1709
1710 ########################################################
1711 # BandRich BandLuxe C170, BandLuxe C270
1712
1713 ;DefaultVendor= 0x1a8d
1714 ;DefaultProduct=0x1000
1715
1716 ;TargetVendor= 0x1a8d
1717 ;TargetProduct= 0x1009
1718
1719 ;MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
1720 ;MessageContent2="5553424312345679000000000000061b000000020000000000000000000000"
1721
1722 ;NeedResponse=1
1723
1724
0 .TH "USB-MODESWITCH" "1"
1 .SH "NAME"
2 usb_modeswitch - switch mode of "multi-state" USB devices
3 .SH "SYNOPSIS"
4 .PP
5 \fBusb_modeswitch\fR [\fB-hvpVPmM23rdHn\fP] [\fB-c \fIfilename\fP]
6 .SH "DESCRIPTION"
7 .PP
8 Several new USB devices have their proprietary Windows drivers onboard,
9 most of them WAN dongles. When plugged in for the first time, they act
10 like a flash storage and start installing the Windows driver from there.
11 If the driver is already installed, it makes the storage device disappear
12 and a new device, mainly composite with modem ports, shows up.
13 .PP
14 On Linux, in most cases the drivers are available as kernel modules,
15 such as "usbserial" or "option". However, the device shows up as
16 "usb-storage" by default. \fBusb_modeswitch\fR can send a provided bulk
17 message (most likely a mass storage command) to the device which is known
18 to initiate the mode switching.
19 .PP
20 In some cases, USB control commands are used for switching. These cases are
21 handled by custom functions, and no bulk message needs to be provided.
22 .PP
23 Usually, the program is distributed with a set of configurations for many
24 known devices, which in combination with a wrapper script launched from the
25 udev daemon allows a fully automatic handling of a device upon insertion.
26
27 .SH "OPTIONS"
28 .PP
29 This program follows the usual GNU command line syntax,
30 with long options starting with two dashes ('--'). A summary of
31 options is included below.
32 .IP "\fB-h\fP \fB\-\-help\fP " 10
33 Show summary of options.
34 .IP "\fB-e\fP \fB\-\-version\fP " 10
35 Print version information and exit.
36 .IP "\fB-v\fP \fB\-\-default-vendor NUM\fP " 10
37 Vendor ID to look for (mandatory), usually given as hex number (example: 0x12d1).
38 Each USB device is identified by a number
39 officialy assigned to the vendor by the USB association and a number for the
40 respective model (product ID) chosen by the vendor
41 .IP "\fB-p\fP \fB\-\-default-product NUM\fP " 10
42 Product ID to look for (mandatory).
43 .IP "\fB-V\fP \fB\-\-target-vendor NUM\fP " 10
44 Target vendor ID. When given will be searched for and detected initially
45 for information purposes. If success checking (option -s) is active,
46 providing target IDs (vendor/product) or target class is recommended
47 .IP "\fB-P\fP \fB\-\-target-product NUM\fP " 10
48 Target product ID
49 .IP "\fB-C\fP \fB\-\-target-class NUM\fP " 10
50 Target Device Class according to the USB specification. Some devices keep
51 their original vendor/product ID after successful switching. To prevent
52 them from being treated again, the device class can be checked.
53 For unswitched devices it is always 8 (storage class), for switched
54 modems it is often 0xff (vendor specific). In composite modes,
55 the class of the first interface is watched
56 .IP "\fB-m\fP \fB\-\-message-endpoint NUM\fP " 10
57 A specific endpoint to use for data transfers. Only for testing purposes; usually
58 endpoints are determined from the device attributes
59 .IP "\fB-M\fP \fB\-\-message-content STRING\fP " 10
60 A bulk message to send as a switching command. Provided as a hexadecimal string
61 .IP "\fB-2, -3\fP \fB\-\-message-content2, \-\-message-content3 STRING\fP " 10
62 Additional bulk messages to send as switching commands. Provided as hexadecimal strings.
63 When used with mass storage commands, setting \fB\-\-need-response\fR is
64 strongly advised to comply with specifications and to avoid likely errors
65 .IP "\fB-w\fP \fB\-\-message-delay NUM\fP " 10
66 If there is more than one message content, wait for NUM milliseconds
67 before sending the next one. Otherwise it is ignored. Note: this will release
68 and reclaim the interface
69 .IP "\fB-n\fP \fB\-\-need-response\fP " 10
70 Read the response (command status wrapper) to a mass storage command
71 transfer.
72 Some devices have trouble switching if the response is not read; most
73 are disappearing right away. When sending multiple mass storage commands
74 with \fB\-2\fR and \fB\-3\fR, this must be set to avoid transfer errors
75 .IP "\fB-r\fP \fB\-\-response-endpoint NUM\fP " 10
76 Try to read the response to a storage command from there
77 if option -n is active. Only for testing purposes; usually
78 endpoints are determined from the device attributes
79 .IP "\fB-d\fP \fB\-\-detach-only\fP " 10
80 Detach the storage driver as the only action. This is sufficient for some
81 devices to switch successfully
82 .IP "\fB-H\fP \fB\-\-huawei-mode\fP " 10
83 Send a special control message used by older Huawei devices
84 .IP "\fB-S\fP \fB\-\-gct-mode\fP " 10
85 Send a special control message used by Sierra devices
86 .IP "\fB-G\fP \fB\-\-gct-mode\fP " 10
87 Send a special control message used by GCT chipsets
88 .IP "\fB-O\fP \fB\-\-sony-mode\fP " 10
89 Apply a special sequence used by Sony Ericsson devices. Implies option -s
90 .IP "\fB-R\fP \fB\-\-reset-usb\fP " 10
91 Send a USB reset command to the device. Can be combined with any switching
92 method or stand alone. It is always done as the last step of all device
93 interactions.
94 Few devices need it to complete the switching; apart from that it may be
95 useful during testing
96 .IP "\fB-c\fP \fB\-\-config filename\fP " 10
97 Use a specific config file. If any ID or switching options are given as
98 command line parameters, this option is ignored.
99 In that case all mandatory parameters have to be provided on
100 the command line
101 .IP "\fB-Q\fP \fB\-\-quiet\fP " 10
102 Don't show progress or error messages
103 .IP "\fB-W\fP \fB\-\-verbose\fP " 10
104 Print all settings before running and show libusb debug messages
105 .IP "\fB-D\fP \fB\-\-sysmode\fP " 10
106 Changes the behaviour of the program slightly. A success message including the
107 effective target device ID is put out and a syslog notice is issued. Mainly for
108 integration with a wrapper script
109 .IP "\fB-s\fP \fB\-\-success NUM\fP " 10
110 After switching, keep checking for the result up to max. NUM seconds. If target IDs
111 or target class were provided, their appearance indicates certain success. Otherwise
112 the disconnection of the original device is rated as likely proof
113 .IP "\fB-I\fP \fB\-\-no-inquire\fP " 10
114 do not obtain SCSI attributes from device (default is on). For proper identification
115 of differing devices the attributes of the storage part provide valuable information.
116 This is not needed for devices that are known and supported
117 .IP "\fB-i\fP \fB\-\-interface NUM\fP " 10
118 Select initial USB interface (default: 0). Only for testing purposes
119 .IP "\fB-u\fP \fB\-\-configuration NUM\fP " 10
120 Select USB configuration (applied after switching). Mainly for testing
121 .IP "\fB-a\fP \fB\-\-altsetting NUM\fP " 10
122 Select alternative USB interface setting (applied after switching). Mainly
123 for testing
124 .SH "AUTHOR"
125 .PP
126 This manual page was originally written by Didier Raboud ([email protected]) for
127 the \fBDebian\fP system. Additions made by Josua Dietze. Permission is
128 granted to copy, distribute and/or modify this document under
129 the terms of the GNU General Public License, Version 2 or any
130 later version published by the Free Software Foundation.
131
132 .PP
133 The complete text of the current GNU General Public
134 License can be found in http://www.gnu.org/licenses/gpl.txt
135
136 .\" last edited 2010-06-21
0 /*
1 Mode switching tool for controlling flip flop (multiple device) USB gear
2 Version 1.1.3, 2010/06/21
3
4 Copyright (C) 2007, 2008, 2009, 2010 Josua Dietze (mail to "usb_admin" at the
5 domain from the README; please do not post the complete address to the Net!
6 Or write a personal message through the forum to "Josh")
7
8 Command line parsing, decent usage/config output/handling, bugfixes and advanced
9 options added by:
10 Joakim Wennergren (jokedst) (gmail.com)
11
12 TargetClass parameter implementation to support new Option devices/firmware:
13 Paul Hardwick (http://www.pharscape.org)
14
15 Created with initial help from:
16 "usbsnoop2libusb.pl" by Timo Lindfors (http://iki.fi/lindi/usb/usbsnoop2libusb.pl)
17
18 Config file parsing stuff borrowed from:
19 Guillaume Dargaud (http://www.gdargaud.net/Hack/SourceCode.html)
20
21 Hexstr2bin function borrowed from:
22 Jouni Malinen (http://hostap.epitest.fi/wpa_supplicant, from "common.c")
23
24 Other contributions: see README
25
26 Device information contributors are named in the "usb_modeswitch.setup" file.
27
28 This program is free software; you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation; either version 2 of the License, or
31 (at your option) any later version.
32
33 This program is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details:
37
38 http://www.gnu.org/licenses/gpl.txt
39
40 */
41
42 /* Recommended tab size: 4 */
43
44 #define VERSION "1.1.3"
45
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <assert.h>
50 #include <signal.h>
51 #include <ctype.h>
52 #include <getopt.h>
53 #include <syslog.h>
54
55 #include <usb.h>
56 #include "usb_modeswitch.h"
57
58 #define LINE_DIM 1024
59 #define BUF_SIZE 4096
60 #define DESCR_MAX 129
61
62 #define SEARCH_DEFAULT 0
63 #define SEARCH_TARGET 1
64
65 #define SHOW_PROGRESS if (show_progress) printf
66
67 //int write_bulk(int endpoint, char *message, int length);
68 //int read_bulk(int endpoint, char *buffer, int length);
69
70 //int find_first_bulk_output_endpoint(struct usb_device *dev);
71 //int find_first_bulk_input_endpoint(struct usb_device *dev);
72
73 char *TempPP=NULL;
74
75 struct usb_device *dev;
76 struct usb_dev_handle *devh;
77
78 int DefaultVendor=0, DefaultProduct=0, TargetVendor=0, TargetProduct=0, TargetClass=0;
79 int MessageEndpoint=0, ResponseEndpoint=0, defaultClass=0, MessageDelay=0;
80 int targetDeviceCount=0;
81 int devnum=-1, busnum=-1;
82 int ret;
83
84 char DetachStorageOnly=0, HuaweiMode=0, SierraMode=0, SonyMode=0, GCTMode=0;
85 char verbose=0, show_progress=1, ResetUSB=0, CheckSuccess=0, config_read=0;
86 char NeedResponse=0, NoDriverLoading=0, InquireDevice=1, sysmode=0;
87
88 char imanufact[DESCR_MAX], iproduct[DESCR_MAX], iserial[DESCR_MAX];
89
90 char MessageContent[LINE_DIM];
91 char MessageContent2[LINE_DIM];
92 char MessageContent3[LINE_DIM];
93 char TargetProductList[LINE_DIM];
94 char ByteString[LINE_DIM/2];
95 char buffer[BUF_SIZE];
96
97 // Settable Interface and Configuration (for debugging mostly) (jmw)
98 int Interface = 0, Configuration = -1, AltSetting = -1;
99
100
101 static struct option long_options[] = {
102 {"help", no_argument, 0, 'h'},
103 {"version", no_argument, 0, 'e'},
104 {"default-vendor", required_argument, 0, 'v'},
105 {"default-product", required_argument, 0, 'p'},
106 {"target-vendor", required_argument, 0, 'V'},
107 {"target-product", required_argument, 0, 'P'},
108 {"target-class", required_argument, 0, 'C'},
109 {"message-endpoint", required_argument, 0, 'm'},
110 {"message-content", required_argument, 0, 'M'},
111 {"message-content2", required_argument, 0, '2'},
112 {"message-content3", required_argument, 0, '3'},
113 {"message-delay", required_argument, 0, 'w'},
114 {"response-endpoint", required_argument, 0, 'r'},
115 {"detach-only", no_argument, 0, 'd'},
116 {"huawei-mode", no_argument, 0, 'H'},
117 {"sierra-mode", no_argument, 0, 'S'},
118 {"sony-mode", no_argument, 0, 'O'},
119 {"gct-mode", no_argument, 0, 'G'},
120 {"need-response", no_argument, 0, 'n'},
121 {"reset-usb", no_argument, 0, 'R'},
122 {"config", required_argument, 0, 'c'},
123 {"verbose", no_argument, 0, 'W'},
124 {"quiet", no_argument, 0, 'Q'},
125 {"sysmode", no_argument, 0, 'D'},
126 {"no-inquire", no_argument, 0, 'I'},
127 {"check-success", required_argument, 0, 's'},
128 {"interface", required_argument, 0, 'i'},
129 {"configuration", required_argument, 0, 'u'},
130 {"altsetting", required_argument, 0, 'a'},
131 {0, 0, 0, 0}
132 };
133
134
135 void readConfigFile(const char *configFilename)
136 {
137 if (verbose) printf("Reading config file: %s\n", configFilename);
138 ParseParamHex(configFilename, TargetVendor);
139 ParseParamHex(configFilename, TargetProduct);
140 ParseParamString(configFilename, TargetProductList);
141 ParseParamHex(configFilename, TargetClass);
142 ParseParamHex(configFilename, DefaultVendor);
143 ParseParamHex(configFilename, DefaultProduct);
144 ParseParamBool(configFilename, DetachStorageOnly);
145 ParseParamBool(configFilename, HuaweiMode);
146 ParseParamBool(configFilename, SierraMode);
147 ParseParamBool(configFilename, SonyMode);
148 ParseParamBool(configFilename, GCTMode);
149 ParseParamBool(configFilename, NoDriverLoading);
150 ParseParamHex(configFilename, MessageEndpoint);
151 ParseParamString(configFilename, MessageContent);
152 ParseParamString(configFilename, MessageContent2);
153 ParseParamString(configFilename, MessageContent3);
154 ParseParamInt(configFilename, MessageDelay);
155 ParseParamHex(configFilename, NeedResponse);
156 ParseParamHex(configFilename, ResponseEndpoint);
157 ParseParamHex(configFilename, ResetUSB);
158 ParseParamHex(configFilename, InquireDevice);
159 ParseParamInt(configFilename, CheckSuccess);
160 ParseParamHex(configFilename, Interface);
161 ParseParamHex(configFilename, Configuration);
162 ParseParamHex(configFilename, AltSetting);
163
164 // TargetProductList has priority over TargetProduct
165 if (strlen(TargetProductList))
166 TargetProduct = 0;
167
168 config_read = 1;
169 }
170
171
172 void printConfig()
173 {
174 if ( DefaultVendor )
175 printf ("DefaultVendor= 0x%04x\n", DefaultVendor);
176 else
177 printf ("DefaultVendor= not set\n");
178 if ( DefaultProduct )
179 printf ("DefaultProduct= 0x%04x\n", DefaultProduct);
180 else
181 printf ("DefaultProduct= not set\n");
182 if ( TargetVendor )
183 printf ("TargetVendor= 0x%04x\n", TargetVendor);
184 else
185 printf ("TargetVendor= not set\n");
186 if ( TargetProduct )
187 printf ("TargetProduct= 0x%04x\n", TargetProduct);
188 else
189 printf ("TargetProduct= not set\n");
190 if ( TargetClass )
191 printf ("TargetClass= 0x%02x\n", TargetClass);
192 else
193 printf ("TargetClass= not set\n");
194 printf ("TargetProductList=\"%s\"\n", TargetProductList);
195 printf ("\nDetachStorageOnly=%i\n", (int)DetachStorageOnly);
196 printf ("HuaweiMode=%i\n", (int)HuaweiMode);
197 printf ("SierraMode=%i\n", (int)SierraMode);
198 printf ("SonyMode=%i\n", (int)SonyMode);
199 printf ("GCTMode=%i\n", (int)GCTMode);
200 if ( MessageEndpoint )
201 printf ("MessageEndpoint=0x%02x\n", MessageEndpoint);
202 else
203 printf ("MessageEndpoint= not set\n");
204 // if ( strlen(MessageContent) )
205 printf ("MessageContent=\"%s\"\n", MessageContent);
206 // else
207 // printf ("MessageContent= not set\n");
208 if ( strlen(MessageContent2) )
209 printf ("MessageContent2=\"%s\"\n", MessageContent2);
210 if ( strlen(MessageContent3) )
211 printf ("MessageContent3=\"%s\"\n", MessageContent3);
212 printf ("NeedResponse=%i\n", (int)NeedResponse);
213 if ( ResponseEndpoint )
214 printf ("ResponseEndpoint=0x%02x\n", ResponseEndpoint);
215 else
216 printf ("ResponseEndpoint= not set\n");
217 printf ("Interface=0x%02x\n", Interface);
218 if ( Configuration > -1 )
219 printf ("Configuration=0x%02x\n", Configuration);
220 if ( AltSetting > -1 )
221 printf ("AltSetting=0x%02x\n", AltSetting);
222 if ( InquireDevice )
223 printf ("\nInquireDevice enabled (default)\n");
224 else
225 printf ("\nInquireDevice disabled\n");
226 if ( CheckSuccess )
227 printf ("Success check enabled, max. wait time %d seconds\n", CheckSuccess);
228 else
229 printf ("Success check disabled\n");
230 if ( sysmode )
231 printf ("System integration mode enabled\n");
232 else
233 printf ("System integration mode disabled\n");
234 printf ("\n");
235 }
236
237
238 int readArguments(int argc, char **argv)
239 {
240 int c, option_index = 0, count=0;
241 // if (argc==1)
242 // return 0;
243 if (argc==1)
244 {
245 printHelp();
246 exit(1);
247 }
248
249 while (1)
250 {
251 c = getopt_long (argc, argv, "heWQDndHSOGRIv:p:V:P:C:m:M:2:3:w:r:c:i:u:a:s:",
252 long_options, &option_index);
253
254 /* Detect the end of the options. */
255 if (c == -1)
256 break;
257 count++;
258 switch (c)
259 {
260 case 'R': ResetUSB = 1; break;
261 case 'v': DefaultVendor = strtol(optarg, NULL, 16); break;
262 case 'p': DefaultProduct = strtol(optarg, NULL, 16); break;
263 case 'V': TargetVendor = strtol(optarg, NULL, 16); break;
264 case 'P': TargetProduct = strtol(optarg, NULL, 16); break;
265 case 'C': TargetClass = strtol(optarg, NULL, 16); break;
266 case 'm': MessageEndpoint = strtol(optarg, NULL, 16); break;
267 case 'M': strcpy(MessageContent, optarg); break;
268 case '2': strcpy(MessageContent2, optarg); break;
269 case '3': strcpy(MessageContent3, optarg); break;
270 case 'w': MessageDelay = strtol(optarg, NULL, 10); count--; break;
271 case 'n': NeedResponse = 1; break;
272 case 'r': ResponseEndpoint = strtol(optarg, NULL, 16); break;
273 case 'd': DetachStorageOnly = 1; break;
274 case 'H': HuaweiMode = 1; break;
275 case 'S': SierraMode = 1; break;
276 case 'O': SonyMode = 1; break;
277 case 'G': GCTMode = 1; break;
278 case 'c': readConfigFile(optarg); break;
279 case 'W': verbose = 1; show_progress = 1; count--; break;
280 case 'Q': show_progress = 0; verbose = 0; count--; break;
281 case 'D': sysmode = 1; count--; break;
282 case 's': CheckSuccess = strtol(optarg, NULL, 10); count--; break;
283 case 'I': InquireDevice = 0; break;
284
285 case 'i': Interface = strtol(optarg, NULL, 16); break;
286 case 'u': Configuration = strtol(optarg, NULL, 16); break;
287 case 'a': AltSetting = strtol(optarg, NULL, 16); break;
288
289 case 'e':
290 printVersion();
291 exit(0);
292 break;
293 case 'h':
294 printVersion();
295 printHelp();
296 exit(0);
297 break;
298
299 default: //Unsupported - error message has already been printed
300 printf ("\n");
301 printHelp();
302 exit(1);
303 }
304 }
305
306 return count;
307 }
308
309
310 int main(int argc, char **argv)
311 {
312 int numDefaults = 0, specialMode = 0, sonySuccess = 0;
313
314 // Make sure we have an empty string even if not set by config
315 TargetProductList[0] = '\0';
316 MessageContent[0] = '\0';
317 MessageContent2[0] = '\0';
318 MessageContent3[0] = '\0';
319
320
321 signal(SIGTERM, release_usb_device);
322 /*
323 * Parameter parsing, USB preparation/diagnosis, plausibility checks
324 */
325
326 // Check command arguments, use params instead of config file when given
327 switch (readArguments(argc, argv)) {
328 case 0: // no argument or -W, -q or -s
329 // readConfigFile("/etc/usb_modeswitch.setup");
330 break;
331 default: // one or more arguments except -W, -q or -s
332 if (!config_read) // if arguments contain -c, the config file was already processed
333 if (verbose) printf("Taking all parameters from the command line\n\n");
334 }
335
336 if (verbose)
337 printVersion();
338
339 if (verbose)
340 printConfig();
341
342 // libusb initialization
343 usb_init();
344
345 if (verbose)
346 usb_set_debug(15);
347
348 usb_find_busses();
349 usb_find_devices();
350
351 // Plausibility checks. The default IDs are mandatory
352 if (!(DefaultVendor && DefaultProduct)) {
353 SHOW_PROGRESS("No default vendor/product ID given. Aborting.\n\n");
354 exit(1);
355 }
356 if (strlen(MessageContent)) {
357 if (strlen(MessageContent) % 2 != 0) {
358 fprintf(stderr, "Error: MessageContent hex string has uneven length. Aborting.\n\n");
359 exit(1);
360 }
361 if ( hexstr2bin(MessageContent, ByteString, strlen(MessageContent)/2) == -1) {
362 fprintf(stderr, "Error: MessageContent %s\n is not a hex string. Aborting.\n\n", MessageContent);
363 exit(1);
364 }
365 }
366 SHOW_PROGRESS("\n");
367
368 if (show_progress)
369 if (CheckSuccess && !(TargetVendor || TargetProduct || strlen(TargetProductList)) && !TargetClass)
370 printf("Note: target parameter missing; success check limited\n");
371
372 // Count existing target devices (remember for success check)
373 if (TargetVendor || TargetClass) {
374 SHOW_PROGRESS("Looking for target devices ...\n");
375 search_devices(&targetDeviceCount, TargetVendor, TargetProduct, TargetProductList, TargetClass, SEARCH_TARGET);
376 if (targetDeviceCount) {
377 SHOW_PROGRESS(" Found devices in target mode or class (%d)\n", targetDeviceCount);
378 } else
379 SHOW_PROGRESS(" No devices in target mode or class found\n");
380 }
381
382 // Count default devices, return the last one found
383 SHOW_PROGRESS("Looking for default devices ...\n");
384 dev = search_devices(&numDefaults, DefaultVendor, DefaultProduct, "\0", TargetClass, SEARCH_DEFAULT);
385 if (numDefaults) {
386 SHOW_PROGRESS(" Found devices in default mode or class (%d)\n", numDefaults);
387 } else {
388 SHOW_PROGRESS(" No devices in default mode or class found. Nothing to do. Bye.\n\n");
389 exit(0);
390 }
391 if (dev != NULL) {
392 devnum = dev->devnum;
393 busnum = (int)strtol(dev->bus->dirname,NULL,10);
394 SHOW_PROGRESS("Accessing device %03d on bus %03d ...\n", devnum, busnum);
395 devh = usb_open(dev);
396 } else {
397 SHOW_PROGRESS(" No default device found. Is it connected? Bye.\n\n");
398 exit(0);
399 }
400
401 // Get class of default device
402 defaultClass = dev->descriptor.bDeviceClass;
403 if (defaultClass == 0)
404 defaultClass = dev->config[0].interface[0].altsetting[0].bInterfaceClass;
405 else
406 if (dev->config[0].interface[0].altsetting[0].bInterfaceClass == 8 && defaultClass != 8) {
407 // Weird device with default class other than 0 and differing interface class
408 SHOW_PROGRESS("Ambiguous Class/InterfaceClass: 0x%02x/0x08", defaultClass);
409 defaultClass = 8;
410 }
411
412 // Check or get endpoints if needed
413 if (!MessageEndpoint && (strlen(MessageContent) || InquireDevice) ) {
414 MessageEndpoint = find_first_bulk_output_endpoint(dev);
415 if (!MessageEndpoint && strlen(MessageContent)) {
416 fprintf(stderr,"Error: message endpoint not given or found. Aborting.\n\n");
417 exit(1);
418 }
419 }
420 if (!ResponseEndpoint && (NeedResponse || InquireDevice) ) {
421 ResponseEndpoint = find_first_bulk_input_endpoint(dev);
422 if (!ResponseEndpoint && NeedResponse) {
423 fprintf(stderr,"Error: response endpoint not given or found. Aborting.\n\n");
424 exit(1);
425 }
426 }
427 if (MessageEndpoint && ResponseEndpoint) {
428 SHOW_PROGRESS("Using endpoints 0x%02x (out) and 0x%02x (in)\n", MessageEndpoint, ResponseEndpoint);
429 } else
430 if (InquireDevice && defaultClass == 0x08) {
431 SHOW_PROGRESS("Endpoints not found, skipping SCSI inquiry\n");
432 InquireDevice = 0;
433 }
434
435 if (InquireDevice && show_progress) {
436 if (defaultClass == 0x08) {
437 SHOW_PROGRESS("Inquiring device details; driver will be detached ...\n");
438 detachDriver();
439 if (deviceInquire() >= 0)
440 InquireDevice = 2;
441 } else
442 SHOW_PROGRESS("Not a storage device, skipping SCSI inquiry\n");
443 }
444
445 deviceDescription();
446 if (show_progress) {
447 printf("\nUSB description data (for identification)\n");
448 printf("-------------------------\n");
449 printf("Manufacturer: %s\n", imanufact);
450 printf(" Product: %s\n", iproduct);
451 printf(" Serial No.: %s\n", iserial);
452 printf("-------------------------\n");
453 }
454
455 // Some scenarios are exclusive, so check for unwanted combinations
456 specialMode = DetachStorageOnly + HuaweiMode + SierraMode + SonyMode;
457 if ( specialMode > 1 ) {
458 SHOW_PROGRESS("Invalid mode combination. Check your configuration. Aborting.\n\n");
459 exit(1);
460 }
461
462 if ( !specialMode && !strlen(MessageContent) && AltSetting == -1 && Configuration == -1 )
463 SHOW_PROGRESS("Warning: no switching method given.\n");
464
465 /*
466 * The switching actions
467 */
468
469 if (sysmode) {
470 openlog("usb_modeswitch", 0, LOG_SYSLOG);
471 syslog(LOG_NOTICE, "switching %04x:%04x (%s: %s)", DefaultVendor, DefaultProduct, imanufact, iproduct);
472 }
473
474 if (DetachStorageOnly) {
475 SHOW_PROGRESS("Only detaching storage driver for switching ...\n");
476 if (InquireDevice == 2) {
477 SHOW_PROGRESS(" Any driver was already detached for inquiry\n");
478 } else {
479 ret = detachDriver();
480 if (ret == 2)
481 SHOW_PROGRESS(" You may want to remove the storage driver manually\n");
482 }
483 }
484
485 if (HuaweiMode) {
486 switchHuaweiMode();
487 }
488 if (SierraMode) {
489 switchSierraMode();
490 }
491 if (GCTMode) {
492 detachDriver();
493 switchGCTMode();
494 }
495 if (SonyMode) {
496 if (CheckSuccess)
497 SHOW_PROGRESS("Note: ignoring CheckSuccess. Separate checks for Sony mode\n");
498 CheckSuccess = 0; // separate and implied success control
499 sonySuccess = switchSonyMode();
500 }
501
502 if (strlen(MessageContent) && MessageEndpoint) {
503 if (specialMode == 0) {
504 if (InquireDevice != 2)
505 detachDriver();
506 switchSendMessage();
507 } else
508 SHOW_PROGRESS("Warning: ignoring MessageContent. Can't combine with special mode\n");
509 }
510
511 if (Configuration != -1) {
512 switchConfiguration ();
513 }
514
515 if (AltSetting != -1) {
516 switchAltSetting();
517 }
518
519 if (ResetUSB) {
520 resetUSB();
521 }
522
523 if (CheckSuccess) {
524 if (checkSuccess()) {
525 if (sysmode) {
526 if (NoDriverLoading)
527 printf("ok:\n");
528 else
529 printf("ok:%04x:%04x\n", TargetVendor, TargetProduct);
530 }
531 } else
532 if (sysmode)
533 printf("fail:\n");
534 } else {
535 if (SonyMode)
536 if (sonySuccess) {
537 if (sysmode) {
538 syslog(LOG_NOTICE, "switched S.E. MD400 to modem mode");
539 printf("ok:\n"); // ACM device, no driver action
540 }
541 SHOW_PROGRESS("-> device should be stable now. Bye.\n\n");
542 } else {
543 if (sysmode)
544 printf("fail:\n");
545 SHOW_PROGRESS("-> switching was probably not completed. Bye.\n\n");
546 }
547 else
548 SHOW_PROGRESS("-> Run lsusb to note any changes. Bye.\n\n");
549 }
550
551 if (sysmode)
552 closelog();
553 if (devh)
554 usb_close(devh);
555 exit(0);
556 }
557
558
559 /* Get descriptor strings if available (identification details) */
560 void deviceDescription ()
561 {
562 int ret;
563 char* c;
564 memset (imanufact, ' ', DESCR_MAX);
565 memset (iproduct, ' ', DESCR_MAX);
566 memset (iserial, ' ', DESCR_MAX);
567
568 if (dev->descriptor.iManufacturer) {
569 ret = usb_get_string_simple(devh, dev->descriptor.iManufacturer, imanufact, DESCR_MAX);
570 if (ret < 0)
571 fprintf(stderr, "Error: could not get description string \"manufacturer\"\n");
572 } else
573 strcpy(imanufact, "not provided");
574 c = strstr(imanufact, " ");
575 if (c)
576 memset((void*)c, '\0', 1);
577
578 if (dev->descriptor.iProduct) {
579 ret = usb_get_string_simple(devh, dev->descriptor.iProduct, iproduct, DESCR_MAX);
580 if (ret < 0)
581 fprintf(stderr, "Error: could not get description string \"product\"\n");
582 } else
583 strcpy(iproduct, "not provided");
584 c = strstr(iproduct, " ");
585 if (c)
586 memset((void*)c, '\0', 1);
587
588 if (dev->descriptor.iSerialNumber) {
589 ret = usb_get_string_simple(devh, dev->descriptor.iSerialNumber, iserial, DESCR_MAX);
590 if (ret < 0)
591 fprintf(stderr, "Error: could not get description string \"serial number\"\n");
592 } else
593 strcpy(iserial, "not provided");
594 c = strstr(iserial, " ");
595 if (c)
596 memset((void*)c, '\0', 1);
597
598 }
599
600 /* Print result of SCSI command INQUIRY (identification details) */
601 int deviceInquire ()
602 {
603 const unsigned char inquire_msg[] = {
604 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,
605 0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,
606 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
607 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
608 };
609 char *command;
610 char data[36];
611 int i, ret;
612
613 command = malloc(31);
614 if (command == NULL) {
615 ret = 1;
616 goto out;
617 }
618
619 memcpy(command, inquire_msg, sizeof (inquire_msg));
620
621 ret = usb_claim_interface(devh, Interface);
622 if (ret != 0) {
623 SHOW_PROGRESS(" Could not claim interface (error %d). Skipping device inquiry\n", ret);
624 goto out;
625 }
626 usb_clear_halt(devh, MessageEndpoint);
627
628 ret = usb_bulk_write(devh, MessageEndpoint, (char *)command, 31, 0);
629 if (ret < 0) {
630 SHOW_PROGRESS(" Could not send INQUIRY message (error %d)\n", ret);
631 goto out;
632 }
633
634 ret = usb_bulk_read(devh, ResponseEndpoint, data, 36, 0);
635 if (ret < 0) {
636 SHOW_PROGRESS(" Could not get INQUIRY response (error %d)\n", ret);
637 goto out;
638 }
639
640 i = usb_bulk_read(devh, ResponseEndpoint, command, 13, 0);
641
642 printf("\nSCSI inquiry data (for identification)\n");
643 printf("-------------------------\n");
644
645 printf(" Vendor String: ");
646 for (i = 8; i < 16; i++) printf("%c",data[i]);
647 printf("\n");
648
649 printf(" Model String: ");
650 for (i = 16; i < 32; i++) printf("%c",data[i]);
651 printf("\n");
652
653 printf("Revision String: ");
654 for (i = 32; i < 36; i++) printf("%c",data[i]);
655
656 printf("\n-------------------------\n");
657
658 out:
659 if (strlen(MessageContent) == 0)
660 usb_clear_halt(devh, MessageEndpoint);
661 usb_release_interface(devh, Interface);
662 free(command);
663 return ret;
664 }
665
666
667 void resetUSB ()
668 {
669 int success;
670 int bpoint = 0;
671
672 if (show_progress) {
673 printf("Resetting usb device ");
674 fflush(stdout);
675 }
676
677 sleep( 1 );
678 do {
679 success = usb_reset(devh);
680 if ( ((bpoint % 10) == 0) && show_progress ) {
681 printf(".");
682 fflush(stdout);
683 }
684 bpoint++;
685 if (bpoint > 100)
686 success = 1;
687 } while (success < 0);
688
689 if ( success ) {
690 SHOW_PROGRESS("\n Reset failed. Can be ignored if device switched OK.\n");
691 } else
692 SHOW_PROGRESS("\n OK, device was reset\n");
693 }
694
695
696 int switchSendMessage ()
697 {
698 int ret;
699
700 // if (MessageContent2[0] != '\0' || MessageContent3[0] != '\0')
701 // NeedResponse = 1;
702
703 SHOW_PROGRESS("Setting up communication with interface %d ...\n", Interface);
704 if (InquireDevice != 2) {
705 ret = usb_claim_interface(devh, Interface);
706 if (ret != 0) {
707 SHOW_PROGRESS(" Could not claim interface (error %d). Skipping message sending\n", ret);
708 return 0;
709 }
710 }
711 usb_clear_halt(devh, MessageEndpoint);
712 SHOW_PROGRESS("Using endpoint 0x%02x for message sending ...\n", MessageEndpoint);
713 if (show_progress)
714 fflush(stdout);
715
716 if ( sendMessage(MessageContent, 1) )
717 goto skip;
718
719 if (NeedResponse) {
720 SHOW_PROGRESS("Reading the response to the message (CSW) ...\n");
721 ret = read_bulk(ResponseEndpoint, ByteString, 0x200);
722 if (ret < 0)
723 goto skip;
724 }
725
726 if (strlen(MessageContent2)) {
727 if (MessageDelay) {
728 usb_release_interface(devh, Interface);
729 SHOW_PROGRESS("Delaying next message transfer for %d ms\n", MessageDelay);
730 usleep(MessageDelay*1000);
731 ret = usb_claim_interface(devh, Interface);
732 if (ret != 0) {
733 SHOW_PROGRESS(" Could not reclaim interface\n");
734 goto skip;
735 }
736 }
737 if ( sendMessage(MessageContent2, 2) )
738 goto skip;
739
740 if (NeedResponse) {
741 SHOW_PROGRESS("Reading the response to message 2 ...\n");
742 ret = read_bulk(ResponseEndpoint, ByteString, 0x200);
743 if (ret < 0)
744 goto skip;
745 }
746 }
747
748 if (strlen(MessageContent3)) {
749 if (MessageDelay) {
750 usb_release_interface(devh, Interface);
751 SHOW_PROGRESS("Delaying next message transfer for %d ms\n", MessageDelay);
752 usleep(MessageDelay*1000);
753 ret = usb_claim_interface(devh, Interface);
754 if (ret != 0) {
755 SHOW_PROGRESS(" Could not reclaim interface\n");
756 goto skip;
757 }
758 }
759 if ( sendMessage(MessageContent3, 3) )
760 goto skip;
761 if (NeedResponse) {
762 SHOW_PROGRESS("Reading the response to message 3 ...\n");
763 ret = read_bulk(ResponseEndpoint, ByteString, 0x200);
764 if (ret < 0)
765 goto skip;
766 }
767 }
768
769 SHOW_PROGRESS("Resetting response endpoint 0x%02x\n", ResponseEndpoint);
770 ret = usb_clear_halt(devh, ResponseEndpoint);
771 if (ret)
772 SHOW_PROGRESS(" Error resetting endpoint: %d\n", ret);
773 // goto skip;
774 SHOW_PROGRESS("Resetting message endpoint 0x%02x\n", MessageEndpoint);
775 ret = usb_clear_halt(devh, MessageEndpoint);
776 if (ret)
777 SHOW_PROGRESS(" Error resetting endpoint: %d\n", ret);
778 // goto skip;
779 ret = usb_release_interface(devh, Interface);
780 if (ret)
781 goto skip;
782 return 1;
783
784 skip:
785 SHOW_PROGRESS(" Device is gone, skipping any further commands\n");
786 usb_close(devh);
787 devh = 0;
788 return 2;
789 }
790
791
792 int switchConfiguration ()
793 {
794 int ret;
795
796 SHOW_PROGRESS("Changing configuration to %i ...\n", Configuration);
797 ret = usb_set_configuration(devh, Configuration);
798 if (ret == 0 ) {
799 SHOW_PROGRESS(" OK, configuration set\n");
800 return 1;
801 }
802 SHOW_PROGRESS(" Setting the configuration returned error %d. Trying to continue\n", ret);
803 return 0;
804 }
805
806
807 int switchAltSetting ()
808 {
809 int ret;
810
811 SHOW_PROGRESS("Changing to alt setting %i ...\n", AltSetting);
812 ret = usb_claim_interface(devh, Interface);
813 ret = usb_set_altinterface(devh, AltSetting);
814 usb_release_interface(devh, Interface);
815 if (ret != 0) {
816 SHOW_PROGRESS(" Changing to alt setting returned error %d. Trying to continue\n", ret);
817 return 0;
818 } else {
819 SHOW_PROGRESS(" OK, changed to alt setting\n");
820 return 1;
821 }
822 }
823
824
825 void switchHuaweiMode ()
826 {
827 int ret;
828
829 SHOW_PROGRESS("Sending Huawei control message ...\n");
830 ret = usb_control_msg(devh, USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_SET_FEATURE, 00000001, 0, buffer, 0, 1000);
831 if (ret != 0) {
832 fprintf(stderr, "Error: sending Huawei control message failed (error %d). Aborting.\n\n", ret);
833 exit(1);
834 } else
835 SHOW_PROGRESS(" OK, Huawei control message sent\n");
836 }
837
838
839 void switchSierraMode ()
840 {
841 int ret;
842
843 SHOW_PROGRESS("Trying to send Sierra control message\n");
844 ret = usb_control_msg(devh, 0x40, 0x0b, 00000001, 0, buffer, 0, 1000);
845 if (ret != 0) {
846 fprintf(stderr, "Error: sending Sierra control message failed (error %d). Aborting.\n\n", ret);
847 exit(1);
848 } else
849 SHOW_PROGRESS(" OK, Sierra control message sent\n");
850 }
851
852
853 void switchGCTMode ()
854 {
855 int ret;
856
857 ret = usb_claim_interface(devh, Interface);
858 if (ret != 0) {
859 SHOW_PROGRESS(" Could not claim interface (error %d). Skipping GCT sequence \n", ret);
860 return;
861 }
862
863 SHOW_PROGRESS("Sending GCT control message 1 ...\n");
864 ret = usb_control_msg(devh, 0xa1, 0xa0, 0, Interface, buffer, 1, 1000);
865 SHOW_PROGRESS("Sending GCT control message 2 ...\n");
866 ret = usb_control_msg(devh, 0xa1, 0xfe, 0, Interface, buffer, 1, 1000);
867 SHOW_PROGRESS(" OK, GCT control messages sent\n");
868 usb_release_interface(devh, Interface);
869 }
870
871
872 int switchSonyMode ()
873 {
874 int i, found, ret;
875 detachDriver();
876
877 if (CheckSuccess) {
878 printf("Note: CheckSuccess pointless with Sony mode, disabling\n");
879 CheckSuccess = 0;
880 }
881
882 SHOW_PROGRESS("Trying to send Sony control message\n");
883 ret = usb_control_msg(devh, 0xc0, 0x11, 2, 0, buffer, 3, 100);
884 if (ret < 0) {
885 fprintf(stderr, "Error: sending Sony control message failed (error %d). Aborting.\n\n", ret);
886 exit(1);
887 } else
888 SHOW_PROGRESS(" OK, control message sent, waiting for device to return ...\n");
889
890 usb_close(devh);
891 devh = 0;
892
893 /* Now waiting for the device to reappear */
894 devnum=-1;
895 busnum=-1;
896 i=0;
897 dev = 0;
898 while ( dev == 0 && i < 30 ) {
899 if ( i > 5 ) {
900 usb_find_busses();
901 usb_find_devices();
902 dev = search_devices(&found, DefaultVendor, DefaultProduct, "\0", TargetClass, SEARCH_TARGET);
903 }
904 if ( dev != 0 )
905 break;
906 sleep(1);
907 if (show_progress) {
908 printf("#");
909 fflush(stdout);
910 }
911 i++;
912 }
913 SHOW_PROGRESS("\n After %d seconds:",i);
914 if ( dev ) {
915 SHOW_PROGRESS(" device came back, proceeding\n");
916 devh = usb_open( dev );
917 if (devh == 0) {
918 fprintf(stderr, "Error: could not get handle on device\n");
919 return 0;
920 }
921 } else {
922 SHOW_PROGRESS(" device still gone, cancelling\n");
923 return 0;
924 }
925
926 sleep(1);
927
928 SHOW_PROGRESS("Sending Sony control message again ...\n");
929 ret = usb_control_msg(devh, 0xc0, 0x11, 2, 0, buffer, 3, 100);
930 if (ret < 0) {
931 fprintf(stderr, "Error: sending Sony control message (2) failed (error %d)\n", ret);
932 return 0;
933 }
934 SHOW_PROGRESS(" OK, control message sent\n");
935 return 1;
936 }
937
938
939 // Detach driver either as the main action or as preparation for other modes
940 int detachDriver()
941 {
942 int ret;
943
944 #ifndef LIBUSB_HAS_GET_DRIVER_NP
945 printf(" Cant't do driver detection and detaching on this platform.\n");
946 return 2;
947 #endif
948
949 SHOW_PROGRESS("Looking for active driver ...\n");
950 ret = usb_get_driver_np(devh, Interface, buffer, BUF_SIZE);
951 if (ret != 0) {
952 SHOW_PROGRESS(" No driver found. Either detached before or never attached\n");
953 return 1;
954 }
955 SHOW_PROGRESS(" OK, driver found (\"%s\")\n", buffer);
956 if (DetachStorageOnly && strcmp(buffer,"usb-storage")) {
957 SHOW_PROGRESS(" Warning: driver is not usb-storage\n");
958 }
959
960 #ifndef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
961 SHOW_PROGRESS(" Can't do driver detaching on this platform\n");
962 return 2;
963 #endif
964
965
966 ret = usb_detach_kernel_driver_np(devh, Interface);
967 if (ret == 0) {
968 SHOW_PROGRESS(" OK, driver \"%s\" detached\n", buffer);
969 } else
970 SHOW_PROGRESS(" Driver \"%s\" detach failed with error %d. Trying to continue\n", buffer, ret);
971 return 1;
972 }
973
974
975 int sendMessage(char* message, int count)
976 {
977 int message_length, ret;
978
979 if (strlen(message) % 2 != 0) {
980 fprintf(stderr, "Error: MessageContent %d hex string has uneven length. Skipping ...\n", count);
981 return 1;
982 }
983 message_length = strlen(message) / 2;
984 if ( hexstr2bin(message, ByteString, message_length) == -1) {
985 fprintf(stderr, "Error: MessageContent %d %s\n is not a hex string. Skipping ...\n", count, MessageContent);
986 return 1;
987 }
988 SHOW_PROGRESS("Trying to send message %d to endpoint 0x%02x ...\n", count, MessageEndpoint);
989 fflush(stdout);
990 ret = write_bulk(MessageEndpoint, ByteString, message_length);
991 if (ret == -19)
992 return 1;
993
994 return 0;
995 }
996
997
998 int checkSuccess()
999 {
1000 int i=0, ret;
1001 int newTargetCount, success=0;
1002
1003 SHOW_PROGRESS("\nChecking for mode switch (max. %d times, once per second) ...\n", CheckSuccess);
1004 sleep(1);
1005
1006 // if target ID is not given but target class is, assign default as target;
1007 // it will be needed for sysmode output
1008 if (!TargetVendor && TargetClass) {
1009 TargetVendor = DefaultVendor;
1010 TargetProduct = DefaultProduct;
1011 }
1012
1013 if (devh) // devh is 0 if device vanished during command transmission
1014 for (i=0; i < CheckSuccess; i++) {
1015
1016 // Test if default device still can be accessed; positive result does
1017 // not necessarily mean failure
1018 SHOW_PROGRESS(" Waiting for original device to vanish ...\n");
1019
1020 ret = usb_claim_interface(devh, Interface);
1021 if (ret < 0) {
1022 SHOW_PROGRESS(" Original device can't be accessed anymore. Good.\n");
1023 if (i == CheckSuccess-1)
1024 SHOW_PROGRESS(" If you want target checking, increase 'CheckSuccess' value.\n");
1025 usb_close(devh);
1026 devh = 0;
1027 break;
1028 } else
1029 usb_release_interface(devh, Interface);
1030
1031 if (i == CheckSuccess-1) {
1032 SHOW_PROGRESS(" Original device still present after the timeout\n\nMode switch most likely failed. Bye.\n\n");
1033 } else
1034 sleep(1);
1035 }
1036 else
1037 SHOW_PROGRESS(" Original device is gone already, not checking\n");
1038
1039
1040 if ( TargetVendor && (TargetProduct || strlen(TargetProductList)) )
1041
1042 // Recount target devices (compare with previous count) if target data is given.
1043 // Target device on the same bus with higher device number is returned,
1044 // description is read for syslog message
1045 for (i=i; i < CheckSuccess; i++) {
1046 SHOW_PROGRESS(" Searching for target devices ...\n");
1047 usb_find_devices();
1048 dev = search_devices(&newTargetCount, TargetVendor, TargetProduct, TargetProductList, TargetClass, SEARCH_TARGET);
1049 if (dev && (newTargetCount > targetDeviceCount)) {
1050 devh = usb_open(dev);
1051 deviceDescription();
1052 usb_close(devh);
1053 devh = 0;
1054 if (verbose) {
1055 printf("\nFound target device %03d on bus %03d\n", \
1056 dev->devnum, (int)strtol(dev->bus->dirname,NULL,10));
1057 printf("\nTarget device description data\n");
1058 printf("-------------------------\n");
1059 printf("Manufacturer: %s\n", imanufact);
1060 printf(" Product: %s\n", iproduct);
1061 printf(" Serial No.: %s\n", iserial);
1062 printf("-------------------------\n");
1063 }
1064 SHOW_PROGRESS(" Found correct target device\n\nMode switch succeeded. Bye.\n\n");
1065 success = 2;
1066 break;
1067 }
1068 if (i == CheckSuccess-1) {
1069 SHOW_PROGRESS(" No new devices in target mode or class found\n\nMode switch has failed. Bye.\n\n");
1070 } else
1071 sleep(1);
1072 }
1073 else
1074 // No target data given, rely on the vanished device
1075 if (!devh) {
1076 SHOW_PROGRESS(" (For a better success check provide target IDs or class)\n");
1077 SHOW_PROGRESS(" Original device vanished after switching\n\nMode switch most likely succeeded. Bye.\n\n");
1078 success = 1;
1079 }
1080
1081 switch (success) {
1082 case 2:
1083 if (sysmode)
1084 syslog(LOG_NOTICE, "switched to %04x:%04x (%s: %s)", TargetVendor, TargetProduct, imanufact, iproduct);
1085 success = 1;
1086 break;
1087 case 1:
1088 if (sysmode)
1089 syslog(LOG_NOTICE, "device seems to have switched");
1090 default:
1091 ;
1092 }
1093 if (sysmode)
1094 closelog();
1095
1096 return success;
1097
1098 }
1099
1100
1101 int write_bulk(int endpoint, char *message, int length)
1102 {
1103 int ret;
1104 ret = usb_bulk_write(devh, endpoint, message, length, 100);
1105 if (ret >= 0 ) {
1106 SHOW_PROGRESS(" OK, message successfully sent\n");
1107 } else
1108 if (ret == -19) {
1109 SHOW_PROGRESS(" Device seems to have vanished right after sending. Good.\n");
1110 } else
1111 SHOW_PROGRESS(" Sending the message returned error %d. Trying to continue\n", ret);
1112 return ret;
1113
1114 }
1115
1116 int read_bulk(int endpoint, char *buffer, int length)
1117 {
1118 int ret;
1119 ret = usb_bulk_read(devh, endpoint, buffer, length, 100);
1120 usb_bulk_read(devh, endpoint, buffer, 13, 100);
1121 if (ret >= 0 ) {
1122 SHOW_PROGRESS(" OK, response successfully read (%d bytes).\n", ret);
1123 } else
1124 if (ret == -19) {
1125 SHOW_PROGRESS(" Device seems to have vanished after reading. Good.\n");
1126 } else
1127 SHOW_PROGRESS(" Response reading got error %d, can probably be ignored\n", ret);
1128 return ret;
1129
1130 }
1131
1132 void release_usb_device(int dummy) {
1133 SHOW_PROGRESS("Program cancelled by system. Bye.\n\n");
1134 if (devh) {
1135 usb_release_interface(devh, Interface);
1136 usb_close(devh);
1137 }
1138 if (sysmode)
1139 closelog();
1140 exit(0);
1141
1142 }
1143
1144
1145 // iterates over busses and devices, counts the ones found and returns the last one of them
1146
1147 struct usb_device* search_devices( int *numFound, int vendor, int product, char* productList, int targetClass, int mode)
1148 {
1149 struct usb_bus *bus;
1150 char *listcopy, *token, buffer[2];
1151 int devClass;
1152 struct usb_device* right_dev = NULL;
1153
1154 // only target class given
1155 if ( targetClass && !(vendor || product) ) {
1156 vendor = DefaultVendor;
1157 product = DefaultProduct;
1158 }
1159 *numFound = 0;
1160
1161 // sanity check
1162 if (!vendor || (!product && productList == '\0') )
1163 return NULL;
1164
1165 if (productList != '\0')
1166 listcopy = malloc(strlen(productList)+1);
1167
1168 for (bus = usb_get_busses(); bus; bus = bus->next) {
1169 struct usb_device *dev;
1170 for (dev = bus->devices; dev; dev = dev->next) {
1171 if (verbose)
1172 printf (" searching devices, found USB ID %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
1173 if (dev->descriptor.idVendor != vendor)
1174 continue;
1175 if (verbose)
1176 printf (" found matching vendor ID\n");
1177 // product list given
1178 if ( strlen(productList) ) {
1179 strcpy(listcopy, productList);
1180 token = strtok(listcopy, ",");
1181 while (token != NULL) {
1182 if (strlen(token) != 4) {
1183 SHOW_PROGRESS("Error: entry in product ID list has wrong length: %s. Ignoring\n", token);
1184 goto NextToken;
1185 }
1186 if ( hexstr2bin(token, buffer, strlen(token)/2) == -1) {
1187 SHOW_PROGRESS("Error: entry in product ID list is not a hex string: %s. Ignoring\n", token);
1188 goto NextToken;
1189 }
1190 product = 0;
1191 product += (unsigned char)buffer[0];
1192 product <<= 8;
1193 product += (unsigned char)buffer[1];
1194 if (product == dev->descriptor.idProduct) {
1195 if (verbose)
1196 printf (" found matching product ID from list\n");
1197 (*numFound)++;
1198 if (busnum == -1)
1199 right_dev = dev;
1200 else
1201 if (dev->devnum >= devnum && (int)strtol(dev->bus->dirname,NULL,10) == busnum) {
1202 right_dev = dev;
1203 TargetProduct = dev->descriptor.idProduct;
1204 break;
1205 }
1206 }
1207
1208 NextToken:
1209 token = strtok(NULL, ",");
1210 }
1211 // product is given
1212 } else
1213 if (product == dev->descriptor.idProduct) {
1214 if (verbose)
1215 printf (" found matching product ID\n");
1216 if (targetClass == 0) {
1217 (*numFound)++;
1218 right_dev = dev;
1219 if (verbose)
1220 printf (" adding device\n");
1221 } else {
1222 devClass = dev->descriptor.bDeviceClass;
1223 if (devClass == 0)
1224 devClass = dev->config[0].interface[0].altsetting[0].bInterfaceClass;
1225 else
1226 // Check for some quirky devices
1227 if (devClass != dev->config[0].interface[0].altsetting[0].bInterfaceClass)
1228 devClass = dev->config[0].interface[0].altsetting[0].bInterfaceClass;
1229 if (devClass == targetClass) {
1230 if (verbose)
1231 printf (" target class %02x matching\n", targetClass);
1232 if (mode == SEARCH_TARGET) {
1233 (*numFound)++;
1234 right_dev = dev;
1235 if (verbose)
1236 printf (" adding device\n");
1237 } else
1238 if (verbose)
1239 printf (" not adding device as default\n");
1240 } else {
1241 if (verbose)
1242 printf (" target class %02x not matching\n", targetClass);
1243 if (mode == SEARCH_DEFAULT) {
1244 (*numFound)++;
1245 right_dev = dev;
1246 if (verbose)
1247 printf (" adding device as default\n");
1248 }
1249 }
1250 }
1251 // dirty hack: if busnum has other than init value, we're at
1252 // success checking and probe for plausible new devnum/busnum
1253 if (busnum != -1)
1254 if (dev->devnum < devnum || (int)strtol(dev->bus->dirname,NULL,10) != busnum) {
1255 if (verbose)
1256 printf (" busnum/devnum indicates an unrelated device\n");
1257 right_dev = NULL;
1258 }
1259 }
1260 }
1261 }
1262 if (productList != NULL)
1263 free(listcopy);
1264 return right_dev;
1265 }
1266
1267
1268 #define USB_DIR_OUT 0x00
1269 #define USB_DIR_IN 0x80
1270
1271 // Autodetect bulk endpoints (ab)
1272
1273 int find_first_bulk_output_endpoint(struct usb_device *dev)
1274 {
1275 int i;
1276 struct usb_interface_descriptor *alt = &(dev->config[0].interface[0].altsetting[0]);
1277 struct usb_endpoint_descriptor *ep;
1278
1279 for(i=0;i < alt->bNumEndpoints;i++) {
1280 ep=&(alt->endpoint[i]);
1281 if( ( (ep->bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_BULK) &&
1282 ( (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT ) ) {
1283 return ep->bEndpointAddress;
1284 }
1285 }
1286
1287 return 0;
1288 }
1289
1290
1291 int find_first_bulk_input_endpoint(struct usb_device *dev)
1292 {
1293 int i;
1294 struct usb_interface_descriptor *alt = &(dev->config[0].interface[0].altsetting[0]);
1295 struct usb_endpoint_descriptor *ep;
1296
1297 for(i=0;i < alt->bNumEndpoints;i++) {
1298 ep=&(alt->endpoint[i]);
1299 if( ( (ep->bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_BULK) &&
1300 ( (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN ) ) {
1301 return ep->bEndpointAddress;
1302 }
1303 }
1304
1305 return 0;
1306 }
1307
1308
1309
1310 // the parameter parsing stuff
1311
1312 char* ReadParseParam(const char* FileName, char *VariableName)
1313 {
1314 static char Str[LINE_DIM];
1315 char *VarName, *Comment=NULL, *Equal=NULL;
1316 char *FirstQuote, *LastQuote, *P1, *P2;
1317 int Line=0, Len=0, Pos=0;
1318 FILE *file=fopen(FileName, "r");
1319
1320 if (file==NULL) {
1321 fprintf(stderr, "Error: Could not find file %s\n\n", FileName);
1322 exit(1);
1323 }
1324
1325 while (fgets(Str, LINE_DIM-1, file) != NULL) {
1326 Line++;
1327 Len=strlen(Str);
1328 if (Len==0) goto Next;
1329 if (Str[Len-1]=='\n' or Str[Len-1]=='\r') Str[--Len]='\0';
1330 Equal = strchr (Str, '='); // search for equal sign
1331 Pos = strcspn (Str, ";#!"); // search for comment
1332 Comment = (Pos==Len) ? NULL : Str+Pos;
1333 if (Equal==NULL or ( Comment!=NULL and Comment<=Equal)) goto Next; // Only comment
1334 *Equal++ = '\0';
1335 if (Comment!=NULL) *Comment='\0';
1336
1337 // String
1338 FirstQuote=strchr (Equal, '"'); // search for double quote char
1339 LastQuote=strrchr (Equal, '"');
1340 if (FirstQuote!=NULL) {
1341 if (LastQuote==NULL) {
1342 fprintf(stderr, "Error reading parameter file %s line %d - Missing end quote.\n", FileName, Line);
1343 goto Next;
1344 }
1345 *FirstQuote=*LastQuote='\0';
1346 Equal=FirstQuote+1;
1347 }
1348
1349 // removes leading/trailing spaces
1350 Pos=strspn (Str, " \t");
1351 if (Pos==strlen(Str)) {
1352 fprintf(stderr, "Error reading parameter file %s line %d - Missing variable name.\n", FileName, Line);
1353 goto Next; // No function name
1354 }
1355 while ((P1=strrchr(Str, ' '))!=NULL or (P2=strrchr(Str, '\t'))!=NULL)
1356 if (P1!=NULL) *P1='\0';
1357 else if (P2!=NULL) *P2='\0';
1358 VarName=Str+Pos;
1359 //while (strspn(VarName, " \t")==strlen(VarName)) VarName++;
1360
1361 Pos=strspn (Equal, " \t");
1362 if (Pos==strlen(Equal)) {
1363 fprintf(stderr, "Error reading parameter file %s line %d - Missing value.\n", FileName, Line);
1364 goto Next; // No function name
1365 }
1366 Equal+=Pos;
1367
1368 if (strcmp(VarName, VariableName)==0) { // Found it
1369 fclose(file);
1370 return Equal;
1371 }
1372 Next:;
1373 }
1374
1375 // not found
1376 // fprintf(stderr, "Error reading parameter file %s - Variable %s not found.",
1377 // FileName, VariableName);
1378 fclose(file);
1379 return NULL;
1380 }
1381
1382
1383 int hex2num(char c)
1384 {
1385 if (c >= '0' && c <= '9')
1386 return c - '0';
1387 if (c >= 'a' && c <= 'f')
1388 return c - 'a' + 10;
1389 if (c >= 'A' && c <= 'F')
1390 return c - 'A' + 10;
1391 return -1;
1392 }
1393
1394
1395 int hex2byte(const char *hex)
1396 {
1397 int a, b;
1398 a = hex2num(*hex++);
1399 if (a < 0)
1400 return -1;
1401 b = hex2num(*hex++);
1402 if (b < 0)
1403 return -1;
1404 return (a << 4) | b;
1405 }
1406
1407 int hexstr2bin(const char *hex, char *buffer, int len)
1408 {
1409 int i;
1410 int a;
1411 const char *ipos = hex;
1412 char *opos = buffer;
1413 // printf("Debug: hexstr2bin bytestring is ");
1414
1415 for (i = 0; i < len; i++) {
1416 a = hex2byte(ipos);
1417 // printf("%02X", a);
1418 if (a < 0)
1419 return -1;
1420 *opos++ = a;
1421 ipos += 2;
1422 }
1423 // printf(" \n");
1424 return 0;
1425 }
1426
1427 void printVersion()
1428 {
1429 char* version = VERSION;
1430 printf("\n * usb-modeswitch: handle USB devices with multiple modes\n");
1431 printf(" * Version %s (C) Josua Dietze 2010\n", version);
1432 printf(" * Based on libusb0 (0.1.12 and above)\n\n");
1433 printf(" ! PLEASE REPORT NEW CONFIGURATIONS !\n\n");
1434 }
1435
1436 void printHelp()
1437 {
1438 printf ("Usage: usb-modeswitch [-hvpVPmMrdHn] [-c filename]\n\n");
1439 printf (" -h, --help this help\n");
1440 printf (" -e, --version print version number and exit\n");
1441 printf (" -v, --default-vendor NUM vendor ID of original mode (mandatory)\n");
1442 printf (" -p, --default-product NUM product ID of original mode (mandatory)\n");
1443 printf (" -V, --target-vendor NUM target mode vendor ID (optional)\n");
1444 printf (" -P, --target-product NUM target mode product ID (optional)\n");
1445 printf (" -C, --target-class NUM target mode device class (optional)\n");
1446 printf (" -m, --message-endpoint NUM direct the message transfer there (optional)\n");
1447 printf (" -M, --message-content <msg> message to send (hex number as string)\n");
1448 printf (" -2 <msg>, -3 <msg> additional messages to send (implies -n)\n");
1449 printf (" -n, --need-response read response to the message transfer (CSW)\n");
1450 printf (" -r, --response-endpoint NUM read response from there (optional)\n");
1451 printf (" -d, --detach-only detach the active driver, no further action\n");
1452 printf (" -H, --huawei-mode apply a special procedure\n");
1453 printf (" -S, --sierra-mode apply a special procedure\n");
1454 printf (" -O, --sony-mode apply a special procedure\n");
1455 printf (" -G, --gct-mode apply a special procedure\n");
1456 printf (" -R, --reset-usb reset the device after all other actions\n");
1457 printf (" -c, --config <filename> load configuration from file\n");
1458 printf (" -Q, --quiet don't show progress or error messages\n");
1459 printf (" -W, --verbose print all settings and debug output\n");
1460 printf (" -D, --sysmode specific result and syslog message\n");
1461 printf (" -s, --success NUM check switching result after NUM secs\n");
1462 printf (" -I, --no-inquire do not get SCSI attributes (default on)\n\n");
1463 printf (" -i, --interface NUM select initial USB interface (default 0)\n");
1464 printf (" -u, --configuration NUM select USB configuration\n");
1465 printf (" -a, --altsetting NUM select alternative USB interface setting\n\n");
1466 }
0 # Configuration for the usb-modeswitch package, a mode switching tool for
1 # USB devices providing multiple states or modes
2 #
3 # This file is evaluated by the wrapper script "usb_modeswitch" in /lib/udev
4 # To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
5 # Everything else counts as "disable"
6
7
8 # Disable automatic mode switching globally (e.g. to access the original
9 # install storage)
10
11 DisableSwitching=0
12
13
14 # Enable logging (results in a extensive report file in /var/log, named
15 # "usb_modeswitch_<interface-name>"
16
17 EnableLogging=0
18
0 ../usb-modeswitch-data/usb_modeswitch.d/
0 /*
1 This file is part of usb-modeswitch, a mode switching tool for controlling
2 flip flop (multiple device) USB gear
3
4 Version 1.1.3, 2010/06/21
5 Copyright (C) 2007, 2008, 2009, 2010 Josua Dietze
6
7 Config file parsing stuff borrowed from Guillaume Dargaud
8 (http://www.gdargaud.net/Hack/SourceCode.html)
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details:
19
20 http://www.gnu.org/licenses/gpl.txt
21
22 */
23
24
25 #include <stdlib.h>
26 #include <usb.h>
27
28 void readConfigFile(const char *configFilename);
29 void printConfig();
30 int switchSendMessage();
31 int switchConfiguration();
32 int switchAltSetting();
33 void switchHuaweiMode();
34 void switchSierraMode();
35 void switchGCTMode();
36 void switchAVMMode();
37 int switchSonyMode();
38 int detachDriver();
39 int checkSuccess();
40 int sendMessage(char* message, int count);
41 int write_bulk(int endpoint, char *message, int length);
42 int read_bulk(int endpoint, char *buffer, int length);
43 void release_usb_device(int dummy);
44 struct usb_device* search_devices( int *numFound, int vendor, int product, char* productList, int targetClass, int mode);
45 int find_first_bulk_output_endpoint(struct usb_device *dev);
46 int find_first_bulk_input_endpoint(struct usb_device *dev);
47 char* ReadParseParam(const char* FileName, char *VariableName);
48 int hex2num(char c);
49 int hex2byte(const char *hex);
50 int hexstr2bin(const char *hex, char *buffer, int len);
51 void printVersion();
52 void printHelp();
53 int readArguments(int argc, char **argv);
54 void deviceDescription();
55 int deviceInquire();
56 void resetUSB();
57 void release_usb_device(int dummy);
58
59 // Boolean
60 #define and &&
61 #define or ||
62 #define not !
63
64 // Bitwise
65 #define bitand &
66 #define bitor |
67 #define compl ~
68 #define xor ^
69
70 // Equals
71 #define and_eq &=
72 #define not_eq !=
73 #define or_eq |=
74 #define xor_eq ^=
75
76 extern char* ReadParseParam(const char* FileName, char *VariableName);
77
78 extern char *TempPP;
79
80 #define ParseParamString(ParamFileName, Str) \
81 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
82 strcpy(Str, TempPP); else Str[0]='\0'
83
84 #define ParseParamInt(ParamFileName, Int) \
85 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
86 Int=atoi(TempPP)
87
88 #define ParseParamHex(ParamFileName, Int) \
89 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
90 Int=strtol(TempPP, NULL, 16)
91
92 #define ParseParamFloat(ParamFileName, Flt) \
93 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
94 Flt=atof(TempPP)
95
96 #define ParseParamBool(ParamFileName, B) \
97 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
98 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0
99
0 #!/bin/sh
1 # next lines for bash, ignored by tclsh, restarting in background\
2 export PATH=/bin:/usr/bin; \
3 if [ ! -e "/usr/bin/tclsh" ]; then \
4 logger -p syslog.error "usb_modeswitch: tcl shell not found, install tcl package!"; \
5 fi; \
6 (/usr/bin/tclsh "$0" "$@" >/dev/null 2>&1 &); \
7 sleep 1; \
8 exit
9
10
11 # Wrapper (tcl) for usb_modeswitch, called from
12 # /lib/udev/rules.d/40-usb_modeswitch.rules
13 # (part of data pack "usb-modeswitch-data")
14 #
15 # Does ID check on hotplugged USB devices and calls the
16 # mode switching program with the matching parameter file
17 # from /etc/usb_modeswitch.d
18 #
19 # Part of usb-modeswitch-1.1.3 package
20 # (C) Josua Dietze 2009, 2010
21
22
23 # Setting of the following switches is done in an external config
24 # file (/etc/usb_modeswitch.conf)
25
26 set logging 0
27 set noswitching 0
28
29
30
31 set env(PATH) "/bin:/usr/bin"
32
33 # Execution starts at file bottom
34
35 proc {Main} {argc argv} {
36
37 global scsi usb match wc device logging noswitching
38
39 # The facility to add a symbolic link pointing to the
40 # ttyUSB port which provides interrupt transfer, i.e.
41 # the port to connect through; returns a symlink name
42 # for udev and exits
43 # This is run once for every device interface by an
44 # udev rule
45
46 if {[lindex $argv 0] == "symlink"} {
47 # puts "symlink: udev path is [lindex $argv 2]"
48 # set device [clock clicks]
49 # set logging 1
50 # Log "symlink: udev path is [lindex $argv 2]"
51 if [llength [glob -nocomplain /tmp/gsmmodem_*]] {
52 set sl [SymLinkName [lindex $argv 2]]
53 # Log "symlink name is :$sl:"
54 puts $sl
55 # puts [SymLinkName [lindex $argv 2]]
56 } else {
57 puts ""
58 }
59 SafeExit
60 }
61
62 set dbdir /etc/usb_modeswitch.d
63 set bindir /usr/sbin
64
65 set devList1 {}
66 set devList2 {}
67
68
69 # argv contains the values provided from the udev rule
70 # separated by "/"
71
72 set argList [split [lindex $argv 0] /]
73
74 if [string length [lindex $argList 1]] {
75 set device [lindex $argList 1]
76 } else {
77 set device "noname"
78 }
79
80 ParseConfigFile
81
82 Log "raw args from udev: $argv"
83
84 if {$device == "noname"} {
85 Log "No data from udev. Exiting"
86 SafeExit
87 }
88
89 # arg 0: the bus id for the device (udev: %b)
90 # arg 1: the "kernel name" for the device (udev: %k)
91 #
92 # Both together give the top directory where the path
93 # to the SCSI attributes can be determined (further down)
94 # Addendum: older kernel/udev version seem to differ in
95 # providing these attributes - or not. So more probing
96 # is needed
97
98 if {[string length [lindex $argList 0]] == 0} {
99 if {[string length [lindex $argList 1]] == 0} {
100 Log "No device number values given from udev! Exiting"
101 SafeExit
102 } else {
103 Log "Bus ID for device not given by udev."
104 Log " Trying to determine it from kernel name ([lindex $argList 1]) ..."
105 if {![regexp {(.*?):} [lindex $argList 1] d dev_top]} {
106 Log "Could not determine top device dir from udev values! Exiting"
107 SafeExit
108 }
109 }
110 } else {
111 set dev_top [lindex $argList 0]
112 regexp {(.*?):} $dev_top d dev_top
113 }
114
115
116 set devdir /sys/bus/usb/devices/$dev_top
117 if {![file isdirectory $devdir]} {
118 Log "Top sysfs directory not found ($devdir)! Exiting"
119 SafeExit
120 }
121
122
123 # Mapping of the short string identifiers (in the config
124 # file names) to the long name used here
125 #
126 # If we need them it's a snap to add new attributes here!
127
128 set match(sVe) scsi(vendor)
129 set match(sMo) scsi(model)
130 set match(sRe) scsi(rev)
131 set match(uMa) usb(manufacturer)
132 set match(uPr) usb(product)
133 set match(uSe) usb(serial)
134
135
136 # Now reading the USB attributes
137
138 ReadUSBAttrs $devdir
139
140 if {[string length "$usb(idVendor)$usb(idProduct)"] < 8} {
141 Log "USB IDs not found in sysfs tree. Exiting"
142 SafeExit
143 }
144
145 Log "----------------\nUSB values from sysfs:"
146 foreach attr {manufacturer product serial} {
147 Log " $attr\t$usb($attr)"
148 }
149 Log "----------------"
150
151 if $noswitching {
152 Log "\nSwitching globally disabled. Exiting\n"
153 catch {exec logger -p syslog.notice "usb_modeswitch: switching disabled, no action for $usb(idVendor):$usb(idProduct)"}
154 SafeExit
155 }
156
157 # Special ZTE check
158 if {"$usb(idVendor)$usb(idProduct)" == "19d22000"} {
159 foreach dir {/etc/udev/rules.d /lib/udev/rules.d} {
160 catch {eval exec grep {"19d2.*2000.*eject"} [glob -nocomplain $dir/*]} result
161 if [regexp {(.*?):.*19d2} $result d ruleFile] {
162 Log "\nWarning: existing ZTE rule found in $ruleFile. Might cause problems\n"
163 }
164 }
165 }
166
167 # Check if there is more than one config file for this USB ID,
168 # which would point to a possible ambiguity. If so, check if
169 # SCSI values are needed
170
171 set configList [glob -nocomplain $dbdir/$usb(idVendor):$usb(idProduct)*]
172 if {[llength $configList] == 0} {
173 Log "Aargh! Config file missing for $usb(idVendor):$usb(idProduct)! Exiting"
174 SafeExit
175 }
176
177 set scsiNeeded false
178 if {[llength $configList] > 1} {
179 if [regexp {:s} $configList] {
180 set scsiNeeded true
181 }
182 }
183 if {!$scsiNeeded} {
184 Log "SCSI attributes not needed, moving on"
185 }
186
187
188 # Getting the SCSI values via libusb results in a detached
189 # usb-storage driver. Not good for devices that want to be
190 # left alone. Fortunately, the sysfs tree provides the values
191 # too without need for direct access
192
193 # First we wait until the SCSI data is ready - or timeout.
194 # Timeout means: no storage driver was bound to the device.
195 # We run 20 times max, every half second (max. 10 seconds
196 # total)
197
198 # We also check if the device itself changes, probably
199 # because it was switched by the kernel (or even unplugged).
200 # Then we do simply nothing and exit quietly ...
201
202 set counter 0
203 while {$scsiNeeded && $counter < 20} {
204 after 500
205 incr counter
206 Log "waiting for storage tree in sysfs"
207
208 set sysdir $devdir/[lindex $argList 1]
209
210 if {![file isdirectory $sysdir]} {
211 # Device is gone. Unplugged? Switched by kernel?
212 Log "sysfs device tree is gone; exiting"
213 SafeExit
214 }
215 set rc [open $devdir/product r]
216 set newproduct [read -nonewline $rc]
217 close $rc
218 if {![string match $newproduct $usb(product)]} {
219 # Device has just changed. Switched by someone else?
220 Log "device has changed; exiting"
221 SafeExit
222 }
223
224 # Searching the storage/SCSI tree; might take a while
225 if {[set dirList [glob -nocomplain $sysdir/host*]] != ""} {
226 set sysdir [lindex $dirList 0]
227 if {[set dirList [glob -nocomplain $sysdir/target*]] != ""} {
228 set sysdir [lindex $dirList 0]
229 regexp {.*target(.*)} $sysdir d subdir
230 if {[set dirList [glob -nocomplain $sysdir/$subdir*]] != ""} {
231 set sysdir [lindex $dirList 0]
232 if [file exists $sysdir/vendor] {
233 # Finally SCSI structure is ready, get the values
234 ReadSCSIAttrs $sysdir
235 Log "SCSI values read"
236 break
237 }
238 }
239 }
240 }
241 }
242 if $scsiNeeded {
243 if {$counter == 20 && [string length $scsi(vendor)] == 0} {
244 Log "SCSI tree not found; you may want to check if this path/file exists:"
245 Log "$sysdir/vendor\n"
246 } else {
247 Log "----------------\nSCSI values from sysfs:"
248 foreach attr {vendor model rev} {
249 Log " $attr\t$scsi($attr)"
250 }
251 Log "----------------"
252 }
253 Log "Waiting 3 secs. after SCSI device was added"
254 after 3000
255 } else {
256 after 500
257 }
258
259 # If SCSI tree in sysfs was not identified, try and get the values
260 # from a (nonswitching) call of usb_modeswitch; this detaches the
261 # storage driver, so it's just the last resort
262
263 if {$scsiNeeded && $scsi(vendor)==""} {
264 set testSCSI [exec $bindir/usb_modeswitch -v 0x$usb(idVendor) -p 0x$usb(idProduct)]
265 regexp { Vendor String: (.*?)\n} $testSCSI d scsi(vendor)
266 regexp { Model String: (.*?)\n} $testSCSI d scsi(model)
267 regexp {Revision String: (.*?)\n} $testSCSI d scsi(rev)
268 Log "SCSI values from usb_modeswitch:"
269 foreach attr {vendor model rev} {
270 Log " $attr\t$scsi($attr)"
271 }
272 }
273
274 # If we don't have the SCSI values by now, we just
275 # leave the variables empty; they won't match anything
276
277 # Time to check for a matching config file.
278 # Matching itself is done by MatchDevice
279 #
280 # Sorting the configuration file names reverse so that
281 # the ones with matching additions are tried first; the
282 # common configs without match attributes are used at the
283 # end and provide a fallback
284
285 set report {}
286 set configList [glob -nocomplain $dbdir/$usb(idVendor):$usb(idProduct)*]
287 foreach configuration [lsort -decreasing $configList] {
288
289 # skipping installer leftovers
290 if [regexp {\.(dpkg|rpm)} $configuration] {continue}
291
292 Log "checking config: $configuration"
293 if [MatchDevice $configuration] {
294 set switch_config $configuration
295 set devList1 [glob -nocomplain /dev/ttyUSB* /dev/ttyACM* /dev/ttyHS*]
296 Log "! matched, now switching"
297 set tc [open /tmp/gsmmodem_$dev_top w]
298 close $tc
299
300 # Now we are actually switching
301 if $logging {
302 Log " (running command: $bindir/usb_modeswitch -I -W -c $configuration)"
303 set report [exec $bindir/usb_modeswitch -I -W -D -c $configuration 2>@ stdout]
304 } else {
305 set report [exec $bindir/usb_modeswitch -I -Q -D -c $configuration]
306 }
307 Log "\nverbose output of usb_modeswitch:"
308 Log "--------------------------------"
309 Log $report
310 Log "--------------------------------"
311 Log "(end of usb_modeswitch output)\n"
312 break
313 } else {
314 Log "* no match, not switching with this config"
315 }
316 }
317
318 # We're finished with switching; success checking
319 # was done by usb_modeswitch and logged via syslog.
320 #
321 # If switching was OK we now check for drivers by
322 # simply recounting serial devices under /dev
323
324 # If target ID given, driver shall be loaded
325 if [regexp -nocase {ok:[0-9a-f]{4}:[0-9a-f]{4}} $report] {
326
327 # For general driver loading; TODO: add respective device names.
328 # Presently only useful for HSO devices (which are recounted now)
329 set driverModule ""
330 set driverIDPath ""
331 set rc [open $configuration r]
332 set lineList [split [read $rc] \n]
333 close $rc
334 foreach line $lineList {
335 regexp {DriverModule[[:blank:]]*=[[:blank:]]*"?(\w+)"?} $line d driverModule
336 regexp {DriverIDPath[[:blank:]]*=[[:blank:]]*?"?([/\-\w]+)"?} $line d driverIDPath
337 }
338 if {$driverModule == ""} {
339 set driverModule "option"
340 set driverIDPath "/sys/bus/usb-serial/drivers/option1"
341 } else {
342 if {$driverIDPath == ""} {
343 set driverIDPath "/sys/bus/usb/drivers/$driverModule"
344 }
345 }
346 Log "Driver module is \"$driverModule\", ID path is $driverIDPath\n"
347
348 # some settling time in ms
349 after 500
350
351 Log "Now checking for newly created serial devices ..."
352 set devList2 [glob -nocomplain /dev/ttyUSB* /dev/ttyACM* /dev/ttyHS*]
353
354 if {[llength $devList1] >= [llength $devList2]} {
355 Log " no new serial devices found"
356
357 if {![file isdirectory $devdir]} {
358 Log "Device directory in sysfs is gone! Something went wrong, aborting"
359 SafeExit
360 }
361
362 # Give the device annother second if it's not fully back yet
363 if {![file exists $devdir/idProduct]} {
364 after 1000
365 }
366
367 ReadUSBAttrs $devdir
368 if {[string length "$usb(idVendor)$usb(idProduct)"] < 8} {
369 regexp {ok:(\w{4}):(\w{4})} $report d usb(idVendor) usb(idProduct)
370 }
371 set t "$usb(idVendor)$usb(idProduct)"
372 if {[string length $t] == 8 && [string trim $t 0] != ""} {
373 set idfile $driverIDPath/new_id
374 if {![file exists $idfile]} {
375 Log "\nTrying to load driver \"$driverModule\""
376 set loader /sbin/modprobe
377 Log " loader is: $loader"
378 if [file exists $loader] {
379 if [catch {set result [exec $loader -v $driverModule]} err] {
380 Log " Running \"$loader $driverModule\" gave an error:\n $err"
381 }
382 } else {
383 Log " /sbin/modprobe not found"
384 }
385 }
386 if [file exists $idfile] {
387 Log "Trying to add ID to driver \"$driverModule\""
388 catch {exec logger -p syslog.notice "usb_modeswitch: adding device ID $usb(idVendor):$usb(idProduct) to driver \"$driverModule\""}
389 catch {exec echo "$usb(idVendor) $usb(idProduct)" >$idfile}
390 after 600
391 set devList2 [glob -nocomplain /dev/ttyUSB* /dev/ttyACM* /dev/ttyHS*]
392 if {[llength $devList1] >= [llength $devList2]} {
393 Log " still no new serial devices found"
394 } else {
395 Log " driver successfully bound"
396 }
397 } else {
398 Log " \"$idfile\" not found, can't add ID"
399 }
400 }
401 } else {
402 Log " new serial devices found, driver has bound"
403 }
404 }
405
406
407
408 if [regexp {ok:$} $report] {
409 Log "Doing no driver checking or binding for this device"
410 }
411
412 # In newer kernels there is a switch to avoid the use of a device
413 # reset (e.g. from usb-storage) which would likely switch back
414 # a mode-switching device
415 if [regexp {ok:} $report] {
416 Log "Checking for AVOID_RESET_QUIRK attribute"
417 if [file exists $devdir/avoid_reset_quirk] {
418 if [catch {exec echo "1" >$devdir/avoid_reset_quirk} err] {
419 Log " Error setting the attribute: $err"
420 } else {
421 Log " AVOID_RESET_QUIRK activated"
422 }
423 } else {
424 Log " AVOID_RESET_QUIRK not present"
425 }
426 }
427
428 Log "\nAll done, exiting\n"
429 SafeExit
430
431 }
432 # end of proc {Main}
433
434
435 proc {ReadSCSIAttrs} {dir} {
436
437 global scsi
438 Log "SCSI dir exists: $dir"
439
440 foreach attr {vendor model rev} {
441 if [file exists $dir/$attr] {
442 set rc [open $dir/$attr r]
443 set scsi($attr) [read -nonewline $rc]
444 close $rc
445 } else {
446 set scsi($attr) ""
447 Log "Warning: SCSI attribute \"$attr\" not found."
448 }
449 }
450
451 }
452 # end of proc {ReadSCSIAttrs}
453
454
455 proc {ReadUSBAttrs} {dir} {
456
457 global usb
458 Log "USB dir exists: $dir"
459
460 foreach attr {idVendor idProduct manufacturer product serial} {
461 if [file exists $dir/$attr] {
462 set rc [open $dir/$attr r]
463 set usb($attr) [read -nonewline $rc]
464 close $rc
465 } else {
466 set usb($attr) ""
467 Log "Warning: USB attribute \"$attr\" not found."
468 }
469 }
470
471 }
472 # end of proc {ReadUSBAttrs}
473
474
475 proc {MatchDevice} {config} {
476
477 global scsi usb match
478
479 set devinfo [file tail $config]
480 set infoList [split $devinfo :]
481 set stringList [lrange $infoList 2 end]
482 if {[llength $stringList] == 0} {return 1}
483
484 foreach teststring $stringList {
485 if {$teststring == "?"} {return 0}
486 set tokenList [split $teststring =]
487 set id [lindex $tokenList 0]
488 set matchstring [lindex $tokenList 1]
489 set blankstring ""
490 regsub -all {_} $matchstring { } blankstring
491 Log "matching $match($id)"
492 Log " match string1: $matchstring"
493 Log " match string2: $blankstring"
494 Log " device string: [set $match($id)]"
495 if {!([string match *$matchstring* [set $match($id)]] || [string match *$blankstring* [set $match($id)]])} {
496 return 0
497 }
498 }
499 return 1
500
501 }
502 # end of proc {MatchDevice}
503
504
505 proc {ParseConfigFile} {} {
506
507 global logging noswitching
508
509 set configFile ""
510 set places [list /etc/usb_modeswitch.conf /etc/sysconfig/usb_modeswitch /etc/default/usb_modeswitch]
511 foreach cfg $places {
512 if [file exists $cfg] {
513 set configFile $cfg
514 break
515 }
516 }
517
518 if {$configFile == ""} {return}
519
520 set rc [open $configFile r]
521 while {![eof $rc]} {
522 gets $rc line
523 if [regexp {DisableSwitching\s*=\s*([^\s]+)} $line d val] {
524 if [regexp -nocase {1|yes|true} $val] {
525 set noswitching 1
526 }
527 }
528 if [regexp {EnableLogging\s*=\s*([^\s]+)} $line d val] {
529 if [regexp -nocase {1|yes|true} $val] {
530 set logging 1
531 }
532 }
533
534 }
535 Log "Using global config file: $configFile"
536
537 }
538 # end of proc {ParseConfigFile}
539
540
541 proc {Log} {msg} {
542
543 global wc logging device
544 if {$logging == 0} {return}
545 if {![info exists wc]} {
546 set wc [open /var/log/usb_modeswitch_$device a]
547 puts $wc "\n\nUSB_ModeSwitch log from [clock format [clock seconds]]\n"
548 }
549 puts $wc $msg
550
551 }
552 # end of proc {Log}
553
554
555
556 # Checking for interrupt endpoint in ttyUSB port; if found,
557 # check for unused "gsmmodem[n]" name.
558 # First link will be "gsmmodem", then "gsmmodem2" and up
559
560 proc {SymLinkName} {path} {
561
562 # HACK ... /tmp/gsmmodem_* was generated by a switching run before;
563 # no way found to signal annother instance in the udev environment
564
565 set idx -1
566 set tmpNames [glob -nocomplain /tmp/gsmmodem_*]
567 foreach tmpName $tmpNames {
568 set dev_top [lindex [split $tmpName _] 1]
569 set dirList [split $path /]
570 set idx [lsearch $dirList $dev_top]
571 if {$idx == -1} {
572 continue
573 } else {break}
574 }
575 if {$idx == -1} {return ""}
576
577 regexp {ttyUSB\d+?} $path myPort
578
579 #Log "symlink: dev_top is $dev_top \npath is $path \nport is $myPort"
580
581 # Unfortunately, there are devices with more than one interrupt
582 # port. We have to check all ports and assume that the lowest
583 # number denotes the working port
584
585 set devDir /sys[join [lrange $dirList 0 $idx] /]
586 set portList {}
587 foreach ifDir [glob -nocomplain $devDir/$dev_top:\[0-9\].\[0-9\]] {
588 # Log "ifDir is $ifDir"
589 if {![regexp {ttyUSB\d+?} [glob -nocomplain $ifDir/*] port]} {continue}
590 foreach epDir [glob -nocomplain $ifDir/ep_*] {
591 if [file exists $epDir/type] {
592 set rc [open $epDir/type r]
593 set type [read $rc]
594 close $rc
595 if [regexp {Interrupt} $type] {
596 lappend portList $port
597 }
598 }
599 }
600 }
601 set lowestPort [lindex [lsort -increasing $portList] 0]
602 if {$lowestPort != $myPort} {
603 return ""
604 }
605 eval file delete dummy $tmpName
606 cd /dev
607 set idx 2
608 set symlinkName "gsmmodem"
609 while {$idx < 256} {
610 if {![file exists $symlinkName]} {
611 break
612 }
613 set symlinkName gsmmodem$idx
614 incr idx
615 }
616
617 return $symlinkName
618
619 }
620 # end of proc {SymLinkName}
621
622
623 proc {SafeExit} {} {
624 global wc
625 if [info exists wc] {
626 catch {close $wc}
627 }
628 exit
629
630 }
631 # end of proc {SafeExit}
632
633
634 # The actual entry point
635 Main $argc $argv
636
0 # Part of usb-modeswitch-data, version 20100623
1 #
2 # This file is intended for USB_ModeSwitch version >= 1.1.2
3 # but will not break anything if used with versions >= 1.0.3
4 #
5
6 ACTION!="add", GOTO="modeswitch_rules_end"
7
8 # This adds a symlink "gsmmodem[n]" to the right (interrupt) ttyUSB port;
9 # will work only with wrapper 1.1.2 and above (otherwise just ignored)
10 KERNEL=="ttyUSB*", PROGRAM="/usr/bin/tclsh /lib/udev/usb_modeswitch symlink name %p", SYMLINK="%c"
11
12 SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
13
14
15 # Most known install partitions are on interface 0, one on 5, one on 9
16 ATTRS{bInterfaceNumber}!="0[059]", GOTO="modeswitch_rules_end"
17
18 # only storage class devices are handled; negative
19 # filtering here would exclude some quirky devices
20 ATTRS{bDeviceClass}=="08", GOTO="modeswitch_rules_begin"
21 ATTRS{bInterfaceClass}=="08", GOTO="modeswitch_rules_begin"
22 GOTO="modeswitch_rules_end"
23
24
25 LABEL="modeswitch_rules_begin"
26
27 # Nokia CS-15
28 ATTRS{idVendor}=="0421", ATTRS{idProduct}=="0610", RUN+="usb_modeswitch '%b/%k'"
29
30 # Vodafone MD950 (Wisue Technology)
31 ATTRS{idVendor}=="0471", ATTRS{idProduct}=="1210", RUN+="usb_modeswitch '%b/%k'"
32
33 # Philips TalkTalk (NXP Semiconductors "Dragonfly")
34 ATTRS{idVendor}=="0471", ATTRS{idProduct}=="1237", RUN+="usb_modeswitch '%b/%k'"
35
36 # Kyocera W06K CDMA modem
37 ATTRS{idVendor}=="0482", ATTRS{idProduct}=="024d", RUN+="usb_modeswitch '%b/%k'"
38
39 # Samsung U209
40 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
41
42 # AVM Fritz!Wlan USB Stick N
43 ATTRS{idVendor}=="057c", ATTRS{idProduct}=="84ff", RUN+="usb_modeswitch '%b/%k'"
44
45 # Samsung SGH-Z810, older Option devices, Vertex Wireless 100 Series, AnyDATA 500 series
46 ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="1000", RUN+="usb_modeswitch '%b/%k'"
47
48 # D-Link DWM-162-U5, Micromax MMX 300c
49 ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="2001", RUN+="usb_modeswitch '%b/%k'"
50
51 # Siptune LM-75
52 ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
53
54 # InfoCert Business Key
55 ATTRS{idVendor}=="072f", ATTRS{idProduct}=="100d", RUN+="usb_modeswitch '%b/%k'"
56
57 # Toshiba G450
58 ATTRS{idVendor}=="0930", ATTRS{idProduct}=="0d46", RUN+="usb_modeswitch '%b/%k'"
59
60 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 1)
61 ATTRS{idVendor}=="0ace", ATTRS{idProduct}=="2011", RUN+="usb_modeswitch '%b/%k'"
62
63 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 2)
64 ATTRS{idVendor}=="0ace", ATTRS{idProduct}=="20ff", RUN+="usb_modeswitch '%b/%k'"
65
66 # Option HSO device
67 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6711", RUN+="usb_modeswitch '%b/%k'"
68
69 # Option HSO device
70 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6731", RUN+="usb_modeswitch '%b/%k'"
71
72 # Option HSO device
73 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6751", RUN+="usb_modeswitch '%b/%k'"
74
75 # Option HSO device
76 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6771", RUN+="usb_modeswitch '%b/%k'"
77
78 # Option HSO device
79 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6791", RUN+="usb_modeswitch '%b/%k'"
80
81 # Option HSO device
82 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6811", RUN+="usb_modeswitch '%b/%k'"
83
84 # Option GlobeSurfer Icon 7.2, new firmware (HSO driver)
85 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6911", RUN+="usb_modeswitch '%b/%k'"
86
87 # Option HSO device
88 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6951", RUN+="usb_modeswitch '%b/%k'"
89
90 # Option iCON 225 HSDPA
91 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6971", RUN+="usb_modeswitch '%b/%k'"
92
93 # Option GlobeTrotter HSUPA Modem
94 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7011", RUN+="usb_modeswitch '%b/%k'"
95
96 # Option HSO device
97 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7031", RUN+="usb_modeswitch '%b/%k'"
98
99 # Option HSO device
100 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7051", RUN+="usb_modeswitch '%b/%k'"
101
102 # Option HSO device
103 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7071", RUN+="usb_modeswitch '%b/%k'"
104
105 # Option HSO device
106 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7111", RUN+="usb_modeswitch '%b/%k'"
107
108 # Option HSO device
109 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7211", RUN+="usb_modeswitch '%b/%k'"
110
111 # Option HSO device
112 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7251", RUN+="usb_modeswitch '%b/%k'"
113
114 # Option HSO device
115 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7271", RUN+="usb_modeswitch '%b/%k'"
116
117 # Option HSO device
118 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7301", RUN+="usb_modeswitch '%b/%k'"
119
120 # Option HSO device
121 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7311", RUN+="usb_modeswitch '%b/%k'"
122
123 # Option HSO device
124 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7361", RUN+="usb_modeswitch '%b/%k'"
125
126 # Option HSO device
127 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7381", RUN+="usb_modeswitch '%b/%k'"
128
129 # Option iCON 401
130 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7401", RUN+="usb_modeswitch '%b/%k'"
131
132 # Vodafone K3760 (made by Option, HSO device)
133 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7501", RUN+="usb_modeswitch '%b/%k'"
134
135 # Option HSO device
136 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7601", RUN+="usb_modeswitch '%b/%k'"
137
138 # Option HSO device
139 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7701", RUN+="usb_modeswitch '%b/%k'"
140
141 # Option HSO device
142 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7801", RUN+="usb_modeswitch '%b/%k'"
143
144 # Option HSO device
145 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="7901", RUN+="usb_modeswitch '%b/%k'"
146
147 # Option HSO device
148 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8200", RUN+="usb_modeswitch '%b/%k'"
149
150 # Option HSO device
151 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8201", RUN+="usb_modeswitch '%b/%k'"
152
153 # Option HSO device
154 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8300", RUN+="usb_modeswitch '%b/%k'"
155
156 # Option HSO device
157 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8302", RUN+="usb_modeswitch '%b/%k'"
158
159 # Option HSO device
160 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8304", RUN+="usb_modeswitch '%b/%k'"
161
162 # Option HSO device
163 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="8400", RUN+="usb_modeswitch '%b/%k'"
164
165 # Option HSO device
166 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="c031", RUN+="usb_modeswitch '%b/%k'"
167
168 # Option HSO device
169 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="c100", RUN+="usb_modeswitch '%b/%k'"
170
171 # Option HSO device
172 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d013", RUN+="usb_modeswitch '%b/%k'"
173
174 # Option HSO device
175 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d031", RUN+="usb_modeswitch '%b/%k'"
176
177 # AT&T USBConnect Quicksilver (made by Option, HSO device)
178 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d033", RUN+="usb_modeswitch '%b/%k'"
179
180 # Option HSO device
181 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d035", RUN+="usb_modeswitch '%b/%k'"
182
183 # Option HSO device
184 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d055", RUN+="usb_modeswitch '%b/%k'"
185
186 # Option HSO device
187 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d057", RUN+="usb_modeswitch '%b/%k'"
188
189 # Option HSO device
190 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d058", RUN+="usb_modeswitch '%b/%k'"
191
192 # Option HSO device
193 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d155", RUN+="usb_modeswitch '%b/%k'"
194
195 # Option HSO device
196 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d157", RUN+="usb_modeswitch '%b/%k'"
197
198 # Option HSO device
199 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d255", RUN+="usb_modeswitch '%b/%k'"
200
201 # Option HSO device
202 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d257", RUN+="usb_modeswitch '%b/%k'"
203
204 # Option HSO device
205 ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="d357", RUN+="usb_modeswitch '%b/%k'"
206
207 # Olivetti Olicard 100 and others
208 ATTRS{idVendor}=="0b3c", ATTRS{idProduct}=="c700", RUN+="usb_modeswitch '%b/%k'"
209
210 # Sony Ericsson MD300
211 ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="d0cf", RUN+="usb_modeswitch '%b/%k'"
212
213 # Sony Ericsson MD400
214 ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="d0e1", RUN+="usb_modeswitch '%b/%k'"
215
216 # Rogers Rocket Stick (a Sony Ericsson device)
217 ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="d103", RUN+="usb_modeswitch '%b/%k'"
218
219 # LG LDU-1900D EV-DO (Rev. A)
220 ATTRS{idVendor}=="1004", ATTRS{idProduct}=="1000", RUN+="usb_modeswitch '%b/%k'"
221
222 # LG HDM-2100 (EVDO Rev.A USB modem)
223 ATTRS{idVendor}=="1004", ATTRS{idProduct}=="607f", RUN+="usb_modeswitch '%b/%k'"
224
225 # LG L-05A
226 ATTRS{idVendor}=="1004", ATTRS{idProduct}=="613a", RUN+="usb_modeswitch '%b/%k'"
227
228 # LG LUU-2100TI
229 ATTRS{idVendor}=="1004", ATTRS{idProduct}=="613f", RUN+="usb_modeswitch '%b/%k'"
230
231 # Huawei E630
232 ATTRS{idVendor}=="1033", ATTRS{idProduct}=="0035", RUN+="usb_modeswitch '%b/%k'"
233
234 # UTStarcom UM175
235 ATTRS{idVendor}=="106c", ATTRS{idProduct}=="3b03", RUN+="usb_modeswitch '%b/%k'"
236
237 # UTStarcom UM185E
238 ATTRS{idVendor}=="106c", ATTRS{idProduct}=="3b06", RUN+="usb_modeswitch '%b/%k'"
239
240 # Sagem F@ST 9520-35-GLR
241 ATTRS{idVendor}=="1076", ATTRS{idProduct}=="7f40", RUN+="usb_modeswitch '%b/%k'"
242
243 # Sierra Wireless Compass 597
244 ATTRS{idVendor}=="1199", ATTRS{idProduct}=="0fff", RUN+="usb_modeswitch '%b/%k'"
245
246 # Digicom 8E4455
247 ATTRS{idVendor}=="1266", ATTRS{idProduct}=="1000", RUN+="usb_modeswitch '%b/%k'"
248
249 # Huawei E169
250 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1001", RUN+="usb_modeswitch '%b/%k'"
251
252 # Huawei devices
253 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="usb_modeswitch '%b/%k'"
254
255 # Huawei U7510 / U7517
256 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="101e", RUN+="usb_modeswitch '%b/%k'"
257
258 # Huawei E180
259 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1414", RUN+="usb_modeswitch '%b/%k'"
260
261 # Huawei E270+
262 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"
263
264 # Huawei K3765
265 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1520", RUN+="usb_modeswitch '%b/%k'"
266
267 # Huawei K4505
268 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1521", RUN+="usb_modeswitch '%b/%k'"
269
270 # Huawei E173
271 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1557", RUN+="usb_modeswitch '%b/%k'"
272
273 # Novatel Wireless Ovation MC950D HSUPA
274 ATTRS{idVendor}=="1410", ATTRS{idProduct}=="5010", RUN+="usb_modeswitch '%b/%k'"
275
276 # Novatel MC990D
277 ATTRS{idVendor}=="1410", ATTRS{idProduct}=="5020", RUN+="usb_modeswitch '%b/%k'"
278
279 # Novatel U760 USB modem
280 ATTRS{idVendor}=="1410", ATTRS{idProduct}=="5030", RUN+="usb_modeswitch '%b/%k'"
281
282 # Novatel MC760 3G
283 ATTRS{idVendor}=="1410", ATTRS{idProduct}=="5031", RUN+="usb_modeswitch '%b/%k'"
284
285 # Novatel Generic MiFi 2352 / Vodafone MiFi 2352
286 ATTRS{idVendor}=="1410", ATTRS{idProduct}=="5041", RUN+="usb_modeswitch '%b/%k'"
287
288 # Motorola 802.11 bg WLAN (TER/GUSB3-E)
289 ATTRS{idVendor}=="148f", ATTRS{idProduct}=="2578", RUN+="usb_modeswitch '%b/%k'"
290
291 # C-motech D-50
292 ATTRS{idVendor}=="16d8", ATTRS{idProduct}=="6803", RUN+="usb_modeswitch '%b/%k'"
293
294 # C-motech CHU-629S
295 ATTRS{idVendor}=="16d8", ATTRS{idProduct}=="700a", RUN+="usb_modeswitch '%b/%k'"
296
297 # C-motech CGU-628
298 ATTRS{idVendor}=="16d8", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
299
300 # Beceem BCSM250
301 ATTRS{idVendor}=="198f", ATTRS{idProduct}=="bccd", RUN+="usb_modeswitch '%b/%k'"
302
303 # ZTE MU351
304 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0003", RUN+="usb_modeswitch '%b/%k'"
305
306 # ZTE AC581
307 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0026", RUN+="usb_modeswitch '%b/%k'"
308
309 # Vodafone (ZTE) K2525
310 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0040", RUN+="usb_modeswitch '%b/%k'"
311
312 # ZTE MF110 (Variant)
313 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0053", RUN+="usb_modeswitch '%b/%k'"
314
315 # ZTE MF110 (Variant)
316 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0083", RUN+="usb_modeswitch '%b/%k'"
317
318 # Vodafone (ZTE) K4505-Z
319 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0101", RUN+="usb_modeswitch '%b/%k'"
320
321 # ZTE MF112
322 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0103", RUN+="usb_modeswitch '%b/%k'"
323
324 # ZTE MF651
325 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0115", RUN+="usb_modeswitch '%b/%k'"
326
327 # Vodafone (ZTE) K3805-Z
328 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="1001", RUN+="usb_modeswitch '%b/%k'"
329
330 # Vodafone (ZTE) K3570-Z
331 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="1007", RUN+="usb_modeswitch '%b/%k'"
332
333 # Vodafone (ZTE) K3571-Z
334 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="1009", RUN+="usb_modeswitch '%b/%k'"
335
336 # ZTE MF620 (aka "Onda MH600HS")
337 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="2000", RUN+="usb_modeswitch '%b/%k'"
338
339 # ZTE AC8710
340 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="fff5", RUN+="usb_modeswitch '%b/%k'"
341
342 # ZTE "fff" devices 2
343 ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="fff6", RUN+="usb_modeswitch '%b/%k'"
344
345 # BandLuxe C120, BandLuxe C120
346 ATTRS{idVendor}=="1a8d", ATTRS{idProduct}=="1000", RUN+="usb_modeswitch '%b/%k'"
347
348 # Hummer DTM5731
349 ATTRS{idVendor}=="1ab7", ATTRS{idProduct}=="5700", RUN+="usb_modeswitch '%b/%k'"
350
351 # EpiValley SEC-7089
352 ATTRS{idVendor}=="1b7d", ATTRS{idProduct}=="0700", RUN+="usb_modeswitch '%b/%k'"
353
354 # Alcatel X200/X060S
355 ATTRS{idVendor}=="1bbb", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
356
357 # Alcatel One Touch X020
358 ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="1001", RUN+="usb_modeswitch '%b/%k'"
359
360 # MyWave SW006 Sport Phone/Modem Combination
361 ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9200", RUN+="usb_modeswitch '%b/%k'"
362
363 # MobiData MBD-200HU
364 ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
365
366 # Solomon S3Gm-660
367 ATTRS{idVendor}=="1dd6", ATTRS{idProduct}=="1000", RUN+="usb_modeswitch '%b/%k'"
368
369 # Option iCON 210
370 ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="f000", RUN+="usb_modeswitch '%b/%k'"
371
372 # Cricket A600
373 ATTRS{idVendor}=="1f28", ATTRS{idProduct}=="0021", RUN+="usb_modeswitch '%b/%k'"
374
375 # Franklin Wireless U210
376 ATTRS{idVendor}=="1fac", ATTRS{idProduct}=="0130", RUN+="usb_modeswitch '%b/%k'"
377
378 LABEL="modeswitch_rules_end"
379
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
2
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
4 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Library General Public License instead.) You can apply it to
18 your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
26
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
31
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
37
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
41
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
48
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
54
55 The precise terms and conditions for copying, distribution and
56 modification follow.
57
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
70
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
77
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
85
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
88
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
93
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
96
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
101
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
112
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
122
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
127
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
132
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
136
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
140
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
147
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
153
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
164
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
170
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
178
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
187
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
195
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
208
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
213
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
224
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
227
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
235
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281 How to Apply These Terms to Your New Programs
282
283 If you develop a new program, and you want it to be of the greatest
284 possible use to the public, the best way to achieve this is to make it
285 free software which everyone can redistribute and change under these terms.
286
287 To do so, attach the following notices to the program. It is safest
288 to attach them to the start of each source file to most effectively
289 convey the exclusion of warranty; and each file should have at least
290 the "copyright" line and a pointer to where the full notice is found.
291
292 <one line to give the program's name and a brief idea of what it does.>
293 Copyright (C) <year> <name of author>
294
295 This program is free software; you can redistribute it and/or modify
296 it under the terms of the GNU General Public License as published by
297 the Free Software Foundation; either version 2 of the License, or
298 (at your option) any later version.
299
300 This program is distributed in the hope that it will be useful,
301 but WITHOUT ANY WARRANTY; without even the implied warranty of
302 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303 GNU General Public License for more details.
304
305 You should have received a copy of the GNU General Public License
306 along with this program; if not, write to the Free Software
307 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
308
309
310 Also add information on how to contact you by electronic and paper mail.
311
312 If the program is interactive, make it output a short notice like this
313 when it starts in an interactive mode:
314
315 Gnomovision version 69, Copyright (C) year name of author
316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 This is free software, and you are welcome to redistribute it
318 under certain conditions; type `show c' for details.
319
320 The hypothetical commands `show w' and `show c' should show the appropriate
321 parts of the General Public License. Of course, the commands you use may
322 be called something other than `show w' and `show c'; they could even be
323 mouse-clicks or menu items--whatever suits your program.
324
325 You should also get your employer (if you work as a programmer) or your
326 school, if any, to sign a "copyright disclaimer" for the program, if
327 necessary. Here is a sample; alter the names:
328
329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
332 <signature of Ty Coon>, 1 April 1989
333 Ty Coon, President of Vice
334
335 This General Public License does not permit incorporating your program into
336 proprietary programs. If your program is a subroutine library, you may
337 consider it more useful to permit linking proprietary applications with the
338 library. If this is what you want to do, use the GNU Library General
339 Public License instead of this License.
0 20100623:
1 Huawei E173 was left out in previous release, add it again;
2 added BandLuxe C170 and C270 (now confirmed working)
3 20100621 (with release 1.1.3):
4 added ZTE devices (MU351, MF110 variants, MF112, MF627);
5 added Sierra target IDs and Option devices (sync to kernel 2.6.34);
6 added LG L-05A, LG LUU-2100TI, LG KP500, Alcatel OT X220L, Olivetti Olicard
7 series, Huawei MTE WM610, Royaltek Q110, Rogers Rocket Stick;
8 changed most ZTE devices again to "eject" command with known specific
9 commands as second message; changed interface filter in rules file to
10 include "5" and "9" besides "0" (quirky devices)
11 20100418 (with release 1.1.2):
12 First version with proper ChangeLog; added Digicom 8E4455 (needs multiple
13 commands, implemented in usb-modeswitch-1.1.2); added all other Pirelli
14 target IDs (from "option" driver) assuming they behave like the Digicom -
15 this is EXPERIMENTAL; added several ZTE devices and S.E. MD300, contributed
16 by Betavine project; new rule to add a symlink to interrupt ports (ignored
17 if wrapper is < 1.1.2)
18 20100322:
19 Changed all ZTE devices to the "non-eject" command after annother report
20 of "eject" failure; even older ZTE devices seem to work with the former;
21 a conflict was exposed between two versions of 16d8:6803 (C-motech D50);
22 changed the default to the one which keeps the ID during switching
23
0 PROG = usb-modeswitch-data
1 VERS = 20100623
2 RM = /bin/rm -f
3 PREFIX = $(DESTDIR)/usr
4 ETCDIR = $(DESTDIR)/etc
5 UDEVDIR = $(DESTDIR)/lib/udev
6 RULESDIR = $(UDEVDIR)/rules.d
7 SBINDIR = $(PREFIX)/sbin
8 MANDIR = $(PREFIX)/share/man/man1
9
10
11 .PHONY: clean
12
13 all:
14
15 clean:
16
17 install: files-install rules-reload
18
19 files-install:
20 install -d $(ETCDIR)/usb_modeswitch.d
21 install --mode=644 -t $(ETCDIR)/usb_modeswitch.d ./usb_modeswitch.d/*
22 install -D --mode=644 40-usb_modeswitch.rules $(RULESDIR)/40-usb_modeswitch.rules
23
24 rules-reload:
25 if [ -f $(ETCDIR)/issue ]; then \
26 if [ -n `which udevadm 2>/dev/null` ]; then \
27 UDEVADM=`which udevadm`; \
28 UDEVADM_VER=`$$UDEVADM -V 2>/dev/null`; \
29 if [ -z $$UDEVADM_VER ]; then \
30 UDEVADM_VER=`$$UDEVADM --version 2>/dev/null`; \
31 fi; \
32 if [ $$UDEVADM_VER -gt 127 ]; then \
33 $$UDEVADM control --reload-rules; \
34 else \
35 $$UDEVADM control --reload_rules; \
36 fi \
37 elif [ `which udevcontrol 2>/dev/null` ]; then \
38 `which udevcontrol` reload_rules; \
39 fi \
40 fi
41
42 uninstall: files-uninstall rules-reload
43
44 files-uninstall:
45 $(RM) $(SBINDIR)/usb_modeswitch
46 $(RM) $(UDEVDIR)/usb_modeswitch
47 $(RM) $(RULESDIR)/40-usb_modeswitch.rules
48 $(RM) -R $(ETCDIR)/usb_modeswitch.d
49
50 .PHONY: clean install uninstall
51
0 README for USB_ModeSwitch Data
1
2
3 For up-to-date and detailed information (plus a friendly forum) visit
4 http://www.draisberghof.de/usb_modeswitch
5
6 PLEASE REPORT NEW DEVICES
7
8
9
10 This is a data package to complement the full release package of
11 USB_ModeSwitch, a tool to switch multi-mode (or composite) USB devices.
12 It is used since usb-modeswitch version 1.0.3.
13
14 Recommended version of usb-modeswitch package is 1.1.2 and above. Some
15 devices contained here may not be switched with older versions, even if
16 they will not cause any error.
17
18
19 Explanation about config file names:
20 ====================================
21
22 Names consist of <VendorID>:<ProductID>, respective to the default device
23 mode.
24 Should more detailed identification become necessary, one or more attributes
25 to test can be attached after further colons:
26 <VendorID>:<ProductID>:<Attribute>=<String>[:<Attribute>=<String> ...]
27
28 The strings match if they are part of the attribute content. Use "_"
29 to match spaces (it will match "_" too!).
30
31 Currently recognized attibutes are:
32
33 uMa = USB, iManufacturer
34 uPr = USB, iProduct
35 uSe = USB, iSerial
36 sVe = SCSI, Vendor
37 sMo = SCSI, Model
38 sRe = SCSI, Revision
39
40 This list is easily extendable if necessary.
41
42 Example:
43 <vid>:<pid>:uPr=CDMA_Mo will match iProduct "CDMA Modem" or "MyCDMA_Mordor"
44
45
46 If information is missing about ambiguous devices, a ":?" is attached
47 to the file/ID in question. Please contact the forum if you need help
48 in such a case.
49
50
51 Notes about specific devices:
52 =============================
53
54 - 16d8:6803 (C-motech D50, CDU-680): two versions popped up; one with
55 ID unchanged, target class 0xff, providing standard serial ports,
56 and one with target product 0x680a, providing an ACM port. There is
57 not enough information how to tell them apart; if you have the second
58 one, we badly need information (usb_modeswitch output with SCSI inquiry)
59
60 - 1004:607f (LG KP500): switching message derived from report but untested
61
62 - 1266:1000 (Royaltek Q110): switching method very likely but unconfirmed
63
64
65 Legal
66 =====
67
68 This program is free software; you can redistribute it and/or modify it under
69 the terms of the GNU General Public License as published by the Free Software
70 Foundation; either version 2 of the License, or (at your option) any later
71 version.
72
73 This program is distributed in the hope that it will be useful, but WITHOUT ANY
74 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
75 PARTICULAR PURPOSE. See the GNU General Public License for more details:
76
77 http://www.gnu.org/licenses/gpl.txt
78
79 Or find it as the file COPYING in this folder.
80
81
82
83
84 Last revised: 2010-06-21, Josua Dietze
85
0 ########################################################
1 # Nokia CS-15
2
3 DefaultVendor= 0x0421
4 DefaultProduct=0x0610
5
6 TargetVendor= 0x0421
7 TargetProduct= 0x0612
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 #########################################
1 # Vodafone MD950 (Wisue Technology)
2
3 DefaultVendor= 0x0471
4 DefaultProduct=0x1210
5
6 TargetVendor= 0x1dbc
7 TargetProduct= 0x0005
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Philips TalkTalk (NXP Semiconductors "Dragonfly")
2
3 DefaultVendor= 0x0471
4 DefaultProduct=0x1237
5
6 TargetVendor= 0x0471
7 TargetProductList="1206,1234"
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000030000000000000000000000"
0 ########################################################
1 # Kyocera W06K CDMA modem
2
3 DefaultVendor= 0x0482
4 DefaultProduct=0x024d
5
6 Configuration=2
0 ########################################################
1 # Samsung U209
2
3 DefaultVendor= 0x04e8
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x04e8
7 TargetProduct= 0x6601
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000616000000000000000000000000000000"
0 ########################################################
1 # AVM Fritz!Wlan USB Stick N
2
3 DefaultVendor= 0x057c
4 DefaultProduct=0x84ff
5
6 TargetVendor= 0x057c
7 TargetProduct= 0x8401
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000ff0000000000000000000000"
12
13 NoDriverLoading=1
14
0 #######################################################
1 # Older Option devices
2
3 DefaultVendor= 0x05c6
4 DefaultProduct= 0x1000
5
6 TargetVendor= 0x0af0
7
8 TargetProductList="6901,6701,6600"
9
10 CheckSuccess=20
11
12 MessageContent="55534243123456780000000000000601000000000000000000000000000000"
13 NeedResponse=1
0 ########################################################
1 # AnyDATA ADU-500A, ADU-510A, ADU-510L, ADU-520A
2
3 DefaultVendor= 0x05c6
4 DefaultProduct= 0x1000
5
6 TargetVendor= 0x16d5
7 TargetProduct= 0x6502
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
12
13
0 ########################################################
1 # Samsung SGH-Z810
2
3 DefaultVendor= 0x05c6
4 DefaultProduct= 0x1000
5
6 TargetVendor= 0x04e8
7 TargetProduct= 0x6601
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000616000000000000000000000000000000"
12
13
0 ########################################################
1 # Vertex Wireless 100 Series
2
3 DefaultVendor= 0x05c6
4 DefaultProduct=0x1000
5
6 TargetVendor= 0x1fe7
7 TargetProduct= 0x0100
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # D-Link DWM-162-U5, Micromax MMX 300c
2
3 DefaultVendor= 0x05c6
4 DefaultProduct=0x2001
5
6 TargetVendor= 0x1e0e
7 TargetProductList="ce16,cefe"
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Siptune LM-75 ("LinuxModem")
2
3 DefaultVendor= 0x05c6
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x05c6
7 TargetProduct= 0x9000
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # InfoCert Business Key (SmartCard/Reader emulation)
2
3 DefaultVendor= 0x072f
4 DefaultProduct=0x100d
5
6 TargetVendor= 0x072f
7 TargetProduct= 0x90cc
8
9 CheckSuccess=20
10
11 MessageContent="01b0000000000000000000000000000000000000000000000000000000000000"
12
13 NoDriverLoading=1
14
0 ########################################################
1 # Toshiba G450
2
3 DefaultVendor= 0x0930
4 DefaultProduct=0x0d46
5
6 TargetVendor= 0x0930
7 TargetProduct= 0x0d45
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 1)
2
3 DefaultVendor= 0x0ace
4 DefaultProduct=0x2011
5
6 CheckSuccess=20
7
8 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
9
10 NoDriverLoading=1
11
0 ########################################################
1 # Zydas ZD1211RW WLAN USB, Sphairon HomeLink 1202 (Variant 2)
2
3 DefaultVendor= 0x0ace
4 DefaultProduct=0x20ff
5
6 CheckSuccess=20
7
8 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
9
10 NoDriverLoading=1
11
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6711
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6731
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6751
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6771
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6791
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6811
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6911
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6951
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x6971
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7011
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7031
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7051
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7071
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7111
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7211
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7251
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7271
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7301
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7311
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7361
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7381
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7401
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7501
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7601
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7701
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7801
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x7901
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8200
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8201
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8300
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8302
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8304
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0x8400
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xc031
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xc100
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd013
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd031
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd033
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd035
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd055
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd057
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd058
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd155
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd157
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd255
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd257
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 #######################################################
1 # Option HSO device
2
3 DefaultVendor= 0x0af0
4 DefaultProduct= 0xd357
5
6 TargetClass= 0xff
7
8 CheckSuccess=10
9
10 MessageContent="55534243785634120100000080000601000000000000000000000000000000"
11
12 NoDriverLoading=1
13
0 ########################################################
1 # Olivetti Olicard 100 and others
2
3 DefaultVendor= 0x0b3c
4 DefaultProduct=0xc700
5
6 TargetVendor= 0x0b3c
7 TargetProductList="c000,c001,c002"
8
9 MessageContent="5553424312345678000000000000061b000000030000000000000000000000"
10 NeedResponse=1
11 CheckSuccess=20
12
0 ########################################################
1 # Sony Ericsson MD300
2
3 DefaultVendor= 0x0fce
4 DefaultProduct=0xd0cf
5
6 TargetClass=0x02
7
8 CheckSuccess=20
9
10 DetachStorageOnly=1
11 Configuration=3
0 ########################################################
1 # Sony Ericsson MD400
2
3 DefaultVendor= 0x0fce
4 DefaultProduct=0xd0e1
5
6 TargetClass=0x02
7
8 CheckSuccess=20
9
10 SonyMode=1
11 Configuration=2
0 ########################################################
1 # Rogers Rocket Stick (a Sony Ericsson device)
2
3 DefaultVendor= 0x0fce
4 DefaultProduct=0xd103
5
6 TargetClass=0x02
7
8 CheckSuccess=20
9
0 ########################################################
1 # LG LDU-1900D EV-DO (Rev. A)
2
3 DefaultVendor= 0x1004
4 DefaultProduct=0x1000
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 MessageContent="55534243123456780000000000000aff554d53434847000000000000000000"
0 ########################################################
1 # LG HDM-2100 (EVDO Rev.A USB modem)
2
3 DefaultVendor= 0x1004
4 DefaultProduct=0x607f
5
6 TargetVendor= 0x1004
7 TargetProduct= 0x6114
8
9 CheckSuccess=20
10
11 MessageContent="1201100102000040041014610000010200018006000100001200"
0 ########################################################
1 # LG L-05A
2
3 DefaultVendor= 0x1004
4 DefaultProduct=0x613a
5
6 TargetVendor= 0x1004
7 TargetProduct= 0x6124
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10 NeedResponse=1
11 CheckSuccess=20
12
0 ########################################################
1 # LG LUU-2100TI (aka AT&T USBConnect Turbo)
2
3 DefaultVendor= 0x1004
4 DefaultProduct=0x613f
5
6 TargetVendor= 0x1004
7 TargetProduct= 0x6141
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10 NeedResponse=1
11 CheckSuccess=20
12
0 ########################################################
1 # Huawei E630
2
3 DefaultVendor= 0x1033
4 DefaultProduct=0x0035
5
6 TargetVendor= 0x12d1
7 TargetProduct= 0x1003
8
9 CheckSuccess=20
10
11 HuaweiMode=1
0 ########################################################
1 # UTStarcom UM175 (distributor "Alltel")
2
3 DefaultVendor= 0x106c
4 DefaultProduct=0x3b03
5
6 TargetVendor= 0x106c
7 TargetProduct= 0x3715
8
9 CheckSuccess=20
10
11 MessageContent="555342431234567824000000800008ff024445564348470000000000000000"
0 ########################################################
1 # UTStarcom UM185E (distributor "Alltel")
2
3 DefaultVendor= 0x106c
4 DefaultProduct=0x3b06
5
6 TargetVendor= 0x106c
7 TargetProduct= 0x3717
8
9 CheckSuccess=20
10
11 MessageContent="55534243b82e238c24000000800008ff020000000000000000000000000000"
0 ########################################################
1 # Sagem F@ST 9520-35-GLR
2
3 DefaultVendor= 0x1076
4 DefaultProduct=0x7f40
5
6 TargetVendor= 0x1076
7 TargetProduct= 0x7f00
8
9 CheckSuccess=20
10
11 GCTMode=1
0 #######################################################
1 # Sierra devices (specific driver)
2
3 DefaultVendor= 0x1199
4 DefaultProduct= 0x0fff
5
6 TargetVendor= 0x1199
7 TargetProductList="0017,0018,0019,0020,0021,0022,0024,0026,0027,0028,0029,0112,0120,0218,0220,0224,6802,6803,6804,6805,6808,6809,6812,6813,6815,6816,6820,6821,6822,6832,6833,6834,6835,6838,6839,683a,683b,683c,683d,683e,6850,6851,6852,6853,6855,6856,6859,685a"
8
9 SierraMode=1"
10
11 CheckSuccess=10"
12
13 NoDriverLoading=1
0 ########################################################
1 # Digicom 8E4455 (and all Pirelli devices - EXPERIMENTAL)
2
3 DefaultVendor= 0x1266
4 DefaultProduct=0x1000
5
6 TargetVendor= 0x1266
7 TargetProductList="1002,1003,1004,1005,1006,1007,1008,1009,100a,100b,100c,100d,100e,100f,1011,1012"
8
9 NeedResponse=1
10
11 MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
12 MessageContent2="5553424387654321000000000000061b000000020000000000000000000000"
13
14 CheckSuccess=20
15
0 ########################################################
1 # Huawei E169
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1001
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 HuaweiMode=1
0 ########################################################
1 # Huawei E220, E230, E270, E870
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1003
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 HuaweiMode=1
0 ########################################################
1 # Huawei U7510 / U7517
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x101e
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 MessageContent="55534243123456780600000080000601000000000000000000000000000000"
0 ########################################################
1 # Huawei E180
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1414
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 HuaweiMode=1
0 ########################################################
1 # Huawei, newer modems
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1446
5
6 TargetVendor= 0x12d1
7 TargetProductList="1001,1406,140c,141b,14ac"
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000011060000000000000000000000000000"
0 ########################################################
1 # Huawei K3765
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1520
5
6 TargetVendor= 0x12d1
7 TargetProduct= 0x1465
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000011060000000000000000000000000000"
0 ########################################################
1 # Huawei K4505
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1521
5
6 TargetVendor= 0x12d1
7 TargetProduct= 0x1464
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000011060000000000000000000000000000"
0 ########################################################
1 # Huawei E173
2
3 DefaultVendor= 0x12d1
4 DefaultProduct=0x1557
5
6 TargetVendor= 0x12d1
7 TargetProduct= 0x14a5
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000011060000000000000000000000000000"
0 ########################################################
1 # Novatel Wireless devices
2
3 DefaultVendor= 0x1410
4 DefaultProduct=0x5010
5
6 TargetVendor= 0x1410
7 TargetProductList="4100,4400"
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Novatel MC990D
2
3 DefaultVendor= 0x1410
4 DefaultProduct=0x5020
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 Interface= 5
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Novatel U760
2
3 DefaultVendor= 0x1410
4 DefaultProduct=0x5030
5
6 TargetVendor= 0x1410
7 TargetProduct= 0x6000
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Novatel MC760 3G
2
3 DefaultVendor= 0x1410
4 DefaultProduct=0x5031
5
6 TargetVendor= 0x1410
7 TargetProduct= 0x6002
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Novatel Generic MiFi 2352 / Vodafone MiFi 2352
2
3 DefaultVendor= 0x1410
4 DefaultProduct=0x5041
5
6 TargetVendor= 0x1410
7 TargetProductList="7001,7003"
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # Motorola 802.11 bg WLAN (TER/GUSB3-E)
2
3 DefaultVendor= 0x148f
4 DefaultProduct=0x2578
5
6 TargetVendor= 0x148f
7 TargetProduct= 0x9021
8
9 CheckSuccess=20
10
11 MessageContent="55534243908ecd89000000000000061b000000020000000000000000000000"
12
13 NoDriverLoading=1
14
0 ########################################################
1 # C-motech D-50 (aka "CDU-680")
2
3 DefaultVendor= 0x16d8
4 DefaultProduct=0x6803
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 MessageContent="555342431234567824000000800008ff524445564348470000000000000000"
0 ########################################################
1 # C-motech D-50 (aka "CDU-680")
2
3 DefaultVendor= 0x16d8
4 DefaultProduct=0x6803
5
6 TargetVendor= 0x16d8
7 TargetProduct= 0x680a
8
9 CheckSuccess=20
10
11 MessageContent="555342431234567824000000800008ff524445564348470000000000000000"
0 ########################################################
1 # C-motech CHU-629S
2
3 DefaultVendor= 0x16d8
4 DefaultProduct=0x700a
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
10 MessageContent="55534243123456782400000080000dfe524445564348473d4e444953000000"
0 ########################################################
1 # C-motech CGU-628 (aka "Franklin Wireless CGU-628A" aka "4G Systems XS Stick W12")
2
3 DefaultVendor= 0x16d8
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x16d8
7 TargetProduct= 0x6006
8
9 CheckSuccess=20
10
11 MessageContent="55534243d85dd88524000000800008ff524445564348470000000000000000"
0 ########################################################
1 # Beceem BCSM250
2
3 DefaultVendor= 0x198f
4 DefaultProduct=0xbccd
5
6 TargetVendor= 0x198f
7 TargetProduct= 0x0220
8
9 CheckSuccess=20
10
11 MessageContent="55534243f0298d8124000000800006bc626563240000000000000000000000"
12
13 NoDriverLoading=1
14
0 ########################################################
1 # ZTE MU351
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0003
5
6 TargetClass=0xff
7
8 CheckSuccess=20
9
0 ########################################################
1 # ZTE AC581
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0026
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0094
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10 NeedResponse=1
11 CheckSuccess=20
12
0 ########################################################
1 # Vodafone (ZTE) K2525
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0040
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0022
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000030000000000000000000000"
0 ########################################################
1 # ZTE MF110 (Variant)
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0053
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0031
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10 MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
11
12 NeedResponse=1
13
14 CheckSuccess=20
15
0 ########################################################
1 # ZTE MF110 (Variant)
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0083
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0124
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # Vodafone (ZTE) K4505-Z
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0101
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0104
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # ZTE MF112
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0103
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0031
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10 MessageContent2="55534243876543212000000080000c85010101180101010101000000000000"
11
12 NeedResponse=1
13
14 CheckSuccess=20
15
0 ########################################################
1 # ZTE MF651
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x0115
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x0116
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # Vodafone (ZTE) K3805-Z
2 #
3 # Note:
4 # This device has multiple USB profiles. Depending upon how it is flipped
5 # from storage mode to modem mode determines its final PID and the packages
6 # shown on its ISO CD image.
7
8 DefaultVendor= 0x19d2
9 DefaultProduct=0x1001
10
11 TargetVendor= 0x19d2
12 TargetProduct= 0x1003
13
14 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
15
16 NeedResponse=1
17
18 CheckSuccess=20
19
0 ########################################################
1 # Vodafone (ZTE) K3570-Z
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x1007
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x1008
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # Vodafone (ZTE) K3571-Z
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0x1009
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0x1010
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # ZTE devices
2
3 DefaultVendor= 0x19d2
4 DefaultProduct= 0x2000
5
6 TargetVendor= 0x19d2
7 TargetProductList="0001,0002,0015,0016,0017,0031,0037,0052,0055,0063,0064,0128"
8
9 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
10
11 NeedResponse=1
12
13 CheckSuccess=20
14
0 ########################################################
1 # ZTE "fff" devices 1
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0xfff5
5
6 TargetVendor= 0x19d2
7 TargetProductList="fff1,ffff"
8
9 MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"
10
11 CheckSuccess=20
12
0 ########################################################
1 # ZTE "fff" devices 2
2
3 DefaultVendor= 0x19d2
4 DefaultProduct=0xfff6
5
6 TargetVendor= 0x19d2
7 TargetProduct= 0xfff1
8
9 MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"
10
11 CheckSuccess=20
12
0 ########################################################
1 # BandLuxe C120
2
3 DefaultVendor= 0x1a8d
4 DefaultProduct=0x1000
5
6 TargetVendor= 0x1a8d
7 TargetProduct= 0x1002
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456781200000080000603000000020000000000000000000000"
12 ResponseNeeded=1
0 ########################################################
1 # BandRich BandLuxe C170, BandLuxe C270
2
3 DefaultVendor= 0x1a8d
4 DefaultProduct=0x1000
5
6 TargetVendor= 0x1a8d
7 TargetProduct= 0x1009
8
9 MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
10 MessageContent2="5553424312345679000000000000061b000000020000000000000000000000"
11
12 NeedResponse=1
13
14 CheckSuccess=20
15
0 ########################################################
1 # Hummer DTM5731
2
3 DefaultVendor= 0x1ab7
4 DefaultProduct=0x5700
5
6 TargetVendor= 0x1ab7
7 TargetProduct= 0x5731
8
9 CheckSuccess=20
10
11 MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
0 ########################################################
1 # EpiValley SEC-7089 (featured by Alegro and Starcomms / iZAP)
2
3 DefaultVendor= 0x1b7d
4 DefaultProduct=0x0700
5
6 TargetVendor= 0x1b7d
7 TargetProduct= 0x0001
8
9 CheckSuccess=20
10
11 MessageContent="555342431234567824000000800008FF05B112AEE102000000000000000000"
0 ########################################################
1 # Alcatel X200/X060S
2
3 DefaultVendor= 0x1bbb
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x1bbb
7 TargetProduct= 0x0000
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
0 ########################################################
1 # Alcatel One Touch X020
2
3 DefaultVendor= 0x1c9e
4 DefaultProduct=0x1001
5
6 TargetVendor= 0x1c9e
7 TargetProduct= 0x6061
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000606f50402527000000000000000000000"
0 ########################################################
1 # MyWave SW006 Sport Phone/Modem Combination
2
3 DefaultVendor= 0x1c9e
4 DefaultProduct=0x9200
5
6 TargetVendor= 0x1c9e
7 TargetProduct= 0x9202
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456780000000000000606f50402527000000000000000000000"
0 ########################################################
1 # MobiData MBD-200HU
2
3 DefaultVendor= 0x1c9e
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x1c9e
7 TargetProductList="9063,9603,9000"
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
0 ########################################################
1 # Solomon S3Gm-660
2
3 DefaultVendor= 0x1dd6
4 DefaultProduct=0x1000
5
6 TargetVendor= 0x1dd6
7 TargetProduct= 0x1002
8
9 CheckSuccess=20
10
11 MessageContent="55534243123456781200000080000603000000020000000000000000000000"
12 ResponseNeeded=1
0 ########################################################
1 # Option iCON 210, PROLiNK PHS100, Hyundai MB-810, A-Link 3GU
2
3 DefaultVendor= 0x1e0e
4 DefaultProduct=0xf000
5
6 TargetVendor= 0x1e0e
7 TargetProductList="9200,9000"
8
9 CheckSuccess=20
10
11 MessageContent="555342431234567800000000000006bd000000020000000000000000000000"
12 ResponseNeeded=1
0 ########################################################
1 # Cricket A600
2
3 DefaultVendor= 0x1f28
4 DefaultProduct=0x0021
5
6 TargetVendor= 0x1f28
7 TargetProduct= 0x0020
8
9 CheckSuccess=20
10
11 MessageContent="555342431234567824000000800108df200000000000000000000000000000"
0 ########################################################
1 # Franklin Wireless U210
2
3 DefaultVendor= 0x1fac
4 DefaultProduct=0x0130
5
6 TargetVendor= 0x1fac
7 TargetProduct= 0x0131
8
9 MessageContent="555342431234567824000000800108df200000000000000000000000000000"
10
11 CheckSuccess=20
12
0 ##2
1 # If first line starts with "##" and has a single digit following it,
2 # it should denote average count of bytes used in representing UTF-8
3 # characters of this locale. This value is utilized into properly
4 # wrapping translated text.
5 #
6 # This is a translation file for Sakis3G All-in-one script.
7 #
8 # All translation files should strictly remain in UTF-8 encoding.
9 # Make sure your editor loads and saves file using UTF-8.
10 #
11 # File information:
12 # - Translator(s):
13 # - Email (optional): xxxxxx is local part. Domain is xxxxxxx.
14 # - Locale: xx_xx.UTF-8
15 # - Location: messages/xx_xx.UTF-8
16 #
17 # To test your translation, execute sakis3g with TRANSLATE argument,
18 # sakis3g TRANSLATE="/home/me/translationfile"
19 #
20 # Notes and guidelines:
21 # - Please respect \n \t or any other character when translating.
22 # - Please respect count, order and datatype of "%" arguments when
23 # translating.
24 # - If a specific statement appears the same way, in your locale, and to
25 # original text, you should place an empty line below it. Do not
26 # copy-paste same content to denote identical original and translated
27 # text. Doing so will lead into problems
28 # - Feel free to alter order of statements according to your taste, as
29 # long as each translation comes after its English text.
30 # - Lines starting with # are ignored.
31 # - Empty line means that above statement does not have a translation. You
32 # should therefore only allow empty lines in pairs. Like those below:
33
34
35 ## End of comments. More comments appear within text to help you translating.
36
37
38 "About Sakis3G"
39
40 "Acquiring exclusive lock to HAL"
41
42 "Acquiring root privileges"
43
44 "Already selected value %s=\"%s\". Is not valid.\n"
45
46 #
47 # This statement appears within connection information which when
48 # displayed from "zenity" displays text aligned. Make sure you append
49 # statements with enough \t characters so that they appear aligned.
50 # All statements appearing in connection information dialog have
51 # "CONNECTION_INFORMATION" tag for you to search for.
52 #
53 "APN:\t\t\t%s"
54 "APN:\t\t\t\t%s"
55 "Available options are:\n"
56
57 "Bluetooth modem"
58
59 "Both \"%s\" and \"%s\" are missing."
60
61 "Cancel"
62
63 "Checking dependencies"
64
65 "Checking tools availability"
66
67 "Choose action for Sakis3G script to follow."
68
69 "Cleaning"
70
71 "Compile embedded Usb-ModeSwitch"
72
73 "Compiling"
74
75 "Connected."
76
77 "Connected"
78
79 #
80 # This statement appears within connection information which when
81 # displayed from "zenity" displays text aligned. Make sure you append
82 # statements with enough \t characters so that they appear aligned.
83 # All statements appearing in connection information dialog have
84 # "CONNECTION_INFORMATION" tag for you to search for.
85 #
86 "Connected since:\t%s\n"
87
88 "Connected to %s."
89
90 "Connected to %s (%s)."
91
92 "Connecting"
93
94 "Connecting (second attempt)"
95
96 "Connection information"
97
98 "Connection Information"
99
100 "Connect with 3G"
101
102 "Create desktop shortcut"
103
104 "Create shortcut"
105
106 #
107 # Make sure you include your name between final "\n\n" like this:
108 #
109 # "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\nTranslation for English: Sakis Dimopoulos\n"
110 #
111 #
112 "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\n\n"
113 "(c) Σάκης Δημόπουλος 2009, 2010 υπό την GNU GPL v2\nΜεταφραση στα Ελληνικά: Σάκης Δημόπουλος\n"
114 "Custom APN..."
115
116 "Custom tty..."
117
118 #
119 # This statement appears within connection information which when
120 # displayed from "zenity" displays text aligned. Make sure you append
121 # statements with enough \t characters so that they appear aligned.
122 # All statements appearing in connection information dialog have
123 # "CONNECTION_INFORMATION" tag for you to search for.
124 #
125 "Default route(s):\t%s\n"
126
127 "Desktop icon"
128
129 "Desktop shortcut created at %s."
130
131 "Device did not report GSM capabilities. You can skip this by adding --noprobe command line switch.\n"
132
133 "Device node \"%s\" does not exist.\n"
134
135 "Device node \"%s\" does not exist. Setup failed."
136
137 #
138 # This statement appears within connection information which when
139 # displayed from "zenity" displays text aligned. Make sure you append
140 # statements with enough \t characters so that they appear aligned.
141 # All statements appearing in connection information dialog have
142 # "CONNECTION_INFORMATION" tag for you to search for.
143 #
144 "Device:\t\t\t%s\n"
145
146 "Disconnect"
147
148 "Disconnect and then connect again"
149
150 "Disconnected.\n"
151
152 "Disconnecting"
153
154 "Either enable interactive mode:\n"
155
156 "Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly. Start by issueing: %s recompile"
157
158 "Enter Bluetooth address"
159
160 "Enter Bluetooth address of undiscoverable device, or leave empty to abort"
161
162 "Enter correct APN, or leave empty to abort. Contact your operator if unsure"
163
164 "Enter name of appropriate kernel module that should be used, or leave empty to abort"
165
166 "Enter password required by APN, or leave empty to abort. Contact your operator if unsure. This information is usually easily retrieved through a fast call to customer support"
167
168 "Enter RFCOMM channel that should be used, or leave empty to abort [1-255]"
169
170 "Enter tty node where your 3G modem resides, or leave empty to abort"
171
172 "Enter username required by APN, or leave empty to abort. Contact your operator if unsure. This information, along with APN password, is usually easily retrieved through a fast call to customer support"
173
174 "Error"
175
176 "Error occured"
177
178 "Exit"
179
180 "Failed to become root."
181
182 "Failed to compile. Compilation output:\n%s\n"
183
184 "Failed to connect.\n"
185
186 "Failed to create device node \"%s\"."
187
188 "Failed to detach wrong driver \"%s\". Please do it yourself and retry.\n"
189
190 "Failed to detect driver of interface %d.\n"
191
192 "Failed to disassemble Sakis3G package.\n"
193
194 "Failed to disconnect.\n"
195
196 "Failed to get valid response from modem while checking for PIN."
197
198 "Failed to link %s. This usually indicates libusb (or libusb-compat) development kit missing.\n"
199
200 "Failed to load module \"%s\".\n"
201
202 "Failed to prepare modem.\n"
203
204 "Failed to setup modem.\n"
205
206 "Failed to succesfully create new version. Old version is still available at \"%s\".\n"
207
208 "Failed to succesfully place new version. You are still using old version.\n"
209
210 "Failed to switch.\n"
211
212 "Failed to unbind driver %s. I am sorry."
213
214 "Failed to unload module \"%s\".\n"
215
216 "Failed to verify result of compilation.\n"
217
218 "Failure to write on %s.\n"
219
220 "Fixing connection"
221
222 "Following dependencies not found within path: %s\n"
223
224 "Header file %s missing from your system.\n"
225
226 "Header file %s missing from your system. This usually indicates libusb (or libusb-compat) development kit missing.\n"
227
228 "Help with this question"
229
230 #
231 # This statement appears within connection information which when
232 # displayed from "zenity" displays text aligned. Make sure you append
233 # statements with enough \t characters so that they appear aligned.
234 # All statements appearing in connection information dialog have
235 # "CONNECTION_INFORMATION" tag for you to search for.
236 #
237 "Interface:\t\t\tP-t-P (%s)\n"
238
239 #
240 # This statement appears within connection information which when
241 # displayed from "zenity" displays text aligned. Make sure you append
242 # statements with enough \t characters so that they appear aligned.
243 # All statements appearing in connection information dialog have
244 # "CONNECTION_INFORMATION" tag for you to search for.
245 #
246 "IP Address:\t\t%s\n"
247
248 #
249 # This statement appears within connection information which when
250 # displayed from "zenity" displays text aligned. Make sure you append
251 # statements with enough \t characters so that they appear aligned.
252 # All statements appearing in connection information dialog have
253 # "CONNECTION_INFORMATION" tag for you to search for.
254 #
255 "Kernel driver:\t\t%s\n"
256
257 #
258 # This statement appears within connection information which when
259 # displayed from "zenity" displays text aligned. Make sure you append
260 # statements with enough \t characters so that they appear aligned.
261 # All statements appearing in connection information dialog have
262 # "CONNECTION_INFORMATION" tag for you to search for.
263 #
264 "Kilobytes received:\t%d\n"
265
266 #
267 # This statement appears within connection information which when
268 # displayed from "zenity" displays text aligned. Make sure you append
269 # statements with enough \t characters so that they appear aligned.
270 # All statements appearing in connection information dialog have
271 # "CONNECTION_INFORMATION" tag for you to search for.
272 #
273 "Kilobytes sent:\t%d\n"
274
275 "Loading driver %s"
276
277 "Locating tty"
278
279 "Manages 3G internet connection and 3G USB modems"
280
281 "Manually enter non-discovered channel..."
282
283 "Manually enter undiscoverable device..."
284
285 "Modem needs PIN"
286
287 "Modem on %s is registered to %s.\n"
288
289 "Modem refused to register operator \"%s\" (currently registered to \"%s\").\n"
290
291 "Modem refused to register operator \"%s\".\n"
292
293 "Modem responded \"%s\" while checking for PIN."
294
295 "Modem selected.\n"
296
297 "Modem setup residing on %s.\n"
298
299 "Modem switched.\n"
300
301 "Modem switched to %s.\n"
302
303 #
304 # This statement appears within connection information which when
305 # displayed from "zenity" displays text aligned. Make sure you append
306 # statements with enough \t characters so that they appear aligned.
307 # All statements appearing in connection information dialog have
308 # "CONNECTION_INFORMATION" tag for you to search for.
309 #
310 "Modem:\t\t\t%s\n"
311
312 #
313 # This statement appears within connection information which when
314 # displayed from "zenity" displays text aligned. Make sure you append
315 # statements with enough \t characters so that they appear aligned.
316 # All statements appearing in connection information dialog have
317 # "CONNECTION_INFORMATION" tag for you to search for.
318 #
319 "Modem type:\t\tBluetooth\n"
320
321 #
322 # This statement appears within connection information which when
323 # displayed from "zenity" displays text aligned. Make sure you append
324 # statements with enough \t characters so that they appear aligned.
325 # All statements appearing in connection information dialog have
326 # "CONNECTION_INFORMATION" tag for you to search for.
327 #
328 "Modem type:\t\tCustom\n"
329
330 #
331 # This statement appears within connection information which when
332 # displayed from "zenity" displays text aligned. Make sure you append
333 # statements with enough \t characters so that they appear aligned.
334 # All statements appearing in connection information dialog have
335 # "CONNECTION_INFORMATION" tag for you to search for.
336 #
337 "Modem type:\t\tUnknown\n"
338
339 #
340 # This statement appears within connection information which when
341 # displayed from "zenity" displays text aligned. Make sure you append
342 # statements with enough \t characters so that they appear aligned.
343 # All statements appearing in connection information dialog have
344 # "CONNECTION_INFORMATION" tag for you to search for.
345 #
346 "Modem type:\t\tUnspecified\n"
347
348 #
349 # This statement appears within connection information which when
350 # displayed from "zenity" displays text aligned. Make sure you append
351 # statements with enough \t characters so that they appear aligned.
352 # All statements appearing in connection information dialog have
353 # "CONNECTION_INFORMATION" tag for you to search for.
354 #
355 "Modem type:\t\tUSB\n"
356
357 "Modem unable to register a network."
358
359 "Module \"%s\" loaded but did not bind to device \"%s\".\n"
360
361 "Module \"%s\" loaded but refused to bind to device \"%s\".\n"
362
363 "More options..."
364
365 "\nAvailable options are:\n"
366
367 #
368 # This statement appears within connection information which when
369 # displayed from "zenity" displays text aligned. Make sure you append
370 # statements with enough \t characters so that they appear aligned.
371 # All statements appearing in connection information dialog have
372 # "CONNECTION_INFORMATION" tag for you to search for.
373 #
374 "Network ID:\t\t%s"
375
376 "\nExample:\n"
377
378 "No method for acquiring root privileges found."
379
380 "No modem selected.\n"
381
382 "Not connected"
383
384 "Not connected.\n"
385
386 "Notification"
387
388 "Not running from within package.\n"
389
390 "No USB modem"
391
392 "No USB modem was selected. No need for a udev example.\n"
393
394 "No write access to temporary folder \"%s\".\n"
395
396 "\nUtility \"%s\" found but cannot be used since we are not interactive.\n"
397
398 "OK"
399
400 "Only prepare modem (Setup + PIN unlock + Register Network + Update HAL)"
401
402 "Only setup modem (Switch + Load module + Setup tty)"
403
404 "Only switch modem (if applicable)"
405
406 "Oops. Weird \"%s\" version. Deleted temporary folder \"%s\".\n"
407
408 #
409 # This statement appears within connection information which when
410 # displayed from "zenity" displays text aligned. Make sure you append
411 # statements with enough \t characters so that they appear aligned.
412 # All statements appearing in connection information dialog have
413 # "CONNECTION_INFORMATION" tag for you to search for.
414 #
415 "Operator name:\t%s"
416
417 "Option"
418
419 "Option %s not implemented.\n"
420
421 "or, force using %s instead:\n"
422
423 "Other..."
424
425 "Other driver..."
426
427 #
428 # This statement appears within connection information which when
429 # displayed from "zenity" displays text aligned. Make sure you append
430 # statements with enough \t characters so that they appear aligned.
431 # All statements appearing in connection information dialog have
432 # "CONNECTION_INFORMATION" tag for you to search for.
433 #
434 "Peer IP Address:\t%s\n"
435
436 "Please appropriate interface"
437
438 "Please enter APN"
439
440 "Please enter name of driver"
441
442 "Please enter PIN number, or leave empty to abort"
443
444 "Please enter RFCOMM channel"
445
446 "Please enter tty"
447
448 "Please select an action"
449
450 "Please select APN"
451
452 "Please select appropriate driver"
453
454 "Please select Bluetooth device"
455
456 "Please select modem"
457
458 "Please select modem type"
459
460 "Please select RFCOMM service"
461
462 "Please select USB modem"
463
464 "Please use numbers %d-%d to perform your selection: "
465
466 "Port %s is currently occupied by %s."
467
468 "Preparing modem"
469
470 "Problem while parsing %s sources.\n"
471
472 "Reconnected to %s.\n"
473
474 "Registering network"
475
476 "Reported by your modem (%s)"
477
478 "Reported package location is not executable: %s\n"
479
480 "Resuming"
481
482 "Retrieving operator icon"
483
484 "Sakis 3G All-in-one script - Version %s\n"
485
486 "Sakis3G tux icon"
487
488 "%s by using %s variable, or by enabling interactive mode.\n"
489
490 "Scan device again"
491
492 "Scan devices again"
493
494 "Scanning bluetooth devices"
495
496 #
497 # First argument is modem name. Second argument is operator name.
498 #
499 "%s connected to %s."
500
501 #
502 # First argument is modem name. Second argument is operator name.
503 #
504 "%s connected to %s (%s)."
505
506 #
507 # Argument is bluetooth address of selected device, in the form
508 # xx:xx:xx:xx:xx:xx
509 #
510 "Seeking %s"
511
512 "Select"
513
514 "Select APN that best describes your connection. Contact your operator if unsure. This information, along with APN username and password, is usually easily retrieved through a fast call to customer support"
515
516 "Select Bluetooth device that provides 3G modem capabilities."
517
518 "Select icon to use for shortcut"
519
520 "Select kernel module that should be used."
521
522 "Select modem category that best fits your 3G modem."
523
524 "Select modem interface of USB device that provides modem capabilities."
525
526 "Select modem that will be used for establishing 3G connection."
527
528 "Select RFCOMM service of Bluetooth device that provides 3G modem capabilities."
529
530 "Select USB device that provides modem capabilities."
531
532 "Sending PIN"
533
534 "Show help"
535
536 "Something really bad happened. I am really sorry. You may need to re-download Sakis3G.\n"
537
538 "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability."
539
540 "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver."
541
542 "Starting up"
543
544 #
545 # This statement appears within connection information which when
546 # displayed from "zenity" displays text aligned. Make sure you append
547 # statements with enough \t characters so that they appear aligned.
548 # All statements appearing in connection information dialog have
549 # "CONNECTION_INFORMATION" tag for you to search for.
550 #
551 "Subnet Mask:\t\t%s\n"
552
553 "Succesfully recompiled.\n"
554
555 "Switching modem"
556
557 "Switching modem (using %s)"
558
559 "Testing compiler"
560
561 "To automatically repeat result of last action, immediately upon device connection, include following line within a %s file within \"%s\" directory:\n%s\n"
562
563 "To automatically repeat result of last action, use following command line:\n%s\n"
564
565 "Unable to check if module is currently loaded or if it has users.\n"
566
567 "Unable to check if %s is occupied. Not root."
568
569 "Unable to create a safe backup to \"%s\".\n"
570
571 "Unable to create device node \"%s\"."
572
573 "Unable to create file %s.\n"
574
575 "Unable to create rfcomm device node \"%s\"."
576
577 "Unable to create rfcomm node %s."
578
579 "Unable to create temporary folder \"%s\".\n"
580
581 "Unable to create temporary pppd config file within %s directory.\n"
582
583 "Unable to create temporary wvdial config file within %s directory.\n"
584
585 "Unable to delete previously existing \"%s\".\n"
586
587 "Unable to delete \"%s\".\n"
588
589 "Unable to determine my path.\n"
590
591 "Unable to discover connected USB devices. Script will now abort."
592
593 "Unable to extract %s source from package.\n"
594
595 "Unable to find available rfcomm device index. Minors occupied.\n"
596
597 "Unable to gather connection information.\n"
598
599 "Unable to get %s icon, unknown reason."
600
601 "Unable to install tray icon to system notification area. You need to install %s.\n"
602
603 "Unable to load driver \"%s\" for device \"%s\""
604
605 "Unable to locate dependency \"%s\". Script will now abort."
606
607 "Unable to locate driver to use for device \"%s\""
608
609 "Unable to overwrite existing package %s. Check if on read-only filesystem.\n"
610
611 "Unable to stop running pppd session. Both %s and % were not found.\n"
612
613 "Unloading driver %s"
614
615 "Unusable binary after including \"%s\".\n"
616
617 "Updating HAL"
618
619 "USB device"
620
621 "Waiting device to settle"
622
623 "Waiting HAL to mount device(s)"
624
625 "Waiting %s to be released by PID %s."
626
627 "Working..."
628
629 "WRONG PIN. Aborting to prevent you from locking your SIM card."
630
631 "You can automate this selection by setting %s variable.\n"
632
633 "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n"
634
635 "You can automate this selection by setting %s variable on command line, click here to discover how.\n"
636
637 "You can automate this selection by setting %s variable on command line.\n"
638
639 "Resolving connection details"
640
641 "Initializing modem"
642
643 "Confirm exit"
644
645 "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?"
646
647 "Disconnected"
648
649 "USB Modem plugged"
650
651 "USB Modem %s is now plugged on computer."
652
653 "Modem %s is now connected to %s."
654
655 "Modem %s is now connected."
656
657 "You are now connected to %s."
658
659 "Computer is now connected."
660
661 "USB Modem Unplugged"
662
663 "No USB modem is anymore plugged on computer."
664
665 "You were disconnected due to modem being unplugged."
666
667 "You are now disconnected from operator."
668
669 "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
670
671 "Locating device"
672
673 "Unable to locate a configuration file for switching device %s.\n"
674
675 "You are running a binary free version of Sakis3G. Unable to recompile %s.\n"
676
677 "%s is not installed on your system.\n"
678
679 "You are running a binary free version of Sakis3G. This action is not available.\n"
680
681 "Trying emergency switch"
682
683 "You need to be connected for generating report.\n"
684
685 "Please report following text:\n"
686
687 "Generate success report"
688
689 "You can automate this selection by setting --%syes or --%sno switches.\n"
690
691 "Scan for network"
692
693 "Modem was unable to register a network. Would you like to manually select a network?"
694
695 "Scanning networks"
696
697 "Please select a network"
698
699 "Select network for modem to register."
700
701 "You are running a stripped version of Sakis3G. This action is not available.\n"
702
703
704
0 Usage:
1 sakis3g [actors] [switches] [variables]
2
3 Sakis3G is a shell script which is supposed to work out-of-the-box for establishing a 3G connection with any combination of modem or operator.
4
5 NOTE: This script requires root priviledges to properly work. If not executed from root, it will try to acquire them.
6
7 Common actors are:
8 connect - Attempts to establish 3G connection.
9 disconnect - Stops all active PPP connections.
10 toggle - Attempts to establish 3G connection. If already connected, it disconnects instead.
11 reconnect - Attempts to establish 3G connection. If already connected, it first disconnects and then attempts.
12 start - Same as connect. Provided for use as init.d script.
13 stop - Same as disconnect. Provided for use as init.d script.
14 reload - Same as reconnect. Provided for use as init.d script.
15 force-reload - Same as reload. Provided for use as init.d script.
16 restart - Same as reload. Provided for use as init.d script.
17 desktop - Creates desktop shortcut for this script.
18 status - Prints connection status and exits. Exit code is 0 if connected, or 6 if not connected.
19 help - Prints this screen and exits.
20 man - Displays man page.
21
22 NOTE: For more information, you should consult man page or official Sakis3G wiki, available at:
23 http://wiki.sakis3g.org/
24
0 # Modem INIT AT commands
1 # Part of Sakis3G package, distributed under GNU GPL v2
2 #
3 # Lines starting with # are comments
4 #
5 # File is of the following format:
6 # <USB IDs>::<tab>STAGE 1 INIT Commands<tab>
7 # STAGE 2 INIT Commands<tab>
8 # STAGE 3 INIT Commands<tab>
9 # STAGE 4 INIT Commands<tab>
10 # STAGE 5 INIT Commands<tab>
11 # STAGE 6 INIT Commands<tab>
12 # STAGE 7 INIT Commands<tab>
13 # Or:
14 # <USB IDs>:SPECIFIC VARIANT:<tab>STAGE 1 INIT Commands...
15 # SPECIFIC VARIANT is the result of AT+CGMM
16 # Stage 1: Before asking for PIN, limited command-set
17 # Stage 2: Specific PIN inquiry command (if other than AT+CPIN=?)
18 # Stage 3: Specific PIN supply command (if other than AT+CPIN=%s)
19 # Entries of this stage must contain a unique %s that will be
20 # replaced by PIN supplied by user.
21 # Stage 4: After PIN unlock, full command-set, network registration not granted
22 # Stage 5: Before initializing, registered to network
23 # Stage 6: Specific initialization (if other than default)
24 # Entries of this stage must contain a unique %s that will be
25 # replaced by APN selected.
26 # Stage 7: After initialization, before ATD*99#
27
28 # ZTE modem (MF636)
29 # Needs +ZOPRT=5 for staying on power.
30 # Needs +CPMS with no arguments which while producing an error, suppresses
31 # +ZUSIMR:2 spamming.
32 19d2:0031:: AT+ZOPRT=5 AT+ZOPRT=5 AT+CPMS AT+ZOPRT=5 AT+CPMS ATS7=60 S30=0
33
34 # Alcatel X200
35 # Needs +CFUN=1 for recovering from power autosaving mode.
36 1bbb:0000:: AT+CFUN=1 AT+CFUN=1 AT+CFUN=1
37
38 # Sony Ericsson MD400
39 0fce:d0e1:MD400: AT+CFUN=1 AT+CPIN="%s" AT+CFUN=1 AT+CGATT=1
40
0 # List of known networks of Sakis3G.
1 # Distributed under GNU GPL v2
2 #
3 # Generic network format:
4 # <ISPID>::<tab>
5 # ISP_NAME<tab>
6 # ISP_PRODUCT<tab>
7 # FGCOLOR<tab>
8 # BGCOLOR<tab>
9 # DIAL<tab>
10 # APN#1<space>APN#2<space>...<space>APN#n<tab>
11 # ICON<EOL>
12 #
13 # Specific operator with network format:
14 # <ISPID>:<SPECIFIC ISP_NAME>:<tab>
15 # ISP_NAME<tab>
16 # ISP_PRODUCT<tab>
17 # FGCOLOR<tab>
18 # BGCOLOR<tab>
19 # DIAL<tab>
20 # APN#1<space>APN#2<space>...<space>APN#n<tab>
21 # ICON<EOL>
22 #
23 # APN#1, #2, ..., #n has format:
24 # APN URL:Description_with_no_spaces:Username:Password
25 #
26 # Empty lines and lines starting with "#" are not taken into consideration.
27 #
28
29 # Greece
30 20201:: GR COSMOTE Cosmote Internet on the Go 8DC919 internet:Real_IP_Internet:user:pass 3g-internet:NAT_IP_Internet:user:pass http://www.cosmote.gr/cosmote/resources/images/sm_logo_on_green.gif
31 20205:: VODAFONE GR VODAFONE Live ff0000 internet.vodafone.gr:Internet:user:pass webkarta.vodafone.gr:CU_Internet:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
32 20209:: WIND GR Wind ADSM 0000ff ffffff *99***1# gint.b-online.gr:Wind:web:web myq:Q_Telecom:user:pass http://www.wind.com.gr/wind_amea/images/logo_1.gif
33 20210:: WIND GR Wind ADSM 0000ff ffffff *99***1# gint.b-online.gr:Wind:web:web myq:Q_Telecom:user:pass http://www.wind.com.gr/wind_amea/images/logo_1.gif
34
35 # Netherlands
36 20404:: Vodafone NL Vodafone Mobiel Internet ff0000 live.vodafone.com:Non-business:vodafone:vodafone office.vodafone.nl:Business:vodafone:vodafone http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
37 20408:: NL KPN KPN Mobiel Internet 29aa2b internet:KPN:KPN:gprs internet:Telfort:telfortnl:pass portalmmm.nl:Hi:user:pass umts.xs4all.nl:XS4ALL:user:pass http://www.kpn.com/v2/static/kpncom/images/kpn_logo.png
38 20412:: Telfort NL T-Mobile Mobiel Internet 0000ff internet::telfortnl:pass http://www.prepaidgsm.net/loghi/logo_telfort.gif
39 20416:: T-Mobile NL T-Mobile Mobiel Internet ff00ff internet:Internet:user:pass internet.ben:Ben:user:pass http://www.t-mobile.at/Tico.ico
40 20420:: Orange NL Orange Mobiel Internet ff6600 internet::orange:orange http://i5.woopic.com/I/Header/orange.gif
41
42 # Belgium
43 20601:: BEL PROXIMUS Proximus Mobile Internet 2f207b internet.proximus.be:Inter:user:pass intraprox.be:Intra:user:pass http://customer.proximus.be/img3ldr/paw30/logos/proximus.png
44 20610:: B mobistar Mobistar Mobile Internet 000000 f0f0f0 internet.be:Mobistar_Personal:mobistar:mobistar web.pro.be:Mobistar_Business:mobistar:mobistar iew.be:Mobistar_Internet_Everywhere:mobistar:mobistar telenetwap.be:Telenet_Mobile:user:pass http://www.mobistar.be/nl/e-services/spage/images/logo/mobistar.gif
45 20620:: Base Base Mobile Internet 435f79 dde6f7 gprs.base.be:BASE:user:pass orangeinternet:Orange:user:pass http://www.prepaidgsm.net/loghi/logo_base.gif
46
47 # France
48 20801:: Orange F Orange Internet 3G+ ff6600 orange.fr:Orange_Contract:orange:orange internet-entreprise:Orange_Business_Contract:orange:orange orange:Orange_Mobicarte:orange:orange orange-mib:Orange_MIB:mportail:mib orange.ie:Orange_Internet_Everywhere_3G:user:pass orange.fr.mnc001.mcc208.gprs:France_Telecom_GPRS:gprs:pass ao.fr:TEN:orange:orange ofnew.fr:TEN_Pay-by-MB:orange:orange http://i5.woopic.com/I/Header/orange.gif
49 20810:: F SFR Clé Internet 3G+ ff0000 websfr:Web_SFR:user:pass wap65:A_Mobile:user:pass http://www.sfr.fr/mobile/edito/img/logoSFR.png
50 20811:: F SFR Clé Internet 3G+ ff0000 websfr:Web_SFR:user:pass wap65:A_Mobile:user:pass http://www.sfr.fr/mobile/edito/img/logoSFR.png
51 20820:: Bouygtel FR Internet Mobile 3G+ 02a9bc ffffff ebouygtel.com:ebouygtel:user:pass b2bouygtel.com:B2Bouygtel:user:pass http://www.bouyguestelecom.fr/client/homev2/imagesSite/header/logo-bouygues-telecom.png
52 20821:: Bouygtel FR Internet Mobile 3G+ 02a9bc ffffff ebouygtel.com:ebouygtel:user:pass b2bouygtel.com:B2Bouygtel:user:pass http://www.bouyguestelecom.fr/client/homev2/imagesSite/header/logo-bouygues-telecom.png
53
54 # Spain
55 21401:: Vodafone ES Vodafone Internet en el Móvil ff0000 airtelnet.es:Vodafone:vodafone:vodafone gprs.pepephone.es:Pepephone:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
56 21403:: Orange ES Orange Internet Everywhere ff6600 internet:Orange:CLIENTE:AMENA internetmas:Másmovil:user:pass gprs-service.com:Simyo:user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
57 21404:: YOIGO ES Yoigo internet móvil ff00ff ffffff Internet::user:pass http://www.prepaidgsm.net/loghi/logo_yoigo.gif
58 21406:: Vodafone ES Vodafone Internet en el Móvil ff0000 airtelnet.es:Vodafone:vodafone:vodafone gprs.pepephone.es:Pepephone:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
59 21407:: Movistar ES Movistar internet móvil 0000ff ffffff movistar.es:Movistar:movistar:movistar Internet:Yoigo:user:pass http://www.movistar.es/flot/terminales_multiidioma/img/logo_movistar_term_multiidioma.jpg
60 21408:: Euskaltel ES Euskaltel internet móvil ff6600 internet.euskaltel.mobi::CLIENTE:EUSKALTEL http://www.euskaltel.com/webektest/Galeria/Imagenes/homes/empresa/tximeleta_gris.jpg
61 21409:: Orange ES Orange Internet Everywhere ff6600 internet:Orange:CLIENTE:AMENA internetmas:Másmovil:user:pass gprs-service.com:Simyo:user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
62 21416:: Telecable ES Telecable internet móvil 0000ff ffffff internet.telecable.es::telecable:telecable http://web.telecable.es/pages/img/es/portal/logoEmpresa.gif
63 21417:: R móbil ES mundo R internet móvil 000000 ffffff internet.mundo-r.com::user:pass http://particulares.mundo-r.com/WCR/imx/r.gif
64 21418:: Ono ES Ono Banda Ancha Movil 000000 ffffff internet.ono.com::user:pass http://www.ono.es/img/ono_logo.png
65 21419:: Simyo ES Simyo internet móvil ff6600 ffffff gprs-service.com::user:pass http://www.simyo.es/documentos/logos_prensa/simyo_logo_small.jpg
66
67 # Hungary
68 21601:: pannon HU pannon internet 0099ff netx:átalánydíjas:user:pass net:Normál:user:pass snet:Tömörített:user:pass http://www.pannon.hu/i/site_logo.jpg
69 21630:: T-Mobile HU T-Mobile Mobilinternet ff00ff internet:Internet:user:pass mms-westel:MMS:mms:pass http://www.t-mobile.at/Tico.ico
70 21670:: Vodafone HU Vodafone Internet ff0000 standardnet.vodafone.net:Előf._Normál:vodawap:vodawap internet.vodafone.net:Előf._töm.:vodawap:vodawap vitamax.snet.vodafone.net:Felt._norm.:user:pass vitamax.internet.vodafone.net:Felt._töm.:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
71
72 # Bosnia & Herzegovina
73 21890:: BH Mobile BH mobilni internet ff6600 mms.bhmobile.ba::user:pass http://www.prepaidgsm.net/loghi/logo_bhtelecom.gif
74
75 # Serbia
76 22001:: RS Telenor Telenor Internet 0099ff internet::telenor:gprs http://www.telenor.co.yu/images/logo.gif
77 22003:: mts RS mts Surf ff0000 gprsinternet::mts:064 http://www.prepaidgsm.net/loghi/logo_telekomsrbija.gif
78 22005:: RS VIP VIP Internet b4516b vipmobile::vipmobile:vipmobile http://www.vipmobile.rs/images/basic/logo_trim.png
79
80 # Italy
81 22201:: I TIM TIM Internet 0000ff ibox.tim.it:ibox:user:pass wap.tim.it:WAP:WAPTIM:pass http://www.tim.it/showimg/55933.gif
82 22210:: Vodafone IT Vodafone Internet ff0000 web.omnitel.it::user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
83 22288:: I WIND Wind Internet Mobile ff6600 internet.wind:Internet:Wind:Wind internet.wind.biz:Business_Internet:Wind:Wind http://www.wind.com.gr/wind_amea/images/logo_1.gif
84 22299:: 3 ITA Tre Internet Mobile 00ffff ffffff tre.it:Tre(Ricaricabile):user:pass datacard.tre.it:Tre(Abbonamento):user:pass apn.fastweb.it:Fastweb(Voce/dati):user:pass datacard.fastweb.it:Fastweb(Solo_dati):user:pass http://www.tre.it/imgs/logo.jpg
85
86 # Romania
87 22601:: Vodafone RO Vodafone Internet ff0000 internet.vodafone.ro::internet.vodafone.ro:vodafone http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
88 22603:: COSMOTE RO Cosmote Connect 8DC919 internet::user:pass http://www.cosmote.gr/cosmote/resources/images/sm_logo_on_green.gif
89 22610:: Orange RO Orange Internet ff6600 internet::user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
90
91 # Switzerland
92 22801:: SWISS GSM Swisscom mobile internet 000049 ffffff gprs.swisscom.ch::gprs:gprs http://de.swisscom.ch/img/logo_swisscom.gif
93 22802:: Sunrise CH Sunrise Internet 72123d internet::internet:internet http://www1.sunrise.ch/is-bin/intershop.static/WFS/Sunrise-Residential-Site/-/de_CH/images/branding.gif
94 22803:: Orange CH Orange Internet Everywhere ff6600 mobileoffice3g::user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
95
96 # Czech Republic
97 23001:: T-Mobile CZ T-Mobile Internet ff00ff internet.t-mobile.cz:T-Mobile_Internet:user:pass internet.click.cz:Paegas_Internet:user:pass profil.click.cz:Paegas_Profil:user:pass http://www.t-mobile.at/Tico.ico
98 23002:: O2 CZ O2 Internet 177db9 gointernet:Go:user:pass internet:Contract:user:pass internet.open:Open_Contract:user:pass http://www.o2online.de/nw/assets/header/header-small-o2-logo-bild.gif
99 23003:: Vodafone CZ Vodafone Internet ff0000 internet:Postpaid:wap:wap ointernet:Prepaid:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
100
101 # Slovakia
102 23101:: Orange SK Orange mobilný internet ff6600 internet::user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
103 23102:: T-Mobile SK T-Mobile mobilný internet ff00ff internet::user:pass http://www.t-mobile.at/Tico.ico
104 23104:: T-Mobile SK T-Mobile mobilný internet ff00ff internet::user:pass http://www.t-mobile.at/Tico.ico
105
106 # Austria
107 23201:: Mobilkom/A1 A1 Breitband ff6600 a1.net::[email protected]:ppp http://www.a1.net/final/de/Images/Layout/a1_logo.png
108 23203:: T-Mobile AT T-Mobile SURF ff00ff gprsinternet:GPRS_Internet:t-mobile:tm web:Former_tele.ring:[email protected]:web http://www.t-mobile.at/Tico.ico
109 23205:: Orange AT Orange Mobiles Internet ff6600 web.one.at:Orange:web:web web.yesss.at:Yesss!:user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
110 23207:: T-Mobile AT T-Mobile SURF ff00ff gprsinternet:GPRS_Internet:t-mobile:tm web:Former_tele.ring:[email protected]:web http://www.t-mobile.at/Tico.ico
111 23210:: Drei AT Drei 3Data ff6600 ffffff drei.at::user:pass http://www.drei.at/portal/media/960/images_1/logo_drei_1.png
112
113 # United Kingdom
114 23402:: O2 UK O2 Mobile broadband 1f3365 m-bb.o2.co.uk:Mobile_Broadband:o2web:password mobile.o2.co.uk:Contract:o2web:password mobile.o2.co.uk:Contract_faster:faster:password payandgo.o2.co.uk:Prepaid:payandgo:payandgo http://www.o2.co.uk/favicon.ico
115 23410:: O2 UK O2 Mobile broadband 1f3365 m-bb.o2.co.uk:Mobile_Broadband:o2web:password mobile.o2.co.uk:Contract:o2web:password mobile.o2.co.uk:Contract_faster:faster:password payandgo.o2.co.uk:Prepaid:payandgo:payandgo http://www.o2.co.uk/favicon.ico
116 23411:: O2 UK O2 Mobile broadband 1f3365 m-bb.o2.co.uk:Mobile_Broadband:o2web:password mobile.o2.co.uk:Contract:o2web:password mobile.o2.co.uk:Contract_faster:faster:password payandgo.o2.co.uk:Prepaid:payandgo:payandgo http://www.o2.co.uk/favicon.ico
117 23415:: Vodafone UK Vodafone Mobile broadband ff0000 internet:Contract:web:web pp.vodafone.co.uk:Prepaid:wap:wap pp.internet:Old_PAYG:user:pass ppbundle.internet:New_PAYG:web:web http://online.vodafone.co.uk/en_GB/assets/static/logo.gif
118 23420:: 3 UK 3 Mobile broadband 000000 ffffff 3internet:Mobile_Internet:user:pass three.co.uk:Mobile_Device:user:pass http://www.three.co.uk/static/images/sitewide/favicon.ico
119 23430:: T-Mobile UK T-Mobile mobile internet ff00ff internet:Mobile_Internet:user:pass http://www.t-mobile.at/Tico.ico
120 23430:VIRGIN: Virgin Virgin Mobile broadband ff0000 vdata:Virgin:user:pass http://www.virginmobile.com/vm/media/images/virginmobilelogo.gif
121 23431:: Virgin Virgin Mobile broadband ff0000 vdata:Virgin:user:pass http://www.virginmobile.com/vm/media/images/virginmobilelogo.gif
122 23432:: Virgin Virgin Mobile broadband ff0000 vdata:Virgin:user:pass http://www.virginmobile.com/vm/media/images/virginmobilelogo.gif
123 23433:: Orange UK Orange Mobile broadband ff00ff orangeinternet:Contract:orange:orange orangewap:Pay_and_Go:orange:multimedia http://www.orange.co.uk/img/homerefresh/logo.gif
124 23434:: Orange UK Orange Mobile broadband ff00ff orangeinternet:Contract:orange:orange orangewap:Pay_and_Go:orange:multimedia http://www.orange.co.uk/img/homerefresh/logo.gif
125
126 # Denmark
127 23801:: TDC TDC Mobilt Bredbånd 006cb8 internet:Internet:user:pass http://i.c.dk/gfx/grd/common/logo/tdc_logo_48x41.png
128 23802:: Telenor DK Telenor mobilt bredbånd 161616 *99***1# internet:Telenor_Internet:user:pass internet.bibob.dk:BiBoB_Internet:user:pass http://www.telenor.dk/Images/logo_tcm69-79084.png
129 23802:BIBOB: BiBoB BiBoB Mobilt Bredbånd 457a91 internet.bibob.dk:Internet:user:pass http://www.bibob.dk/data/archive/favicon.ico
130 23806:: 3 DK 3 mobilt bredbånd 000000 ffffff bredband.tre.dk:3_Bredbånd:user:pass net.tre.dk:3_Bredbånd_Premium_Kontant:user:pass data.tre.dk:3_Mobil_Abonnement:user:pass bredband.oister.dk:OiSTER_Bredbånd:user:pass http://www.three.co.uk/static/images/sitewide/favicon.ico
131 23806:OISTER: OISTER OiSTER mobilt bredbånd 705ea6 bredband.oister.dk:Bredbånd:user:pass http://www.oister.dk/wp-content/themes/oister/images/oister-logo-new.png
132 23820:: Telia DK Telia mobilt bredbånd b5006d ffffff www.internet.mtelia.dk:Internet:user:pass http://static.telia.dk/09_facelift/gfx/head/logo_telia_head_fadebg_mirror.png
133 23830:: Telia DK Telia mobilt bredbånd b5006d ffffff www.internet.mtelia.dk:Internet:user:pass http://static.telia.dk/09_facelift/gfx/head/logo_telia_head_fadebg_mirror.png
134
135 # Sweden
136 24001:: Telia SE Telia Mobilt Bredband cf0566 online.telia.se:Telia:user:pass halebop.telia.se:Halebop:user:pass http://www.telia.se/img/header/telia_logo.gif
137 24002:: 3 SE 3Bredband ff6600 ffffff data.tre.se:Mobil:user:pass bredband.tre.se:Bredband:user:pass net.tre.se:Bredband_Kontantkort:user:pass http://www.drei.at/portal/media/960/images_1/logo_drei_1.png
138 24004:: Sweden 3G Sweden 3G internet internet.telenor.se:Telenor_Mobilt_Bredband:user:pass services.telenor.se:Telenor_Mobilsurf_med_maxtaxa:user:pass data.tre.se:3Mobil:user:pass bredband.tre.se:3Bredband:user:pass net.tre.se:3Bredband_Kontantkort:user:pass internet.se:TDC:user:pass mobileinternet.tele2.se:Tele2:user:pass online.telia.se:Telia:user:pass halebop.telia.se:Halebop:user:pass
139 24005:: Sweden 3G Sweden 3G internet 000000 ffffff internet.se:TDC:user:pass mobileinternet.tele2.se:Tele2:user:pass online.telia.se:Telia:user:pass halebop.telia.se:Halebop:user:pass
140 24006:: Telenor SE Telenor Mobilt Bredband 161616 internet.telenor.se:Telenor_Mobilt_Bredband:user:pass services.telenor.se:Telenor_Mobilsurf_med_maxtaxa:user:pass data.tre.se:3Mobil:user:pass bredband.tre.se:3Bredband:user:pass net.tre.se:3Bredband_Kontantkort:user:pass http://www.telenor.no/Images/logo_tcm38-4340.png
141 24007:: Tele2 SE Tele2 Mobilt Internet 000000 ffffff mobileinternet.tele2.se:Tele2:user:pass internet.se:TDC:user:pass http://www.tele2.lv/images/e220_modems_tele2_logo.png
142 24008:: Telenor SE Telenor Mobilt Bredband 161616 internet.telenor.se:Telenor_Mobilt_Bredband:user:pass services.telenor.se:Telenor_Mobilsurf_med_maxtaxa:user:pass data.tre.se:3Mobil:user:pass bredband.tre.se:3Bredband:user:pass net.tre.se:3Bredband_Kontantkort:user:pass http://www.telenor.no/Images/logo_tcm38-4340.png
143
144 # Norway
145 24201:: N Telenor Telenor Mobilt Bredbånd 161616 internet::user:pass http://www.telenor.no/Images/logo_tcm38-4340.png
146 24202:: N COM NetCom Mobilt Bredbånd ff6600 ffffff internet.netcom.no:NetCom:netcom:netcom internet:Lebara:user:pass internet:OneCall:user:pass http://mmslss.netcom.no/mms.mnc002.mcc242.gprs/no/webnonsubscriber/img/NetCom-logo3.gif
147 24204:: Network NO NetworkNorway ff0000 ffffff internet::user:pass http://www.networknorway.no/getfile.php/Bilder/Logo/nwn_logo.png
148 24205:: Network NO NetworkNorway ff0000 ffffff internet::user:pass http://www.networknorway.no/getfile.php/Bilder/Logo/nwn_logo.png
149
150 # Finland
151 24403:: DNA FI DNA Internet e20070 internet::user:pass http://www.dna.fi/Style 0brary/Images/Dna/dna_logo.gif
152 24405:: Elisa FI Elisa Internet 0e8ad4 internet:Elisa:user:pass internet.saunalahti:Saunalahti:user:pass http://www.elisa.fi/etusivu/assets/img/global-logo-trans.png
153 24421:: Saunalahti FI Saunalahti Internet f25822 internet.saunalahti:Saunalahti:user:pass http://img.saunalahti.fi/pic_gen/logo_saastoa_joka_minuutti.png
154 24491:: Sonera FI Sonera Internet ff0000 ffffff internet:Internet:user:pass prointernet:Prointernet:user:pass http://www.sonera.fi/images/sonera.gif
155
156 # Lithuania
157 24601:: OMNITEL LT Omnitel Omniconnect 0000ff 8dc919 internet:Omniconnect:user:omni http://www.omnitel.lt/media/images/hdr/logo_lt.gif
158
159 # Latvia
160 24701:: LMT LMT Internets telefonā a90031 ffffff internet.lmt.lv::user:pass http://www.lmt.lv/images/design/lmt-logo.png
161 24702:: TELE2 TELE2 Internets telefonā 000000 ffffff internet.tele2.lv::gprs:internet http://www.tele2.lv/images/e220_modems_tele2_logo.png
162
163 # Russia
164 25001:: MTS RU MTS Интернет ff0000 internet.mts.ru::mts:mts http://www.mts.ru/upload/images/design/i/logo.gif
165 25002:: Megafon RU Мегафон Интернет 00ff00 internet.nw:NW_Северо-Запад:user:pass internet.ugsm:UGSM_Урал:user:pass internet.usi.ru:usi:user:pass internet.dv:DV_Дальний_Восток:user:pass internet.kvk:kvk_Кавказ:user:pass internet.ltmsk:ltmsk:user:pass internet.sib:sib_Сибирь:user:pass internet.volga:volga_Поволжье:user:pass internet.mc:mc_Центр:user:pass internet:Moscow_Москва:gdata:gdata http://www.prepaidgsm.net/loghi/logo_megafon.gif
166 25003:: NCC RU NCC Интернет b10042 internet::ncc:pass http://ncc-volga.ru/bitrix/templates/ncc/img/logo.gif
167 25005:: ETK RU Енисей Телеком Интернет 0066ae internet.etk.ru:Internet:etk:pass wap.etk.ru:Wap:user:pass http://www.etk.ru/pictures/etc_pictures/logo.gif
168 25012:: BWC RU БайкалВестКом Интернет 0075ab ffffff inet.bwc.ru::bwc:bwc http://www.bwc.ru/f/1/gsm/bwc_vsegda.jpg
169 25016:: NTC RU NTC Интернет 194493 ffffff internet.ntc::user:pass http://www.vntc.ru/images/skin/logo.png
170 25020:: Tele2 RU Теле2 Интернет 00a4ee ffffff wap.tele2.ru::gprs:pass http://novgorod.tele2.ru/system_images/logo_t2.gif
171 25028:: Beeline RU Билайн Интернет 000000 ffffff internet.beeline.ru::beeline:beeline http://www.beeline.ru/media/design/beeline_logo_bs.gif
172 25035:: Motiv RU Мотив Интернет ff6600 inet.ycc.ru::motiv:pass http://www.ycc.ru/i/ami/logo.gif
173 25039:: U-tel RU U-tel Интернет d11228 internet.usi.ru::user:pass http://www.u-tel.ru/images/logo.gif
174 25099:: Beeline RU Билайн Интернет 000000 ffffff internet.beeline.ru::beeline:beeline http://www.beeline.ru/media/design/beeline_logo_bs.gif
175
176 # Ukraine
177 25501:: MTC UA MTC Мобільний GPRS-Інтернет ff0000 internet:Internet:internet:pass www.umc.ua:umc:user:pass www.jeans.ua:Jeans:user:pass hyper.net:Hyper:user:pass http://www.mts.com.ua/img/tmpl/logo_ukr.gif
178 25502:: Beeline UA Beeline Мобільний інтернет 000000 ffffff internet.beeline.ua::user:pass http://www.beeline.ua/media/design/ua/beeline_logo.gif
179 25503:: UA Kyivstar Kyivstar Интернет 3G 0295df www.ab.kyivstar.net:Ace&Base:igprs:internet www.djuice.com.ua:Djuice:user:pass http://www.prepaidgsm.net/loghi/logo_kyivstar.gif
180 25506:: Life UA life;) Інтернет ff0000 internet:Standard:user:pass speed:Faster:user:pass http://www.life.com.ua/i/newh/logo.uk.png
181 25507:: Utel UA Utel Інтернет ff0000 3g.utel.ua::user:pass http://utel.ua/img/index/big_logo100.jpg
182
183 # Belarus
184 25701:: VELCOM BY Услуги Мобильный Интернет 000000 fff200 wap.velcom.by:GPRS_WAP:wap:wap web.velcom.by:GPRS_WEB:web:web plus.velcom.by:GPRS_WEB_PLUS:plus:plus privet.velcom.by:GPRS_PRIVET:privet:privet web1.velcom.by:WEB_BASIC:web1:web1 web2.velcom.by:WEB_25:web2:web2 web3.velcom.by:WEB_150:web3:web3 vmi.velcom.by:WEB_500:vmi:vmi http://www.velcom.by/im/logo.gif
185 25702:: MTS BY MTC Интернет + ff0000 internet.mts.by::mts:mts http://www.mts.by/f/i/logo.gif
186 25703:: BY Life 3G life ff0000 internet.life.com.by::user:pass http://www.life.com.ua/i/newh/logo.uk.png
187
188 # Moldova
189 25901:: Orange MD Orange Internet Acum ff6600 internet::user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
190 25902:: MD MOLDCELL Moldcell Internet mobil ff6600 internet::gprs:gprs http://www.prepaidgsm.net/loghi/logo_moldcell.gif
191 25904:: MD Eventis Eventis Internet mobil 92cf2a 339edb internet.md::user:pass http://eventis.md/ro/wp-content/uploads/2010/02/0984bc8e-a2de-4054-ae59-a8ee6c5ebbda.jpg
192
193 # Poland
194 26001:: Plus GSM iPlus Mobilny Internet 68af23 www.plusgsm.pl::user:pass http://www.plus.pl/images/nowe_menu_top/plus_logo.gif
195 26002:: ERA PL Era Internet Blueconnect 0097ea erainternet:ERA:erainternet:erainternet heyah.pl:Heyah:heyah:heyah http://www.era.pl/repositories/era_pl_repo1/logo/era_logo.gif
196 26003:: Orange PL Orange Mobilny Internet ff6600 internet::internet:internet http://www.orange.at/Content.Node/images/orange-logo.gif
197 26006:: Play Mobile Play Internet 7e098f Internet::user:pass http://www.playmobile.pl/pl/_img/_top/logo.png
198
199 # Germany
200 26201:: T-Mobile D1 T-Mobile Internet ff00ff internet.t-d1.de::user:t-d1 http://www.t-mobile.at/Tico.ico
201 26202:: Vodafone D2 Vodafone Live! ff0000 web.vodafone.de::Vodafone:vodafone:vodafone event.vodafone.de:Vodafone_WebSessions:vodafone:vodafone mail.partner.de:1und1:D2:Web http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
202 26203:: E-Plus E-Plus Internet 36533d ffffff internet.eplus.de:E-Plus:eplus:gprs internet.eplus.de:MedionMobile:eplus:gprs internet.eplus.de:blau.de:eplus:gprs internet.vistream.net:Vistream_reseller:web:vistream http://www.eplus.de/img/logo.png
203 26204:: Vodafone D2 Vodafone Live! ff0000 web.vodafone.de::Vodafone:vodafone:vodafone event.vodafone.de:Vodafone_WebSessions:vodafone:vodafone mail.partner.de:1und1:D2:Web http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
204 26205:: E-Plus E-Plus Internet 36533d ffffff internet.eplus.de:E-Plus:eplus:gprs internet.eplus.de:MedionMobile:eplus:gprs internet.eplus.de:blau.de:eplus:gprs internet.vistream.net:Vistream_reseller:web:vistream http://www.eplus.de/img/logo.png
205 26206:: T-Mobile D1 T-Mobile Internet ff00ff internet.t-d1.de::user:t-d1 http://www.t-mobile.at/Tico.ico
206 26207:: O2 DE O2 Mobiles Internet 177db9 internet:O2_Pay_by_MB:user:pass surfo2:O2_Pay_by_time:user:pass pinternet.interkom.de:FONIC:user:pass http://www.o2online.de/nw/assets/header/header-small-o2-logo-bild.gif
207 26208:: O2 DE O2 Mobiles Internet 177db9 internet:O2_Pay_by_MB:user:pass surfo2:O2_Pay_by_time:user:pass pinternet.interkom.de:FONIC:user:pass http://www.o2online.de/nw/assets/header/header-small-o2-logo-bild.gif
208 26209:: Vodafone D2 Vodafone Live! ff0000 web.vodafone.de:Vodafone::vodafone:vodafone event.vodafone.de:Vodafone_WebSessions:vodafone:vodafone mail.partner.de:1und1:D2:Web http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
209 26211:: O2 DE O2 Mobiles Internet 177db9 internet:O2_Pay_by_MB:user:pass surfo2:O2_Pay_by_time:user:pass pinternet.interkom.de:FONIC:user:pass http://www.o2online.de/nw/assets/header/header-small-o2-logo-bild.gif
210 26216:: Vistream Network Vistream Internet internet.vistream.net:Vistream:user:pass http://www.o2online.de/nw/assets/header/header-small-o2-logo-bild.gif
211 26277:: E-Plus E-Plus Internet 36533d ffffff internet.eplus.de:E-Plus:eplus:gprs internet.eplus.de:MedionMobile:eplus:gprs internet.eplus.de:blau.de:eplus:gprs internet.vistream.net:Vistream_reseller:web:vistream http://www.eplus.de/img/logo.png
212
213 # Luxembourg
214 27001:: LUXGSM LUXGSM Internet Mobile 8cb0ea webp.pt.lu::user:pass http://www.luxgsm.lu/assets/templates/luxgsm/images/general/logo_luxgsm.gif
215 27077:: L Tango Tango Mobile ADSL e8f2fe 2272b9 internet::tango:tango http://www.tango.lu/style/site/interface/public/tango/logohead.jpg
216 27099:: Orange LU Orange Internet Mobile ff6600 vox.lu::user:pass http://www.orange.at/Content.Node/images/orange-logo.gif
217
218 # Albania
219 27602:: VODAFONE AL VODAFONE Internet ff0000 Twa::user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
220
221 # Malta
222 27801:: VODAFONE MT VODAFONE Internet ff0000 Internet::Internet:Internet http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
223 27821:: GO Mobile GO Internet On The Move ff6600 ffffff gosurfing:Postpaid:user:pass rtgsurfing:Prepaid:user:pass http://www.go.com.mt/Files/Filer/AboutUs/Photos_Images/GO-Logo_250px.jpg
224
225 # Cyprus
226 28001:: Cytamobile Vodafone CY VODAFONE Mobile Internet ff0000 internet::user:pass http://www.cytamobile-vodafone.com/miPortal/cmImages/header1/dual-logo.jpg
227 28010:: MTN CY MTN 3G Internet 000000 ff6600 internet::wap:wap http://www.prepaidgsm.net/loghi/logo_mtn.gif
228
229 # Portugal
230 28601:: VODAFONE PT VODAFONE Internet ff0000 internet.vodafone.pt::user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
231 28603:: P Optimus Optimus Kanguru Internet ff6600 ffffff internet:Optimus:user:pass kangurufixo:Fixo:user:pass myconnection:Kanguru:user:pass http://www.optimus.pt/img/CDP/phone.png
232 28606:: P TMN TMN internetnotelemovel 1299aa internet::user:pass http://www.tmn.pt/tmnassets/layout/images/logos/logo_tmn.gif
233 26801:: VODAFONE PT VODAFONE Internet ff0000 internet.vodafone.pt:Vodafone_Internet:user:pass internet.zon.pt:ZON_Mobile:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
234 26801:VODAFONE PT: VODAFONE PT VODAFONE Internet ff0000 internet.vodafone.pt:Vodafone_Internet:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
235 26801:ZON: ZON PT ZON Mobile 000000 ffffff internet.zon.pt:Zon_Mobile:user:pass http://www.zon.pt/downloadsmobile/Screensaver/MOBILE_128x160.gif
236 26803:: P Optimus Optimus Kanguru Internet ff6600 ffffff internet:Optimus:user:pass kangurufixo:Fixo:user:pass myconnection:Kanguru:user:pass clixinternetmovel:Clix:user:pass http://www.optimus.pt/img/CDP/phone.png
237 26806:: P TMN TMN internetnotelemovel 1299aa internet::user:pass http://www.tmn.pt/tmnassets/layout/images/logos/logo_tmn.gif
238
239 # Slovenia
240 29340:: SI MOBITEL Mobitel Internet cb040d internet:Postpaid:mobitel:internet internetpro::mobitel:internet http://itm.siol.net/_m/pic/logo.png
241 29341:: SI MOBIL Simobil Mobilni Internet 75c247 internet::simobil:internet http://www.prepaidgsm.net/loghi/logo_simobil.gif
242
243 # Montenegro
244 29701:: ProMonte ProMonte Mobilni Internet 000000 ffffff gprs.promonte.com::user:pass http://www.promonte.com/Images/banneri/part-of-telenor-group.gif
245 29702:: T-Mobile CG T-Mobile Mobilni Internet ff00ff internet-postpaid::user:pass http://www.t-mobile.at/Tico.ico
246 29703:: m:tel CG m:tel Mobilni Internet ff0000 gprsinternet::user:pass http://www.mtel-cg.com/haloton/images/new/logo.gif
247
248 # Mexico
249 33402:: TELCEL Internet Telcel 3c78c3 internet.itelcel.com::webgprs:webgprs2002 http://www.telcel.com/portal/framework/skins/telcel/images/logo.gif
250 33403:: Movistar MX Internet Movistar 0000ff a9d03f internet.movistar.mx::movistar:movistar http://www.movistar.es/flot/terminales_multiidioma/img/logo_movistar_term_multiidioma.jpg
251
252 # French Guyana, Martinique and Guadeloupe
253 34001:: Orange Internet Everywhere 3G ff6600 orangeweb:Internet_3G:orange:orange http://i5.woopic.com/I/Header/orange.gif
254
255 # Australia
256 50501:: Telstra AU Telstra Wireless Broadband 068fc5 telstra.wap:Wap:user:pass telstra.datapack:3G_data_pack:user:Telstra telstra.internet:Next_G:user:pass telstra.pcpack:3G_PC_pack_pay-by-time:user:Telstra http://www.telstra.com.au/global/themes/v9/images/telstra_logo.gif
257 50502:: Optus AU Optus Internet On Mobile 00708f ffd006 internet:Optus_Internet:user:pass CONNECT:Optus_3G:user:pass VirginInternet:Virgin_Internet:guest:guest http://www.optus.com.au/home/images/logo-yes-optus.gif
258 50503:: Vodafone AU Vodafone Mobile Internet ff0000 vfinternet.au:Postpaid:user:pass vfprepaymbb:Prepaid:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
259 50506:: 3 AUS 3 Mobile Internet 0e9938 3netaccess:Internet:a:a 3services:Prepaid:a:a http://www.three.com.au/cs/Three/images/logo.png
260
261 # Indonesia
262 51001:: IndosatM2 IndosatM2 Broom 0000ff ffffff indosatm2:IndosatM2_Internet:: http://www.indosatm2.com/files/images/common/logo-im2-default.gif
263 51089:: 3 3 Internet 000000 ffffff 3data:3_Internet:3data:3data http://www.three.co.id/ShowDoc/BEA+Repository/data/theme/web/images/logo01.gif
264
265 # Thailand
266 52015:: ToT Mobile ToT 3G 2584c8 ffffff internet:Internet:user:pass http://www.tot.co.th/templates/tot_detail02/images/tot.jpg
267
268 # New Zealand
269 53000:: Telecom NZ Telecom XT mobile 3fc1ed wap.telecom.co.nz:WAP:user:pass internet.telecom.co.nz:Internet_with_Firewall:user:pass direct.telecom.co.nz:Internet_without_Firewall:user:pass oa.telecom.co.nz:Office:user:pass http://www.telecom.co.nz/images/5/logo2.gif
270 53001:: Vodafone NZ Vodafone Internet ff0000 live.vodafone.com:WAP:user:pass www.vodafone.net.nz:Restricted:user:pass internet:Public:user:pass http://www.vodafone.pt/vodafone/gui09/img/menu/logo.gif
271 53005:: Telecom NZ Telecom XT mobile 3fc1ed wap.telecom.co.nz:WAP:user:pass internet.telecom.co.nz:Internet_with_Firewall:user:pass direct.telecom.co.nz:Internet_without_Firewall:user:pass oa.telecom.co.nz:Office:user:pass http://www.telecom.co.nz/images/5/logo2.gif
272
273 # Morocco
274 60400:: Meditel Meditel Internet Mobile+ ff0000 wap.meditel.ma::MEDIWAP:MEDIWAP http://www.meditel.ma/img_refonte/backgrounds/v2_logo.jpg
275 60401:: MOR IAM IAM Internet 3G+ ff0000 iam::wac:1987 http://www.iam.ma/Particuliers/Publishingimages/logoA_MT.gif
276
277 # South Africa
278 65501:: Voda Vodacom Broadband fafff9 0573b0 internet:Internet:user:pass unrestricted:Unrestricted:user:pass http://www.vodacom.co.za/ci/downloads/pb_cs_logo.gif
279 65507:: Cell C Cell C mobile internet ff0000 internet:Cellcis:user:pass vdata:Virgin_Mobile:user:pass http://www.cellc.co.za/images/new/page_headings/logo_white.gif
280 65510:: MTN SA MTN broadband 000000 ffb500 internet::user:pass http://www.prepaidgsm.net/loghi//logo_mtn.gif
281
282 # Guatemala
283 70401:: Claro GT Turbonett Móvil Claro ff0000 internet.ideasclaro http://www.claro.com.gt/images/LogoClaro.jpg
284 70402:: Tigo GT Internet Móvil Tigo 245597 Wap.tigo.gt:Wap:Wap:Wap broadband.tigo.gt:Broadband:guest:guest http://www.tigo.com.gt/resources/images/generales/logo.png
285
286 # Honduras
287 70802:: Tigo HN Internet Móvil Tigo 245597 internet.tigo.hn::user:pass broadband.tigo.hd::guest:guest http://www.tigo.com.hn/resources/images/generales/logo.png
288
289 # Peru
290 71606:: Movistar PE Speedy Móvil Movistar 0000ff a9d03f movistar.pe::movistar@datos:movistar http://www.movistar.es/flot/terminales_multiidioma/img/logo_movistar_term_multiidioma.jpg
291 71610:: Claro PE Internet Claro ff0000 tim.pe::tim:tulibertad http://www.claro.com.gt/images/LogoClaro.jpg
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 # Sakis3G USB device database
1 # Distributed under GNU GPL v2
2 #
3 # Empty lines and lines starting with "#" are ignored
4 #
5 # Format is:
6 # <Vendor ID>:<Product ID>:<tab>
7 # Driver #1<space>Driver #2<space>...<space>Driver #n<tab>
8 # Interface<EOL>
9
10 # Sony Ericsson MD400
11 0fce:d0e1: cdc_acm 1
12
13 # ZTE MF636
14 19d2:0031: option
15
16 # General ZTE rule
17 19d2:: option
18
0 .TH "SAKIS3G" "1"
1 .SH "NAME"
2 sakis3g - Manages 3G modems and connections
3
4 .SH "SYNOPSIS"
5 .PP
6 \fBsakis3g\fP [ \fIactors\fP ] [ \fIswitches\fP ] [ \fIvariables\fP ]
7
8 \fBsakis3g disassemble\fP \fIdestination\fP
9 \fBsakis3g getfile\fP \fIfile\fP
10 \fBsakis3g ls\fP
11
12 \fBsakis3g usb_modeswitch\fP [ \fIarguments\fP ]
13
14 \fBsakis3g man\fP [ \fIsakis3g\fP | \fIsakis3g.conf\fP | \fIusb_modeswitch\fP ]
15 \fBsakis3g version\fP
16 \fBsakis3g help\fP
17
18 .SH "DESCRIPTION"
19 .PP
20 Sakis3G is a \fIshell script\fP which is supposed to work out-of-the-box
21 for establishing a 3G connection with any combination of modem or
22 \fIoperator\fP. If you are lucky enough, you may be connected 30 seconds
23 after downloading script.
24 .PP
25 Sakis3G script is built around some fundamental requirements:
26 .PP
27 .IP "\fB1.\fR" 3
28 As less as possible disk size requirements.
29 .IP "\fB2.\fR" 3
30 As few as possible third-party dependencies: Nothing more than you should need if manually setting up.
31 .IP "\fB3.\fR" 3
32 As fast as possible installation procedure: There is no installation, download and make it executable.
33 .IP "\fB4.\fR" 3
34 As clean as possible operation: No files are installed/modified on your disk.
35 .IP "\fB5.\fR" 3
36 No configuration is required: No need for configuring \fIwvdial\fP, \fIpppd\fP, \fIudev\fP, \fIhal\fP or \fIusb_modeswitch\fP.
37 .IP "\fB6.\fR" 3
38 As good as possible user experience: "sakis3g connect" or "sakis3g disconnect", or no arguments at all for a simple UI to appear.
39 .PP
40 This script comes to fill in the gap of no/partial support to some
41 distributions for using \fIUSB modems\fP, or to work around the "clumsy
42 way" others do. While major distributions will gradually find their
43 way into reliably, and in a unified way, support these devices, this
44 script will end-up as a lightweight replacement to
45 NetworkManager/ModemManager bundle, or to gnome-ppp/wvdial bundle,
46 or to kppp for small footprint distributions.
47
48 .SH "INVOCATION METHODS"
49 .PP
50 .IP "[ \fIactors\fP ] [ \fIswitches\fP ] [ \fIvariables\fP ]" 10
51 Using this syntax, you can define:
52 .IP " \fB*\fP" 13
53 Actions for Sakis3G script to follow, by defining action's corresponding \fBactor\fP.
54 .IP " \fB*\fP" 13
55 Alter \fBactors'\fP behaviour, by setting \fBswitches\fP.
56 .IP " \fB*\fP" 13
57 Provide values to \fBactors\fP, by using \fBvariables\fP.
58 .IP "" 10
59 You should consult \fBsakis3g.conf\fP(5) for information on \fBswitches\fP and \fBvariables\fP available. For a list of available \fBactors\fP see below.
60 .IP "\fBdisassemble\fP \fIdestination\fP" 10
61 Extracts Sakis3G \fIembedded package\fP within \fIdestination\fP directory and exits.
62 .IP "\fBgetfile\fP \fIfile\fP" 10
63 Extracts \fIfile\fP from Sakis3G \fIembedded package\fP and displays it on \fIstandard output\fP.
64 .IP " \fB*\fP" 13
65 \fIRelative path\fP of file is also supported if \fIfile\fP is able to uniquely identify file within package.
66 .IP " \fB*\fP" 13
67 \fIWildcard characters\fP are \fBnot\fP supported.
68 .IP " \fB*\fP" 13
69 \fIFile\fP should exist within Sakis3G \fIembedded package\fP.
70 .IP "\fBls\fP" 10
71 Displays contents of Sakis3G \fIembedded package\fP and exits. No further \fIarguments\fP exist, allowing output to be filtered.
72 .IP "\fBusb_modeswitch\fP [ \fIarguments\fP ]" 10
73 Provides direct access to the \fIembedded\fP \fBUsb-ModeSwitch\fP binary. Any subsequent \fIcommand line arguments\fP are passed to \fBUsb-ModeSwitch\fP. Consult \fBusb_modeswitch\fP(1) for a detailed list of acceptable \fIarguments\fP.
74 .IP "\fBman\fP [ \fIsakis3g\fP | \fIsakis3g.conf\fP | \fIusb_modeswitch\fP ]" 10
75 Displays one of:
76 .IP " \fB*\fP" 13
77 \fBsakis3g\fP(1)
78 .IP " \fB*\fP" 13
79 \fBsakis3g.conf\fP(5)
80 .IP " \fB*\fP" 13
81 \fBusb_modeswitch\fP(1)
82 .IP "" 10
83 If no argument is specified, \fBsakis3g\fP(1) is displayed.
84 .IP "\fBversion\fP, \fB--version\fP" 10
85 Displays Sakis3G script's version and exits.
86 .IP "\fBhelp\fP, \fB--help\fP" 10
87 Displays a minimal help page and exists.
88
89 .SH "ACTORS"
90 .PP
91 Each \fBactor\fP refers to a specific action Sakis3G script should execute. Many programs provide a similar functionality, allowing to execute a specific action by explicitly defining it through \fIcommand line\fP. When no \fBactor\fP is defined in \fIcommand line\fP, behavior depends upon selected \fIuser interface\fP. As a general rule, when using an \fIinteractive UI\fP, \fBmenu actor\fP is implied leading to \fIMain Menu\fP appearing.
92
93 .SH "CHAINS"
94 .PP
95 Sakis3G script allows defining more than one \fBactors\fP, which altogether form a \fBChain\fP.
96 .IP " \fB*\fP" 3
97 An \fBactor\fP may be referenced twice or more within a chain, leading into being executed an equivalent count of times.
98 .IP " \fB*\fP" 3
99 Whenever an \fBactor\fP is terminated (successfully or not), it sets its \fIresult code\fP accordingly.
100 .IP " \fB*\fP" 3
101 If \fIresult code\fP is not \fI0 (zero)\fP, which denotes success, or if no other \fBactor\fP is specified in \fBchain\fP, then Sakis3G script itself terminates, returning \fIresult code\fP previously set, as \fIexit status\fP.
102 .IP " \fB*\fP" 3
103 If \fIresult code\fP equals to \fI0 (zero)\fP, next \fBactor\fP in \fBchain\fP is executed.
104
105 .SH "COMMON ACTORS"
106 .PP
107 .IP "\fBconnect\fP, \fBstart\fP" 10
108 Attempts to establish a data connection with \fIoperator\fP.
109 .IP "\fBreconnect\fP, \fBrestart\fP" 10
110 Drops current data connection and, using same connection settings, connects again. Useful when data connection seems \fIstalled\fP (it is still up but no traffic occurs).
111 .IP "\fBdisconnect\fP, \fBstop\fP" 10
112 Drops all currently running \fiP-t-P connections\fP.
113 .IP "\fBswitchonly\fP" 10
114 Only \fIswitches\fP a \fIUSB modem\fP.
115 .IP "\fBrecompile\fP" 10
116 Recompiles \fIembedded\fP \fIUsb-ModeSwitch\fP version for your system.
117 .IP "\fBstatus\fP" 10
118 Displays connection status.
119 .IP "\fBinfo\fP" 10
120 Displays information about current connection.
121 .IP "\fBreport\fP" 10
122 Generates a report for providing feedback.
123 .IP "\fBdesktop\fP" 10
124 Creates a shortcut for Sakis3G script on your \fIdesktop\fP.
125 .IP "\fBhelper\fP" 10
126 Enables \fIHelper mode\fP for script to occupy a slot in \fBnotification area\fP.
127
128 .SH "SPECIAL ACTORS"
129 .PP
130 In order to allow more sophisticated \fBchains\fP there are some \fBspecial actors\fP available. \fBSpecial actors\fP never display \fIerrors\fP or \fInotifications\fP, allowing to avoid expected error messages:
131 .PP
132 .IP "\fBconnected\fP" 10
133 Returns \fI0 (zero)\fP if currently connected.
134 .IP "\fBdisconnected\fP" 10
135 Returns \fI0 (zero)\fP if not currently connected.
136 .IP "\fBplugged\fP" 10
137 Returns \fI0 (zero)\fP when a \fIUSB modem\fP is currently plugged.
138 .IP "\fBunplugged\fP" 10
139 Returns \fI0 (zero)\fP when no \fIUSB modem\fP is currently plugged.
140 .IP "\fBswitched\fP" 10
141 Returns \fI0 (zero)\fP when a \fIUSB modem\fP is currently plugged, and no \fIswitchable\fP modem is detected.
142 .IP "\fBswitchable\fP" 10
143 Returns \fI0 (zero)\fP when a \fIswitchable\fP modem is detected.
144 .IP "\fBwait, sleep\fP" 10
145 Waits for one second and then unconditionally returns \fI0 (zero)\fP. Using this \fBactor\fP as the last one, within a \fBchain\fP, is pointless.
146
147 .SH "OPERATOR ACTORS"
148 .PP
149 In order to allow even more sophisticated \fBchains\fP, \fBspecial actors\fP imitating what we usually call \fIunary operators\fP, are also offered:
150 .PP
151 .IP "\fBignore\fP" 10
152 Unconditionally converts \fIresult\fP of next \fBactor\fP to \fI0 (zero)\fP, forcing \fBchain\fP to continue traversing.
153 .IP "\fBnot\fP" 10
154 Reverses \fIresult\fP of next \fBactor\fP.
155 .PP
156 .IP "\fBNote:\fP" 6
157 Keep in mind that while "\fBnot connected\fP" is equal to "\fBdisconnected\fP", you should be cautious when using "\fBnot\fP" operator and avoid making false assumptions. As an example, "\fBnot switched\fP" is not (always) equivalent to "\fBswitchable\fP", and vice versa.
158
159 .SH "ACTION ACTORS"
160 .PP
161 .IP "\fBabout\fP" 10
162 Displays copyright information about Sakis3G script.
163 .IP "\fBclicked\fP" 10
164 When a \fIdesktop shortcut\fP is created, this \fBactor\fP is by default placed as argument. It initiates \fBmenu actor\fP, unless selected \fIUI\fP is \fIinteractive terminal\fP or \fIterminal\fP, in which case it initiates \fBtoggle actor\fP. You can later modify \fIdesktop shortcut\fP, to explicitly call an \fBactor\fP of your taste instead.
165 .IP "\fBconnect\fP, \fBstart\fP" 10
166 Attempts to establish a data connection with your \fIoperator\fP, calling \fBprepare actor\fP if necessary.
167 .IP "\fBdesktop\fP" 10
168 Attempts to create a shortcut for Sakis3G script on calling user's \fIdesktop\fP.
169 .IP "\fBdisconnect\fP, \fBstop\fP" 10
170 Attempts to terminate all currently running \fIP-t-P connections\fP.
171 .IP "\fBhelper\fP" 10
172 Forces Sakis3G script to enter \fBHelper mode\fP. This \fBactor\fP prevents the rest of the \fBchain\fP from ever being executed.
173 .IP "\fBinfo\fP" 10
174 Displays information about currently established connection. Fails if invoked while not connected.
175 .IP "\fBmenu\fP" 10
176 Displays \fIMain Menu\fP of Sakis3G script. Returns:
177 .IP " \fB*\fP" 13
178 \fI0 (zero)\fP if user selected \fICancel\fP , or
179 .IP " \fB*\fP" 13
180 \fI98\fP if user selected \fIExit\fP, thus terminating execution of \fBchain\fP.
181 .IP "\fBmodem\fP, \fBselect\fP" 10
182 Executes \fIdevice selection procedure\fP. Returns \fI0 (zero)\fP if a modem was selected. This \fBactor\fP does not perform any setup operation. Using this \fBactor\fP as the last one, within a \fBchain\fP, is pointless.
183 .IP "\fBmoremenu\fP, \fBmore\fP, \fBmenumore\fP" 10
184 Displays \fIMore actions\fP menu of Sakis3G script. Returns:
185 .IP " \fB*\fP" 13
186 \fI0 (zero)\fP if user selected \fICancel\fP , or
187 .IP " \fB*\fP" 13
188 \fI98\fP if user selected \fIExit\fP, thus terminating execution of \fBchain\fP.
189 .IP "\fBprepare\fP, \fBinit\fP" 10
190 It attempts to \fIPIN unlock\fP modem, \fIregister network\fP and \fIupdate HAL\fP. Calls \fBsetup actor\fP if required.
191 .IP "\fBrecompile\fP" 10
192 Attempts to recompile \fIembedded\fP \fBUsb-ModeSwitch\fP binary for you.
193 .IP "\fBreconnect\fP, \fBrestart\fP" 10
194 Attempts to drop current connection (if any), and then attempts to connect again.
195 .IP "\fBreport\fP" 10
196 Generates a report for providing feedback. Fails if invoked while not connected.
197 .IP "\fBsetup\fP" 10
198 Attempts to load required \fIkernel module\fP and create appropriate \fItty node\fP (if not created already), calling \fBswitchonly actor\fP if required.
199 .IP "\fBstate\fP" 10
200 Provided for convenience. Suggests \fBvariable\fP values and \fBswitches\fP that could help you repeat result of previously executed \fBactor(s)\fP, by avoiding to answer as many questions as possible. Always returns \fI0 (zero)\fP.
201 .IP "\fBstatus\fP" 10
202 Displays information about current connection status. Returns:
203 .IP " \fB*\fP" 13
204 \fI0 (zero)\fP if currently connected.
205 .IP " \fB*\fP" 13
206 \fI6 (six)\fP if not currently connected.
207 .IP "\fBswitchonly\fP" 10
208 Attempts to only \fIswitch\fP selected \fIUSB modem\fP, calling \fBmodem actor\fP if necessary.
209 .IP "\fBtoggle\fP" 10
210 Attempts to toggle current connection status:
211 .IP " \fB*\fP" 13
212 Attempts to disconnect if currently connected, or
213 .IP " \fB*\fP" 13
214 attempts to connect if not yet connected.
215 .IP "\fBudevrule\fP" 10
216 Provided for convenience. Suggests a \fIudev rule file\fP, that could be used, for repeating results of previously executed \fBactor(s)\fP, immediately upon physical connection of \fIUSB modem\fP. Always returns \fI0 (zero)\fP.
217
218 .SH "USER INTERFACE"
219 .PP
220 Sakis3G script will attempt to automatically determine best fitted \fIUI\fP upon each one execution. Automatic selection will only happen if a \fIUI\fP is not explicitly set using \fBSGUI variable\fP, or corresponding \fBswitches\fP, or \fIUI\fP explicitly set, through these methods, is not available.
221 .PP
222 There are several aspects taken into consideration when Sakis3G script attempts to detect best fitted \fIUI\fP:
223 .IP "1." 3
224 Existence or not of a valid \fIlocal\fP X session display on which access is granted,
225 .IP "2." 3
226 One or more of the following \fBswitches\fP being set:
227 .IP " \fB*\fP" 6
228 \fB--console switch\fP forcing the use of \fItext mode UIs\fP only.
229 .IP " \fB*\fP" 6
230 \fB--interactive switch\fP allowing the use of an \fIinteractive UI\fP.
231 .IP " \fB*\fP" 6
232 \fB--osd switch\fP requesting for \fIOSD messages\fP being displayed.
233 .IP " \fB*\fP" 6
234 \fB--balloons switch\fP requesting for "balloon-like" \fInotifications\fP being presented through \fIlibnotify\fP.
235 .IP "3." 3
236 Availability of respective utilities within system's \fIPATH\fP.
237 .PP
238 If more than one \fIUI\fP providers are available, the one that will be used is determined according to the following list (most to least preferred):
239 .IP "1." 3
240 \fIkdialog\fP,
241 .IP "2." 3
242 \fIzenity\fP,
243 .IP "3." 3
244 \fIXdialog\fP,
245 .IP "4." 3
246 Terminal emulator in the following order:
247 .IP " \fB*\fP" 6
248 \fIgnome-terminal\fP
249 .IP " \fB*\fP" 6
250 \fIkonsole\fP
251 .IP " \fB*\fP" 6
252 \fIxterm\fP
253 .IP "5." 3
254 \fIwhiptail\fP,
255 .IP "6." 3
256 \fIdialog\fP,
257 .IP "7." 3
258 \fIinteractive terminal\fP, which resembles an elementary \fIUI\fP through \fIshell builtin functions\fP.
259 .IP "8." 3
260 \fIterminal\fP, which is no \fIUI\fP at all. Sometimes useful to set (e.g. when using Sakis3G from within another \fIshell script\fP).
261 .PP
262 .IP "\fBNote:\fP" 6
263 \fI9menu\fP is never automatically selected. It can only be used by explicitly setting either one of those two:
264 \fB--9menu\fP
265 \fBSGUI="9menu"\fP
266
267 .SH "GRAPHICAL UI"
268 .PP
269 \fIGraphical UI\fP is only used if:
270 .IP "\fB*\fP" 2
271 A valid \fIlocal\fP X session display is available, and
272 .IP "\fB*\fP" 2
273 access is granted to that display, and
274 .IP "\fB*\fP" 2
275 \fB--console switch\fP is not set, and
276 .IP "\fB*\fP" 2
277 at least one of the following is available:
278 .IP " \fB*\fP" 4
279 \fIzenity\fP, or
280 .IP " \fB*\fP" 4
281 \fIkdialog\fP, or
282 .IP " \fB*\fP" 4
283 \fIXdialog\fP, or
284 .IP " \fB*\fP" 4
285 \fI9menu\fP, or
286 .IP " \fB*\fP" 4
287 \fIgnome-terminal\fP or \fIkonsole\fP or \fIxterm\fP
288 .IP "\fBNote:\fP" 6
289 You can redirect Sakis3G script to a specific display using \fBDISPLAY\fP and \fBLOCALAUTHORITY variables\fP.
290
291 .SH "CONFIGURATION FILES"
292 .PP
293 \fBVariables\fR and \fBswitches\fR can either be supplied on command line, or be placed within \fIconfiguration file(s)\fP. It is not possible to define an \fBactor\fR within a \fIconfiguration file\fP. For detailed information about \fIconfiguration files\fP, please consult \fBsakis3g.conf\fR(5).
294
295 .SH "EXAMPLES"
296 .PP
297 \fBExample #1:\fR Extract source of Sakis3G script within \fI/usr/src\fP folder:
298
299 # sakis3g disassemble /usr/src
300 # ls -ld /usr/src/sakis3g-*
301 drwxr-x--- 2 sakis sakis 4096 2010-04-14 06:04 sakis3g-0.2.0
302 #
303 .PP
304 \fBExample #2:\fR Determine status according to \fIresult code\fP:
305
306 #!/bin/sh
307 /usr/bin/sakis3g silent status
308 ret=$?
309 if [ "${ret}" -eq "0" ]; then
310 echo "Connected."
311 elif [ "${ret}" -eq "6" ]; then
312 /usr/bin/sakis3g silent plugged
313 ret=$?
314 if [ "${ret}" -eq "0" ]; then
315 echo "Not connected."
316 else
317 echo "No modem plugged."
318 fi
319 else
320 echo "Error ${ret} occurred." >> /dev/stderr
321 fi
322
323 .PP
324 \fBExample #3:\fR Extract source of \fIembedded\fP \fBUsb-ModeSwitch\fP version and compile a binary for your own use:
325
326 $ sakis3g getfile usb_modeswitch.h > usb_modeswitch.h
327 $ sakis3g getfile usb_modeswitch.c > usb_modeswitch.c
328 $ gcc -Wall -lusb -o "usb_modeswitch" "usb_modeswitch.c"
329
330 .PP
331 \fBExample #4:\fR Check version of \fIembedded\fP \fBUsb-ModeSwitch\fP binary.
332
333 $ sakis3g usb_modeswitch --version
334
335 .PP
336 \fBExample #5:\fR Directly use \fIembedded\fP \fBUsb-ModeSwitch\fP binary to switch a ZTE device:
337
338 $ sakis3g usb_modeswitch -v 19d2 -p 2000
339 -M "55534243123456782000000080000c85010101180101010101000000000000"
340
341 .PP
342 \fBExample #6:\fR Display \fIman page\fP of \fIembedded\fP \fBUsb-ModeSwitch\fP version:
343
344 $ sakis3g man usb_modeswitch
345
346 .PP
347 \fBExample #7:\fR Display Sakis3G script's \fIman page\fP:
348
349 $ sakis3g man
350
351 .PP
352 \fBExample #8\fR: \fBinfo actor\fR will only be executed if \fBconnect actor\fR succeeded into establishing data connection:
353
354 $ sakis3g connect info
355
356 .PP
357 \fBExample #9:\fR On this example, \fBconnect actor\fR will never be executed!
358
359 $ sakis3g disconnect info connect
360
361 Let us discover reason behind:
362 .IP " \fB*\fP" 3
363 If \fBdisconnect actor\fR failed (e.g. you did not provide it with root password), \fBchain\fR will anyway stop.
364 .IP " \fB*\fP" 3
365 If \fBdisconnect actor\fR succeeded, then \fBinfo actor\fR will anyway fail, since no active connection exists.
366
367 .PP
368 \fBExample #10:\fR Executing \fBswitchonly actor\fR while no \fIswitchable\fP device exists, results into error "No switchable modem found" being displayed. Using this example, you avoid seeing the error message, by aborting \fBchain\fR before \fBswitchonly actor\fR being executed:
369
370 $ sakis3g switchable switchonly
371
372 .PP
373 \fBExample #11:\fR Re-implementing \fBreconnect actor\fR:
374
375 $ sakis3g ignore disconnect connect
376
377 .PP
378 \fBExample #12:\fR Re-implementing \fBtoggle actor\fR:
379
380 $ sakis3g connected disconnect || sakis3g disconnected connect
381
382 .IP "\fBNote:\fP" 6
383 Using this example, instead of \fBtoggle actor\fP, is a waste of cpu-cycles.
384
385 .PP
386 \fBExample #13:\fR Implementing a more clever \fBreconnect\fR like behavior. This may be useful when your operator sometimes drops connection after a while:
387
388 $ sakis3g ignore disconnect connect wait wait wait wait not connected connect
389
390 .PP
391 \fBExample #14:\fR A native language statement:
392
393 $ sakis3g If not connected anywhere, then connect somewhere.
394
395 .IP " \fB*\fP" 3
396 "If": Unrecognized, ignored.
397 .IP " \fB*\fP" 3
398 "not": \fBnot operator\fR reversing next \fBactor\fR.
399 .IP " \fB*\fP" 3
400 "connected": \fBconnected special actor\fR.
401 .IP " \fB*\fP" 3
402 "anywhere,": Additional unrecognized text, in order to be able to use comma ",". Using it next to "\fBconnected\fR" would lead into "connected," being parsed which would be ignored as unrecognized.
403 .IP " \fB*\fP" 3
404 "then": Unrecognized, ignored.
405 .IP " \fB*\fP" 3
406 "connect": \fBconnect actor\fR.
407 .IP " \fB*\fP" 3
408 "somewhere.": Additional unrecognized text, in order to be able to use dot ".". Using it next to "\fBconnect\fR" would lead into "connect." being parsed which would be ignored as unrecognized.
409
410 .PP
411 \fBExample #15:\fR Exercising our manners:
412
413 $ sakis3g Can you please connect for me?
414
415 .IP " \fB*\fP" 3
416 "Can", "you": Unrecognized, ignored.
417 .IP " \fB*\fP" 3
418 "please": A synonym of \fB--voodoo switch\fR.
419 .IP " \fB*\fP" 3
420 "connect": \fBconnect actor\fR.
421 .IP " \fB*\fP" 3
422 "for", "me?": Additional unrecognized text, in order to be able to use question mark "?". Using it next to "\fBconnect\fR" would lead into "connect?" being parsed which would be ignored as unrecognized.
423
424 .SH "EXIT STATUS"
425 .PP
426 The \fIexit status\fP of Sakis3G script is set to indicate whether any error was
427 detected, or the reason for the \fIscript\fP being terminated. Values used are:
428 .PP
429 \fB0\fR No error occured, or
430 Connected. [ status actor ]
431 .PP
432 \fB1\fR Failed to become root through sudo, or
433 Unexpected internal error.
434 .PP
435 \fB2\fR Reserved.
436 .PP
437 \fB3\fR No method for acquiring root privileges.
438 .PP
439 \fB4\fR Required utility not found within PATH.
440 .PP
441 \fB5\fR Sakis3G itself, not found within PATH.
442 .PP
443 \fB6\fR Not connected, or unable to detect if connected. [ status actor ]
444 .PP
445 \fB7\fR Unable to locate/enumerate connected USB devices.
446 .PP
447 \fB8\fR Error while setting up modem.
448 .PP
449 \fB9\fR Failed to unload existing driver.
450 .PP
451 \fB10\fR Failed to locate appropriate driver for use with USB modem.
452 .PP
453 \fB11\fR Failed to load appropriate driver for USB modem.
454 .PP
455 \fB12\fR Wrong PIN. Aborting to prevent SIM LOCK.
456 .PP
457 \fB13\fR Modem is unable to register a network.
458 .PP
459 \fB95\fR Failed to connect (wvdial or pppd failed to connect).
460 .PP
461 \fB98\fR User interaction required or user requested to terminate.
462 .PP
463 \fB99\fR Unknown error.
464
465 .SH "KNOWN PROBLEMS"
466 .PP
467 Known problems should be fixed in the future:
468 .PP
469 \fB1.\fR Connecting with an operator using CDMA is not yet possible.
470 .PP
471 \fB2.\fR If OSD messages output method is osd_cat/xosd and font defined by XOSDFONT configuration variable does not exist, nothing appears on X screen. Use \fIxfontsel\fP or \fIxlsfonts\fP utilities to construct/locate a valid font string for your system.
472 .PP
473 \fB3.\fR If you connect using Sakis3G script and then disconnect and connect back by using other software, script may incorrectly report status of connection according to information from previous connection.
474 .PP
475 \fB4.\fR Ironic messages may appear when invoking script using only non-recognized arguments.
476
477 .SH "LIMITATIONS"
478 .PP
479 This page refers to known limitations of Sakis3G script. Known limitations are problems, issues or functionality which one should not expect to be fixed/added in the future.
480 .PP
481 \fB1.\fR For \fISIM card\fP safety reasons, this script does its best to only allow exactly 4-digit PIN numbers. If you use a shorter/longer than 4-digits PIN number, it will not work. Plug \fISIM card\fP to a \fIcellular phone\fP and have its PIN number limited to 4 digits.
482 .PP
483 \fB2.\fR Unpredicted behavior if more than one modem units with identical USB IDs are connected.
484 .PP
485 \fB3.\fR Due to the fundamental requirement that script should change nothing on filesystem(s):
486 .IP " \fB*\fP" 5
487 It does not store your network configuration prior into getting connected with your 3G/GSM provider.
488 .IP " \fB*\fP" 5
489 As a result, after being disconnected:
490 .IP " \fB1.\fP" 8
491 it does not revert \fI/etc/resolv.conf\fP back to the configuration prior to making the connection,
492 .IP " \fB2.\fP" 8
493 nor it restores your previous default gateway to your routing table.
494 .IP " \fB*\fP" 5
495 If your existing infrastructure provides DNS servers and gateways from DHCP, you could/should try to disconnect and reconnect to network to get a working setup again.
496 .IP " \fB*\fP" 5
497 If you were not connected to any other network while establishing 3G connection, this limitation does not apply.
498 .PP
499 \fB4.\fR This script does not allow sending SMS.
500 .PP
501 \fB5.\fR This script does not allow monitoring of signal quality and band.
502 .PP
503 \fB6.\fR This script does not in any way interfere with your iptables configuration and does intend to do it in the future.
504 .IP " \fB*\fP" 5
505 If you want to manage your iptables configuration, use CONNECTION_HOOK variable to invoke a tailor-made command.
506 .IP " \fB*\fP" 5
507 As a note, if you encounter problems while sharing (do NAT through) your 3G connection, consider using the following command:
508 .IP "" 5
509 iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN
510 -j TCPMSS --clamp-mss-to-pmtu
511 .PP
512 \fB7.\fR While disconnecting, this script will kill all running pppd instances, thus eliminating any other P-t-P connections you might have running. If you have a complex setup (i.e. bridging across ppp connections), you should NOT (need to) use this script, as it also messes up with your routing tables: you were warned.
513
514 .SH "FILES"
515 .PP
516 Sakis3G script never touches anything on your filesystem(s), except when:
517 .IP " \fB*\fP" 3
518 explicitly instructed to create a \fIdesktop shortcut\fP, and when
519 .IP " \fB*\fP" 3
520 explicitly instructed to generate a log.
521 .PP
522 .IP "\fI/tmp/sakis3g.3gnet\fP " 10
523 Temporary file containing information useful to Sakis3G script for presenting connection information.
524 .IP "\fI/etc/sakis3g.conf\fP " 10
525 Sakis3G configuration file. Consult \fBsakis3g.conf\fP(5) for more information.
526 .IP "\fI~/.3gpin\fP" 10
527 Allows user to define its own \fIPIN number\fP. This value gets overriden if \fBSIM_PIN variable\fP is set through \fIcommand line\fP or within a \fIconfiguration file\fP.
528 .PP
529 Other than that, you may only temporarily witness some file(s) appearing on your \fI/tmp\fP directory.
530
531 .SH "SEE ALSO"
532 .PP
533 \fBsakis3g.conf\fP(5), \fBusb_modeswitch\fP(1), \fBpppd\fP(8), \fBwvdial\fP(1), \fBudev\fP(1), \fBudevd\fP(8), \fBhald\fP(8)
534
535 .SH "AUTHOR"
536 .PP
537 Sakis3G script and this man page are written by Sakis Dimopoulos (sakis at project's domain). Official page of project is at:
538 .PP
539 http://www.sakis3g.org/
540 .PP
541 Official documentation of latest Sakis3G script version, is available at:
542 .PP
543 http://wiki.sakis3g.org/
544
545 .SH "LICENSE"
546 .PP
547 Sakis3G script is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
548 .PP
549 This program is distributed in the hope that it will be useful, but \fBWITHOUT ANY WARRANTY\fR; without even the implied warranty of \fBMERCHANTABILITY\fR or \fBFITNESS FOR A PARTICULAR PURPOSE\fR. See the GNU General Public License for more details:
550 .PP
551 http://www.gnu.org/licenses/gpl.txt
552 .PP
553 Above statement includes additional charges you may receive from your operator by using this program, defects to your SIM card including but not limited to being PIN blocked, defects on your hardware, 3G service abuse ban etc. \fBUSE WITH CARE\fR. Author of this program or authors of any of its dependencies have no responsibility for what may happen to you.
554 .PP
555 Author is not related in any way with any of the companies, being operators or modem manufacturers, other than being a customer to some of them. Logos and trademarks mentioned by this package belong to their respective owners.
556 .PP
557 This program, in order to remain as self-contained as possible, includes original source packages of some of its dependencies. You should consult their respective COPYING and README files to identify terms under which they are redistributed by Sakis3G script.
558
0 .TH "sakis3g.conf" "5"
1 .SH "NAME"
2 sakis3g.conf - Configuration file of Sakis3G script
3
4 .SH "DESCRIPTION"
5 .PP
6 Every time \fBSakis3G script\fP is started, configuration is determined by running a specific sequence. If more than one of the eligible \fIconfiguration file(s)\fP exist, they are processed in the order they appear below:
7 .PP
8 \fB1.\fR ~/.3gpin
9 \fB2.\fR \fICommand line arguments
10 \fB3.\fR /etc/default/3gpin
11 \fB4.\fR /etc/sysconfig/3gpin
12 \fB5.\fR /etc/3gpin
13 \fB6.\fR /etc/default/sakis3g.3gpin
14 \fB7.\fR /etc/sysconfig/sakis3g.3gpin
15 \fB8.\fR /etc/sakis3g.3gpin
16 \fB9.\fR /etc/default/sakis3g
17 \fB10.\fR /etc/sysconfig/sakis3g
18 \fB11.\fR /etc/sakis3g.conf
19 .PP
20 This means that \fI/etc/sakis3g.conf\fP overrides anything
21
22
23 .SH "CONFIGURATION TYPES"
24 .PP
25 There are two types of \fIconfiguration options\fP for Sakis3G script:
26 .IP "\fBSwitches\fR" 10
27 Switches alter behavior of script, enabling or disabling \fIfunctionality\fP. It is usually provided only one switch per functionality: the one that alters default operation. As an example, \fBstorage switch\fP is a synonym for \fBnostorage switch\fP. There is not such thing as yesstorage since default functionality anyway respects storage personality of a \fIUSB device\fP.
28 .IP "\fBVariables\fR" 10
29 Variables provide an other than default value to \fIinternal variables\fP of Sakis3G script, or provide a shortcut mechanism to avoid answering the same question again and again. As an example, providing \fBSIM_PIN="1234"\fP makes sure that script will never ask you again for the \fIPIN number\fP of your \fISIM card\fP (and will effectively block any other \fISIM card\fP requiring \fIPIN number\fP, that might get connected to your computer).
30 .PP
31 Both \fIconfiguration types\fP can either be supplied on \fIcommand line\fP, or
32 be placed within \fIconfiguration files\fP. It is not possible to define an \fBactor\fR within a \fIconfiguration file\fP.
33 .PP
34 If a \fBvariable\fP exists in both the \fIcommand line\fP and a \fIconfiguration file\fP, value from \fIconfiguration file\fP will be used. A \fBvariable\fP defined on \fIcommand line\fP can be unset, within a \fIconfiguration file\fP, by being assigned an empty value (e.g. \fBSIM_PIN=""\fP). On the other hand, if a \fBswitch\fP exists in \fIcommand line\fP, there is no way it can be unset within a \fIconfiguration file\fP and vice versa.
35 .PP
36 If a \fBvariable\fP exists more than once in \fIcommand line\fP, right-most assignment is taken into consideration. As an example, command:
37 .IP "" 12
38 sakis3g SIM_PIN=1234 SIM_PIN=1111
39 .PP
40 will be executed using "1111" as \fIPIN number\fP.
41 .PP
42 Keep in mind that:
43 .IP "\fB*\fR" 2
44 Sakis3G script will never generate or modify any \fIconfiguration file\fP. You need to create/edit \fIconfiguration file(s)\fP by yourself.
45 .IP "\fB*\fR" 2
46 Lines starting with '#' and empty lines are ignored.
47 .IP "\fB*\fR" 2
48 \fBVariable\fP values and \fBswitches\fP specified within \fIconfiguration file(s)\fP cannot be overridden/purged from \fIcommand line\fP. You should therefore be cautious on what you place inside \fIconfiguration file(s)\fP.
49 .IP "\fB*\fR" 2
50 \fBVariable\fP values and \fBswitches\fP, specified within \fIconfiguration file(s)\fP, should appear only \fIone per line\fP. Example:
51 .IP "" 10
52 --nostorage
53 MODEM="19d2:0031 1bbb:0000 1bbb:f000 19d2:2000"
54
55 .SH "SWITCHES"
56 .PP
57 \fBSwitches\fP are supposed to be not prefixed, or prefixed with a single or with double minus.
58 .PP
59 [-][-]<switch name|switch synonym>
60 .PP
61 Following our previous \fBswitch\fP example, all:
62 .PP
63 \fB*\fP --nostorage,
64 \fB*\fP --storage,
65 \fB*\fP -nostorage,
66 \fB*\fP -storage,
67 \fB*\fP nostorage,
68 \fB*\fP storage
69 .PP
70 have the exact same effect. Most \fBswitches\fP also offer \fIsynonyms\fP like our \fBnostorage\fP example.
71 .PP
72 .IP "\fB*\fP" 2
73 \fISynonyms\fP are only provided for aesthetic and backwards compatibility purposes.
74 .IP "\fB*\fP" 2
75 Since a \fIsynonym's\fP functionality may change in the future, you should generally avoid using \fIsynonyms\fP.
76 .IP "\fB*\fP" 2
77 \fISynonym\fP are not listed below. Please consult documentation to discover available \fIsynonyms\fP.
78
79 .IP "\fB-b\fP, \fB--balloons\fP" 10
80 This \fBswitch\fP instructs Sakis3G script to:
81 .IP " \fB*\fP" 12
82 display balloon notifications, using \fInotify-send\fP utility, when an action is complete.
83 .IP " \fB*\fP" 12
84 display balloon notifications, using \fIzenity\fP, when events occur and script is running as \fIhelper\fP.
85 .IP "" 10
86 \fBNotes:\fP
87 .IP " \fB*\fP" 12
88 This \fBswitch\fP is \fIdisabled\fP when using a \fItext mode UI\fP.
89 .IP " \fB*\fP" 12
90 Action completion \fInotifications\fP are \fIdisabled\fP when \fB--osd switch\fP is set.
91 .IP " \fB*\fP" 12
92 Some systems fail to present \fInotifications\fP when \fInotify-send\fP is called by \fIroot\fP, displaying following text:
93 .IP "" 14
94 libnotify-Message: Unable to get session bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
95
96 .IP "\fB-c\fP, \fB--console\fP" 10
97 This \fBswitch\fP instructs Sakis3G script not to take into consideration any active X displays and instead remain in (virtual) terminal from which it was invoked.
98 .IP " \fBNote:\fP" 16
99 If you need an \fIinteractive text mode UI\fP to be used, then use of this switch requires you to also set:
100 .IP " \fB*\fP" 18
101 \fB--interactive switch\fP, or
102 .IP " \fB*\fP" 18
103 explicitly set an \fIinteractive text mode UI\fP through \fBSGUI variable\fP or corresponding \fBswitches\fP.
104
105 .IP "\fB-d\fP, \fB--debug\fP" 10
106 This \fBswitch\fP enables \fIdebug mode\fP.
107 .IP " \fB*\fP" 12
108 This is the first step one should make when troubleshooting.
109 .IP " \fB*\fP" 12
110 When Sakis3G script operates in \fIdebug mode\fP a huge amount of \fIdebug information\fP is sent to \fIstandard error\fP.
111 .IP " \fB*\fP" 12
112 Providing \fIdebug output\fP when seeking support is essential.
113 .IP "" 10
114 To grab debug information use following syntax:
115 .IP "" 12
116 sakis3g connect --debug 2> /home/sakis/sakis3g.log
117 .IP " \fBNote:\fP" 16
118 Use of this switch significantly reduces performance. Make sure it is not set when not required.
119
120 .IP "\fB-f\fP, \fB--nofix\fP" 10
121 Whenever a data connection is initiated, and before \fIinforming\fP you about connection being established, Sakis3G script performs the following two actions:
122 .IP " \fB1.\fP" 13
123 Forces \fIdefault gateway\fP to be the \fIP-t-P peer\fP provided by newly created \fIinterface\fP.
124 .IP " \fB2.\fP" 13
125 If DNS servers, provided by operator, are 10.11.12.13 and 10.11.12.14, sets \fIGoogle DNS servers\fP instead.
126 .IP "" 10
127 These actions take care that newly initiated P-t-P connection is properly setup.
128 .IP "" 10
129 This \fBswitch\fP allows you to \fIprevent\fP these actions from taking place. This can be useful:
130 .IP " \fB*\fP" 12
131 if you do not want all traffic to pass through "expensive" WAN connection and only direct specific traffic through mobile internet, or
132 .IP " \fB*\fP" 12
133 if you anyway set appropriate \fIDNS servers\fP using another method/interface/IP.
134
135 .IP " \fBNotes:\fP" 17
136 .IP " \fB*\fP" 19
137 Action which might be specified by \fBCONNECTION_HOOK variable\fP is still performed when this \fBswitch\fP is set.
138 .IP " \fB*\fP" 19
139 This \fBswitch\fP \fIdisables\fP \fB--googledns switch\fP and \fBDNS variable\fP.
140
141 .IP "\fB-G\fP, \fB--guruplug\fP" 10
142 Instructs script to attempt and utilize leds, found on GuruPlug devices, for indicating progress, errors and success. Using this \fBswitch\fP while
143 not running on a GuruPlug device has no effect.
144 .IP " \fBNotes:\fP" 17
145 .IP " \fB*\fP" 19
146 This \fBswitch\fP is affected by \fB--noverbose\fP, \fB--noerrors\fP, \fB--nonotify\fP and \fB--quiet switches\fP.
147 .IP " \fB*\fP" 19
148 Sakis3G script will restore leds, on the state they had been before invoking it, upon exit.
149 .IP " \fB*\fP" 19
150 Errors are denoted by both leds blinking red for 5 seconds.
151 .IP " \fB*\fP" 19
152 Success is denoted by both leds blinking green for 5 seconds.
153 .IP " \fB*\fP" 19
154 Progress is indicated by both leds being green, while they swap blinking each time progress is advanced. If a step is persisted (e.g. when
155 waiting for modem to register a network), blinking led goes red.
156
157 .IP "\fB-g\fP, \fB--googledns\fP" 10
158 Setting this \fBswitch\fP instructs Sakis3G script to set \fIGoogle DNS servers\fP immediately after connection with operator is established, regardless of \fIname servers\fP suggested by operator.
159 .IP " \fBNotes:\fP" 17
160 .IP " \fB*\fP" 19
161 This \fBswitch\fP is equivalent to:
162 .IP "" 23
163 DNS="8.8.8.8 8.8.4.4"
164 .IP " \fB*\fP" 19
165 This \fBswitch\fP is \fIdisabled\fP when \fB--nofix switch\fP is set.
166
167 .IP "\fB-h\fP, \fB--nohal\fP" 10
168 This \fBswitch\fP instructs Sakis3G script not to contact \fBHAL\fP.
169 .IP "" 10
170 Sakis3G script interacts with \fBHAL\fP (if \fIhald\fP is installed) in two occasions:
171 .IP " \fB1.\fP" 13
172 Before \fIswitching\fP modem in order to \fIexclusively lock\fP interface \fIorg.freedesktop.Hal.Device.Storage\fP and avoid \fBHAL\fP messing with \fIUSB device\fP while Sakis3G script does not expect it.
173 .IP " \fB1.\fP" 13
174 Immediately after modem has been \fIPIN unlocked\fP and \fIregistered to network\fP (and before setting \fIAPN\fP and connecting) in order to inform \fBHAL\fP that a modem exists.
175 .IP " \fBNotes:\fP" 17
176 .IP " \fB*\fP" 19
177 This \fBswitch\fP is automatically set when one or more of the following utilities are \fInot found\fP within path:
178 .IP " \fB*\fP" 21
179 \fIhal-device\fP
180 .IP " \fB*\fP" 21
181 \fIhal-find-by-property\fP
182 .IP " \fB*\fP" 21
183 \fIhal-get-property\fP
184 .IP " \fB*\fP" 21
185 \fIhal-lock\fP
186 .IP " \fB*\fP" 21
187 \fIhal-set-property\fP
188 .IP " \fB*\fP" 19
189 This \fBswitch\fP also implies \fB--nohalinform switch\fP.
190
191 .IP "\fB-i\fP, \fB--interactive\fP" 10
192 This \fBswitch\fP informs Sakis3G script that it can utilize its \fIinteractive mode\fP and not abort when user interference is required.
193
194 This means:
195 .IP " \fB*\fP" 12
196 It can ask user to perform selections when required,
197 .IP " \fB*\fP" 12
198 It can prompt user to provide values when required,
199 .IP " \fB*\fP" 12
200 User can provide root password if required.
201 .IP "" 10
202 Script takes this information into consideration when deciding which \fIUI\fP to use.
203 .IP " \fBNotes:\fP" 17
204 .IP " \fB*\fP" 19
205 Explicitly setting a \fIUI\fP (by using \fBSGUI variable\fP or respective \fBswitches\fP) which requires \fB--interactive switch\fP being set, results into \fIinteractive mode\fP anyway being set.
206 .IP " \fB*\fP" 19
207 When \fIinteractive mode\fP is \fInot\fP enabled, and not implied, Sakis3G script will abort whenever user interference is required.
208 .IP " \fB*\fP" 19
209 When:
210 .IP " \fB*\fP" 25
211 DISPLAY \fIenvironment variable\fP points to a valid local X session display, and
212 .IP " \fB*\fP" 25
213 access is granted for that display, and
214 .IP " \fB*\fP" 25
215 tools required for using at least one \fIGraphical UI\fP are available, then
216 .IP "" 19
217 this switch is set unconditionally. In other words, an X display \fBimplies\fP \fIinteractive mode\fP availability.
218
219 If you need to prevent this assumption (however, this will prevent you from using any Graphical UI):
220 .IP " \fB*\fP" 25
221 consider using \fB--console switch\fP, or
222 .IP " \fB*\fP" 25
223 unset DISPLAY \fIenvironment variable\fP before invoking Sakis3G script:
224 .IP "" 29
225 unset DISPLAY; sakis3g
226
227 .IP "\fB-k\fP, \fB--nostorage\fP" 10
228 Some \fIUSB modems\fP provide a \fIstorage interface\fP even after being \fImode switched\fP. This is essentially true for devices offering an SD/microSD/MMC slot. This triggers numerous procedures being initiated for setting up those \fIblock device(s)\fP exported by \fIstorage interface\fP. Depending on \fIkernel version\fP and \fIsystem setup\fP:
229 .IP " \fB*\fP" 12
230 Setting up those volume(s) may take several seconds.
231 .IP " \fB*\fP" 14
232 Especially if your system intends to automatically \fImount\fP exported volume(s).
233 .IP " \fB*\fP" 12
234 Setting up those volume(s), may render modem unusable.
235 .IP " \fB*\fP" 12
236 Accessing those volume(s) (even after data connection is established) may still render modem unusable.
237 .IP " \fB*\fP" 12
238 Setting up modem-part and storage-part simultaneously may render one or both parts unusable.
239 .IP "" 10
240 Sakis3G script takes all measures required for preventing any simultaneous modem and storage operations, leading to an, as much as possible, stable environment:
241 .IP " \fB1.\fP" 13
242 Locks \fBHAL\fP before \fIswitching\fP device.
243 .IP " \fB2.\fP" 13
244 \fISwitches\fP device.
245 .IP " \fB3.\fP" 13
246 Checks if \fBusb_storage\fP got bound to \fIstorage interface\fP.
247 .IP " \fB*\fP" 16
248 If it is bound:
249 .IP " \fB*\fP" 18
250 \fIUnlocks\fP \fBHAL\fP and checks if \fBHAL\fP spawned a \fIpolling process\fP.
251 .IP " \fB*\fP" 20
252 If a \fIpolling process\fP was spawned:
253 .IP " \fB*\fP" 22
254 Awaits for spawned process to finish \fImounting volumes\fP.
255 .IP " \fB*\fP" 16
256 If it is not bound:
257 .IP " \fB*\fP" 18
258 Unlocks HAL.
259 .IP " \fB4.\fP" 13
260 Then proceeds into setting up modem-part.
261 .IP "" 10
262 Doing all these may take \fIseveral\fP seconds (even up to 30 seconds). Even then, things can still be destroyed by another \fIsilly\fP process messing with modem or volume(s).
263
264 This \fBswitch\fP instructs Sakis3G script to \fIsafely unbind\fP \fBusb_storage\fP \fImodule\fP from \fIstorage interface\fP (if possible). Chances of storage-part operations interfering with modem-part operations are then highly reduced.
265 .IP " \fBNotes:\fP" 17
266 .IP " \fB*\fP" 19
267 Using this \fBswitch\fP renders \fIUSB modem's\fP SD/microSD/MMC card slot unusable.
268 .IP " \fB*\fP" 19
269 Using this \fBswitch\fP simultaneously with \fB--nohal switch\fP, may get you into various troubles:
270 .IP " \fB*\fP" 21
271 Your system and/or file manager may complain about volume disappearing.
272 .IP " \fB*\fP" 21
273 Your system may recover by \fIre-binding\fP \fBusb_storage\fP \fImodule\fP to \fIstorage interface\fP.
274 .IP " \fB*\fP" 23
275 Still Sakis3G script will be considering it did its job into eliminating storage part and will proceed.
276 .IP " \fB*\fP" 23
277 Simultaneous access/setup operations to modem and storage parts will be taking place, leading into one or both parts being unusable.
278
279 .IP "\fB-l\fP, \fB--nohalinform\fP" 10
280 Whenever Sakis3G script has finished setting up your modem, it updates \fIserial node's\fP \fBHAL entry\fP so that your system is aware of the newly attached modem. Using this \fBswitch\fP you can disable this functionality.
281 .IP " \fBNotes:\fP" 17
282 .IP " \fB*\fP" 19
283 Disabling this functionality may be helpful if \fImodemmanager\fP keeps messing with newly appeared modems, preventing (or delaying) Sakis3G script from using modem.
284 .IP " \fB*\fP" 19
285 This \fBswitch\fP is implied when \fB--nohal switch\fP is set.
286
287 .IP "\fB-n\fP, \fB--noprobegsm\fP" 10
288 Sakis3G script probes \fIcharacter device node\fP (aka. \fItty node\fP) for \fIGSM capabilities\fP before proceeding into attempting data connection. However, some modems do not advertise their \fIGSM capabilities\fP resulting into Sakis3G script aborting connection.
289
290 Setting this \fBswitch\fP allows you to force Sakis3G script consider \fItty node\fP GSM capable.
291
292 .IP "\fB-o\fP, \fB--osd\fP" 10
293 This \fBswitch\fP instructs Sakis3G script to use \fIOSD messages\fP for \fIverbosing\fP and displaying \fIprogress bars\fP, instead of method provided by \fIUI\fP.
294 .IP " \fB*\fP" 12
295 This \fBswitch\fP requires \fIaosd_cat\fP/aosd or \fIosc_cat\fP/xosd being available within \fBPATH\fP.
296 .IP " \fB*\fP" 12
297 If none of them is found within \fBPATH\fP, this \fBswitch\fP will be ignored.
298 .IP " \fB*\fP" 12
299 If both of them are found, \fIosd_cat\fP/xosd is used since it is able to provide \fIprogress bar functionality\fP.
300 .IP " \fB*\fP" 12
301 If \fB--noverbose switch\fP is set, \fIOSD messages\fP still appear as a \fIfinal notification\fP text (e.g. "Connected to..." or "Disconnected").
302 .IP " \fB*\fP" 14
303 If you do need to also eliminate these:
304 .IP " \fB*\fP" 16
305 Either set \fB--nonotify switch\fP, or
306 .IP " \fB*\fP" 16
307 do not set \fB--osd switch\fP at first place.
308
309 .IP " \fBNotes:\fP" 17
310 .IP " \fB*\fP" 19
311 You need to have access to a valid local X session display. Either appropriately set DISPLAY \fIenvironment variable\fP or use Sakis3G \fBDISPLAY\fP and \fBLOCALAUTHORITY variables\fP to specify target display.
312 .IP " \fB*\fP" 19
313 Use of this \fBswitch\fP disables \fB--balloons switch\fP.
314 .IP " \fB*\fP" 19
315 This \fBswitch\fP is disabled when using a \fItext mode UI\fP, even if an X session DISPLAY is available/detected.
316
317 .IP "\fB-P\fP, \fB--persist\fP" 10
318 This \fBswitch\fP is only taken into consideration with \fBhelper actor\fP is running. This \fBswitch\fP instructs \fIhelper\fP to ignore user selecting \fIExit option\fP and instead keep running.
319 .IP " \fB*\fP" 12
320 This can be useful when you have to cope with users that keep selecting \fIExit\fP and then complain that "it disappeared".
321 .IP " \fBNote:\fP" 16
322 Using this \fBswitch\fP can be really annoying when you attempt to stop Sakis3G script by killing it.
323
324 .IP "\fB-p\fP, \fB--pppd\fP" 10
325 This \fBswitch\fP instructs Sakis3G script to directly use \fIpppd\fP and not call \fIwvdial\fP. This \fBswitch\fP is automatically set when \fIwvdial\fP is not found within \fBPATH\fP.
326
327 .IP "\fB-q\fP, \fB--quiet\fP" 10
328 Eliminates any \fIconfirmation/information/error/verbose text\fP and \fIprogress bars\fP from appearing.
329
330 Dialogs prompting user to make a selection or provide a value will still appear. If you want to also suppress prompts, then both:
331 .IP " \fB*\fP" 12
332 set \fB--console switch\fP, and
333 .IP " \fB*\fP" 12
334 make sure \fB--interactive switch\fP is not set.
335 .IP " \fBNotes:\fP" 17
336 .IP " \fB*\fP" 19
337 This \fBswitch\fP implies all \fB--noerrors\fP, \fB--nonotify\fP and \fB--noverbose switches\fP.
338
339 .IP "\fB--noerrors\fP" 10
340 Eliminates any \fIerror message\fP from appearing.
341 .IP " \fBNote:\fP" 16
342 This \fBswitch\fP is implied when \fB--quiet\fP switch is set.
343
344 .IP "\fB--nonotify\fP" 10
345 Eliminates any \fIconfirmation/information text\fP from appearing. Dialogs prompting user to perform a selection or provide a value will still appear.
346
347 .IP " \fBNote:\fP" 16
348 This \fBswitch\fP is implied when \fB--quiet\fP switch is set.
349
350 .IP "\fB--noverbose\fP" 10
351 Eliminates any \fIverbose text\fP or \fIprogress bar\fP from appearing while Sakis3G script is working.
352 .IP " \fBNote:\fP" 16
353 This \fBswitch\fP is implied when \fB--quiet\fP switch is set.
354
355
356 .IP "\fB--scanno\fP" 10
357 If modem is unable to automatically register a network, script will offer you to manually select one,
358 by scanning for available networks. This \fBswitch\fP instructs script not to scan for available networks
359 and unconditionally fail whenever modem fails to register a network.
360 .IP " \fBAlso see:\fP" 20
361 \fB--scanyes\fP
362
363 .IP "\fB--scanyes\fP" 10
364 Instructs script to scan for available networks whenever modem does not automatically register one.
365 .IP " \fBAlso see:\fP" 20
366 \fB--scanno\fP
367
368
369 .IP "\fB-s\fP, \fB--sudo\fP" 10
370 This \fBswitch\fP instructs Sakis3G script to always use \fIsudo\fP utility for acquiring root privileges. This can be useful when you do not want to share \fIroot password\fP with users, still allow them to use Sakis3G script. Example:
371 .IP "" 12
372 Type this:
373 .IP "" 18
374 $ sudo visudo
375 .IP "" 12
376 Append similar lines to file and save it.
377 .IP "" 17
378 %bar ALL=(root) NOPASSWD: /usr/bin/sakis3g
379 foo ALL=(root) NOPASSWD: /usr/bin/sakis3g
380 .IP "" 12
381 User \fIfoo\fP and members of \fIbar\fP group will
382 then be able to use Sakis3G script without ever
383 being prompt to supply administrator password.
384 .IP " \fBNotes:\fP" 17
385 .IP " \fB*\fP" 19
386 When using a \fIsudo based\fP distribution (like Ubuntu), there is no need to use this \fBswitch\fP, since \fIgksu\fP will anyway use \fIsudo\fP as backend.
387 .IP " \fB*\fP" 19
388 Setting this \fBswitch\fP while using a \fIGraphical UI\fP, will force Sakis3G script to \fIfail\fP since \fIsudo\fP output will end up to \fIvoid\fP, unless you use \fBNOPASSWD\fP as illustrated in example above.
389
390 .IP "\fB-T\fP, \fB--showtext\fP" 10
391 This \fBswitch\fP (in conjuction with \fB--debug switch\fP) results into \fIdebug information\fP, regarding translations, to appear in \fIstandard error\fP.
392
393 .IP "\fB-t\fP, \fB--notranslate\fP" 10
394 If there is a translation for your \fIlocale\fP, it is automatically used as long as \fIUI\fP allows it. Setting this \fBswitch\fP disables translations.
395 .IP " \fBNotes:\fP" 17
396 .IP " \fB*\fP" 19
397 If no appropriate translation is found, and no other translation file is provided through \fBTRANSLATE variable\fP, this \fBswitch\fP is automatically set.
398 .IP " \fB*\fP" 19
399 If you can afford English text, setting this \fBswitch\fP will significantly improve performance.
400
401 .IP "\fB-u\fP, \fB--unsafe\fP" 10
402 Several \fIUSB devices\fP have a tendency to "break" after being plugged for a while. This may happen due to:
403 .IP " \fB1.\fP" 13
404 Bad hardware implementation of modem or USB controller, or
405 .IP " \fB2.\fP" 13
406 Bugs in device EEPROM, or
407 .IP " \fB3.\fP" 13
408 An unknown/undocumented \fIAT command\fP is required to prevent device from enterring its propretiary "power saving" mode.
409 .IP "" 10
410 Sometimes, when this happens, any application trying to access \fIUSB bus\fP goes \fIstalled\fP until device is physically removed from bus. Sakis3G script uses safety checks to avoid being \fIstalled\fP. Instead, it informs user that he should try reconnecting device.
411
412 Setting this \fBswitch\fP allows you to disable those safety checks.
413 .IP " \fB*\fP" 12
414 If this never happens to your device, it is safe that you set it and reduce time required to connect by a maximum of 4 seconds.
415 .IP " \fB*\fP" 12
416 If Sakis3G script incorrectly reports it happened and stops working for no reason, you can try setting this \fBswitch\fP in case it helps (but I doubt it will).
417
418 .IP "\fB-v\fP, \fB--voodoo\fP" 10
419 Enables \fIVoodoo mode\fP. When Sakis3G script is executed under \fIvoodoo mode\fP it will attempt to perform without your interference (if possible).
420 .IP " \fBNote:\fP" 16
421 You should be cautious when using \fIvoodoo mode\fP. If your modem is not found with \fIembedded\fP \fBUsb-ModeSwitch\fP \fIdevice database\fP, and in order to avoid asking you about which your modem is, Sakis3G script may consider an attached \fImass storage USB device\fP being a not yet \fIswitched\fP device. This will lead into device being \fIejected\fP.
422
423 .IP "\fB--9menu\fP, \fB--kdialog\fP, \fB--zenity\fP, \fB--Xdialog\fP" 10
424 Forces script to use respective application for presenting \fIuser interface\fP.
425 .IP " \fB*\fP" 12
426 If respective application is not found within \fBPATH\fP, another \fIUI\fP will be used instead.
427 .IP " \fB*\fP" 12
428 Equivalent to:
429 .IP "" 15
430 SGUI="9menu" or
431 SGUI="kdialog" or
432 SGUI="Xdialog" or
433 SGUI="zenity"
434 .IP " \fBNotes:\fP" 17
435 .IP " \fB*\fP" 19
436 You need to have access to a valid local X session display. Either appropriately set DISPLAY \fIenvironment variable\fP or use Sakis3G \fBDISPLAY\fP and \fBLOCALAUTHORITY variables\fP to specify target display. Otherwise, a \fItext mode UI\fP will be used instead.
437 .IP " \fB*\fP" 19
438 These \fBswitches\fP imply \fB--interactive switch\fP.
439 .IP " \fB*\fP" 19
440 Translations are not available when using \fI9menu\fP or \fIXdialog\fP for displaying \fIUI\fP.
441
442 .IP "\fB--gnome-terminal\fP, \fB--konsole\fP, \fB--xterm\fP" 10
443 Forces script to spawn a new Sakis3G script instance within respective \fIterminal emulation application\fP. Spawned instance will be using best available \fItext mode UI\fP. There is no way to specify \fIUI\fP which spawned instance will be using. If respective \fIterminal application\fP is not found within \fBPATH\fP, another \fIUI\fP will be used instead.
444
445 Equivalent to:
446 .IP "" 15
447 SGUI="gnome-terminal" or
448 SGUI="konsole" or
449 SGUI="xterm"
450 .IP " \fBNotes:\fP" 17
451 .IP " \fB*\fP" 19
452 You need to have access to a valid local X session display. Either appropriately set DISPLAY \fIenvironment variable\fP or use Sakis3G \fBDISPLAY\fP and \fBLOCALAUTHORITY variables\fP to specify target display. Otherwise, a \fItext mode UI\fP will be used instead.
453 .IP " \fB*\fP" 19
454 These switches imply \fB--interactive switch\fP.
455
456 .IP "\fB--dialog\fP, \fB--whiptail\fP" 10
457 Forces script to use respective utility for presenting \fIUI\fP. If required utility is not found within \fBPATH\fP another \fIUI\fP will be used instead, not necessarily a \fItext mode UI\fP. If you want to make sure a \fItext mode UI\fP will be used, also supply \fB--console switch\fP.
458
459 Equivalent to:
460 .IP "" 15
461 SGUI="dialog" or
462 SGUI="whiptail"
463 .IP " \fBNote:\fP" 16
464 Both \fBswitches\fP imply \fB--interactive switch\fP.
465
466 .IP "\fB--iterm\fP" 10
467 Forces script not use any application for providing \fIUI\fP and instead resemble a simple \fItext mode UI\fP using colored output and gathering input through \fIshell builtin functions\fP.
468
469 Equivalent to:
470 .IP "" 15
471 SGUI="interactive terminal"
472 .IP " \fBNote:\fP" 16
473 Implies \fB--interactive switch\fP.
474
475 .IP "\fB--term\fP" 10
476 Forces script not to use \fIany UI\fP. All required options and values, of \fBactor(s)\fP specified in \fIcommand line\fP, must be already supplied either using \fIcommand line\fP or through a \fIconfiguration file\fP. Otherwise, \fBactor(s)\fP will fail.
477
478 Equivalent to:
479 .IP "" 15
480 SGUI="terminal"
481
482 .IP "\fB--legacy\fP" 10
483 Provided for convenience, simulating \fIlegacy version's\fP appearance. Equivalent to supplying both:
484 .IP "" 15
485 --9menu --osd
486
487 .SH "VARIABLES"
488 .PP
489 \fBVariables\fP are expected to have the following syntax:
490 .IP "" 5
491 \fI<Variable name>\fP = [ "\fI<Variable value>\fP" | \fI<Valuewithnospace>\fP ]
492 .PP
493 Which means that quotes are only necessary when a white space is to be included within value.
494 .PP
495 There is also \fImultiple values\fP syntax:
496 .IP "" 5
497 \fI<Variable name>\fP = "\fI<Value1>\fP [ \fI<Value2>\fP [ \fI...\fP ] ]"
498 .PP
499 \fIMultiple values\fP syntax allows you to provide multiple valid values for a \fBvariable\fP. Sakis3G script will iterate through supplied values until first one being valid is encountered. This value automatically replaces contents of \fBvariable\fP and iteration stops. \fIMultiple values\fP syntax is only available for the following \fBvariables\fP:
500 .PP
501 \fB*\fP APN \fB*\fP MODEM \fB*\fP USBDRIVER
502 \fB*\fP BLUETOOTH \fB*\fP MOREMENU \fB*\fP USBINTERFACE
503 \fB*\fP DESKTOPICON \fB*\fP OTHER \fB*\fP USBMODEM
504 \fB*\fP MENU \fB*\fP RFSERVICE
505 .PP
506 Sakis3G script does not require that you provide a value to any of these \fBvariables\fP. Even if it fails to find appropriate value itself, it will ask that you do it through \fIUI\fP. You only need to supply a value on \fBvariables\fP if:
507 .IP " \fB1.\fP" 4
508 no \fIUI\fP is available, rendering script unable to proceed lacking your feedback,
509 .IP " \fB2.\fP" 4
510 you want to avoid navigating and providing answers through \fIUI\fP,
511 .IP " \fB3.\fP" 4
512 automatically selected value is not correct,
513 .IP " \fB4.\fP" 4
514 you want to prevent users from making wrong decisions themselves, and instead force appropriate values through a \fIconfiguration file\fP.
515 .IP " \fB5.\fP" 4
516 you want to fine tune Sakis3G script operation.
517
518 .IP "\fBAOSDFONT\fP" 10
519 This \fBvariable\fP defines \fIfont\fP that should be used when displaying \fIOSD messages\fP using \fIaosd_cat\fP utility. If no value is provided, default value \fIDejaVuSans 36\fP is loaded. If value specified refers to a \fIfont\fP not available in system, \fIaosd_cat\fP replaces it with a valid one.
520
521 Example:
522 .IP "" 18
523 AOSDFONT="DejaVuSans 24"
524 .IP "" 10
525 See also: \fBXOSDFONT\fP, \fBOSDFONT\fP
526
527 .IP "\fBAPN\fP" 10
528 This variable defines \fIAPN\fP (\fIAccess Point Name\fP) that should be used to establish connection. Value assigned must be a valid \fIAPN\fP for your \fIoperator\fP, or word "\fICUSTOM_APN\fP". If value assigned is not a valid \fIAPN\fP for your \fIoperator\fP, value is discarded.
529
530 If your \fIoperator\fP is not found within \fIlist of known operators\fP, Sakis3G script will check if your modem has an \fIAPN\fP stored since its last connection. If it has, that \fIAPN\fP will be considered a valid \fIAPN\fP.
531
532 If none of the above operations indicated a valid \fIAPN\fP for you to use, no matter what value is already loaded, "\fICUSTOM_APN\fP" is automatically set.
533 .IP " \fB*\fP" 12
534 When value "\fICUSTOM_APN\fP" is specified, \fIAPN name\fP is instead retrieved from \fBCUSTOM_APN variable\fP.
535 .IP "" 10
536 Examples:
537 .IP "" 18
538 APN="internet.myprovider"
539 APN="CUSTOM_APN" CUSTOM_APN="internet.myprovider"
540 .IP "" 10
541 See also: \fBAPN_USER\fP, \fBAPN_PASS\fP, \fBCUSTOM_APN\fP, \fBFORCE_APN\fP
542
543 .IP "\fBAPN_USER\fP" 10
544 This value defines \fIusername\fP which \fIoperator\fP requires when using selected \fIAPN\fP (\fIAccess Point Name\fP).
545 .IP " \fB*\fP" 12
546 If \fIoperator\fP provided you with a \fIusername\fP, required for performing connection, this is the place to use it.
547 .IP " \fB*\fP" 12
548 Most \fIoperators\fP are reasonable enough not to require a special \fIusername\fP for widely used \fIAPNs\fP.
549 .IP " \fB*\fP" 12
550 If \fIoperator\fP does not require a \fIusername\fP, you can place anything you like.
551 .IP " \fBNote:\fP" 16
552 Even if your \fIAPN\fP does not need a \fIusername\fP, you still have to provide a value in this \fBvariable\fP. By convention, on these cases we usually use "\fIuser\fP" as \fIusername\fP, indicating that no exact value is required.
553 .IP "" 10
554 Example:
555 .IP "" 18
556 APN="CUSTOM_APN"
557 CUSTOM_APN="internet.myprovider.com"
558 APN_USER="myphonenumber"
559 .IP "" 10
560 See also: \fBAPN\fP, \fBAPN_PASS\fP, \fBCUSTOM_APN\fP, \fBFORCE_APN\fP
561
562 .IP "\fBAPN_PASS\fP" 10
563 This value defines \fIpassword\fP which \fIoperator\fP requires when using selected \fIAPN\fP (\fIAccess Point Name\fP).
564 .IP " \fB*\fP" 12
565 If \fIoperator\fP provided you with a \fIpassword\fP, required for performing connection, this is the place to use it.
566 .IP " \fB*\fP" 12
567 Most \fIoperators\fP are reasonable enough not to require a special \fIpassword\fP for widely used \fIAPNs\fP.
568 .IP " \fB*\fP" 12
569 If \fIoperator\fP does not require a \fIpassword\fP, you can place anything you like.
570 .IP " \fBNote:\fP" 16
571 Even if your \fIAPN\fP does not need a \fIpassword\fP, you still have to provide a value in this \fBvariable\fP. By convention, on these cases we usually use "\fIpass\fP" as \fIpassword\fP, indicating that no exact value is required.
572 .IP "" 10
573 Example:
574 .IP "" 18
575 APN="CUSTOM_APN"
576 CUSTOM_APN="internet.myprovider.com"
577 APN_USER="myphonenumber"
578 APN_PASS="internet123"
579 .IP "" 10
580 See also: \fBAPN\fP, \fBAPN_USER\fP, \fBCUSTOM_APN\fP, \fBFORCE_APN\fP
581
582 .IP "\fBBAUD\fP" 10
583 This \fBvariable\fP allows user to specify \fIbaud rate\fP which \fIpppd\fP and/or \fIwvdial\fP should be instructed to use. Since \fIwvdial\fP also
584 relies on \fIpppd\fP for establishing connection, you should consult \fBpppd\fP(8) for determining available values. If this \fBvariable\fP
585 is not set, default value \fI460800\fP is used.
586 .IP "" 10
587 In addition to the usual numeric values, Sakis3G script allows assigning following values to this \fBvariable\fP:
588 .IP " \fBDEFAULT\fP" 18
589 Results into value \fI460800\fP being used.
590 .IP " \fBMAX\fP" 18
591 Results into value \fI4000000\fP being used.
592 .IP " \fBMIN\fP" 18
593 Results into value \fI115200\fP being used.
594 .IP " \fBNotes:\fP" 17
595 .IP " \fB*\fP" 13
596 You can consult your running kernel's sources (header file \fIinclude/asm/termbits.h\fP) for a list of possible values.
597 .IP " \fB*\fP" 13
598 Using an invalid or unsupported value might render connection impossible.
599 .IP "" 10
600 Examples:
601 .IP " \fB1.\fP" 15
602 Use maximum possible rate:
603 BAUD=MAX
604 .IP " \fB2.\fP" 15
605 Use a really safe value:
606 BAUD=MIN
607 .IP " \fB3.\fP" 15
608 Use a custom value:
609 BAUD=921600
610 .IP "" 10
611 See also: \fBPPPD_OPTIONS\fP
612
613 .IP "\fBBLUETOOTH\fP" 10
614 This \fBvariable\fP should either contain the \fIBluetooth address\fP of a currently \fIdiscoverable\fP Bluetooth device, or the word "\fIUNDISCOVERABLE\fP". If value is not valid, or device is not currently \fIdiscoverable\fP, value of this \fBvariable\fP is discarded. This \fBvariable\fP is only taken into consideration when \fBOTHER variable\fP contains word "\fIBLUETOOTH\fP" and is used for selecting a \fIdiscoverable\fP Bluetooth device. If value "\fIUNDISCOVERABLE\fP" is loaded, device selection procedure refers to \fBUNDISCOVERABLE variable\fP.
615 .IP " \fBNote:\fP" 16
616 Even if device is \fIdiscoverable\fP, you may find defining it as \fIundiscoverable\fP more convenient (see example #2). This can save you a couple of seconds by avoiding scan of Bluetooth devices.
617 .IP "" 10
618 Examples:
619 .IP " \fB1.\fP" 15
620 Define \fIdiscoverable\fP device:
621 MODEM="OTHER" OTHER="BLUETOOTH"
622 BLUETOOTH="00:25:47:59:AA:00"
623 .IP " \fB2.\fP" 15
624 Define \fIundiscoverable\fP device:
625 MODEM="OTHER" OTHER="BLUETOOTH"
626 BLUETOOTH="UNDISCOVERABLE"
627 UNDISCOVERABLE="00:25:47:59:AA:00"
628 .IP "" 10
629 See also: \fBMODEM\fP, \fBOTHER\fP, \fBRFSERVICE\fP, \fBRFCHANNEL\fP, \fBUNDISCOVERABLE\fP
630
631 .IP "\fBCHAT_ABORT_STRINGS\fP" 10
632 This \fBvariable\fP provides control over \fIchat\fP abort strings. You can find additional information on \fBchat\fP(8). If no value is assigned, default value is automatically set.
633
634 Default value is:
635 ABORT BUSY
636 ABORT ERROR
637 ABORT BLOCKED
638 ABORT NOCARRIER
639 .IP "" 10
640 Example: Prevent \fIany\fP PIN operation.
641 .IP "" 15
642 CHAT_ABORT_STRINGS="ABORT BUSY ABORT ERROR ABORT BLOCKED ABORT NOCARRIER ABORT 'SIM PIN'"
643
644 .IP "\fBCONNECTION_HOOK\fP" 10
645 This \fBvariable\fP allows you to specify a \fIcommand\fP that should be run, whenever a connection with \fIoperator\fP is succesfully established. If no value is provided, nothing is executed.
646
647 \fIConnection hook\fP is executed even if \fB--nofix switch\fP is set. \fIConnected notification dialog\fP of Sakis3G script does not appear before \fIconnection hook\fP has returned. When executed, \fIconnection hook\fP may enjoy information found within \fIenvironment variables\fP (see example).
648
649 There is no "formal way" that \fIconnection hook\fP could use to inform back Sakis3G script to terminate connection. Both \fIoutput\fP and \fIexit status\fP of \fIconnection hook\fP command are discarded from Sakis3G script. If you need to disconnect from within \fIconnection hook\fP you could still call:
650 .IP "" 15
651 sakis3g disconnect
652 .IP "" 10
653 You should however be aware that when \fIconnection hook\fP has finished, Sakis3G script will display \fIFailed to connect\fP error dialog.
654 .IP " \fBExample:\fP" 20
655 Save \fIenvironment variables\fP, during invocation of \fIconnection hook\fP, onto a file. You can later review them and construct amazing \fIshell
656 scripts\fP like this one:
657 .IP "" 10
658 CONNECTION_HOOK="set > /var/log/sakis3g.environment"
659 .IP " \fBNote:\fP" 16
660 This \fBvariable\fP cannot be used from \fIcommand line\fP for \fIsecurity reasons\fP. It would be risky to allow users provide a \fIcommand\fP to be executed with \fIroot privileges\fP.
661
662 .IP "\fBCUSTOM_APN\fP" 10
663 This \fBvariable\fP defines the \fIAPN\fP (\fIAccess Point Name\fP) that should be used to establish connection, which can be different than the one that \fIinternal database\fP of Sakis3G script indicates, and the one that your modem might remember since its last connection. This \fBvariable\fP is only taken into consideration when \fBAPN variable\fP contains value "\fICUSTOM_APN\fP". If value assigned is not an acceptable \fIAPN\fP by your \fIoperator\fP, connection will fail.
664 .IP "" 10
665 Example:
666 .IP "" 18
667 APN="CUSTOM_APN"
668 CUSTOM_APN="internet.myprovider.com"
669 APN_USER="myphonenumber"
670 APN_PASS="internet123"
671 .IP "" 10
672 See also: \fBAPN\fP, \fBAPN_USER\fP, \fBAPN_PASS\fP, \fBFORCE_APN\fP
673
674 .IP "\fBCUSTOM_TTY\fP" 10
675 This \fBvariable\fP should only contain the full path of an existing \fIcharacter device node\fP. This \fBvariable\fP is only taken into consideration when \fBOTHER variable\fP contains word "\fICUSTOM_TTY\fP" and is used for selecting an already existing \fIcharacter device node\fP offering \fImodem capabilities\fP. If value is not valid, or node does not exist already, value of this variable is discarded.
676 .IP " \fBNote:\fP" 16
677 If \fIcharacter device node\fP resides within \fI/dev\fP directory, then you may just provide its \fIbasename\fP (see example #2).
678 .IP "" 10
679 Examples:
680 .IP " \fB1.\fP" 15
681 Use already existing \fI/dev/ttyS0\fP as a modem.
682 MODEM="OTHER"
683 OTHER="CUSTOM_TTY"
684 CUSTOM_TTY="/dev/ttyS0"
685 .IP " \fB2.\fP" 15
686 Same effect as example above.
687 MODEM="OTHER"
688 OTHER="CUSTOM_TTY"
689 CUSTOM_TTY="ttyS0"
690 .IP "" 10
691 See also: \fBMODEM\fP, \fBOTHER\fP
692
693 .IP "\fBDESKTOP\fP" 10
694 This \fBvariable\fP allows you to specify directory where your \fIdesktop\fP resides. This \fBvariable\fP is only taken into consideration during \fIdesktop shortcut\fP creation. If no value is provided, and DESKTOP \fIenvironment variable\fP exists, it is used instead. If directory specified does not exist and \fB$HOME/$DESKTOP\fP also does not exist, value is discarded. If no directory is found, \fIdesktop shortcut\fP is created within your \fIhome directory\fP.
695 .IP " \fBNote:\fP" 16
696 You may need to set this \fBvariable\fP if you are using a \fIlocalized\fP name for your \fIdesktop folder\fP.
697 .IP "" 10
698 Examples:
699 .IP " \fB1.\fP" 15
700 Point a \fIcustomly named\fP desktop.
701 DESKTOP="/home/myself/FatsaKarta"
702 .IP " \fB2.\fP" 15
703 A more appropriate form, with the same effect, for use within a global \fIconfiguration file\fP.
704 DESKTOP="FatsaKarta"
705
706 .IP "\fBDIAL\fP" 10
707 This \fBvariable\fP forces Sakis3G script to dial whatever is supplied as value, when attempting to establish data connection. Value should only contain \fIdecimal digits\fP or symbols "\fB#\fP" and "\fB*\fP". If an invalid value is supplied, behavior depends on your modem, but it will usually fail to find \fIcarrier\fP. If this value is not set, \fIinternal operators database\fP is consulted to determine phone number to dial. If no value was supplied using this \fBvariable\fP and no entry was found within \fIinternal operators database\fP, default number "\fB*99#\fP" is dialed.
708 .IP "" 10
709 Example:
710 .IP "" 18
711 DIAL="*99***1#"
712
713 .IP "\fBDISPLAY\fP" 10
714 This \fBvariable\fP allows you to explicitly specify the X session display on which Sakis3G UI should appear. If no value is provided, DISPLAY \fIenvironment variable\fP is automatically loaded if available. If loaded value does not refer to a valid local display, it is automatically discarded. If you have no access to display specified, value loaded is automatically discarded. To avoid such thing, either:
715 .IP " \fB*\fP" 13
716 Merge \fIcookie\fP to your \fIauthority file\fP, or
717 Use \fBLOCALAUTHORITY variable\fP to point to an \fIauthority\fP file which contains a valid \fIcookie\fP for display specified.
718 .IP "" 10
719 If no value is provided, or is discarded already, then Sakis3G script will attempt to locate a \fItext-mode UI\fP instead.
720
721 Example:
722 .IP "" 18
723 DISPLAY=":1"
724 .IP "" 10
725 See also: \fBLOCALAUTHORITY\fP
726
727 .IP "\fBDNS\fP" 10
728 This \fBvariable\fP allows you to provide specific \fIDNS servers\fP that should be used after connection with \fIoperator\fP is established. This \fBvariable\fP is only taken into consideration if \fB--nofix switch\fP is \fBnot\fP set. If no value is assigned, \fIDNS server\fP settings provided by \fIoperator\fP are used. If \fIoperator\fP did not provide any \fIDNS servers\fP settings, Sakis3G script will automatically set \fIGoogle DNS servers\fP for your convenience.
729 .IP " \fBNote:\fP" 16
730 If \fB--googledns switch\fP is set, this value will anyway be set to \fIGoogle DNS servers\fP.
731 .IP " \fBExample:\fP" 19
732 Equivalent to \fB--googledns switch\fP.
733 .IP "" 18
734 DNS="8.8.8.8 8.8.4.4"
735
736 .IP "\fBFORCE_APN\fP" 10
737 This \fBvariable\fP defines the \fIAPN\fP (\fIAccess Point Name\fP) that should be used to establish connection, no matter what \fIinternal database\fP of Sakis3G script or your modem might indicate. If value assigned is not an acceptable \fIAPN\fP by your \fIoperator\fP, connection will fail.
738
739 This variable seems like a duplicate to \fBAPN\fP and/or \fBCUSTOM_APN variables\fP but is not:
740 .IP " \fB1.\fP" 13
741 \fBAPN variable\fP can only contain a value found within \fIlist of known operators\fP, or retrieved from your modem's memory.
742 .IP " \fB2.\fP" 13
743 \fBCUSTOM_APN variable\fP can indeed contain any value but causes both \fIinternal database\fP and modem be queried, while seeking for a valid \fIAPN\fP, in cases where \fIoperator\fP was not found within \fIlist of known operators\fP.
744 .IP " \fB3.\fP" 13
745 \fBFORCE_APN variable\fP bypasses all validation, queries to \fIinternal database\fP and query against modem memory to unconditionally set specified \fIAPN\fP.
746 .IP " \fBExamples:\fP" 21
747 .IP " \fB1.\fP" 13
748 \fIOperator\fP is found within \fIdatabase\fP and \fIAPN\fP was also mentioned. \fIUsername\fP and \fIpassword\fP are also retrieved from database and they need not to be mentioned:
749 APN="internet.myprovider.com"
750
751 .IP " \fB2.\fP" 13
752 \fIOperator\fP was not found within \fIdatabase\fP but \fIAPN\fP was retrieved by modem's memory. In this case, you have to supply \fIusername\fP and \fIpassword\fP:
753 APN="internet.myprovider.com"
754 APN_USER="postpay"
755 APN_PASS="internet"
756
757 .IP " \fB3.\fP" 13
758 \fIOperator\fP was not found within \fIdatabase\fP and modem did not report any recent \fIAPN\fP being used. Or, what was found within \fIdatabase\fP is not appropriate for your contract/product. In both cases, you have to supply all information yourself:
759 APN="CUSTOM_APN"
760 CUSTOM_APN="internet.myprovider.com"
761 APN_USER="postpay"
762 APN_PASS="internet"
763
764 .IP " \fB4.\fP" 13
765 No matter if \fIoperator\fP exists or not in \fIdatabase\fP, defined \fIAPN\fP is used and modem is never queried:
766 FORCE_APN="internet.myprovider.com"
767 APN_USER="postpay"
768 APN_PASS="internet"
769
770 .IP " \fB5.\fP" 13
771 An alternative syntax having the same effect with example #4:
772 FORCE_APN="internet.myprovider.com::postpay:internet"
773
774 .IP " \fBNotes:\fP" 17
775 .IP " \fB*\fP" 13
776 You can use \fBFORCE_APN variable\fP to improve performance by skipping \fIinternal database\fP lookups (compare examples #3 and #4).
777 .IP " \fB*\fP" 13
778 \fBFORCE_APN variable\fP offers an alternative syntax which allows setting up \fBAPN_USER\fP and \fBAPN_PASS\fP variables also (compare examples #4 and #5).
779
780 See also: \fBAPN\fP, \fBAPN_USER\fP, \fBAPN_PASS\fP, \fBCUSTOM_APN\fP
781
782 .IP "\fBFORCE_ISP\fP" 10
783 This \fBvariable\fP instructs Sakis3G script to \fIdisable roaming\fP on modem and instead stick with \fInetwork\fP specified in value. Value should contain the \fInumeric ID\fP of \fInetwork\fP to be used. If an invalid value is supplied, behavior depends on your modem (whether it will disconnect from any \fInetwork\fP already registered to, or will remain connected). If \fInetwork\fP specified is not available, or modem refused to \fIregister network\fP, Sakis3G script will refuse to proceed with connection.
784
785 This \fBvariable\fP can be useful, when you live near a country's borders, into avoiding unintended roaming costs. However, this may lead into limited \fInetwork coverage\fP on cases where your \fIoperator\fP transparently (without additional cost) cooperates with another \fInetwork\fP to extend coverage.
786
787 .IP " \fBExample:\fP" 19
788 Force modem to stick with \fBGR COSMOTE\fP.
789 .IP "" 18
790 FORCE_ISP="20201"
791 .IP " \fBNote:\fP" 16
792 To discover your \fInetwork's ID\fP, consult \fIConnection Information\fP after getting connected, or use:
793 .IP "" 18
794 $ sakis3g console info
795
796 .IP "\fBINIT\fP" 10
797 This \fBvariable\fP provides access to initialization \fIAT commands\fP that will be sent to modem. Value provided here is sent to modem just before \fIdialing operator\fP and immediately after Sakis3G script has finished all initialization it should do. This \fBvariable\fP is provided for end-user to be able to supply the \fIweird-non-standard command\fP that might be required by modem for establishing a reliable connection.
798 .IP " \fBNote:\fP" 16
799 Dialing will occur even if \fIAT commands\fP, specified by this value, produced an \fBERROR\fP to modem.
800 .IP " \fBExample:\fP" 19
801 Request some information from modem.
802 .IP "" 19
803 INIT="ATI AT+CGDCONT? AT+COPS=0,2 AT+COPS? AT+COPS=0,0 AT+COPS?"
804 .IP "" 10
805 See also: \fBPREPARE\fP
806
807
808 .IP "\fBLOCALAUTHORITY\fP" 10
809 This \fBvariable\fP allows you to specify an \fIauthority file\fP which contains a valid \fIcookie\fP for X display selected (either by \fIenvironment variable\fP DISPLAY, or by \fBDISPLAY variable\fP). If no value is provided, your own X \fIauthority file\fP is assumed. If value does not refer to an X \fIauthority file\fP, or read access is not granted, it is automatically discarded. If both your own and the alternative X \fIauthority files\fP do not contain a valid \fIcookie\fP for X display selected, Sakis3G script will attempt to locate a \fItext-mode UI\fP instead.
810
811 Example:
812 .IP "" 19
813 XAUTHORITY="/home/sakis/authorities/cryo"
814 .IP "" 10
815 See also: \fBDISPLAY\fP
816
817 .IP "\fBLOG_POSITION\fP" 10
818 This \fBvariable\fP allows you to specify position of \fIlog file\fP that should be used when Sakis3G script is called through \fIudevd\fP. If no value is provided, default value \fI/var/log/sakis3g.log\fP is used. If value provided refers to a non-existing path, value is discarded.
819
820 Example:
821 .IP "" 19
822 LOG_FILE="/var/log/sakis3g/log"
823
824 .IP "\fBMENU\fP" 10
825 This \fBvariable\fP provides a shortcut for \fImenu action\fP that should be followed upon first execution of \fBmenu actor\fP. Value assigned will be discarded after \fBmenu actor\fP is executed, and only after corresponding \fBactor\fP, specified by value, has finished (regardless of success or failure) . Use of this \fBvariable\fP could be avoided since all operations offered by \fBmenu actor\fP are also available as stand-alone \fBactors\fP.
826 .IP "" 10
827 Valid values are:
828 .IP " \fB*\fP" 13
829 \fICONNECT\fP: Calls \fBconnect actor\fP.
830 .IP " \fB*\fP" 13
831 \fIDISCONNECT\fP: Calls \fBdisconnect actor\fP.
832 .IP " \fB*\fP" 13
833 \fIINFO\fP: Calls \fBinfo actor\fP.
834 .IP " \fB*\fP" 13
835 \fIDESKTOP\fP: Calls \fBdesktop actor\fP.
836 .IP " \fB*\fP" 13
837 \fIABOUT\fP: Calls \fBabout actor\fP.
838 .IP " \fB*\fP" 13
839 \fIMOREMENU\fP: Calls \fBmoremenu actor\fP.
840 .IP " \fB*\fP" 13
841 \fIEXIT\fP: Forces \fBmenu actor\fP to return \fI98\fP on exit, preventing execution of remaining \fBactors\fP within currently executed \fBchain\fP.
842 .IP "" 10
843 If value assigned is not valid, it is automatically discarded. This is essentially true when:
844 .IP " \fB*\fP" 13
845 Value assigned is "\fIDISCONNECT\fP", "\fIINFO\fP", "\fIDESKTOP\fP" while not connected.
846 .IP " \fB*\fP" 13
847 Value assigned is "\fICONNECT\fP" while already connected.
848 .IP "" 10
849 .IP " \fBExamples:\fP" 21
850 .IP " \fB1.\fP" 13
851 Implement splash-like functionality for the first time that \fImenu\fP will appear.
852 MENU="ABOUT"
853 .IP " \fB2.\fP" 13
854 Force \fImenu\fP not to appear. However, defining \fBmenu actor\fP twice, will eventually make \fImenu\fP appear.
855 MENU="EXIT"
856 .IP "" 10
857 See also: \fBMOREMENU\fP
858
859 .IP "\fBMENUFONT\fP"
860 This \fBvariable\fP defines \fIfont\fP that should be used when using \fI9menu\fP for displaying \fIUI\fP. If no value is provided, default value "\fI-monotype-arial-medium-r-normal-*-18-*-*-*-*-*-*-*\fP" is loaded. If value specified refers to a \fIfont\fP not available in system, \fI9menu\fP replaces it with a valid one. You can use \fIxlsfonts\fP or \fIxfontsel\fP utilities for discovering/constructing a valid \fIfont string\fP.
861 .IP "" 10
862 Examples:
863 .IP " \fB*\fP" 13
864 MENUFONT="-unknown-freesans-medium-r-normal-*-17-*-*-*-*-*-*-*"
865 .IP " \fB*\fP" 13
866 MENUFONT="-dejavu-sans-medium-r-normal-*-18-*-*-*-*-*-*-*"
867 .IP "" 10
868 See also: \fBAOSDFONT\fP, \fBOSDFONT\fP, \fBXOSDFONT\fP
869
870 .IP "\fBMODEM\fP" 10
871 This \fBvariable\fP is expected to either hold \fIUSB IDs\fP of the \fIUSB modem\fP which is going to be used for getting connected, or the word "\fIOTHER\fP". If word "\fIOTHER\fP" is found, device selection procedure will refer to \fBOTHER variable\fP for locating modem that will be used. If provided value refers to a \fIUSB modem\fP not currently connected, its contents are discarded.
872 .IP " \fB*\fP" 13
873 If no value is loaded (or loaded value was discarded previously) and only one \fIUSB modem\fP is detected, this one \fIUSB modem\fP is automatically selected.
874 .IP " \fB*\fP" 13
875 If no value is loaded (or loaded value was discarded previously) and no other \fIUSB modem\fP is detected, it is automatically loaded with the "\fIOTHER\fP" value.
876 .IP "" 10
877 Therefore, use of \fBMODEM variable\fP is only meaningful when:
878 .IP " \fB1.\fP" 13
879 There are more than two \fIUSB modems\fP plugged and you need to select a specific one (see example #1).
880 .IP " \fB2.\fP" 13
881 Your \fIUSB device\fP is not automatically detected as a \fIUSB modem\fP (see example #3).
882 .IP " \fB3.\fP" 13
883 Your modem is not a \fIUSB modem\fP (see example #4).
884 .IP "" 10
885 Examples:
886 .IP " \fB1.\fP" 13
887 Select one among many modems.
888 MODEM="19d2:2000"
889 .IP " \fB2.\fP" 13
890 Force script to always ask about modem type.
891 MODEM="OTHER"
892 .IP " \fB3.\fP" 13
893 Consider a \fIUSB device\fP as a \fIUSB modem\fP.
894 MODEM="OTHER"
895 OTHER="USBMODEM"
896 USBMODEM="19d2:2001"
897 .IP " \fB4.\fP" 13
898 Define a specific \fItty\fP as an already setup modem.
899 MODEM="OTHER"
900 OTHER="CUSTOM_TTY"
901 CUSTOM_TTY="/dev/ttyS1"
902 .IP "" 10
903 See also: \fBOTHER\fP, \fBUSBMODEM\fP, \fBBLUETOOTH\fP, \fBCUSTOM_TTY\fP
904
905 .IP "\fBMOREMENU\fP" 10
906 This \fBvariable\fP provides a shortcut for \fImenu action\fP that should be followed upon first execution of \fBmoremenu actor\fP. Value assigned will be discarded after \fBmoremenu actor\fP is executed, and only after corresponding \fBactor\fP, specified by value, has finished (regardless of success or failure) . Use of this \fBvariable\fP could be avoided since all operations offered by \fBmoremenu actor\fP are also available as stand-alone \fBactors\fP.
907 .IP "" 10
908 Valid values are:
909 .IP " \fB*\fP" 13
910 \fICONNECT\fP: Calls \fBconnect actor\fP.
911 .IP " \fB*\fP" 13
912 \fIRECONNECT\fP: Calls \fBreconnect actor\fP.
913 .IP " \fB*\fP" 13
914 \fIDISCONNECT\fP: Calls \fBdisconnect actor\fP.
915 .IP " \fB*\fP" 13
916 \fIPREPARE\fP: Calls \fBprepare actor\fP.
917 .IP " \fB*\fP" 13
918 \fISETUP\fP: Calls \fBsetup actor\fP.
919 .IP " \fB*\fP" 13
920 \fISWITCH\fP: Calls \fBswitchonly actor\fP.
921 .IP " \fB*\fP" 13
922 \fICOMPILE\fP: Calls \fBrecompile actor\fP.
923 .IP " \fB*\fP" 13
924 \fIINFO\fP: Calls \fBinfo actor\fP.
925 .IP " \fB*\fP" 13
926 \fIREPORT\fP: Calls \fBreport actor\fP.
927 .IP " \fB*\fP" 13
928 \fIDESKTOP\fP: Calls \fBdesktop actor\fP.
929 .IP " \fB*\fP" 13
930 \fIABOUT\fP: Calls \fBabout actor\fP.
931 .IP " \fB*\fP" 13
932 \fIHELP\fP: Calls \fBshowhelp actor\fP.
933 .IP " \fB*\fP" 13
934 \fIEXIT\fP: Forces \fBmoremenu actor\fP to return \fI98\fP on exit, preventing execution of remaining \fBactors\fP within currently executed \fBchain\fP.
935 .IP "" 10
936 If value assigned is not valid, it is automatically discarded. This is essentially true when:
937 .IP " \fB*\fP" 13
938 Value assigned is "\fIDISCONNECT\fP", "\fIRECONNECT\fP", "\fIINFO\fP", "\fIREPORT\fP" while not connected.
939 .IP " \fB*\fP" 13
940 Value assigned is "\fICONNECT\fP", "\fIPREPARE\fP", "\fISETUP\fP", "\fISWITCH\fP" while already connected.
941 .IP "" 10
942 .IP " \fBExamples:\fP" 21
943 .IP " \fB1.\fP" 13
944 Implement splash-like functionality for the first time that \fImenu\fP will appear.
945 MOREMENU="ABOUT"
946 .IP " \fB2.\fP" 13
947 Force \fImenu\fP not to appear. However, defining \fBmoremenu actor\fP twice, will eventually make \fImenu\fP appear.
948 MOREMENU="EXIT"
949 .IP "" 10
950 See also: \fBMENU\fP
951
952 .IP "\fBOSDFONT\fP" 10
953 This \fBvariable\fP defines \fIfont string\fP that should be used when displaying \fIOSD messages\fP regardless of backend utility. It just sets both \fBAOSDFONT\fP and \fBXOSDFONT variables\fP to the same content. It is user's responsibility to supply \fIfont string\fP expected by selected \fIOSD\fP backend.
954 .IP " \fBExamples:\fP" 21
955 .IP " \fB1.\fP" 13
956 Defining a font appropriate for use with aosd_cat
957 OSDFONT="DejaVuSans 24"
958 .IP " \fB2.\fP" 13
959 Defining a font appropriate for use with osd_cat
960 OSDFONT="-misc-fixed-medium-r-semicondensed--36-*-*-*-c-*-*-*"
961 .IP "" 10
962 See also: \fBAOSDFONT\fP, \fBXOSDFONT\fP
963
964 .IP "\fBOTHER\fP" 10
965 This \fBvariable\fP should only contain one of possible values. It is only taken into consideration if \fBMODEM variable\fP contains word "\fIOTHER\fP" and is used for determining type of modem. According to its value, device selection procedure will refer to \fBUSBMODEM\fP, \fBBLUETOOTH\fP or \fBCUSTOM_TTY variable\fP for locating modem that will be used.
966 .IP " \fBExamples:\fP" 21
967 .IP " \fB1.\fP" 13
968 Modem is a \fIUSB modem\fP.
969 MODEM="OTHER"
970 OTHER="USBMODEM"
971 .IP " \fB2.\fP" 13
972 Modem is a \fIBluetooth modem\fP.
973 MODEM="OTHER"
974 OTHER="BLUETOOTH"
975 .IP " \fB3.\fP" 13
976 3. Modem is already setup and a \fItty\fP already exist.
977 MODEM="OTHER"
978 OTHER="CUSTOM_TTY"
979 See also: \fBMODEM\fP, \fBUSBMODEM\fP, \fBBLUETOOTH\fP, \fBCUSTOM_TTY\fP
980
981 .IP "\fBPPPD_OPTIONS\fP" 10
982 This \fBvariable\fP allows you to modify \fIarguments\fP that will be passed to \fIpppd daemon\fP. This \fBvariable\fP is only taken into consideration when \fIwvdial\fP is not installed, or when \fB--pppd switch\fP is set. If no values are provided, default values are used.
983
984 Default values used when no value is supplied are:
985 .IP "" 12
986 modem crtscts -detach defaultroute dump
987 noipdefault replacedefaultroute usepeerdns
988 usehostname ktune logfd 2 noauth name sakis3g
989 lock maxfail 3
990 .IP "" 10
991 If, within \fIdirectory\fP denoted by \fBPPPD_PEERS variable\fP, exists a \fIpeer\fP (a file) named \fIsakis3g\fP, then:
992 .IP " \fB*\fP" 13
993 this \fBvariable\fP is ignored, and
994 .IP " \fB*\fP" 13
995 \fIdaemon pppd\fP is called with the following arguments:
996 .IP "" 15
997 -detach dump logfd 2
998 maxfail 3 name sakis3gpeer call sakis3g
999 .IP " \fB*\fP" 13
1000 and you should instead edit file \fIPPPD_PEERS/sakis3g\fP to modify \fIpppd options\fP.
1001 .IP " \fBNote:\fP" 16
1002 You should avoid specifying \fIbaud rate\fP within this \fBvariable\fP and instead use \fBBAUD variable\fP. Specifying \fIbaud rate\fP using
1003 \fBPPPD_OPTIONS\fP will result into two \fIbaud rates\fP (possibly different) being passed to \fIpppd\fP, leading to doubts on which one will
1004 be used.
1005 .IP " \fBExample:\fP" 20
1006 Options to \fIpppd\fP are read from file \fI/home/sakis/custom\fP
1007 .IP "" 15
1008 PPPD_PEERS="/home/sakis"
1009 PPPD_OPTIONS="call custom"
1010 .IP "" 10
1011 See also: \fBBAUD\fP, \fBPPPD_PEERS\fP
1012
1013 .IP "\fBPPPD_PEERS\fP"
1014 This \fBvariable\fP allows you to specify \fIdirectory\fP where \fIpppd peer files\fP are located. If no value is provided, default value "\fI/etc/ppp/peers\fP" is used. If:
1015 .IP " \fB*\fP" 13
1016 \fIdirectory\fP specified exists, and
1017 .IP " \fB*\fP" 13
1018 within \fIdirectory\fP a file named \fIsakis3g\fP exists, and
1019 .IP " \fB*\fP" 13
1020 \fIwvdial\fP is not installed, or \fB--pppd switch\fP is set, then
1021 .IP "" 10
1022 \fIpppd\fP is instructed to read \fIoptions\fP from \fIPPPD_PEERS/sakis3g\fP.
1023
1024 .IP " \fBExample:\fP" 20
1025 Let it check for if file \fI/etc/ppp/peers/custom/sakis3g\fP exists.
1026 .IP "" 15
1027 PPPD_PEERS="/etc/ppp/peers/custom"
1028 .IP "" 10
1029 See also: \fBPPPD_OPTIONS\fP
1030
1031 .IP "\fBPPPINT\fP" 10
1032 This \fBvariable\fP allows you to specify \fIinterface name\fP your system uses for \fIP-t-P connection\fP. If no value is provided, default value "\fIppp0\fP" is used. This value is only taken into consideration when checking status of connection.
1033
1034 This value is not taken into consideration when disconnecting:
1035 .IP " \fB*\fP" 13
1036 All active \fIpppd sessions\fP are terminated, eliminating all your \fIP-t-P connections\fP.
1037 .IP " \fB*\fP" 13
1038 While disconnecting, this script will \fIkill\fP all running \fIpppd\fP instances, thus eliminating any other \fIP-t-P connections\fP you might have running.
1039 .IP " \fBNotes:\fP" 18
1040 .IP " \fB*\fP" 19
1041 If value provided does not match \fIinterface name\fP created, you should expect some serious Sakis3G script malfunctions to occur.
1042 .IP " \fB*\fP" 19
1043 If you have a complex setup (i.e. \fIbridging\fP across \fIppp connections\fP or \fImultilink ppp\fP connections), you should \fBNOT\fP (need to) use this script, as it also messes up with your \fIrouting tables\fP: you were warned.
1044 .IP " \fBExample:\fP" 20
1045 Use \fIppp1\fP instead of \fIppp0\fP.
1046 .IP "" 15
1047 PPPINT="ppp1"
1048 PPPD_OPTIONS="unit 1 ...
1049
1050 .IP "\fBPREPARE\fP" 10
1051 This \fBvariable\fP allows you to send custom \fIAT commands\fP to modem. \fIAT commands\fP specified here are sent to modem before \fIany\fP other command is sent.
1052 .IP " \fBNote:\fP" 16
1053 Procedure will carry on even if \fIAT commands\fP, specified by this value, produced an \fBERROR\fP to modem.
1054 .IP " \fBExample:\fP" 19
1055 Make sure \fIECHO\fP is turned on.
1056 .IP "" 19
1057 PREPARE="ATE1"
1058 .IP "" 10
1059 See also: \fBINIT\fP
1060
1061 .IP "\fBRFCHANNEL\fP" 10
1062 This \fBvariable\fP should contain the decimal representation of an \fIRFCOMM channel\fP of the \fIBluetooth device\fP previously defined using \fBBLUETOOTH\fP or \fBUNDISCOVERABLE variables\fP. This \fBvariable\fP is only taken into consideration when \fBRFSERVICE\fP variable contains word "\fIRFCHANNEL\fP". If value is not valid, or \fIRFCOMM channel\fP defined, is not available/valid in device, connection will be impossible.
1063
1064 .IP " \fBNote:\fP" 17
1065 Even if device reports \fIRFCOMM channel\fP, you may find defining it through \fBRFCHANNEL variable\fP more convenient (see examples #2 and #3). This can save you a couple of seconds by avoiding querying \fIBluetooth device\fP for available services. Examples #1 and #3 have exactly the same effect if device and appropriate channel are \fIdiscoverable\fP. However, example #3 skips all validation saving up to 6 seconds. Keep in mind, this may lead into problems if device is currently out of range.
1066 .IP " \fBExamples:\fP" 21
1067 .IP " \fB1.\fP" 13
1068 Define \fIdiscoverable\fP channel.
1069 MODEM="OTHER"
1070 OTHER="BLUETOOTH"
1071 BLUETOOTH="00:25:47:59:AA:00"
1072 RFSERVICE="1"
1073 .IP " \fB2.\fP" 13
1074 Define \fIundiscoverable\fP channel.
1075 MODEM="OTHER"
1076 OTHER="BLUETOOTH"
1077 BLUETOOTH="00:25:47:59:AA:00"
1078 RFSERVICE="RFCHANNEL"
1079 RFCHANNEL="1"
1080 .IP " \fB3.\fP" 13
1081 Skip all validation.
1082 MODEM="OTHER"
1083 OTHER="BLUETOOTH"
1084 BLUETOOTH="UNDISCOVERABLE"
1085 UNDISCOVERABLE="00:25:47:59:AA:00"
1086 RFSERVICE="RFCHANNEL"
1087 RFCHANNEL="1"
1088 .IP "" 10
1089 See also: \fBBLUETOOTH\fP, \fBMODEM\fP, \fBOTHER\fP, \fBRFSERVICE\fP, \fBUNDISCOVERABLE\fP
1090
1091
1092 .IP "\fBRFSERVICE\fP" 10
1093 This \fBvariable\fP should contain the decimal representation of a \fIdiscoverable RFCOMM channel\fP of the Bluetooth device previously defined using \fBBLUETOOTH\fP or \fBUNDISCOVERABLE variables\fP. If value is not valid, or \fIRFCOMM channel\fP was not reported by device, value of this \fBvariable\fP is discarded. If this \fBvariable\fP is loaded with the "\fIRFCHANNEL\fP" value, device selection procedure skips validating \fIRFCOMM channel\fP by querying Bluetooth device and uses channel defined by \fBRFCHANNEL variable\fP unconditionally.
1094
1095 .IP " \fBNote:\fP" 17
1096 Even if device reports \fIRFCOMM channel\fP, you may find defining it through \fBRFCHANNEL variable\fP more convenient (see examples #2 and #3). This can save you a couple of seconds by avoiding querying \fIBluetooth device\fP for available services. Examples #1 and #3 have exactly the same effect if device and appropriate channel are \fIdiscoverable\fP. However, example #3 skips all validation saving up to 6 seconds. Keep in mind, this may lead into problems if device is currently out of range.
1097 .IP " \fBExamples:\fP" 21
1098 .IP " \fB1.\fP" 13
1099 Define \fIdiscoverable\fP channel.
1100 MODEM="OTHER"
1101 OTHER="BLUETOOTH"
1102 BLUETOOTH="00:25:47:59:AA:00"
1103 RFSERVICE="1"
1104 .IP " \fB2.\fP" 13
1105 Define \fIundiscoverable\fP channel.
1106 MODEM="OTHER"
1107 OTHER="BLUETOOTH"
1108 BLUETOOTH="00:25:47:59:AA:00"
1109 RFSERVICE="RFCHANNEL"
1110 RFCHANNEL="1"
1111 .IP " \fB3.\fP" 13
1112 Skip all validation.
1113 MODEM="OTHER"
1114 OTHER="BLUETOOTH"
1115 BLUETOOTH="UNDISCOVERABLE"
1116 UNDISCOVERABLE="00:25:47:59:AA:00"
1117 RFSERVICE="RFCHANNEL"
1118 RFCHANNEL="1"
1119 .IP "" 10
1120 See also: \fBBLUETOOTH\fP, \fBMODEM\fP, \fBOTHER\fP, \fBRFCHANNEL\fP, \fBUNDISCOVERABLE\fP
1121
1122
1123 .IP "\fBSGUI\fP" 10
1124 This \fBvariable\fP defines \fIUI\fP that should be used, overriding the one that Sakis3G script would automatically select. If value is not within list of valid values, it is automatically discarded and \fIUI\fP selection procedure will proceed like this \fBvariable\fP was never set.
1125
1126 If value specified refers to a UI not currently available, it is automatically discarded:
1127 .IP " \fB1.\fP" 13
1128 If you selected a \fIgraphical UI\fP while no X session exists, or
1129 .IP " \fB2.\fP" 13
1130 If utility required for selected \fIUI\fP was not found within \fBPATH\fP.
1131 .IP "" 10
1132 Valid values are:
1133 .IP "" 12
1134 \fBText mode\fP \fBGraphics mode\fP
1135
1136 \fB*\fP terminal \fB*\fP xterm
1137 \fB*\fP interactive terminal \fB*\fP konsole
1138 \fB*\fP dialog \fB*\fP gnome-terminal
1139 \fB*\fP whiptail \fB*\fP 9menu
1140 \fB*\fP Xdialog
1141 \fB*\fP kdialog
1142 \fB*\fP zenity
1143 .IP "" 10
1144 Keep in mind that:
1145 .IP " \fB*\fP" 12
1146 All values, except "\fIterminal\fP", also set \fB--interactive switch\fP.
1147 .IP " \fB*\fP" 12
1148 Values "\fIxterm\fP", "\fIkonsole\fP" and "\fIgnome-terminal\fP" spawn corresponding \fIterminal emulation\fP utility, within which Sakis3G script is executed, with \fB--console switch\fP enabled, leading into one of "\fIwhiptail\fP", "\fIdialog\fP" or "\fIinteractive terminal\fP" being selected as \fIUI\fP.
1149 .IP " \fBNotes:\fP" 18
1150 .IP " \fB*\fP" 19
1151 There is no way to affect \fIUI\fP that will be used by newly spawned Sakis3G script instance within \fIterminal emulation\fP utility.
1152 .IP " \fB*\fP" 19
1153 You can easily render Sakis3G script invisible (thus, unusable) by modifying \fIdesktop shortcut\fP so that it appoints \fBSGUI variable\fP a value referring to a \fItext mode UI\fP. This way, whenever you double-click \fIdesktop shortcut\fP, Sakis3G script will actually being started, but its \fIoutput\fP will end-up to void.
1154 .IP " \fBExamples:\fP" 21
1155 .IP " \fB1.\fP" 13
1156 Use \fI9menu\fP:
1157 SGUI="9menu"
1158 .IP " \fB2.\fP" 13
1159 Use \fIdialog\fP:
1160 SGUI="dialog"
1161
1162 .IP "\fBSIM_PIN\fP" 10
1163 This \fBvariable\fP allows you to explicitly provide \fIPIN number\fP that should be used if \fISIM card\fP placed inside modem requires it. This value is only utilized when modem reports that \fISIM card\fP needs \fIPIN number\fP. If value provided is not consisted of exactly four decimal digits, it is automatically discarded. If no value is provided, or is discarded already, then Sakis3G script:
1164 .IP " \fB*\fP" 13
1165 will ask you to provide it, if selected \fIUI\fP allows it, or
1166 .IP " \fB*\fP" 13
1167 will abort execution, if selected \fIUI\fP does not provide a way to ask you.
1168 .IP " \fBNotes:\fP" 18
1169 .IP " \fB*\fP" 19
1170 If value supplied, by any means, is rejected by modem, Sakis3G script will immediately cease operation to prevent you from having your \fISIM card PIN-blocked\fP, from accidental consequent failed attempts. If forementioned failed attempt, had been the last one allowed by your \fISIM card\fP, then you just succeed into \fIPIN-blocking\fP your \fISIM card\fP.
1171 .IP " \fB*\fP" 19
1172 When modem reports \fISIM card\fP needs another kind of number (PIN #2, PUK, PUK #2), Sakis3G script will refuse to proceed. You might temporarily place your \fISIM card\fP to a \fIcellular phone\fP, unlock card so that it asks for \fIPIN number\fP instead.
1173 .IP " \fBExample:\fP" 20
1174 .IP "" 15
1175 SIM_PIN="1212"
1176
1177 .IP "\fBTRANSLATION\fP" 10
1178 This \fBvariable\fP defines full path name of translation file that should be used. This is useful for testing purposes, when creating a new translation for Sakis3G script. Setting this \fBvariable\fP \fIempty\fP will not succeed into preventing Sakis3G script from using translations. If you want to prevent translations you should use \fB--notranslate switch\fP.
1179
1180 \fBExample:\fP
1181
1182 TRANSLATION="/home/sakis/Documents/sakis3g.translation.txt"
1183
1184 .IP "\fBUNDISCOVERABLE\fP" 10
1185 This \fBvariable\fP should only contain a valid \fIBluetooth address\fP of a Bluetooth device. If value is not valid, or device is not currently within range, connecting will be impossible. This \fBvariable\fP is only taken into consideration when \fBBLUETOOTH variable\fP contains word "\fIUNDISCOVERABLE\fP" and is used for manually specifying the \fIBluetooth address\fP of a \fIundiscoverable\fP Bluetooth device.
1186 .IP " \fBNote:\fP" 17
1187 Even if device is \fIdiscoverable\fP, you may find defining it as \fIundiscoverable\fP more convenient (see example #2). This can save you a couple of seconds by avoiding scan of Bluetooth devices.
1188 .IP " \fBExamples:\fP" 21
1189 .IP " \fB1.\fP" 13
1190 Define \fIdiscoverable\fP device.
1191 MODEM="OTHER"
1192 OTHER="BLUETOOTH"
1193 BLUETOOTH="00:25:47:59:AA:00"
1194 .IP " \fB2.\fP" 13
1195 Define \fIundiscoverable\fP device.
1196 MODEM="OTHER"
1197 OTHER="BLUETOOTH"
1198 BLUETOOTH="UNDISCOVERABLE"
1199 UNDISCOVERABLE="00:25:47:59:AA:00"
1200 .IP "" 10
1201 See also: \fBMODEM\fP, \fBOTHER\fP, \fBBLUETOOTH\fP
1202
1203 .IP "\fBUSBDRIVER\fP" 10
1204 This \fBvariable\fP should contain the name of \fIkernel module\fP that should be bound to \fIUSB interface\fP which provides a usable data modem, for corresponding \fIdevice node\fP to be created. If assigned value is not valid, or if this \fIkernel module\fP does not exist, value is discarded. If no value is assigned, or value was discarded previously, script will seek for a candidate driver. If no candidate is found, it automatically selects \fBoption\fP \fImodule\fP. It can sometimes be useful that you explicitly define \fBoption\fP \fImodule\fP, to avoid having to select it among other candidates.
1205 .IP " \fBExamples:\fP" 21
1206 .IP " \fB1.\fP" 13
1207 Select \fBcdc_acm\fP \fImodule\fP:
1208 USBDRIVER="cdc_acm"
1209 .IP " \fB2.\fP" 13
1210 Explicitly select \fBoption\fP \fImodule\fP:
1211 USBDRIVER="option"
1212 .IP "" 10
1213 See also: \fBUSBINTERFACE\fP
1214
1215 .IP "\fBUSBINTERFACE\fP" 10
1216 This \fBvariable\fP should contain the decimal representation of \fIUSB interface\fP that should be used. If assigned value is not valid, or if this \fIinterface number\fP does not exist, value is discarded.
1217 .IP " \fBExample:\fP" 20
1218 Select \fIinterface\fP #3:
1219 .IP "" 20
1220 USBINTERFACE="3"
1221 .IP "" 10
1222 See also: \fBUSBDRIVER\fP
1223
1224 .IP "\fBUSBMODEM\fP" 10
1225 This \fBvariable\fP should only contain \fIUSB IDs\fP of a currently connected \fIUSB device\fP. If value is not valid, or device is not currently connected, value of this \fBvariable\fP is discarded. This \fBvariable\fP is only taken into consideration when \fBOTHER variable\fP contains word "\fIUSBMODEM\fP" and is used for selecting the \fIUSB device\fP which is actually a modem.
1226
1227 While this \fBvariable\fP looks an equivalent to \fBMODEM variable\fP, they actually differ:
1228 .IP " \fB*\fP" 13
1229 \fBMODEM variable\fP considers valid \fIUSB IDs\fP those listed within its Sakis3G \fIdevice database\fP, or within \fIembedded\fP \fBUsb-Modeswitch\fP \fIdevice database\fP.
1230 .IP " \fB*\fP" 13
1231 \fBUSBMODEM variable\fP considers valid all \fIUSB IDs\fP of currently connected \fIUSB devices\fP.
1232 .IP " \fBExample:\fP" 20
1233 Consider a \fIUSB device\fP as a \fIUSB modem\fP:
1234 .IP "" 20
1235 MODEM="OTHER"
1236 OTHER="USBMODEM"
1237 USBMODEM="19d2:2001"
1238 .IP "" 10
1239 See also: \fBMODEM\fP, \fBOTHER\fP, \fBUSBDRIVER\fP, \fBUSBINTERFACE\fP
1240
1241 .IP "\fBXOSDFONT\fP" 10
1242 This \fBvariable\fP defines \fIfont\fP that should be used when displaying \fIOSD messages\fP using \fIosd_cat\fP utility. If no value is provided, default value "\fI-*-freesans-bold-r-*-*-36-*-*-*-*-*-*-*\fP" is loaded. If value specified refers to a \fIfont\fP not available in system, \fIosd_cat\fP does not display message requested. You can use \fIxlsfonts\fP or \fIxfontsel\fP utilities for discovering/constructing a valid \fIfont string\fP.
1243 .IP " \fBExamples:\fP" 21
1244 .IP "" 10
1245 XOSDFONT="-*-helvetica-*-r-*-*-36-*-*-*-*-*-*-*"
1246
1247 XOSDFONT="-adobe-helvetica-*-r-*-*-24-*-*-*-*-*-*-*"
1248
1249 XOSDFONT="-misc-fixed-medium-r-semicondensed--36-*-*-*-c-*-*-*"
1250
1251 XOSDFONT="-monotype-arial-medium-r-normal-*-36-*-*-*-*-*-*-*"
1252 .IP "" 10
1253 See also: \fBAOSDFONT\fP, \fBMENUFONT\fP, \fBOSDFONT\fP
1254
1255
1256 .SH "SEE ALSO"
1257 .PP
1258 \fBsakis3g\fR(1), \fBchat\fP(8), \fBpppd\fP(8)
1259
1260 .SH "AUTHOR"
1261 .PP
1262 Sakis3G script and this man page are written by Sakis Dimopoulos (sakis at project's domain). Official page of project is at:
1263 .PP
1264 http://www.sakis3g.org/
1265 .PP
1266 Official documentation of latest Sakis3G script version, is available at:
1267 .PP
1268 http://wiki.sakis3g.org/
1269 .SH "LICENSE"
1270 .PP
1271 Sakis3G script is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
1272 .PP
1273 This program is distributed in the hope that it will be useful, but \fBWITHOUT ANY WARRANTY\fR; without even the implied warranty of \fBMERCHANTABILITY\fR or \fBFITNESS FOR A PARTICULAR PURPOSE\fR. See the GNU General Public License for more details:
1274 .PP
1275 http://www.gnu.org/licenses/gpl.txt
1276 .PP
1277 Above statement includes additional charges you may receive from your operator by using this program, defects to your SIM card including but not limited to being PIN blocked, defects on your hardware, 3G service abuse ban etc. \fBUSE WITH CARE\fR. Author of this program or authors of any of its dependencies have no responsibility for what may happen to you.
1278 .PP
1279 Author is not related in any way with any of the companies, being operators or modem manufacturers, other than being a customer to some of them. Logos and trademarks mentioned by this package belong to their respective owners.
1280 .PP
1281 This program, in order to remain as self-contained as possible, includes original source packages of some of its dependencies. You should consult their respective COPYING and README files to identify terms under which they are redistributed by Sakis3G script.
1282
0 ##1
1 "About Sakis3G"
2 "Über Sakis3G"
3 "Acquiring exclusive lock to HAL"
4 "Erlange exklusiven Zugriff auf HAL"
5 "Acquiring root privileges"
6 "Erlange root-Rechte"
7 "Already selected value %s=\"%s\". Is not valid.\n"
8 "Schon ausgewählter Wert %s=\"%s\". ist nicht gültig.\n"
9 "APN:\t\t\t%s"
10 "APN:\t\t\t%s"
11 "Available options are:\n"
12 "Verfügbare Optionen sind:\n"
13 "Bluetooth modem"
14 "Bluetooth Modem"
15 "Both \"%s\" and \"%s\" are missing."
16 "Beide Werte \"%s\" und \"%s\" fehlen."
17 "Cancel"
18 "Abbruch"
19 "Checking dependencies"
20 "Überprüfe Abhängigkeiten"
21 "Checking tools availability"
22 "Überprüfe Verfügbarkeit von Tools"
23 "Choose action for Sakis3G script to follow."
24 "Wähle eine der folgenden Aktionen für Sakis3G script:"
25 "Cleaning"
26 "Bereinigen"
27 "Compile embedded Usb-ModeSwitch"
28 "Kompiliere eingebettetes Usb-ModeSwitch"
29 "Compiling"
30 "Kompiliere"
31 "Connected."
32 "Verbunden."
33 "Connected"
34 "Verbunden"
35 "Connected since:\t%s\n"
36 "Verbunden seit:\t%s\n"
37 "Connected to %s."
38 "Verbunden mit %s."
39 "Connected to %s (%s)."
40 "Verbunden mit %s (%s)."
41 "Connecting"
42 "Verbinde..."
43 "Connecting (second attempt)"
44 "Verbinde... (zweiter Versuch)"
45 "Connection information"
46 "Verbindungsinformation"
47 "Connection Information"
48 "Verbindungsinformation"
49 "Connect with 3G"
50 "Verbinden mit 3G"
51 "Create desktop shortcut"
52 "Erzeuge Desktop-Link"
53 "Create shortcut"
54 "Erzeuge Link"
55 "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\n\n"
56 "(c) Sakis Dimopoulos 2009, 2010 unter GNU GPL v2\nÜbersetzung durch Hartmut Giessmann\n"
57 "Custom APN..."
58 "Eigener APN..."
59 "Custom tty..."
60 "Eigenes tty..."
61 "Default route(s):\t%s\n"
62 "Standard Route: \t%s\n"
63 "Desktop icon"
64 "Desktop Icon"
65 "Desktop shortcut created at %s."
66 "Desktop-Link erzeugt in %s."
67 "Device did not report GSM capabilities. You can skip this by adding --noprobe command line switch.\n"
68 "Gerät meldet keine GSM-Verbindungen. Sie können dies durch Hinzufügen des --noprobe Kommandozeilenschalters überspringen.\n"
69 "Device node \"%s\" does not exist.\n"
70 "Geräteadresse \"%s\" existiert nicht.\n"
71 "Device node \"%s\" does not exist. Setup failed."
72 "Geräteadresse \"%s\" existiert nicht. Setup fehlerhaft."
73 "Device:\t\t\t%s\n"
74 "Gerät:\t\t\t%s\n"
75 "Disconnect"
76 "Verbindung trennen"
77 "Disconnect and then connect again"
78 "Verbindung trennen und wieder verbinden"
79 "Disconnected.\n"
80 "Verbindung getrennt.\n"
81 "Disconnecting"
82 "trenne Verbindung"
83 "Either enable interactive mode:\n"
84 "Ermögliche interaktiven Modus:\n"
85 "Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly. Start by issueing: %s recompile"
86 "Integriertes USB-ModeSwitch-Binary ist nicht für Ihre Architektur zugelassen. Sie müssen neu kompilieren um Geräte erfolgreich umzuschalten. Starte Vorgang mit: %s recompile"
87 "Enter Bluetooth address"
88 "Geben Sie die Bluetooth Adresse ein"
89 "Enter Bluetooth address of undiscoverable device, or leave empty to abort"
90 "Geben Sie die Bluetooth-Adresse des nicht erkannten Gerätes ein oder keine Eingabe um abzubrechen"
91 "Enter correct APN, or leave empty to abort. Contact your operator if unsure"
92 "Geben Sie den korrekten APN ein oder keine Eingabe, um abzubrechen. Kontaktieren Sie ihren GSM-Anbieter, wenn Sie sich nicht sicher sind"
93 "Enter name of appropriate kernel module that should be used, or leave empty to abort"
94 "Geben Sie den Namen des zu nutzenden passenden Kernelmodules, oder keine Eingabe um abzubrechen"
95 "Enter password required by APN, or leave empty to abort. Contact your operator if unsure. This information is usually easily retrieved through a fast call to customer support"
96 "Geben Sie das Passwort für APN ein, oder nichts, um abzubrechen. Kontaktieren Sie Ihren GSM-Anbieter wenn Sie sich nicht sicher sind. Diese Information ist für gewöhnlich bei Ihrem Anbieter-Benutzersupport erhältlich."
97 "Enter RFCOMM channel that should be used, or leave empty to abort [1-255]"
98 "Geben Sie den zu nutzenden RFCOMM-Kanal ein, oder nichts, um abzubrechen [1-255]"
99 "Enter tty node where your 3G modem resides, or leave empty to abort"
100 "Geben Sie den tty-Node ein, an dem Ihr 3G-Modem hängt, oder nichts, um abzubrechen."
101 "Enter username required by APN, or leave empty to abort. Contact your operator if unsure. This information, along with APN password, is usually easily retrieved through a fast call to customer support"
102 "Geben Sie den erforderlichen APN-Usernamen ein, oder nichts, um abzubrechen. Kontaktieren Sie Ihren GSM-Anbieter, wenn Sie sich nicht sicher sind. Diese Information, zusammen mit dem APN-Passwort, erhalten Sie für gewöhnlich bei Ihrem Anbieter-Benutzersupport."
103 "Error"
104 "Fehler"
105 "Error occured"
106 "Fehler aufgetreten"
107 "Exit"
108 "Ende"
109 "Failed to become root."
110 "Fehler beim Wechsel zu root."
111 "Failed to compile. Compilation output:\n%s\n"
112 "Kann nicht kompilieren. Siehe Ausgabe:\n%s\n"
113 "Failed to connect.\n"
114 "Fehler beim Verbinden.\n"
115 "Failed to create device node \"%s\"."
116 "Fehler beim Erzeugen der Geräteadresse \"%s\"."
117 "Failed to detach wrong driver \"%s\". Please do it yourself and retry.\n"
118 "Fehler beim Abmelden des falschen Treibers \"%s\". Bitte selber machen und wiederholen.\n"
119 "Failed to detect driver of interface %d.\n"
120 "Fehler beim Erkennen des Treibers für das Interface %d.\n"
121 "Failed to disassemble Sakis3G package.\n"
122 "Fehler beim Disassemblieren des Sakis3G-Paketes.\n"
123 "Failed to disconnect.\n"
124 "Fehler beim Trennen.\n"
125 "Failed to get valid response from modem while checking for PIN."
126 "Fehler beim Erkennen einer gültigen Antwort vom Modem während der PIN-Überprüfung."
127 "Failed to link %s. This usually indicates libusb (or libusb-compat) development kit missing.\n"
128 "Fehler beim Linken von %s. Dies bedeutet gewöhnlich das Fehlen des libusb (oder libusb-compat) Entwicklungskits.\n"
129 "Failed to load module \"%s\".\n"
130 "Fehler beim Laden des Modules \"%s\".\n"
131 "Failed to prepare modem.\n"
132 "Fehler bei der Modeminitialisierung.\n"
133 "Failed to setup modem.\n"
134 "Fehler beim Modemsetup.\n"
135 "Failed to succesfully create new version. Old version is still available at \"%s\".\n"
136 "Fehler beim Erzeugen einer neuen Version. Die alte Version ist noch verfügbar in \"%s\".\n"
137 "Failed to succesfully place new version. You are still using old version.\n"
138 "Fehler beim Ersetzen mit neuer Version. Sie benutzen noch die alte Version.\n"
139 "Failed to switch.\n"
140 "Fehler beim Umschalten.\n"
141 "Failed to unbind driver %s. I am sorry."
142 "Fehler beim Lösen des Treibers %s. Entschuldigung."
143 "Failed to unload module \"%s\".\n"
144 "Fehler beim Entlades des Modules \"%s\".\n"
145 "Failed to verify result of compilation.\n"
146 "Fehler beim Überprüfen des Kompilationsresultates.\n"
147 "Failure to write on %s.\n"
148 "Fehler beim Schreiben auf %s.\n"
149 "Fixing connection"
150 "Fixiere Verbindung"
151 "Following dependencies not found within path: %s\n"
152 "Die folgenden Abhängigkeiten wurden nicht im Pfad gefunden: %s\n"
153 "Header file %s missing from your system.\n"
154 "Header-Datei %s fehlt auf Ihrem System.\n"
155 "Header file %s missing from your system. This usually indicates libusb (or libusb-compat) development kit missing.\n"
156 "Header-Datei %s fehlt auf Ihrem System. Dies bedeutet gewöhnlich das Fehlen des libusb (oder libusb-compat) Entwicklungskits.\n"
157 "Help with this question"
158 "Hilfe zur Aktion"
159 "Interface:\t\t\tP-t-P (%s)\n"
160 "Schnittstelle: \t\t\tP-t-P (%s)\n"
161 "IP Address:\t\t%s\n"
162 "IP Adresse:\t\t%s\n"
163 "Kernel driver:\t\t%s\n"
164 "Kernel Treiber:\t\t%s\n"
165 "Kilobytes received:\t%d\n"
166 "Kilobytes empfangen:\t%d\n"
167 "Kilobytes sent:\t%d\n"
168 "Kilobytes gesendet:\t%d\n"
169 "Loading driver %s"
170 "Lade Treiber %s"
171 "Locating tty"
172 "Suche tty"
173 "Manages 3G internet connection and 3G USB modems"
174 "Verwaltet 3G Internet-Verbindungen und 3G USB-Modems"
175 "Manually enter non-discovered channel..."
176 "Geben Sie den nicht gefundenen Kanal an..."
177 "Manually enter undiscoverable device..."
178 "Geben Sie das nicht gefundene Gerät an..."
179 "Modem needs PIN"
180 "Modem benötigt PIN"
181 "Modem on %s is registered to %s.\n"
182 "Modem von %s ist registriert für %s.\n"
183 "Modem refused to register operator \"%s\" (currently registered to \"%s\").\n"
184 "Modem verweigert die Registrierung des GSM-Anbieters \"%s\" (momentan registriert auf \"%s\").\n"
185 "Modem refused to register operator \"%s\".\n"
186 "Modem verweigert die Registrierung des GSM-Anbieters \"%s\".\n"
187 "Modem responded \"%s\" while checking for PIN."
188 "Modem antwortet mit \"%s\" während der PIN-Überprüfung."
189 "Modem selected.\n"
190 "Modem ausgewählt.\n"
191 "Modem setup residing on %s.\n"
192 "Modem Setup existiert in %s.\n"
193 "Modem switched.\n"
194 "Modem umgeschaltet.\n"
195 "Modem switched to %s.\n"
196 "Modem umgeschaltet zu %s.\n"
197 "Modem:\t\t\t%s\n"
198 "Gerät:\t\t\t%s\n"
199 "Modem type:\t\tBluetooth\n"
200 "Modem Typ:\t\tBluetooth\n"
201 "Modem type:\t\tCustom\n"
202 "Modem Typ:\t\tbenutzerdefiniert\n"
203 "Modem type:\t\tUnknown\n"
204 "Modem Typ:\t\tunbekannt\n"
205 "Modem type:\t\tUnspecified\n"
206 "Modem Typ:\t\tnicht spezifiziert\n"
207 "Modem type:\t\tUSB\n"
208 "Modem Typ:\t\tUSB\n"
209 "Modem unable to register a network."
210 "Modem ist nicht in der Lage, ein Netzwerk zu registrieren."
211 "Module \"%s\" loaded but did not bind to device \"%s\".\n"
212 "Modul \"%s\" ist geladen, aber nicht an Gerät \"%s\" gebunden.\n"
213 "Module \"%s\" loaded but refused to bind to device \"%s\".\n"
214 "Modul \"%s\" ist geladen, verweigert aber die Bindung an Gerät \"%s\".\n"
215 "More options..."
216 "Weitere Optionen..."
217 "\nAvailable options are:\n"
218 "\nVerfügbare Optionen sind:\n"
219 "Network ID:\t\t%s"
220 "Netzwerk ID:\t\t%s"
221 "\nExample:\n"
222 "\nBeispiel:\n"
223 "No method for acquiring root privileges found."
224 "Keine Methode für das Erlangen von root-Rechten gefunden."
225 "No modem selected.\n"
226 "Kein Modem ausgewählt.\n"
227 "Not connected"
228 "Nicht verbunden"
229 "Not connected.\n"
230 "Nicht verbunden.\n"
231 "Notification"
232 "Benachrichtigung"
233 "Not running from within package.\n"
234 "Läuft nicht aus dem Programmpaket heraus.\n"
235 "No USB modem"
236 "Kein USB-Modem"
237 "No USB modem was selected. No need for a udev example.\n"
238 "USB-Modem wurde nicht ausgewählt. Keine Notwendigkeit für ein UDEV-Beispiel.\n"
239 "No write access to temporary folder \"%s\".\n"
240 "Kein Schreibzugriff auf das temporäre Verzeichnis \"%s\".\n"
241 "\nUtility \"%s\" found but cannot be used since we are not interactive.\n"
242 "Dienstprogramm \"%s\" gefunden, kann aber nicht genutzt werden, da wir nicht im interaktiven Modus sind.\n"
243 "OK"
244 "Ok"
245 "Only prepare modem (Setup + PIN unlock + Register Network + Update HAL)"
246 "Nur Modem vorbereiten (Einrichten + PIN freischalten + Registriere Netzwerk + Aktualisiere HAL)"
247 "Only setup modem (Switch + Load module + Setup tty)"
248 "Nur Modem Setup (Umschalten + Laden der Module + Einrichten tty)"
249 "Only switch modem (if applicable)"
250 "Nur Modem umschalten (falls anwendbar)"
251 "Oops. Weird \"%s\" version. Deleted temporary folder \"%s\".\n"
252 "Uups. Merkwürdige \"%s\" Version. Gelöschtes temporäres Verzeichnis \"%s\".\n"
253 "Operator name:\t%s"
254 "GSM-Anbieter Name:\t%s"
255 "Option"
256 "Aktion"
257 "Option %s not implemented.\n"
258 "Option %s nicht implementiert.\n"
259 "or, force using %s instead:\n"
260 "oder forciere %s stattdessen:\n"
261 "Other..."
262 "Andere..."
263 "Other driver..."
264 "Anderer Treiber..."
265 "Peer IP Address:\t%s\n"
266 "Peer-IP Adresse:\t%s\n"
267 "Please appropriate interface"
268 "Bitte adäquates Interface"
269 "Please enter APN"
270 "Bitte APN eingeben"
271 "Please enter name of driver"
272 "Bitte Treibernamen eingeben"
273 "Please enter PIN number, or leave empty to abort"
274 "Bitte PIN eingeben oder leer lassen, um abzubrechen"
275 "Please enter RFCOMM channel"
276 "Bitte RFCOMM-Kanal eingeben"
277 "Please enter tty"
278 "Bitte tty eingeben"
279 "Please select an action"
280 "Bitte eine Aktion auswählen"
281 "Please select APN"
282 "Bitte APN auswählen"
283 "Please select appropriate driver"
284 "Bitte adäquaten Treiber auswählen"
285 "Please select Bluetooth device"
286 "Bitte Bluetooth-Gerät auswählen"
287 "Please select modem"
288 "Bitte Modem auswählen"
289 "Please select modem type"
290 "Bitte Modemtyp auswählen"
291 "Please select RFCOMM service"
292 "Bitte RFCOMM-Dienst auswählen"
293 "Please select USB modem"
294 "Bitte USB-Modem auswählen"
295 "Please use numbers %d-%d to perform your selection: "
296 "Benutzen Sie bitte die Zahlen %d-%d um Ihre Auswahl zu bestätigen: "
297 "Port %s is currently occupied by %s."
298 "Port %s ist momentan besetzt durch %s."
299 "Preparing modem"
300 "Bereite Modem vor"
301 "Problem while parsing %s sources.\n"
302 "Problem während des Durchsuchens von %s Quellen.\n"
303 "Reconnected to %s.\n"
304 "Wiederverbunden zu %s.\n"
305 "Registering network"
306 "Registriere Netzwerk"
307 "Reported by your modem (%s)"
308 "Berichtet durch Ihr Modem (%s)"
309 "Reported package location is not executable: %s\n"
310 "Berichteter Programmpaket-Ort ist nicht ausführbar: %s\n"
311 "Resuming"
312 "fortsetzen"
313 "Retrieving operator icon"
314 "Empfangenes GSM-Netz-Icon"
315 "Sakis 3G All-in-one script - Version %s\n"
316 "Sakis 3G Alles-in-einem-Script - Version %s\n"
317 "Sakis3G tux icon"
318 "Sakis3G Tux-Icon"
319 "%s by using %s variable, or by enabling interactive mode.\n"
320 "%s durch Benutzung der Variable %s oder durch Aktivierung des Interactiven Modus.\n"
321 "Scan device again"
322 "Suche das Gerät noch einmal"
323 "Scan devices again"
324 "Suche die Geräte noch einmal"
325 "Scanning bluetooth devices"
326 "Suche bluetooth Geräte"
327 "%s connected to %s."
328 "%s verbunden mit %s."
329 "%s connected to %s (%s)."
330 "%s verbunden mit %s (%s)."
331 "Seeking %s"
332 "Finde %s"
333 "Select"
334 "Auswahl"
335 "Select APN that best describes your connection. Contact your operator if unsure. This information, along with APN username and password, is usually easily retrieved through a fast call to customer support"
336 "Wählen Sie den APN aus, der am besten Ihre Verbindung beschreibt. Kontaktieren Sie Ihren GSM-Anbieter falls Sie sich nicht sicher sind. Diese Information zusammen mit dem APN-Benutzernamen und dem Passwort kann gewöhnlich leicht durch einen Serviceanruf erhalten werden."
337 "Select Bluetooth device that provides 3G modem capabilities."
338 "Wählen Sie das Bluetooth-Gerät aus, das über 3G-Modem-Fähigkeiten verfügt."
339 "Select icon to use for shortcut"
340 "Wählen Sie das Icon für den Link aus"
341 "Select kernel module that should be used."
342 "Wählen Sie den Kernelmodul, der benutzt werden sollte."
343 "Select modem category that best fits your 3G modem."
344 "Wählen Sie die Modemkategorie, die am besten zu Ihrem 3G-Modem passt."
345 "Select modem interface of USB device that provides modem capabilities."
346 "Wählen Sie das Modeminterface des USB-Gerätes aus, das über Modemfähigkeiten verfügt."
347 "Select modem that will be used for establishing 3G connection."
348 "Wählen Sie das Modem aus, das für die Erstellung einer 3G-Verbindung benutzt wird."
349 "Select RFCOMM service of Bluetooth device that provides 3G modem capabilities."
350 "Wählen Sie den RFCOMM-Dienst des Bluetooth-Gerätes aus, das über 3G-Modem-Fähigkeiten verfügt."
351 "Select USB device that provides modem capabilities."
352 "Wählen Sie das USB-Gerät aus, das über Modemfähigkeiten verfügt."
353 "Sending PIN"
354 "Sende PIN"
355 "Show help"
356 "Hilfe"
357 "Something really bad happened. I am really sorry. You may need to re-download Sakis3G.\n"
358 "Etwas ist wirklich schlecht gelaufen. Ich entschuldige mich. Sie sollten Sakis3G erneut herunterladen.\n"
359 "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability."
360 "Störende Änderungen in tty %s. Ziehen Sie die Verwendung des \"killstorage\"-Schalters in Betracht, falls es die Stabilität verbessert."
361 "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver."
362 "Störende Änderungen in tty %s. Problem kann eventuell gelöst werden, wenn Sie den Kernel aktualisieren oder einen anderen Treiber verwenden."
363 "Starting up"
364 "Starte"
365 "Subnet Mask:\t\t%s\n"
366 "Subnetzmaske:\t\t%s\n"
367 "Succesfully recompiled.\n"
368 "Erfolgreich rekompiliert.\n"
369 "Switching modem"
370 "Schalte Modem"
371 "Switching modem (using %s)"
372 "Schalte Modem (unter Benutzung von %s)"
373 "Testing compiler"
374 "Teste den Compiler"
375 "To automatically repeat result of last action, immediately upon device connection, include following line within a %s file within \"%s\" directory:\n%s\n"
376 "Um das Resultat der letzten Aktion unmittelbar nach der Geräteverbindung automatisch zu wiederholen, fügen Sie die folgende Zeile innerhalb einer %s-Datei in dem \"%s\"-Verzeichnis ein:\n%s\n"
377 "To automatically repeat result of last action, use following command line:\n%s\n"
378 "Um das Resultat der letzten Aktion automatisch zu wiederholen, benutzen Sie die folgende Kommandozeile:\n%s\n"
379 "Unable to check if module is currently loaded or if it has users.\n"
380 "Unfähig zu überprüfen, ob das Modul momentan geladen ist, oder ob es benutzt wird.\n"
381 "Unable to check if %s is occupied. Not root."
382 "Unfähig zu überprüfen, ob %s in Benutzung ist. Bin nicht root."
383 "Unable to create a safe backup to \"%s\".\n"
384 "Unfähig, ein sicheres Backup in \"%s\" zu erzeugen.\n"
385 "Unable to create device node \"%s\"."
386 "Unfähig, den Geräte-Node \"%s\" zu erzeugen."
387 "Unable to create file %s.\n"
388 "Unfähig, die Datei %s zu erzeugen.\n"
389 "Unable to create rfcomm device node \"%s\"."
390 "Unfähig, den RFCOMM-Geräte-Node \"%s\" zu erzeugen."
391 "Unable to create rfcomm node %s."
392 "Unfähig, den RFCOMM-Node %s zu erzeugen."
393 "Unable to create temporary folder \"%s\".\n"
394 "Unfähg, das temporäre Verzeichnis \"%s\" zu erzeugen.\n"
395 "Unable to create temporary pppd config file within %s directory.\n"
396 "Unfähig, die temporäre pppd-Konfigdatei innerhalb des Verzeichnisses %s zu erzeugen.\n"
397 "Unable to create temporary wvdial config file within %s directory.\n"
398 "Unfähig, die temporäre wvdial-Konfigdatei innerhalb des Verzeichnisses %s zu erzeugen.\n"
399 "Unable to delete previously existing \"%s\".\n"
400 "Unfähig, das vorherige \"%s\" zu löschen.\n"
401 "Unable to delete \"%s\".\n"
402 "Unfähig, \"%s\" zu löschen.\n"
403 "Unable to determine my path.\n"
404 "Unfähig, meinen Pfad zu bestimmen.\n"
405 "Unable to discover connected USB devices. Script will now abort."
406 "Unfähig, die verbundenen USB-Geräte zu entdecken. Das Script bricht jetzt ab."
407 "Unable to extract %s source from package.\n"
408 "Unfähig, die %s-Quelle vom Programmpaket zu extrahieren.\n"
409 "Unable to find available rfcomm device index. Minors occupied.\n"
410 "Unfähig, den verfügbaren rfcomm-Geräteindex zu finden. Minors sind belegt.\n"
411 "Unable to gather connection information.\n"
412 "Unfähig, Verbindungsinformationen zu sammeln.\n"
413 "Unable to get %s icon, unknown reason."
414 "Unfähig, das %s-Icon zu erhalten - unbekannter Grund."
415 "Unable to install tray icon to system notification area. You need to install %s.\n"
416 "Unfähig, das TrayIcon in der Systembenachrichtigungsfläche zu installieren. Sie müssen %s installieren.\n"
417 "Unable to load driver \"%s\" for device \"%s\""
418 "Unfähig, den Treiber \"%s\" für das Gerät \"%s\" zu laden."
419 "Unable to locate dependency \"%s\". Script will now abort."
420 "Unfähig, die Abhängigkeit zu \"%s\" zu finden. Das Script bricht jetzt ab."
421 "Unable to locate driver to use for device \"%s\""
422 "Unfähig, den Treiber für die Benutzung von \"%s\" zu finden."
423 "Unable to overwrite existing package %s. Check if on read-only filesystem.\n"
424 "Unfähig, das existierende Programmpaket %s zu überschreiben. Überprüfen Sie, ob das Dateisystem read-only ist.\n"
425 "Unable to stop running pppd session. Both %s and % were not found.\n"
426 "Unfähig, die laufende pppd-Session zu stoppen. Die beiden %s und %s wurden nicht gefunden.\n"
427 "Unloading driver %s"
428 "Entlade Treiber %s"
429 "Unusable binary after including \"%s\".\n"
430 "Unbenutzbares Binary nach Einfügen von \"%s\".\n"
431 "Updating HAL"
432 "Aktualisiere HAL"
433 "USB device"
434 "USB-Gerät"
435 "Waiting device to settle"
436 "Warte auf die Abarbeitung des Gerätes"
437 "Waiting HAL to mount device(s)"
438 "Warte auf HAL, um Gerät zu mounten."
439 "Waiting %s to be released by PID %s."
440 "Warte bis %s durch PID %s freigegeben wird."
441 "Working..."
442 "Arbeite..."
443 "WRONG PIN. Aborting to prevent you from locking your SIM card."
444 "Falsche PIN. Abbruch, um Sie vor dem Sperren Ihrer SIM-Karte zu schützen."
445 "You can automate this selection by setting %s variable.\n"
446 "Sie können diese Auswahl durch das Setzen der %s Variable automatisieren.\n"
447 "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n"
448 "Sie können diese Auswahl durch das Setzen der %s Variable automatisieren, Geben Sie \"*\" ein, um zu sehen, wie das geht.\n"
449 "You can automate this selection by setting %s variable on command line, click here to discover how.\n"
450 "Sie können diese Auswahl durch das Setzen der %s Variable auf der Kommandozeile automatisieren, klicken Sie hier, um zu sehen, wie das geht.\n"
451 "You can automate this selection by setting %s variable on command line.\n"
452 "Sie können diese Auswahl durch das Setzen der %s Variable auf der Kommandozeile automatisieren.\n"
453 "Resolving connection details"
454 "Auflösung der Verbindungsdetails"
455 "Initializing modem"
456 "Initialisiere Modem"
457 "Confirm exit"
458 "Bestätige Beenden"
459 "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?"
460 "Beenden entfernt auch das Tray-Icon. Sind Sie sicher, Sakis3G zu beenden?"
461 "Disconnected"
462 "Getrennt"
463 "USB Modem plugged"
464 "USB-Modem eingesteckt"
465 "USB Modem %s is now plugged on computer."
466 "USB-Modem %s ist jetzt im Computer eingesteckt."
467 "Modem %s is now connected to %s."
468 "Modem %s ist jetzt mit %s verbunden."
469 "Modem %s is now connected."
470 "Modem %s ist jetzt verbunden."
471 "You are now connected to %s."
472 "Sie sind jetzt mit %s verbunden."
473 "Computer is now connected."
474 "Computer ist jetzt verbunden."
475 "USB Modem Unplugged"
476 "USB-Modem entfernt"
477 "No USB modem is anymore plugged on computer."
478 "Es ist kein USB-Modem an Ihrem Computer angeschlossen."
479 "You were disconnected due to modem being unplugged."
480 "Sie wurden getrennt, da das Modem herausgezogen wurde."
481 "You are now disconnected from operator."
482 "Sie sind jetzt vom GSM-Anbieter getrennt."
483 "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
484 "Wahrscheinlich ist ein elektrischer USB-Bus-Fehler aufgetreten. Sie müssen Ihr Modem erneut einstecken, damit es ordentlich arbeiten kann.\n"
485 "Locating device"
486 "Lokalisiere das Gerät"
487 "Unable to locate a configuration file for switching device %s.\n"
488 "Unfähig, eine Konfigurationsdatei für das Switching-Gerät %s zu finden.\n"
489 "You are running a binary free version of Sakis3G. Unable to recompile %s.\n"
490 "Sie lassen eine Binary-freie Version von Sakis3G laufen. Unfähig zum Recompilieren von %s.\n"
491 "%s is not installed on your system.\n"
492 "%s ist nicht auf Ihrem System installiert.\n"
493 "You are running a binary free version of Sakis3G. This action is not available.\n"
494 "Sie lassen eine Binary-freie Version von Sakis3G laufen. Diese Aktion ist nicht verfügbar.\n"
495 "Trying emergency switch"
496 "Versuche den Notfall-Schalter"
497 "You need to be connected for generating report.\n"
498 "Sie müssen verbunden sein, um den Bericht zu erzeugen.\n"
499 "Please report following text:\n"
500 "Bitte berichten Sie folgenden Text:\n"
501 "Generate success report"
502 "Erzeuge Erfolgsbericht"
503 "You can automate this selection by setting --%syes or --%sno switches.\n"
504 "Sie können diese Auswahl durch das Setzen der Schalter --%syes or --%sno automatisieren.\n"
505 "Scan for network"
506 "Suche das Netzwerk"
507 "Modem was unable to register a network. Would you like to manually select a network?"
508 "Modem konnte kein Netzwerk registrieren. Möchten Sie ein Netzwerk manuell auswählen?"
509 "Scanning networks"
510 "Registriere Netzwerk"
511 "Please select a network"
512 "Wählen Sie bitte ein Netzwerk aus"
513 "Select network for modem to register."
514 "Wählen Sie das zu registrierende Netzwerk für das Modem aus"
515 "You are running a stripped version of Sakis3G. This action is not available.\n"
516 "Sie lassen die kleinstmögliche Version von Sakis3G laufen. Diese Aktion ist nicht verfügbar.\n"
517
518
0 ##2
1 "About Sakis3G"
2 "Σχετικά με το Sakis3G"
3 "Acquiring exclusive lock to HAL"
4 "Αποκλειστικό κλείδωμα στο HAL"
5 "Acquiring root privileges"
6 "Ανάκτηση δικαιωμάτων διαχειριστή"
7 "Already selected value %s=\"%s\". Is not valid.\n"
8 "Η ήδη επιλεγμένη τιμή %s=\"%s\" δεν είναι έγκυρη.\n"
9 "APN:\t\t\t%s"
10 "APN:\t\t\t\t%s"
11 "Available options are:\n"
12 "Οι διαθέσιμες επιλογές είναι:\n"
13 "Bluetooth modem"
14 "Bluetooth μόντεμ"
15 "Both \"%s\" and \"%s\" are missing."
16 "Τόσο το \"%s\" όσο και το \"%s\" απουσιάζουν."
17 "Cancel"
18 "Ακύρωση"
19 "Checking dependencies"
20 "Έλεγχος εξαρτήσεων"
21 "Checking tools availability"
22 "Έλεγχος διαθεσιμότητας εργαλείων"
23 "Choose action for Sakis3G script to follow."
24 "Επιλέξτε την ενέργεια που θέλετε να πραγματοποιήσει το Sakis3G script."
25 "Cleaning"
26 "Καθαρισμός"
27 "Compile embedded Usb-ModeSwitch"
28 "Μεταγλωττισμός ενσωματομένου Usb-ModeSwitch"
29 "Compiling"
30 "Μεταγλωττισμός"
31 "Connected."
32 "Συνδεδεμένο."
33 "Connected"
34 "Συνδεδεμένο"
35 "Connected since:\t%s\n"
36 "Συνδεδεμένο από τις:\t%s\n"
37 "Connected to %s."
38 "Συνδεδεμένο με %s."
39 "Connected to %s (%s)."
40 "Συνδεδεμένο με %s (%s)."
41 "Connecting"
42 "Σύνδεση"
43 "Connecting (second attempt)"
44 "Σύνδεση (δεύτερη προσπάθεια)"
45 "Connection information"
46 "Πληροφορίες σύνδεσης"
47 "Connection Information"
48 "Πληροφορίες Σύνδεσης"
49 "Connect with 3G"
50 "Σύνδεση με 3G"
51 "Create desktop shortcut"
52 "Δημιουργία συντόμευσης"
53 "Create shortcut"
54 "Δημιουργία συντόμευσης"
55 "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\n\n"
56 "(c) Σάκης Δημόπουλος 2009, 2010 υπό την GNU GPL v2\nΜετάφραση στα Ελληνικά: Σάκης Δημόπουλος\n"
57 "Custom APN..."
58 "Άλλο APN..."
59 "Custom tty..."
60 "Άλλο tty..."
61 "Default route(s):\t%s\n"
62 "Προκαθορισμένη πύλη:\t%s\n"
63 "Desktop icon"
64 "Εικονίδιο επιφάνειας εργασίας"
65 "Desktop shortcut created at %s."
66 "Η συντόμευση δημιουργήθηκε σαν %s."
67 "Device did not report GSM capabilities. You can skip this by adding --noprobe command line switch.\n"
68 "Η συσκευή δεν ανέφερε δυνατότητες GSM. Μπορείτε να προσπεράσετε αυτό τον έλεγχο προσθέτοντας το όρισμα --noprobe στη γραμμή εντολών.\n"
69 "Device node \"%s\" does not exist.\n"
70 "Ο κόμβος συσκευής \"%s\" δεν υπάρχει.\n"
71 "Device node \"%s\" does not exist. Setup failed."
72 "Ο κόμβος συσκευής \"%s\" δεν υπάρχει. Η ρύθμιση απέτυχε."
73 "Device:\t\t\t%s\n"
74 "Συσκευή:\t\t\t\t%s\n"
75 "Disconnect"
76 "Αποσύνδεση"
77 "Disconnect and then connect again"
78 "Αποσύνδεση και επανασύνδεση"
79 "Disconnected.\n"
80 "Αποσυνδέθηκε.\n"
81 "Disconnecting"
82 "Αποσύνδεση"
83 "Either enable interactive mode:\n"
84 "Είτε ενεργοποιήστε την αλληλεπιδραστική (interactive) λειτουργία:\n"
85 "Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly. Start by issueing: %s recompile"
86 "Το ενσωματομένο εκτελέσιμο του Usb-ModeSwitch δεν είναι έγκυρο για την αρχιτεκτονική σας. Χρειάζεται να το μεταγλωττίσετε εκ νέου ώστε οι συσκευές να κάνουν switch. Ξεκινήστε με: %s recompile"
87 "Enter Bluetooth address"
88 "Εισάγετε την διεύθυνση bluetooth"
89 "Enter Bluetooth address of undiscoverable device, or leave empty to abort"
90 "Εισάγετε την διεύθυνση bluetooth της μη ανιχνεύσιμης συσκευής, ή αφήστε άδειο για ματαίωση"
91 "Enter correct APN, or leave empty to abort. Contact your operator if unsure"
92 "Εισάγετε το σωστό APN, ή αφήστε άδεια για ματαίωση. Επικοινωνήστε με τον πάροχο εάν έχετε αμφιβολία"
93 "Enter name of appropriate kernel module that should be used, or leave empty to abort"
94 "Εισάγετε το όνομα του σωστού kernel module που πρέπει να χρησιμοποιηθεί, ή αφήστε το άδειο για ματαίωση"
95 "Enter password required by APN, or leave empty to abort. Contact your operator if unsure. This information is usually easily retrieved through a fast call to customer support"
96 "Εισάγετε τον κωδικό που απαιτεί το APN, ή αφήστε άδειο για ματαίωση. Επικοινωνήστε με τον πάροχο εάν έχετε αμφιβολία. Αυτή η πληροφορία συνήθως είναι εύκολο να την βρεί κανείς με μία κλήση στην υποστήριξη πελατών"
97 "Enter RFCOMM channel that should be used, or leave empty to abort [1-255]"
98 "Εισάγετε το κανάλι RFCOMM που πρέπει να χρησιμοποιηθεί, ή αφήστε άδειο για ματαίωση [1-255]"
99 "Enter tty node where your 3G modem resides, or leave empty to abort"
100 "Εισάγετε τον κόμβο συσκευής tty που βρίσκεται το 3G μόντεμ σας, ή αφήστε άδειο για ματαίωση"
101 "Enter username required by APN, or leave empty to abort. Contact your operator if unsure. This information, along with APN password, is usually easily retrieved through a fast call to customer support"
102 "Εισάγετε το όνομα χρήστη που απαιτεί το APN, ή αφήστε άδειο για ματαίωση. Επικοινωνήστε με τον πάροχο εάν έχετε αμφιβολία. Αυτή η πληροφορία συνήθως είναι εύκολο να την βρεί κανείς με μία κλήση στην υποστήριξη πελατών"
103 "Error"
104 "Πρόβλημα"
105 "Error occured"
106 "Προέκυψε πρόβλημα"
107 "Exit"
108 "Έξοδος"
109 "Failed to become root."
110 "Αποτυχία προαγωγής σε διαχειριστή."
111 "Failed to compile. Compilation output:\n%s\n"
112 "Ο μεταγλωττισμός απέτυχε. Η έξοδος της μεταγλώττισης:\n%s\n"
113 "Failed to connect.\n"
114 "H σύνδεση απέτυχε.\n"
115 "Failed to create device node \"%s\"."
116 "Αποτυχία δημιουργίας του κόμβου συσκευής \"%s\"."
117 "Failed to detach wrong driver \"%s\". Please do it yourself and retry.\n"
118 "Αποτυχία αποπροσάρτησης του λάθος οδηγού \"%s\". Παρακαλώ κάντε το μόνος σας και δοκιμάστε ξανα.\n"
119 "Failed to detect driver of interface %d.\n"
120 "Αποτυχία ανίχνευσης του οδηγού που είναι προσαρτημένος στην διεπαφή (interface) %d.\n"
121 "Failed to disassemble Sakis3G package.\n"
122 "Απέτυχε η αποσυναρμολόγηση του Sakis3G πακέτου.\n"
123 "Failed to disconnect.\n"
124 "Αποτυχία αποσύνδεσης.\n"
125 "Failed to get valid response from modem while checking for PIN."
126 "Δεν λήφθηκε έγκυρη απάντηση από το μόντεμ κατά τη διάρκεια ελέγχου για PIN."
127 "Failed to link %s. This usually indicates libusb (or libusb-compat) development kit missing.\n"
128 "Απέτυχε το linking του %s. Αυτό συνήθως υποδηλώνει πως τα εργαλεία ανάπτυξης του libusb (ή του libusb-compat) απουσιάζουν.\n"
129 "Failed to load module \"%s\".\n"
130 "Απέτυχε να φορτωθεί το module \"%s\".\n"
131 "Failed to prepare modem.\n"
132 "Απέτυχε η προετοιμασία του μόντεμ.\n"
133 "Failed to setup modem.\n"
134 "Απέτυχε η ρύθμιση του μόντεμ.\n"
135 "Failed to succesfully create new version. Old version is still available at \"%s\".\n"
136 "Απέτυχε η δημιουργία της νέας έκδοσης. Η παλαιά έκδοση είναι ακόμα διαθέσιμη στη θέση \"%s\".\n"
137 "Failed to succesfully place new version. You are still using old version.\n"
138 "Απέτυχε η εγκατάσταση της νέας έκδοσης. Χρησιμοποιείτε ακόμα την παλιά έκδοση.\n"
139 "Failed to switch.\n"
140 "Το switch απέτυχε.\n"
141 "Failed to unbind driver %s. I am sorry."
142 "Απέτυχε η αποσύνδεση του οδηγού %s. Λυπάμαι."
143 "Failed to unload module \"%s\".\n"
144 "Απέτυχε η εκφόρτωση του module \"%s\".\n"
145 "Failed to verify result of compilation.\n"
146 "Αποτυχία επαλήθευσης του αποτελέσματος της μεταγλώττισης.\n"
147 "Failure to write on %s.\n"
148 "Αποτυχία εγγραφής στο %s.\n"
149 "Fixing connection"
150 "Τελική ρύθμιση σύνδεσης"
151 "Following dependencies not found within path: %s\n"
152 "Οι παρακάτω εξαρτήσεις δεν βρέθηκαν στο path: %s\n"
153 "Header file %s missing from your system.\n"
154 "Το αρχείο κεφαλίδων %s δεν βρέθηκε στο σύστημα.\n"
155 "Header file %s missing from your system. This usually indicates libusb (or libusb-compat) development kit missing.\n"
156 "Το αρχείο κεφαλίδων %s δεν βρέθηκε στο σύστημα. Αυτό συνήθως υποδηλώνει πως τα εργαλεία ανάπτυξης του libusb (ή του libusb-compat) απουσιάζουν.\n"
157 "Help with this question"
158 "Βοήθεια σχετικά με αυτή την ερώτηση"
159 "Interface:\t\t\tP-t-P (%s)\n"
160 "Διεπαφή:\t\t\t\tP-t-P (%s)\n"
161 "IP Address:\t\t%s\n"
162 "Διεύθυνση IP:\t\t\t%s\n"
163 "Kernel driver:\t\t%s\n"
164 "Οδηγός πυρήνα:\t\t%s\n"
165 "Kilobytes received:\t%d\n"
166 "Ληφθέντα Kilobytes:\t%d\n"
167 "Kilobytes sent:\t%d\n"
168 "Απεσταλμένα Kilobytes:\t%d\n"
169 "Loading driver %s"
170 "Φόρτωση οδηγού %s"
171 "Locating tty"
172 "Εντοπισμός tty"
173 "Manages 3G internet connection and 3G USB modems"
174 "Χειρίζεται 3G συνδέσεις internet και 3G USB μόντεμ"
175 "Manually enter non-discovered channel..."
176 "Χειροκίνητη εισαγωγή μη ανιχνευμένου channel..."
177 "Manually enter undiscoverable device..."
178 "Χειροκίνητη εισαγωγή μη ανιχνεύσιμης συσκευής..."
179 "Modem needs PIN"
180 "Το μόντεμ απαιτεί PIN"
181 "Modem on %s is registered to %s.\n"
182 "To μόντεμ %s έχει εισέλθει στο δίκτυο %s.\n"
183 "Modem refused to register operator \"%s\" (currently registered to \"%s\").\n"
184 "Το μόντεμ αρνήθηκε να εισέλθει στο δίκτυο \"%s\" (αυτή τη στιγμή βρίσκεται στο \"%s\").\n"
185 "Modem refused to register operator \"%s\".\n"
186 "Το μόντεμ αρνήθηκε να εισέλθει στο δίκτυο \"%s\".\n"
187 "Modem responded \"%s\" while checking for PIN."
188 "Το μόντεμ αποκρίθηκε \"%s\" κατά τη διάρκεια του ελέγχου PIN."
189 "Modem selected.\n"
190 "Επιλέχθηκε μόντεμ.\n"
191 "Modem setup residing on %s.\n"
192 "Το μόντεμ ρυθμίστηκε και βρίσκεται στη θέση %s.\n"
193 "Modem switched.\n"
194 "Το μόντεμ έκανε switch.\n"
195 "Modem switched to %s.\n"
196 "Το μόντεμ έκανε switch σε %s.\n"
197 "Modem:\t\t\t%s\n"
198 "Μόντεμ:\t\t\t\t%s\n"
199 "Modem type:\t\tBluetooth\n"
200 "Τύπος μόντεμ:\t\t\tBluetooth\n"
201 "Modem type:\t\tCustom\n"
202 "Τύπος μόντεμ:\t\t\tΆλλο\n"
203 "Modem type:\t\tUnknown\n"
204 "Τύπος μόντεμ:\t\t\tΆγνωστο\n"
205 "Modem type:\t\tUnspecified\n"
206 "Τύπος μόντεμ:\t\t\tΜη ορισμένο\n"
207 "Modem type:\t\tUSB\n"
208 "Τύπος μόντεμ:\t\t\tUSB\n"
209 "Modem unable to register a network."
210 "Το μόντεμ αδυνατεί να βρεί κάποιο δίκτυο."
211 "Module \"%s\" loaded but did not bind to device \"%s\".\n"
212 "Το module \"%s\" φορτώθηκε αλλά δεν προσαρτήθηκε στη συσκευή \"%s\".\n"
213 "Module \"%s\" loaded but refused to bind to device \"%s\".\n"
214 "Το module \"%s\" φορτώθηκε αλλά αρνήθηκε να προσαρτηθεί στη συσκευή \"%s\".\n"
215 "More options..."
216 "Περισσότερες επιλογές..."
217 "\nAvailable options are:\n"
218 "\nΟι διαθέσιμες επιλογές είναι:\n"
219 "Network ID:\t\t%s"
220 "Κωδικός δικτύου:\t\t%s"
221 "\nExample:\n"
222 "\nΠαράδειγμα:\n"
223 "No method for acquiring root privileges found."
224 "Δεν βρέθηκε μέθοδος ανάκτησης δικαιωμάτων διαχειριστή."
225 "No modem selected.\n"
226 "Δεν επιλέχθηκε μόντεμ.\n"
227 "Not connected"
228 "Μη συνδεδεμένο"
229 "Not connected.\n"
230 "Μη συνδεδεμένο.\n"
231 "Notification"
232 "Ενημέρωση"
233 "Not running from within package.\n"
234 "Δεν εκτελούμαι μέσα από το πακέτο.\n"
235 "No USB modem"
236 "Δεν υπάρχει USB μόντεμ"
237 "No USB modem was selected. No need for a udev example.\n"
238 "Δεν επιλέχθηκε USB μόντεμ. Δεν υπάρχει ανάγκη udev παραδείγματος.\n"
239 "No write access to temporary folder \"%s\".\n"
240 "Δεν υπάρχει δικαίωμα εγγραφής στον προσωρινό κατάλογο \"%s\".\n"
241 "\nUtility \"%s\" found but cannot be used since we are not interactive.\n"
242 "\nΤο εργαλείο \"%s\" βρέθηκε αλλά δεν μπορεί να χρησιμοποιηθεί καθώς δεν γίνεται αλληλεπιδραστική εκτέλεση.\n"
243 "OK"
244 "Εντάξει"
245 "Only prepare modem (Setup + PIN unlock + Register Network + Update HAL)"
246 "Μόνο προετοιμασία (Ρύθμιση + ξεκλείδωμα PIN + Είσοδος στο δίκτυο + Ενημέρωση HAL)"
247 "Only setup modem (Switch + Load module + Setup tty)"
248 "Μόνο ρύθμιση (Switch + Φόρτωση οδηγού + Ρύθμιση tty)"
249 "Only switch modem (if applicable)"
250 "Μόνο switch (εάν γίνεται)"
251 "Oops. Weird \"%s\" version. Deleted temporary folder \"%s\".\n"
252 "Ωωώχ. Περίεργη έκδοση \"%s\". Έσβησε τον προσωρινό κατάλογο \"%s\".\n"
253 "Operator name:\t%s"
254 "Όνομα παρόχου:\t\t%s"
255 "Option"
256 "Επιλογή"
257 "Option %s not implemented.\n"
258 "Η επιλογή %s δεν έχει υλοποιηθεί.\n"
259 "or, force using %s instead:\n"
260 "ή, εξαναγκάστε τη χρήση του %s:\n"
261 "Other..."
262 "Άλλο..."
263 "Other driver..."
264 "Άλλος οδηγός..."
265 "Peer IP Address:\t%s\n"
266 "Διεύθυνση IP ετέρου:\t%s\n"
267 "Please appropriate interface"
268 "Παρακαλώ επιλέξτε την κατάλληλη διεπαφή (interface)"
269 "Please enter APN"
270 "Παρακαλώ επιλέξτε APN"
271 "Please enter name of driver"
272 "Παρακαλώ εισάγετε το όνομα του οδηγού"
273 "Please enter PIN number, or leave empty to abort"
274 "Παρακαλώ εισάγετε τον αριθμό PIN, ή αφήστε άδειο για ματαίωση"
275 "Please enter RFCOMM channel"
276 "Παρακαλώ εισάγετε το RFCOMM channel"
277 "Please enter tty"
278 "Παρακαλώ εισάγετε το tty"
279 "Please select an action"
280 "Παρακαλώ επιλέξτε μία ενέργεια"
281 "Please select APN"
282 "Παρακαλώ επιλέξτε APN"
283 "Please select appropriate driver"
284 "Παρακαλώ επιλέξτε τον κατάλληλο οδηγό"
285 "Please select Bluetooth device"
286 "Παρακαλώ επιλέξτε την Bluetooth συσκευή"
287 "Please select modem"
288 "Παρακαλώ επιλέξτε μόντεμ"
289 "Please select modem type"
290 "Παρακαλώ επιλέξτε τον τύπο του μόντεμ"
291 "Please select RFCOMM service"
292 "Παρακαλώ επιλέξτε την RFCOMM υπηρεσία"
293 "Please select USB modem"
294 "Παρακαλώ επιλέξτε USB μόντεμ"
295 "Please use numbers %d-%d to perform your selection: "
296 "Παρακαλώ χρησιμοποιείστε τους αριθμούς %d-%d για να υποδείξετε την επιλογή σας: "
297 "Port %s is currently occupied by %s."
298 "Η θύρα %s είναι απασχολημένη από το %s."
299 "Preparing modem"
300 "Προετοιμασία του μόντεμ"
301 "Problem while parsing %s sources.\n"
302 "Πρόβλημα κατά την ανάγνωση του πηγαίου κώδικα του %s.\n"
303 "Reconnected to %s.\n"
304 "Eπανασυνδέθηκε στο %s.\n"
305 "Registering network"
306 "Είσοδος στο δίκτυο"
307 "Reported by your modem (%s)"
308 "Όπως αναφέρθηκε από το modem (%s)"
309 "Reported package location is not executable: %s\n"
310 "Η θέση του πακέτου που αναφέρθηκε δεν είναι εκτελέσιμη: %s\n"
311 "Resuming"
312 "Συνέχεια"
313 "Retrieving operator icon"
314 "Ανάκτηση εικονιδίου παρόχου"
315 "Sakis 3G All-in-one script - Version %s\n"
316 "Sakis 3G All-in-one script - Έκδοση %s\n"
317 "Sakis3G tux icon"
318 "Το εικονίδιο του Sakis3G με τον Tux"
319 "%s by using %s variable, or by enabling interactive mode.\n"
320 "%s χρησιμοποιώντας την μεταβλητή %s, ή ενεργοποιώντας την αλληλεπιδραστική (interactive) λειτουργία.\n"
321 "Scan device again"
322 "Ανίχνευση συσκευής ξανά"
323 "Scan devices again"
324 "Ανίχνευση συσκευών ξανά"
325 "Scanning bluetooth devices"
326 "Ανίχνευση bluetooth συσκευών"
327 "%s connected to %s."
328 "Το %s συνδέθηκε στο %s."
329 "%s connected to %s (%s)."
330 "Το %s συνδέθηκε στο %s (%s)."
331 "Seeking %s"
332 "Ανίχνευση του %s"
333 "Select"
334 "Επιλογή"
335 "Select APN that best describes your connection. Contact your operator if unsure. This information, along with APN username and password, is usually easily retrieved through a fast call to customer support"
336 "Επιλέξτε το APN που καλύτερα περιγράφει την σύνδεσή σας. Επικοινωνήστε με τον πάροχο αν έχετε αμφιβολίες. Αυτή η πληροφορία, καθώς και το όνομα χρήστη APN και ο κωδικός του, συνήθως ανακτούντε εύκολα με μία γρήγορη κλήση στην υποστήριξη πελατών"
337 "Select Bluetooth device that provides 3G modem capabilities."
338 "Επιλέξτε την Bluetooth συσκευή που παρέχει δυνατότητες 3G μόντεμ."
339 "Select icon to use for shortcut"
340 "Επιλέξτε εικονίδιο για χρήση στη συντόμευση"
341 "Select kernel module that should be used."
342 "Επιλέξτε το kernel module που πρέπει να χρησιμοποιηθεί."
343 "Select modem category that best fits your 3G modem."
344 "Επιλέξτε την κατηγορία που περιγράφει καλύτερα το 3G μόντεμ σας."
345 "Select modem interface of USB device that provides modem capabilities."
346 "Επιλέξτε την διεπαφή (interface) της USB συσκευής που παρέχει τις ικανότητες σύνδεσης."
347 "Select modem that will be used for establishing 3G connection."
348 "Επιλέξτε το μόντεμ που θα χρησιμοποιηθεί για την επίτευξη της 3G σύνδεσης."
349 "Select RFCOMM service of Bluetooth device that provides 3G modem capabilities."
350 "Επιλέξτε την RFCOMM υπηρεσία της Bluetooth συσκευής, μέσω της οποίας παρέχονται οι 3G δυνατότητες."
351 "Select USB device that provides modem capabilities."
352 "Επιλέξτε τη USB συσκευή που φέρει δυνατότητες σύνδεσης."
353 "Sending PIN"
354 "Αποστολή του PIN"
355 "Show help"
356 "Προβολή βοήθειας"
357 "Something really bad happened. I am really sorry. You may need to re-download Sakis3G.\n"
358 "Κάτι πραγματικά άσχημο συνέβει. Λυπάμαι πολύ. Ίσως χρειάζεται να κατεβάσετε εκ νέου του Sakis3G.\n"
359 "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability."
360 "Ύποπτες αλλαγές στο tty %s. Σκεφτείτε τη χρήση του ορίσματος \"killstorage\" μήπως βελτιωθεί η σταθερότητα."
361 "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver."
362 "Ύποπτες αλλαγές στο tty %s. Το πρόβλημα ίσως λυθεί με αναβάθμιση του πυρήνα ή επιλέγοντας άλλον οδηγό."
363 "Starting up"
364 "Εκκίνηση"
365 "Subnet Mask:\t\t%s\n"
366 "Μάσκα υποδικτύου:\t%s\n"
367 "Succesfully recompiled.\n"
368 "Επιτυχής μεταγλώττιση.\n"
369 "Switching modem"
370 "Γίνεται switch του μόντεμ"
371 "Switching modem (using %s)"
372 "Γίνεται switch του μόντεμ (με χρήση του %s)"
373 "Testing compiler"
374 "Έλεγχος μεταγλωττιστή"
375 "To automatically repeat result of last action, immediately upon device connection, include following line within a %s file within \"%s\" directory:\n%s\n"
376 "Για να επαναλάβετε αυτόματα τα αποτελέσματε της τελευταίας ενέργειας, αμέσως μετά την σύνδεση της συσκευής, συμπεριλάβετε την παρακάτω γραμμή σε ένα %s αρχείο εντός του καταλόγου \"%s\":\n%s\n"
377 "To automatically repeat result of last action, use following command line:\n%s\n"
378 "Για να επαναλάβετε αυτόματα τα αποτελέσματα της τελευταίας ενέργειας, από την γραμμή εντολών:\n%s\n"
379 "Unable to check if module is currently loaded or if it has users.\n"
380 "Αδυναμία για έλεγχο εάν το module έχει φορτωθεί ή εαν χρησιμοποιείται από κάποιον.\n"
381 "Unable to check if %s is occupied. Not root."
382 "Αδυναμία ελέγχου για την κατάληψης του %s. Δεν είμαστε διαχειριστές."
383 "Unable to create a safe backup to \"%s\".\n"
384 "Αδυναμία δημιουργίας ασφαλούς αντιγράφου στη θέση \"%s\".\n"
385 "Unable to create device node \"%s\"."
386 "Αδυναμία δημιουργίας του κόμβου συσκευής \"%s\"."
387 "Unable to create file %s.\n"
388 "Αδυναμία δημιουργίας του αρχείου %s.\n"
389 "Unable to create rfcomm device node \"%s\"."
390 "Αδυναμία δημιουργίας του rfcomm κόμβου συσκευής \"%s\"."
391 "Unable to create rfcomm node %s."
392 "Αδυναμία δημιουργίας του rfcomm κόμβου %s."
393 "Unable to create temporary folder \"%s\".\n"
394 "Αδυναμία δημιουργίας του προσωρινού καταλόγου \"%s\".\n"
395 "Unable to create temporary pppd config file within %s directory.\n"
396 "Αδυναμία δημιουργίας προσωρινού αρχείου ρυθμίσεων για το pppd εντός του καταλόγου %s.\n"
397 "Unable to create temporary wvdial config file within %s directory.\n"
398 "Αδυναμία δημιουργίας προσωρινού αρχείου ρυθμίσεων για το wvdial εντός του καταλόγου %s.\n"
399 "Unable to delete previously existing \"%s\".\n"
400 "Αδυναμία διαγραφής του προϋπάρχοντος \"%s\".\n"
401 "Unable to delete \"%s\".\n"
402 "Αδυναμία διαγραφής του \"%s\".\n"
403 "Unable to determine my path.\n"
404 "Αδυναμία εντοπισμού της θέσης μου.\n"
405 "Unable to discover connected USB devices. Script will now abort."
406 "Αδυναμία ανίχνευσης των συνδεδεμένων USB συσκευών. Η εκτέλεση του Script θα ματαιωθεί."
407 "Unable to extract %s source from package.\n"
408 "Αδυναμία εξαγωγής του πηγαίου κώδικα του %s από το πακέτο.\n"
409 "Unable to find available rfcomm device index. Minors occupied.\n"
410 "Αδυναμία ανίχνευσης διαθέσιμης θέσης rfcomm συσκευής. Όλοι οι minor αριθμοί είναι κατηλημμένοι.\n"
411 "Unable to gather connection information.\n"
412 "Αδυναμία να συγκεντρωθούν οι πληροφορίες σύνδεσης.\n"
413 "Unable to get %s icon, unknown reason."
414 "Αδυναμία λήψης του εικονιδίου του %s, για άγνωστο λόγο."
415 "Unable to install tray icon to system notification area. You need to install %s.\n"
416 "Αδυναμία εγκατάστασης εικονιδίου στην περιοχή ειδοποιήσεων. Χρειάζεται να εγκαταστήσετε το %s.\n"
417 "Unable to load driver \"%s\" for device \"%s\""
418 "Αδυναμία φόρτωσης του οδηγού \"%s\" για την συσκευή \"%s\""
419 "Unable to locate dependency \"%s\". Script will now abort."
420 "Αδυναμία ανίχνευσης της εξάρτησης \"%s\". Η εκτέλεση του script θα ματαιωθεί."
421 "Unable to locate driver to use for device \"%s\""
422 "Αδυναμία εντοπισμού του οδηγού που πρέπει να χρησιμοποιηθεί με την συσκευή \"%s\""
423 "Unable to overwrite existing package %s. Check if on read-only filesystem.\n"
424 "Αδυναμία εγγραφής επί του υφιστάμενου πακέτου %s. Ελέξτε μήπως βρίσκεται σε σύστημα αρχείων που είναι μόνο για ανάγνωση.\n"
425 "Unable to stop running pppd session. Both %s and % were not found.\n"
426 "Αδυναμία διακοπής τους τρέχουσας συνεδρίας του pppd. Τόσο το %s όσο και το %s δεν βρέθηκαν.\n"
427 "Unloading driver %s"
428 "Εκφόρτωση του οδηγού %s"
429 "Unusable binary after including \"%s\".\n"
430 "Η περίληψη του \"%s\" δημιουργεί βλάβη στο εκτελέσιμο αρχείο.\n"
431 "Updating HAL"
432 "Ενημέρωση του HAL"
433 "USB device"
434 "USB συσκευή"
435 "Waiting device to settle"
436 "Αναμονή εγκαθίδρυσης της συσκευής"
437 "Waiting HAL to mount device(s)"
438 "Αναμονή για την προσάρτηση των συσκευών από το HAL"
439 "Waiting %s to be released by PID %s."
440 "Αναμονή για απελευθέρωση του %s από την διεργασία %s.\n"
441 "Working..."
442 "Εργασία σε εξέλιξη..."
443 "WRONG PIN. Aborting to prevent you from locking your SIM card."
444 "ΛΑΘΟΣ PIN. Ματαίωση για να αποτραπεί το κλείδωμα της κάρτας SIM."
445 "You can automate this selection by setting %s variable.\n"
446 "Μπορείτε να αυτοματοποιήσετε αυτή την επιλογή, θέτοντας την μεταβλητή %s.\n"
447 "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n"
448 "Μπορείτε να αυτοματοποιήσετε αυτή την επιλογή, θέτοντας την μεταβλητή %s από τη γραμμή εντολών.\nΕισάγετε \"*\" για να ανακαλύψετε τον τρόπο.\n"
449 "You can automate this selection by setting %s variable on command line, click here to discover how.\n"
450 "Μπορείτε να αυτοματοποιήσετε αυτή την επιλογή, θέτοντας την μεταβλητή %s από τη γραμμή εντολών, κάνετε κλίκ εδώ για να ανακαλύψετε τον τρόπο.\n"
451 "You can automate this selection by setting %s variable on command line.\n"
452 "Μπορείτε να αυτοματοποιήσετε αυτή την επιλογή, θέτοντας την μεταβλητή %s από τη γραμμή εντολών.\n"
453 "Resolving connection details"
454 "Συγκέντρωση ρυθμίσεων σύνδεσης"
455 "Initializing modem"
456 "Αρχικοποίηση του μόντεμ"
457 "Confirm exit"
458 "Επιβεβαίωση εξόδου"
459 "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?"
460 "Η έξοδος θα αφαιρέσει και το εικονίδιο από την περιοχή ειδοποιήσεων. Είστε βέβαιος πως επιθυμείτε έξοδο από το Sakis3G;"
461 "Disconnected"
462 "Αποσυνδεθήκατε"
463 "USB Modem plugged"
464 "Προσαρτήθηκε USB μόντεμ"
465 "USB Modem %s is now plugged on computer."
466 "Προσαρτήθηκε το USB μόντεμ %s στον υπολογιστή."
467 "Modem %s is now connected to %s."
468 "Το μόντεμ %s συνδέθηκε με %s."
469 "Modem %s is now connected."
470 "Το μόντεμ %s συνδέθηκε."
471 "You are now connected to %s."
472 "Συνδεθήκατε με %s."
473 "Computer is now connected."
474 "Ο υπολογιστής έχει συνδεθεί."
475 "USB Modem Unplugged"
476 "Αφαιρέθηκε το USB μόντεμ"
477 "No USB modem is anymore plugged on computer."
478 "Δεν υπάρχει πλέον USB μόντεμ συνδεδεμένο στον υπολογιστή."
479 "You were disconnected due to modem being unplugged."
480 "Αποσυνδεθήκατε καθώς έγινε αποπροσάρτηση του μόντεμ."
481 "You are now disconnected from operator."
482 "Αποσυνδεθήκατε από το δίκτυο."
483 "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
484 "Φαίνεται πως υπάρχει κάποιο ηλεκτρικό πρόβλημα ή πρόβλημα στον USB δίαυλο. Ίσως χρειάζεται να επανασυνδέσετε το μόντεμ σας στον υπολογιστή για να δουλέψει σωστά.\n"
485 "Locating device"
486 "Εντοπισμός συσκευής"
487 "Unable to locate a configuration file for switching device %s.\n"
488 "Αδύνατο να εντοπιστεί αρχείο ρυθμίσεων για να γίνει switch η συσκευή %s.\n"
489 "You are running a binary free version of Sakis3G. Unable to recompile %s.\n"
490 "Χρησιμοποιείτε την binary free έκδοση του Sakis3G. Είναι αδύνατος ο μεταγλωττισμός του %s.\n"
491 "%s is not installed on your system.\n"
492 "Το %s δεν είναι εγκατεστημένο στο σύστημά σας.\n"
493 "You are running a binary free version of Sakis3G. This action is not available.\n"
494 "Χρησιμοποιείτε την binary free έκδοση του Sakis3G. Αυτή η ενέργεια δεν είναι διαθέσιμη.\n"
495 "Trying emergency switch"
496 "Δοκιμή πρόχειρου switch"
497 "You need to be connected for generating report.\n"
498 "Πρέπει να έχετε συνδεθεί για να ετοιμαστεί η αναφορά.\n"
499 "Please report following text:\n"
500 "Παρακαλώ αναφέρατε το παρακάτω κείμενο:\n"
501 "Generate success report"
502 "Δημιουργία αναφοράς"
503 "You can automate this selection by setting --%syes or --%sno switches.\n"
504 "Μπορείτε να αυτοματοποιήσετε αυτή την απάντηση χρησιμοποιώντας τους διακόπτες --%syes και --%sno.\n"
505 "Scan for network"
506 "Ανίχνευση για δίκτυο"
507 "Modem was unable to register a network. Would you like to manually select a network?"
508 "Το μόντεμ δεν κατάφερε να εισέλθει σε κάποιο δίκτυο. Θέλετε να επιλέξετε χειροκίνητα κάποιο δίκτυο;"
509 "Scanning networks"
510 "Ανίχνευση δικτύων"
511 "Please select a network"
512 "Παρακαλώ επιλέξτε δίκτυο"
513 "Select network for modem to register."
514 "Επιλέξτε το δίκτυο που πρέπει να εισέλθει το μόντεμ."
515 "You are running a stripped version of Sakis3G. This action is not available.\n"
516 "Χρησιμοποιείτε την stripped έκδοση του Sakis3G. Αυτή η ενέργεια δεν είναι διαθέσιμη.\n"
517
518
0 ##1
1 # This is a translation file for Sakis3G All-in-one script.
2 #
3 # File information:
4 # - Translator(s): Jean-Pierre VAISSIERE
5 # - Email (optional): jpiebrig-nav at French Yahoo.
6 # - Locale: fr_FR.UTF-8
7 # - Location: messages/fr_FR.UTF-8
8 #
9 ## End of comments. More comments appear within text to help you translating.
10
11
12 "About Sakis3G"
13 "A propos de Sakis3G"
14 "Acquiring exclusive lock to HAL"
15 "Acquisition du blocage exclusif pour HAL"
16 "Acquiring root privileges"
17 "Acquisition des privilèges root"
18 "Already selected value %s=\"%s\". Is not valid.\n"
19 "Valeur déjà sélectionnée %s=\"%s\". N'est pas valable.\n"
20 "APN:\t\t\t%s"
21 "APN:\t\t\t%s"
22 "APN:\t\t\t\t%s"
23 "APN:\t\t\t\t%s"
24 "Available options are:\n"
25 "Les options disponibles sont:\n"
26 "Bluetooth modem"
27 "Modem Bluetooth"
28 "Both \"%s\" and \"%s\" are missing."
29 "\"%s\" et \"%s\" sont manquants."
30 "Cancel"
31 "Abandon"
32 "Checking dependencies"
33 "Contrôle des dépendances"
34 "Checking tools availability"
35 "Contrôle de la disponibilité des outils"
36 "Choose action for Sakis3G script to follow."
37 "Choisissez une action pour le script Sakis3G."
38 "Cleaning"
39 "Nettoyage en cours"
40 "Compile embedded Usb-ModeSwitch"
41 "Compilation d'Usb-ModeSwitch intégré"
42 "Compiling"
43 "Compilation en cours"
44 "Connected."
45 "Connecté."
46 "Connected"
47 "Connecté"
48 "Connected since:\t%s\n"
49 "Connecté depuis:\t%s\n"
50 "Connected to %s."
51 "Connecté à %s."
52 "Connected to %s (%s)."
53 "Connecté à %s (%s)."
54 "Connecting"
55 "Connexion en cours"
56 "Connecting (second attempt)"
57 "Connexion en cours (deuxième essai)"
58 "Connection information"
59 "Information de connexion"
60 "Connection Information"
61 "Information de connexion"
62 "Connect with 3G"
63 "Connecter en 3G"
64 "Create desktop shortcut"
65 "Créer un raccourci bureau"
66 "Create shortcut"
67 "Créer un raccourci"
68 "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\n\n"
69 "(c) Sakis Dimopoulos 2009, 2010 sous GNU GPL v2\nTraduction en français: Jean-Pierre VAISSIERE\n"
70 "Custom APN..."
71 "APN habituel..."
72 "Custom tty..."
73 "tty habituel..."
74 "Default route(s):\t%s\n"
75 "Chemin(s) par défaut:\t%s\n"
76 "Desktop icon"
77 "Icône du bureau"
78 "Desktop shortcut created at %s."
79 "Raccourci bureau créé à %s."
80 "Device did not report GSM capabilities. You can skip this by adding --noprobe command line switch.\n"
81 "Périphérique sans fonction GSM. Vous pouvez sauter ceci en ajoutant le commutateur --noprobe dans la ligne de commande.\n"
82 "Device node \"%s\" does not exist.\n"
83 "Noeud de périphérique \"%s\" non existant.\n"
84 "Device node \"%s\" does not exist. Setup failed."
85 "Noeud de périphérique \"%s\" non existant. Installation avortée."
86 "Device:\t\t\t%s\n"
87 "Périphérique:\t\t\t%s\n"
88 "Disconnect"
89 "Déconnecter"
90 "Disconnect and then connect again"
91 "Déconnecter et reconnecter"
92 "Disconnected.\n"
93 "Déconnecté.\n"
94 "Disconnecting"
95 "Déconnexion en cours"
96 "Either enable interactive mode:\n"
97 "L'un ou l'autre permettent le mode interactif:\n"
98 "Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly. Start by issueing: %s recompile"
99 "Usb-ModeSwitch intégré n'est pas valide pour votre architecture. Re-compiler pour que le périphérique commute correctement. Démarrez par: %s recompile"
100 "Enter Bluetooth address"
101 "Entrer l'adresse Bluetooth"
102 "Enter Bluetooth address of undiscoverable device, or leave empty to abort"
103 "Entrer l'adresse Bluetooth du périphérique non trouvé, ou laissez vide pour interrompre"
104 "Enter correct APN, or leave empty to abort. Contact your operator if unsure"
105 "Entrez l'APN correct, ou laissez vide pour interrompre. Si vous doutez, contactez votre opérateur"
106 "Enter name of appropriate kernel module that should be used, or leave empty to abort"
107 "Entrer le nom du module du noyau approprié qui doit être utilisé, ou laissez vide pour interrompre"
108 "Enter password required by APN, or leave empty to abort. Contact your operator if unsure. This information is usually easily retrieved through a fast call to customer support"
109 "Entrez le mot de passe requis par l'APN, ou laissez vide pour interrompre. Si vous doutez, contactez votre opérateur. Cette information est habituellement facilement obtenue par un appel au service clientèle"
110 "Enter RFCOMM channel that should be used, or leave empty to abort [1-255]"
111 "Entrez le canal RFCOMM qui doit être utilisé, ou laissez vide pour interrompre [1-255]"
112 "Enter tty node where your 3G modem resides, or leave empty to abort"
113 "Entrez le noeud tty du modem 3G, ou laissez vide pour interrompre"
114 "Enter username required by APN, or leave empty to abort. Contact your operator if unsure. This information, along with APN password, is usually easily retrieved through a fast call to customer support"
115 "Entrez le nom d'utilisateur requis par l'APN, ou laissez vide pour interrompre. Si vous doutez, contactez votre opérateur. Cette information, ainsi que le mot de passe APN, est habituellement facilement obtenue par un appel au service clientèle"
116 "Error"
117 "Erreur"
118 "Error occured"
119 "Une erreur s'est produite"
120 "Exit"
121 "Quitter"
122 "Failed to become root."
123 "Echec d'appropriation de root"
124 "Failed to compile. Compilation output:\n%s\n"
125 "Echec de compilation. Sortie de compilation:\n%s\n"
126 "Failed to connect.\n"
127 "Echec de connexion.\n"
128 "Failed to create device node \"%s\"."
129 "Echec de création du noeud de périphérique \"%s\"."
130 "Failed to detach wrong driver \"%s\". Please do it yourself and retry.\n"
131 "Echec du détachement du mauvais pilote \"%s\". Faites le vous-même et ré-essayez SVP.\n"
132 "Failed to detect driver of interface %d.\n"
133 "Echec de détection du pilote de l'interface %d.\n"
134 "Failed to disassemble Sakis3G package.\n"
135 "Echec de désassemblage du paquet Sakis3G.\n"
136 "Failed to disconnect.\n"
137 "Echec de déconnexion.\n"
138 "Failed to get valid response from modem while checking for PIN."
139 "Echec d'obtention d'une réponse valide du modem pendant le contrôle du PIN"
140 "Failed to link %s. This usually indicates libusb (or libusb-compat) development kit missing.\n"
141 "Echec de création du lien %s. Ceci indique habituellement que le kit de développement libusb (ou libusb-compat) est manquant.\n"
142 "Failed to load module \"%s\".\n"
143 "Echec du chargement du module \"%s\".\n"
144 "Failed to prepare modem.\n"
145 "Echec de préparation du modem.\n"
146 "Failed to setup modem.\n"
147 "Echec de configuration du modem.\n"
148 "Failed to succesfully create new version. Old version is still available at \"%s\".\n"
149 "Echec de création d'une nouvelle version. L'ancienne version est toujours disponible à \"%s\".\n"
150 "Failed to succesfully place new version. You are still using old version.\n"
151 "Echec d'installation d'une nouvelle version. Vous utilisez toujours l'ancienne version.\n"
152 "Failed to switch.\n"
153 "Echec de commutation.\n"
154 "Failed to unbind driver %s. I am sorry."
155 "Echec de détachemment du pilote %s. Désolé."
156 "Failed to unload module \"%s\".\n"
157 "Echec de déchargement du module \"%s\".\n"
158 "Failed to verify result of compilation.\n"
159 "Echec de vérification du résultat de compilation.\n"
160 "Failure to write on %s.\n"
161 "Echec d'écriture sur %s.\n"
162 "Fixing connection"
163 "Réparation de la connexion en cours"
164 "Following dependencies not found within path: %s\n"
165 "Les dépendances suivantes n'ont pu être trouvées dans: %s\n"
166 "Header file %s missing from your system.\n"
167 "Fichier d'en-tête manquant sur votre système.\n"
168 "Header file %s missing from your system. This usually indicates libusb (or libusb-compat) development kit missing.\n"
169 "Fichier d'en-tête manquant sur votre système. Ceci indique habituellement que le kit de développement libusb (ou libusb-compat) est manquant.\n"
170 "Help with this question"
171 "Aide contextuelle"
172 "Interface:\t\t\tP-t-P (%s)\n"
173 "Interface:\t\t\tP-t-P (%s)\n"
174 "IP Address:\t\t%s\n"
175 "Adresse IP:\t\t%s\n"
176 "Kernel driver:\t\t%s\n"
177 "Pilote du noyau:\t\t%s\n"
178 "Kilobytes received:\t%d\n"
179 "Kilobytes reçus:\t%d\n"
180 "Kilobytes sent:\t%d\n"
181 "Kilobytes envoyés:\t%d\n"
182 "Loading driver %s"
183 "Chargement du pilote %s"
184 "Locating tty"
185 "Recherche du tty"
186 "Manages 3G internet connection and 3G USB modems"
187 "Gère la connexion internet 3G et les modems USB 3G"
188 "Manually enter non-discovered channel..."
189 "Entrez manuellement le canal non trouvé..."
190 "Manually enter undiscoverable device..."
191 "Entrez manuellement le périphérique non trouvé..."
192 "Modem needs PIN"
193 "Le modem a besoin du PIN"
194 "Modem on %s is registered to %s.\n"
195 "Le modem sur %s est enregistré à %s.\n"
196 "Modem refused to register operator \"%s\" (currently registered to \"%s\").\n"
197 "Le modem refuse d'enregistrer l'opérateur \"%s\" (enregistré actuellement à \"%s\").\n"
198 "Modem refused to register operator \"%s\".\n"
199 "Le modem refuse d'enregistrer l'opérateur \"%s\".\n"
200 "Modem responded \"%s\" while checking for PIN."
201 "le modem a répondu \"%s\" pendant le contrôle du PIN."
202 "Modem selected.\n"
203 "Modem sélectionné.\n"
204 "Modem setup residing on %s.\n"
205 "La configuration du modem est sur %s.\n"
206 "Modem switched.\n"
207 "Le modem a commuté.\n"
208 "Modem switched to %s.\n"
209 "Le modem a commuté en %s.\n"
210 "Modem:\t\t\t%s\n"
211 "Modem:\t\t\t%s\n"
212 "Modem type:\t\tBluetooth\n"
213 "Type du modem:\t\tBluetooth\n"
214 "Modem type:\t\tCustom\n"
215 "Type du modem:\t\tUsuel\n"
216 "Modem type:\t\tUnknown\n"
217 "Type du modem:\t\tInconnu\n"
218 "Modem type:\t\tUnspecified\n"
219 "Type du modem:\t\tNon-spécifié\n"
220 "Modem type:\t\tUSB\n"
221 "Type du modem:\t\tUSB\n"
222 "Modem unable to register a network."
223 "Le modem ne peut pas enregistrer un réseau"
224 "Module \"%s\" loaded but did not bind to device \"%s\".\n"
225 "Le module \"%s\" se charge mais ne se lie pas au périphérique \"%s\".\n"
226 "Module \"%s\" loaded but refused to bind to device \"%s\".\n"
227 "Le module \"%s\" se charge mais refuse de se lier au périphérique \"%s\".\n"
228 "More options..."
229 "Plus d'options..."
230 "\nAvailable options are:\n"
231 "\nLes options disponibles sont:\n"
232 "Network ID:\t\t%s"
233 "ID du réseau:\t\t%s"
234 "\nExample:\n"
235 "\nExemple:\n"
236 "No method for acquiring root privileges found."
237 "Aucune méthode trouvée pour acquérir les privilèges root."
238 "No modem selected.\n"
239 "Pas de modem sélectionné.\n"
240 "Not connected"
241 "Pas connecté"
242 "Not connected.\n"
243 "Pas connecté.\n"
244 "Notification"
245 "Notification"
246 "Not running from within package.\n"
247 "Ne s'execute depuis ce paquet.\n"
248 "No USB modem"
249 "Pas de modem USB"
250 "No USB modem was selected. No need for a udev example.\n"
251 "Pas de modem USB sélectionné. Pas nécessaire pour un exemple udev.\n"
252 "No write access to temporary folder \"%s\".\n"
253 "Pas de droit d'accès au dossier temporaire \"%s\".\n"
254 "\nUtility \"%s\" found but cannot be used since we are not interactive.\n"
255 "\nUtilitaire \"%s\" trouvé mais ne peut être utilisé tant que nous ne serons pas interactif.\n"
256 "OK"
257 "OK"
258 "Only prepare modem (Setup + PIN unlock + Register Network + Update HAL)"
259 "Prépare seulement le modem (Configuration + Déverouillage PIN + Enregistrement du réseau + Mise à jour HAL)"
260 "Only setup modem (Switch + Load module + Setup tty)"
261 "Configure seulement le modem (Commute + Charge le module + Configure tty)"
262 "Only switch modem (if applicable)"
263 "Commute seulement le modem (si applicable)"
264 "Oops. Weird \"%s\" version. Deleted temporary folder \"%s\".\n"
265 "Oops. Weird \"%s\" version. Dossier temporaire effacé \"%s\".\n"
266 "Operator name:\t%s"
267 "Nom de l'opérateur:\t%s"
268 "Option"
269 "Option"
270 "Option %s not implemented.\n"
271 "Option %s non implémentée.\n"
272 "or, force using %s instead:\n"
273 "ou, forcer l'utilisation de %s au lieu de:\n"
274 "Other..."
275 "Autre..."
276 "Other driver..."
277 "Autre pilote..."
278 "Peer IP Address:\t%s\n"
279 "Adresse IP paire:\t%s\n"
280 "Please appropriate interface"
281 "Appropriez- vous l'interface SVP"
282 "Please enter APN"
283 "Entrez l'APN SVP"
284 "Please enter name of driver"
285 "Entrez le nom du pilote SVP"
286 "Please enter PIN number, or leave empty to abort"
287 "Entrez le PIN, ou laissez vide pour interrompre"
288 "Please enter RFCOMM channel"
289 "Entrez le canal RFCOMM SVP"
290 "Please enter tty"
291 "Entrez le tty SVP"
292 "Please select an action"
293 "Sélectionnez une action SVP"
294 "Please select APN"
295 "Sélectionner l'APN SVP"
296 "Please select appropriate driver"
297 "Sélectionnez le pilote approprié SVP"
298 "Please select Bluetooth device"
299 "Sélectionnez le périphérique Bluetooth SVP"
300 "Please select modem"
301 "Sélectionnez le modem SVP"
302 "Please select modem type"
303 "Sélectionnez le type du modem SVP"
304 "Please select RFCOMM service"
305 "Sélectionnez le service RFCOMM SVP"
306 "Please select USB modem"
307 "Sélectionnez le modem USB SVP"
308 "Please use numbers %d-%d to perform your selection: "
309 "Utlisez les nombres %d-%d pour effectuer la sélection: "
310 "Port %s is currently occupied by %s."
311 "Le port %s est actuellement occupé par %s."
312 "Preparing modem"
313 "Préparation du modem en cours"
314 "Problem while parsing %s sources.\n"
315 "Problème pendant l'analyse %s des sources.\n"
316 "Reconnected to %s.\n"
317 "Reconnecté à %s.\n"
318 "Registering network"
319 "Enregistrement du réseau en cours"
320 "Reported by your modem (%s)"
321 "Rapporté par votre modem (%s)"
322 "Reported package location is not executable: %s\n"
323 "L'emplacement du paquet signalé n'est pas exécutable : %s\n"
324 "Resuming"
325 "Reprise en cours"
326 "Retrieving operator icon"
327 "Récupération en cours de l'icône de l'opérateur"
328 "Sakis 3G All-in-one script - Version %s\n"
329 "Sakis 3G All-in-one script - Version %s\n"
330 "Sakis3G tux icon"
331 "Icône tux Sakis3G"
332 "%s by using %s variable, or by enabling interactive mode.\n"
333 "%s en utilisant la variable %s, ou en activant le mode interactif.\n"
334 "Scan device again"
335 "Ré-examen du périphérique"
336 "Scan devices again"
337 "Ré-examen des périphériques"
338 "Scanning bluetooth devices"
339 "Examen des périphériques bluetooth en cours"
340 "%s connected to %s."
341 "%s connecté à %s."
342 "%s connected to %s (%s)."
343 "%s connecté à %s (%s)."
344 "Seeking %s"
345 "Recherche de %s en cours"
346 "Select"
347 "Sélectionnez"
348 "Select APN that best describes your connection. Contact your operator if unsure. This information, along with APN username and password, is usually easily retrieved through a fast call to customer support"
349 "Sélectionnez l'APN correspondant le mieux à votre connexion. Si vous doutez, contactez votre opérateur. Cette information, ainsi que le nom d'utilisateur et le mot de passe APN, est habituellement facilement obtenue par un appel au service clientèle"
350 "Select Bluetooth device that provides 3G modem capabilities."
351 "Sélectionnez le périphérique Bluetooth fournissant les fonction modem 3G"
352 "Select icon to use for shortcut"
353 "Sélectionnez l'icône à utiliser pour le raccourci"
354 "Select kernel module that should be used."
355 "Sélectionnez le module du noyau à utiliser"
356 "Select modem category that best fits your 3G modem."
357 "Sélectionnez la catégorie du modem qui s'ajuste le mieux à votre modem 3G."
358 "Select modem interface of USB device that provides modem capabilities."
359 "Sélectionnez l'interface du modem du périphérique USB qui fournit les fonctions modem."
360 "Select modem that will be used for establishing 3G connection."
361 "Sélectionnez le modem qui sera utilisé pour établir la connexion 3G."
362 "Select RFCOMM service of Bluetooth device that provides 3G modem capabilities."
363 "Sélectionnez le service RFCOMM du périphérique Bluetooth qui fournit les fonctions modem 3G."
364 "Select USB device that provides modem capabilities."
365 "Sélectionnez le périphérique USB qui fournit les fonctions modem."
366 "Sending PIN"
367 "Envoi du PIN en cours"
368 "Show help"
369 "Montrer l'aide"
370 "Something really bad happened. I am really sorry. You may need to re-download Sakis3G.\n"
371 "Il s'est passé un truc vraiment pas bien. Je suis réellement désolé. Vous devez re-télécharger Sakis3G.\n"
372 "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability."
373 "Changements bizarres dans le tty %s. Envisagez d'utiliser le descriptif \"killstorage\" au cas ou cela affecte la stabilité."
374 "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver."
375 "Changements bizarres dans le tty %s. Le problème peut être résolu en mettant à jour votre noyau ou en choisissant un autre pilote."
376 "Starting up"
377 "Démarrage en cours"
378 "Subnet Mask:\t\t%s\n"
379 "Masque du sous-réseau:\t\t%s\n"
380 "Succesfully recompiled.\n"
381 "Re-compilé avec succès.\n"
382 "Switching modem"
383 "Commutation du modem en cours"
384 "Switching modem (using %s)"
385 "Commutation du modem en cours (en utilisant %s)"
386 "Testing compiler"
387 "Test du compilateur en cours"
388 "To automatically repeat result of last action, immediately upon device connection, include following line within a %s file within \"%s\" directory:\n%s\n"
389 "Pour répéter automatiquement le résultat de la dernière action, immédiatement, dès la connexion du périphérique, inclure la phrase suivante dans un fichier %s avec \"%s\" répertoire:\n%s\n"
390 "To automatically repeat result of last action, use following command line:\n%s\n"
391 "Pour répéter automatiquement le résultat de la dernière action, utilisez la ligne de commande suivante:\n%s\n"
392 "Unable to check if module is currently loaded or if it has users.\n"
393 "Impossible de contrôler si le module est actuellement chargé ou s'il a des utilisateurs.\n"
394 "Unable to check if %s is occupied. Not root."
395 "Impossible de contrôler si %s est occupé. Pas de privilège root."
396 "Unable to create a safe backup to \"%s\".\n"
397 "Impossible de créer une sauvegarde saine à \"%s\".\n"
398 "Unable to create device node \"%s\"."
399 "Impossible de créer le noeud de périphérique \"%s\"."
400 "Unable to create file %s.\n"
401 "Impossible de créer le fichier %s.\n"
402 "Unable to create rfcomm device node \"%s\"."
403 "Impossible de créer le noeud du périphérique rfcomm \"%s\"."
404 "Unable to create rfcomm node %s."
405 "Impossible de créer le noeud rfcomm %s."
406 "Unable to create temporary folder \"%s\".\n"
407 "Impossible de créer le dossier temporaire \"%s\".\n"
408 "Unable to create temporary pppd config file within %s directory.\n"
409 "Impossible de créer le fichier de configuration temporaire pppd dans le répertoire %s.\n"
410 "Unable to create temporary wvdial config file within %s directory.\n"
411 "Impossible de créer le fichier de configuration temporaire wvdial dans le répertoire %s.\n"
412 "Unable to delete previously existing \"%s\".\n"
413 "Impossible d'effacer \"%s\" pré-existant.\n"
414 "Unable to delete \"%s\".\n"
415 "Impossible d'effacer \"%s\".\n
416 "Unable to determine my path.\n"
417 "Impossible de définir mon chemin.\n"
418 "Unable to discover connected USB devices. Script will now abort."
419 "Impossible de trouver les périphériques USB connectés. Le script va s'interrompre."
420 "Unable to extract %s source from package.\n"
421 "Impossible d'extraire la source %s du paquet.\n"
422 "Unable to find available rfcomm device index. Minors occupied.\n"
423 "Impossible de trouver l'index disponible du périphérique rfcomm. Minors occupés.\n"
424 "Unable to gather connection information.\n"
425 "Impossible de rassembler l'information de connexion.\n"
426 "Unable to get %s icon, unknown reason."
427 "Impossible d'obtenir l'icône %s, raison inconnue."
428 "Unable to install tray icon to system notification area. You need to install %s.\n"
429 "Impossible d'installer l'icône de la barre dans la zone de notification sytème. Vous devez installer %s.\n"
430 "Unable to load driver \"%s\" for device \"%s\""
431 "Impossible de charger le pilote \"%s\" pour le périphérique \"%s\""
432 "Unable to locate dependency \"%s\". Script will now abort."
433 "Impossible de trouver la dépendance \"%s\". Le script va s'interrompre."
434 "Unable to locate driver to use for device \"%s\""
435 "Impossible de situer le pilote à utiliser pour le périphérique \"%s\""
436 "Unable to overwrite existing package %s. Check if on read-only filesystem.\n"
437 "Impossible d'écrire par dessus le paquet existant %s. Contrôlez s'il n'est pas en lecture seule .\n"
438 "Unable to stop running pppd session. Both %s and % were not found.\n"
439 "Impossible d'arrêter la session pppd en cours. Aussi bien %s que % n'ont pu être trouvés.\n"
440 "Unloading driver %s"
441 "Déchargement du pilote %s en cours"
442 "Unusable binary after including \"%s\".\n"
443 "Binaire inutilisable après inclusion de \"%s\".\n"
444 "Updating HAL"
445 "Mise à jour Hal en cours"
446 "USB device"
447 "Périphérique USB"
448 "Waiting device to settle"
449 "Attente d'installation du périphérique"
450 "Waiting HAL to mount device(s)"
451 "Montage du/des périphérique(s) en attente d'HAL"
452 "Waiting %s to be released by PID %s."
453 "Attente d' %s pour être libérer par PID %s."
454 "Working..."
455 "Travail en cours..."
456 "WRONG PIN. Aborting to prevent you from locking your SIM card."
457 "MAUVAIS PIN. Abandon afin que votre carte SIM ne soit pas bloquée."
458 "You can automate this selection by setting %s variable.\n"
459 "Vous pouvez automatiser cette sélection en paramétrant la variable %s.\n"
460 "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n"
461 "Vous pouvez automatiser cette sélection en paramétrant la variable %s.\nEntrer \"*\" pour savoir comment.\n"
462 "You can automate this selection by setting %s variable on command line, click here to discover how.\n"
463 "Vous pouvez automatiser cette sélection en paramétrant la variable %s en ligne de commande, cliquer ici pour savoir comment.\n"
464 "You can automate this selection by setting %s variable on command line.\n"
465 "Vous pouvez automatiser cette sélection en paramétrant la variable %s en ligne de commande.\n"
466 "Resolving connection details"
467 "Résolution des détails de connexion"
468 "Initializing modem"
469 "Initialisation du modem en cours"
470 "Confirm exit"
471 "Confirmez la sortie"
472 "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?"
473 "Quitter enlèvera aussi l'icône de la barre. Etes-vous sûr de vouloir quitter Sakis3G?"
474 "Disconnected"
475 "Déconnecté"
476 "USB Modem plugged"
477 "Modem USB branché"
478 "USB Modem %s is now plugged on computer."
479 "Le modem USB %s est maintenant branché sur l'ordinateur."
480 "Modem %s is now connected to %s."
481 "Le modem %s est maintenant connecté à %s."
482 "Modem %s is now connected."
483 "Le modem %s est maintenant connecté."
484 "You are now connected to %s."
485 "Vous êtes maintenant connecté à %s."
486 "Computer is now connected."
487 "L'ordinateur est maintenant connecté."
488 "USB Modem Unplugged"
489 "Modem USB débranché"
490 "No USB modem is anymore plugged on computer."
491 "Aucun modem USB n'est plus branché sur l'ordinateur."
492 "You were disconnected due to modem being unplugged."
493 "Vous avez été déconnecté car le modem a été débranché."
494 "You are now disconnected from operator."
495 "Vous êtes maintenant déconnecté de l'opérateur."
496 "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
497 "Une erreur électrique ou du bus USB semble être survenue. Vous devez rebrancher votre modem afin qu'il fonctionne correctement.\n"
498 "Locating device"
499 "Recherche du périphérique en cours"
500 "Unable to locate a configuration file for switching device %s.\n"
501 "Impossible de trouver un fichier de configuration pour commuter le périphérique %s.\n"
502 "You are running a binary free version of Sakis3G. Unable to recompile %s.\n"
503 "Vous utilisez une version binaire libre de Sakis3G. Impossible de recompiler %s.\n"
504 "%s is not installed on your system.\n"
505 "%s n'est pas installé sur votre système.\n"
506 "You are running a binary free version of Sakis3G. This action is not available.\n"
507 "Vous utilisez une version binaire libre de Sakis3G. Cette action n'est pas disponible.\n"
508 "Trying emergency switch"
509 "Tentative de commutation d'urgence en cours"
510 "You need to be connected for generating report.\n"
511 "Vous devez être connecté pour générer le rapport.\n"
512 "Please report following text:\n"
513 "Veuillez rapporter le texte suivant:\n"
514 "Generate success report"
515 "Rapport de connexion réussie"
516 "You can automate this selection by setting --%syes or --%sno switches.\n"
517 "Vous pouvez automatiser cette sélection en réglant les commutateurs sur --%syes ou --%sno.\n"
518 "Scan for network"
519 "Recherche de réseau"
520 "Modem was unable to register a network. Would you like to manually select a network?"
521 "Le modem n'a pas pu enregistrer un réseau. Voulez-vous sélectionner manuellement un réseau?"
522 "Scanning networks"
523 "Examen des réseaux en cours"
524 "Please select a network"
525 "Sélectionnez un réseau SVP"
526 "Select network for modem to register."
527 "Sélectionnez un réseau pour que le modem s'enregistre."
528 "You are running a stripped version of Sakis3G. This action is not available.\n"
529 "Vous utilisez une version réduite de Sakis3G. Cette action n'est pas disponible.\n"
530
531
0 #!/bin/sh
1
2 compressor="bzip2"
3 decompressor="bunzip2"
4 extension="bz2"
5
6 if [ -f "src/sakis3g" ]; then
7 BASEDIR=`pwd`
8 elif [ -f "../src/sakis3g" ]; then
9 BASEDIR=`dirname \`pwd\``
10 else
11 echo "This script should be run while being within Sakis3G root directory."
12 exit 1
13 fi
14
15 [ "a${BASEDIR}" = "a" ] && echo "Unable to locate Sakis3G root directory." && exit 2
16
17 echo "Base directory: ${BASEDIR}."
18
19 cd "${BASEDIR}"
20
21 case "a$1" in
22 "astripped"|"anormal"|"aredist"|"aplain"|"asmall"|"asmallest")
23 mode="stripped"
24 requirements="src/sakis3g src/sakis3gz"
25 dependencies="tar dd ${compressor} stat find touch"
26 items="src/sakis3g files messages"
27 ;;
28 "aembedded"|"ano_usb_modeswitch")
29 mode="embedded"
30 requirements="src/sakis3g src/sakis3gz"
31 dependencies="tar dd ${compressor} stat find touch"
32 items="build Changelog compile COPYING CONTRIB man README scripts src/sakis3g src/sakis3gz files messages docs"
33 ;;
34 "a"|"afull"|"ayes_usb_modeswitch"|"aall"|"a+usb_modeswitch")
35 mode="full"
36 requirements="src/sakis3g src/sakis3gz dependencies/usb-modeswitch/usb_modeswitch.c dependencies/usb-modeswitch/usb_modeswitch.h scripts/device-database-gen"
37 dependencies="tar dd ${compressor} stat find touch gcc"
38 items="build Changelog compile COPYING CONTRIB dependencies man README scripts src/sakis3g src/sakis3gz files messages docs"
39 ;;
40 esac
41
42
43 for file in ${requirements}
44 do
45 [ ! -f "${file}" ] && echo "File \"${file}\" not found. Please re-install." && exit 3
46 done
47 echo "Source files: All found."
48
49 for utility in ${dependencies}
50 do
51 [ ! "`which ${utility} 2> /dev/null`" ] && echo "Utility ${utility} not found." && exit 4
52 done
53
54 if [ "a${mode}" = "afull" ]; then
55 [ ! -d "dependencies/usb-modeswitch-data" ] && echo "Usb-ModeSwitch device database not found." && exit 4
56 rm -f "build/switchconfig"
57 ./scripts/device-database-gen > "build/switchconfig"
58 [ ! -f "build/switchconfig" ] && echo "Failed to transform device database." && exit 5
59 echo "Device database: Found and transformed."
60 else
61 echo "Device database: Skipped. Relying on external Usb-ModeSwitch database."
62 fi
63
64 if [ "a${mode}" = "afull" ]; then
65 rm -f "build/usb_modeswitch.compiled"
66 gcc -Wall -l usb -o build/usb_modeswitch.compiled dependencies/usb-modeswitch/usb_modeswitch.c -I dependencies/usb-modeswitch
67 [ ! -f "build/usb_modeswitch.compiled" ] && echo "Failed to compile usb-modeswitch." && exit 6
68 [ "`which strip 2> /dev/null`" ] && strip "build/usb_modeswitch.compiled"
69 rm -f "build/usb_modeswitch" ; mv "build/usb_modeswitch.compiled" "build/usb_modeswitch"
70 [ ! -f "build/usb_modeswitch" ] && exit 7
71 echo "Usb-ModeSwitch: Compiled."
72 else
73 rm -f "build/"*
74 echo "Usb-ModeSwitch: NOT embedded. Relying on external Usb-ModeSwitch binary."
75 fi
76
77 mkdir tmp 2> /dev/null
78 mkdir tmp/sakis3g 2> /dev/null
79 rm -rf tmp/sakis3g/*
80 mkdir tmp/sakis3g/src 2> /dev/null
81
82
83 for target in ${items}
84 do
85 cp -R "${target}" "tmp/sakis3g/${target}"
86 done
87 rm -f "tmp/sakis3g/build/sakis3gz" "tmp/sakis3g/build/.sakis3gz" "tmp/sakis3g.tar" "tmp/sakis3g.tar.${extension}"
88 chmod +x "tmp/sakis3g/src/sakis3g"
89
90 cd tmp
91 find sakis3g/ -print0 | xargs -0 touch
92 contents=`tar cvf sakis3g.tar sakis3g`
93 executables=`find sakis3g/ -executable \! -type d \! -type l`
94 cd ..
95
96 [ ! -f "tmp/sakis3g.tar" ] && echo "Failed to create tar file." && exit 10
97
98 tarsize=`stat --printf="%s\n" tmp/sakis3g.tar 2>/dev/null`; tarsize=`echo ${tarsize}`
99 ${compressor} --best tmp/sakis3g.tar
100
101 [ ! -f "tmp/sakis3g.tar.${extension}" ] && echo "Failed to compress tar file." && exit 11
102
103 echo "Compressed file: Created."
104
105 rm -rf tmp/sakis3g/*
106 rmdir tmp/sakis3g 2> /dev/null
107 rm -f "build/.sakis3gz"
108
109 packagesize=`stat --printf="%s\n" tmp/sakis3g.tar.${extension} 2>/dev/null`; packagesize=`echo ${packagesize}`
110
111 echo "#!/bin/sh" > "build/.sakis3gz"
112 grep "^MYVERSION" src/sakis3g >> "build/.sakis3gz"
113 grep "^#" src/sakis3gz >> "build/.sakis3gz"
114 echo "PACKAGE_SIZE=${packagesize}" >> "build/.sakis3gz"
115 echo "BLOCKSIZE=1024" >> "build/.sakis3gz"
116 echo "PACKAGE_CONTENTS=\"${contents}\"" >> "build/.sakis3gz"
117 echo "PACKAGE_EXECUTABLES=\"${executables}\"" >> "build/.sakis3gz"
118 echo "decompressor=\"${decompressor}\"" >> "build/.sakis3gz"
119 echo "extension=\"${extension}\"" >> "build/.sakis3gz"
120 case "${mode}" in
121 full)
122 ;;
123 stripped)
124 echo "binaryfree=\"yes\"" >> "build/.sakis3gz"
125 echo "stripped=\"yes\"" >> "build/.sakis3gz"
126 echo "export binaryfree" >> "build/.sakis3gz"
127 echo "export stripped" >> "build/.sakis3gz"
128 ;;
129 embedded)
130 echo "binaryfree=\"yes\"" >> "build/.sakis3gz"
131 echo "export binaryfree" >> "build/.sakis3gz"
132 ;;
133 esac
134
135 tmpsize=`stat --printf="%s\n" build/.sakis3gz 2>/dev/null`; tmpsize=`echo ${tmpsize}`
136 size=`stat --printf="%s\n" src/sakis3gz 2>/dev/null`; size=`echo ${size}`
137 [ "a${size}" = "a" ] && size=0
138 size=`expr ${size} + 513 + ${tmpsize}`; size=`echo ${size}`
139 size=`expr ${size} / 1024`; size=`echo ${size}`
140 size=`expr ${size} + 1`; size=`echo ${size}`
141
142 echo "PACKAGE_OFFSET=${size}" >> "build/.sakis3gz"
143 grep -v "^#" "src/sakis3gz" >> "build/.sakis3gz"
144 echo "exit 99" >> "build/.sakis3gz"
145
146 dd if=tmp/sakis3g.tar.${extension} of=build/.sakis3gz obs=1024 seek=${size} > /dev/null 2>&1
147 rm -f "tmp/sakis3g.tar.${extension}"
148
149 rm -f "build/sakis3gz"; mv "build/.sakis3gz" "build/sakis3gz"
150 chmod +x "build/sakis3gz"
151 finalsize=`stat --printf="%s\n" build/sakis3gz 2>/dev/null`; finalsize=`echo ${finalsize}`
152
153 ratio=`expr ${finalsize} \* 10000`; ratio=`echo ${ratio}`
154 ratio=`expr ${ratio} / ${tarsize}`; ratio=`echo ${ratio}`
155 ratio=`expr 10000 - ${ratio}`; ratio=`echo ${ratio}`
156 ratio=`echo ${ratio} | sed -e "s/^\([0-9]*\)\([0-9][0-9]\)$/\1.\2/g"`
157
158 echo "Compilation complete."
159 echo "Compression ratio ${ratio}% (${finalsize}/${tarsize})."
160 echo
161 echo "Sakis3G script is available at: build/sakis3gz"
162
163 case "${mode}" in
164 full)
165 echo "This is all you need. You may delete the rest."
166 echo
167 echo "If you later want to compile it for another platform, invoke it with"
168 echo "\"recompile\" argument, or use \"disassemble\" argument to recreate"
169 echo "source folder."
170 ;;
171 embedded)
172 echo "Full functionality is preserved and script is architect independed and"
173 echo "self-contained. However, for using it with a switchable USB modem:"
174 echo " * Usb-ModeSwitch must be available within PATH, and "
175 echo " * Usb-ModeSwitch device database needs to be available at"
176 echo " /etc/usb_modeswitch.d."
177 ;;
178 stripped)
179 echo "Script is architect independed but:"
180 echo " * Relies on a working Usb-ModeSwitch installation available on PATH."
181 echo " * Needs Usb-ModeSwitch device database installed at /etc/usb_modeswitch.d"
182 echo " * It is impossible to \"disassemble\" it back to its contents."
183 echo " * It is impossible to view man pages using \"man\" argument. You need to"
184 echo " install files man/* on your system's man subsystem for this to be"
185 echo " possible."
186 echo " * Files README, CONTRIB and COPYING are not embedded. You need to ship"
187 echo " them as well, for being compliant with Sakis3G license."
188 ;;
189 esac
190 echo
191 echo "For installing it, use:"
192 echo " $ sudo bash || su"
193 echo " Password:"
194 echo " # cp build/sakis3gz /usr/bin/sakis3g"
195 echo
0 #!/bin/sh
1
2 if [ -d "dependencies" ]; then
3 BASEDIR=`pwd`
4 elif [ -d "../dependencies" ]; then
5 BASEDIR=`dirname \`pwd\``
6 else
7 echo "This script should be run from Sakis3G root directory." > /dev/stderr
8 exit
9 fi
10
11 [ ! -d "${BASEDIR}/dependencies/usb-modeswitch-data/usb_modeswitch.d" ] && echo "Unable to locate Usb-ModeSwitch device database" && exit 2
12
13
14 cd "${BASEDIR}/dependencies/usb-modeswitch-data/usb_modeswitch.d"
15
16 knowndevices=`ls -1 * | cut -d: -f1,2 | sort | uniq`
17 knowndevices=`echo ${knowndevices}`
18
19 switcheddevices=""
20
21 for i in *
22 do
23 unset CheckSuccess
24 unset Configuration
25 unset DefaultProduct
26 unset DefaultVendor
27 unset GCTMode
28 unset HuaweiMode
29 unset Interface
30 unset MessageContent
31 unset ResponseNeeded
32 unset SierraMode
33 unset SonyMode
34 unset TargetClass
35 unset TargetProduct
36 unset TargetProductList
37 unset TargetVendor
38 sed -e "s/ //g" "$i" > /tmp/$$.tmp
39 . /tmp/$$.tmp
40 rm -f "/tmp/$$.tmp"
41 for ven in ${TargetVendor}
42 do
43 if [ -n "${TargetProductList}" ]; then
44 list=`echo ${TargetProductList} | sed -e "s/,/ /g"`
45 for pro in $list
46 do
47 switcheddevices="${switcheddevices} ${ven}:${pro}"
48 done
49 unset list
50 elif [ -n "${TargetProduct}" ]; then
51 switcheddevices="${switcheddevices} ${ven}:${TargetProduct}"
52 fi
53 done
54 done
55
56 switcheddevices=`echo ${switcheddevices} | sed -e "s/0x//g" | tr " " "\n" | sort | uniq`
57 switcheddevices=`echo ${switcheddevices}`
58
59 cd "${BASEDIR}"
60
61 cat <<andl
62 getswitchabledevices() {
63 unset usbswitchabledevices
64 usbswitchabledevices="${knowndevices}"
65 unset usbswitcheddevices
66 usbswitcheddevices="${switcheddevices}"
67 }
68
69 andl
70
71 for i in ${knowndevices}
72 do
73 func=`echo $i | sed -e "s/:/_/g"`
74 cat <<andl
75 usbswitchconf_${func}() {
76 andl
77 files=`ls -1r dependencies/usb-modeswitch-data/usb_modeswitch.d/${i}* | wc -l`
78 files=`echo ${files}`
79 if [ "${files}" -gt "1" ]; then
80 needscsi=`ls -1r dependencies/usb-modeswitch-data/usb_modeswitch.d/${i}:s* 2> /dev/null | wc -l`
81 needscsi=`echo ${needscsi}`
82 if [ "${needscsi}" -gt "0" ]; then
83 cat <<andl
84 usb_scsisysfsattr ${i}
85 andl
86 else
87 cat <<andl
88 usb_sysfsattr ${i}
89 andl
90 fi
91 cat<<andl
92 if [ "1" = "2" ]; then
93 echo Dummy IF
94 andl
95 for file in `ls -1r dependencies/usb-modeswitch-data/usb_modeswitch.d/${i}*`
96 do
97 bn=`basename ${file}`
98 crit=`echo "${bn}" | cut -d: -f3-`
99 crit=`echo ${crit}`
100 if [ "a${crit}" != "a" ]; then
101 field=`echo "${crit}" | cut -d= -f1`
102 value=`echo "${crit}" | cut -d= -f2`
103 if [ "a${value}" = "a" ]; then
104 echo "FIXME: File ${file} does not specify value of criteria." > /dev/stderr
105 value="ERROR OCCURRED"
106 fi
107 len=`echo "${value}" | wc -c`
108 len=`echo ${len}`
109 len=`expr ${len} - 1`
110 len=`echo ${len}`
111 case "${field}" in
112 sVe)
113 cat<<andl
114 elif [ "a${value}" = "a\`echo \${SYSFS_SCSI_Vendor} | \${cutbin} -b1-${len}\`" ]; then
115 andl
116 ;;
117 sMo)
118 cat<<andl
119 elif [ "a${value}" = "a\`echo \${SYSFS_SCSI_Model} | \${cutbin} -b1-${len}\`" ]; then
120 andl
121 ;;
122 sRe)
123 cat<<andl
124 elif [ "a${value}" = "a\`echo \${SYSFS_SCSI_Revision} | \${cutbin} -b1-${len}\`" ]; then
125 andl
126 ;;
127 uMa)
128 cat<<andl
129 elif [ "a${value}" = "a\`echo \${SYSFS_USB_Manufacturer} | \${cutbin} -b1-${len}\`" ]; then
130 andl
131 ;;
132 uPr)
133 cat<<andl
134 elif [ "a${value}" = "a\`echo \${SYSFS_USB_Product} | \${cutbin} -b1-${len}\`" ]; then
135 andl
136 ;;
137 uSe)
138 cat<<andl
139 elif [ "a${value}" = "a\`echo \${SYSFS_USB_Serial} | \${cutbin} -b1-${len}\`" ]; then
140 andl
141 ;;
142 "?")
143 cat<<andl
144 elif [ "a" = "NEVER" ]; then
145 echo ## Ignored entry
146 andl
147 ;;
148 *)
149 echo "ERROR: Unknown criteria when halding file ${file}. Please FIX ME." > /dev/stderr
150 cat<<andl
151 elif [ "a${value}" = "NEVER" ]; then
152 echo ## Internal Sakis3G Error
153 andl
154 ;;
155 esac
156 else
157 cat<<andl
158 elif [ "1" = "1" ]; then
159 andl
160 fi
161
162 cat<<andl
163 modeswitchconf="`basename ${file}`"
164 andl
165 done
166 cat <<andl
167 else
168 modeswitchconf=""
169 fi
170 andl
171 else
172 cat <<andl
173 modeswitchconf="${i}"
174 andl
175 fi
176 cat<<andl
177 }
178
179 andl
180 done
181
0 #!/bin/sh
1 MYVERSION="0.2.0e"
2
3 # Transform debug to DEBUG, in order to declare debug method.
4 if [ -n "${debug}" ]; then
5 echo "Warning: debug variable is obsolete. Use DEBUG instead." >> /dev/stderr
6 export DEBUG="${debug}"
7 unset debug
8 fi
9
10 # Display formatted debug output if DEBUG variable is set.
11 # This method should have as less dependencies as possible.
12 debug() {
13 if [ "a$1" != "arun_command" -a "a$1" != "ashow_file" -a -z "${DEBUG}" ]; then
14 return 0
15 elif [ "a$1" = "arun_command" -a -z "${DEBUG}" ]; then
16 shift
17 sh -c "$*" > /dev/null 2> /dev/null
18 return $?
19 elif [ "a$1" = "arun_command" -a -n "${DEBUG}" ]; then
20 shift
21 printf "/-------------------------------------------------------------------------------\n" >> "/dev/stderr"
22 printf "[%.5d] [%s] Will now run command: \'%s\'\n" "$$" "`date "+%H:%M:%S"`" "${*}" >> "/dev/stderr"
23 printf "/-------------------------------------------------------------------------------\n" >> "/dev/stderr"
24 sh -c "$*" >> "/dev/stderr" 2>&1
25 rdebug=$?
26 printf "\-------------------------------------------------------------------------------\n" >> "/dev/stderr"
27 printf "[%.5d] [%s] Command returned %d.\n" "$$" "`date "+%H:%M:%S"`" "${rdebug}" >> "/dev/stderr"
28 printf "\-------------------------------------------------------------------------------\n" >> "/dev/stderr"
29 return ${rdebug}
30 elif [ -z "${DEBUG}" ]; then
31 return 0
32 elif [ "a$1" = "ashow_file" ]; then
33 if [ -f "$2" ]; then
34 printf "/-------------------------------------------------------------------------------\n" >> "/dev/stderr"
35 printf "[%.5d] [%s] Will now display contents of: \'%s\'\n" "$$" "`date "+%H:%M:%S"`" "$2" >> "/dev/stderr"
36 printf "/-------------------------------------------------------------------------------\n" >> "/dev/stderr"
37 cat "$2" >> "/dev/stderr"
38 printf "\-------------------------------------------------------------------------------\n" >> "/dev/stderr"
39 ls -ld "$2" >> "/dev/stderr"
40 printf "\-------------------------------------------------------------------------------\n" >> "/dev/stderr"
41 else
42 printf "/-------------------------------------------------------------------------------\n" >> "/dev/stderr"
43 printf "[%.5d] [%s] File does not exist: \'%s\'\n" "$$" "`date "+%H:%M:%S"`" "$2" >> "/dev/stderr"
44 printf "\-------------------------------------------------------------------------------\n" >> "/dev/stderr"
45 fi
46 return 0
47 else
48 rfmt="$1"
49 shift
50 if [ "a${YESFUNCNAME}" = "a" ]; then
51 if [ "$#" -ge "1" ]; then
52 printf "[%.5d] [%s] ${rfmt}" "$$" "`date "+%H:%M:%S"`" "${@}" >> "/dev/stderr"
53 else
54 printf "[%.5d] [%s] ${rfmt}" "$$" "`date "+%H:%M:%S"`" >> "/dev/stderr"
55 fi
56 else
57 if [ "$#" -ge "1" ]; then
58 printf "[%.5d] [%s] [%-20s] ${rfmt}" "$$" "`date "+%H:%M:%S"`" "${FUNCNAME[1]}" "${@}" >> "/dev/stderr"
59 else
60 printf "[%.5d] [%s] [%-20s] ${rfmt}" "$$" "`date "+%H:%M:%S"`" "${FUNCNAME[1]}" >> "/dev/stderr"
61 fi
62 fi
63 unset rfmt
64 fi
65 return 0
66 }
67
68 # Print debug header
69 debug_header() {
70 if [ -n "${DEBUG}" ]; then
71 echo >> "/dev/stderr"
72 echo "-------------------------------------------" >> "/dev/stderr"
73 echo "Sakis3G ${MYVERSION} running on DEBUG mode." >> "/dev/stderr"
74 echo "-------------------------------------------" >> "/dev/stderr"
75 date >> "/dev/stderr"
76 echo "-------------------------------------------" >> "/dev/stderr"
77 if [ "a${allargs}" = "a" ]; then
78 echo "Command line was: $0 $@" >> "/dev/stderr"
79 else
80 echo "Command line was: $0 ${allargs}" >> "/dev/stderr"
81 fi
82 echo "Running with PID: $$" >> "/dev/stderr"
83 echo "-------------------------------------------" >> "/dev/stderr"
84 echo "Environment is:" >> "/dev/stderr"
85 set >> "/dev/stderr"
86 echo "-------------------------------------------" >> "/dev/stderr"
87 echo "Will now proceed with Sakis3G execution." >> "/dev/stderr"
88 echo "-------------------------------------------" >> "/dev/stderr"
89 fi
90 }
91
92 need_arg() {
93 [ "a`eval echo \\\$$1 2> /dev/null`" != "a" ] && return 0
94 case "$1" in
95 foldwrapping)
96 export foldwrapping=60
97 ;;
98 pppint)
99 export pppint="ppp0"
100 ;;
101 CHAT_ABORT_STRINGS)
102 # Abort strings that chat program may encounter
103 export CHAT_ABORT_STRINGS="ABORT BUSY ABORT ERROR ABORT BLOCKED ABORT NOCARRIER"
104 ;;
105 BAUD)
106 export BAUD="460800"
107 ;;
108 PPPD_OPTIONS)
109 # Options passed to pppd when called directly
110 export PPPD_OPTIONS="modem crtscts -detach defaultroute dump noipdefault usepeerdns usehostname ktune logfd 2 noauth name sakis3g lock maxfail 3"
111 ;;
112 PPPD_PEERS)
113 # Directory where pppd keeps its peers
114 export PPPD_PEERS=/etc/ppp/peers
115 ;;
116 SERIALDRIVERS)
117 export SERIALDRIVERS="ftdi_sio ipaq safe_serial usbserial visor"
118 ;;
119 LOGPOSITION)
120 export LOGPOSITION="/var/log/sakis3g.log"
121 ;;
122 XOSDFONT)
123 export XOSDFONT='-*-freesans-bold-r-*-*-36-*-*-*-*-*-*-*'
124 ;;
125 AOSDFONT)
126 export AOSDFONT='DejaVuSans 36'
127 ;;
128 MENUFONT)
129 export MENUFONT="-monotype-arial-medium-r-normal-*-18-*-*-*-*-*-*-*"
130 ;;
131 *)
132 debug "No default value for %s was found.\n" "$1"
133 ;;
134 esac
135 debug "Loaded default value for %s: %s\n" "$1" "`eval echo \\\$$1 2> /dev/null`"
136 }
137
138 sanitize() {
139 echo "$@" 2> /dev/null | ${trbin} "\\" " " 2> /dev/null | ${trbin} "\"" " " | ${trbin} "'" " " | ${trbin} "\`" " "
140 }
141
142 release_X_cookie() {
143 debug "Disposing stolen X session cookie for %s.\n" "${XCOOKIE}"
144 if [ -n "${XCOOKIE}" ] && find_binary "xauth"; then
145 # If having an authority file that does not belong to us, unset it.
146 if [ "a${XAUTHORITY}" = "a${runhome}/.Xauthority" -a "a$HOME" != "a${runhome}" ]; then
147 unset XAUTHORITY
148 fi
149 found=`${xauthbin} nlist ${XCOOKIE} | ${wcbin} -l`
150 found=`echo ${found}`
151 if [ "a${found}" = "a0" ]; then
152 debug "Cookie already disposed.\n"
153 else
154 ${xauthbin} remove ${XCOOKIE}
155 found=`xauth nlist ${XCOOKIE} | ${wcbin} -l`
156 found=`echo ${found}`
157 if [ "a${found}" = "a0" ]; then
158 debug "Cookie disposed as it should.\n"
159 unset XCOOKIE
160 else
161 debug "Failed to dispose cookie.\n"
162 fi
163 fi
164 unset found
165 fi
166 }
167
168 # Callback function called on EXIT to execute traps.
169 exittrap() {
170 if [ -n "${TRAPS}" ]; then
171 debug "Now executing traps.\n"
172 for tr in ${TRAPS}
173 do
174 debug "Executing trap \"%s\".\n" "${tr}"
175 ${tr}
176 done
177 else
178 debug "No exit traps defined.\n"
179 fi
180 if ppp_fast_status; then
181 debug "\n>>>>>>>>> If program is paused, you may freely press Ctrl+C. <<<<<<<<<\n>>> This happens due to DEBUG being set. Connection will NOT drop. <<<\n"
182 fi
183 }
184
185 # Adds trap to be executed on EXIT
186 addexittrap() {
187 [ "a$1" = "a" ] && return 0;
188 if [ "a${TRAPS}" = "a" ]; then
189 trap exittrap EXIT
190 debug "Established trap handler.\n"
191 fi
192 if ! strinstr "$1" "${TRAPS}" " "; then
193 TRAPS="$1 ${TRAPS}"
194 debug "Traps are now: %s\n" "${TRAPS}"
195 else
196 debug "Trap %s already registered.\n" "${1}"
197 fi
198 }
199
200 translate_load() {
201 unset translatebase
202 ! find_binary "printf" && return 1
203 ! find_binary "grep" && return 1
204 ! find_binary "head" && return 1
205 ! find_binary "tail" && return 1
206 ! find_binary "sed" && return 1
207 ! find_binary "cat" && return 1
208 ! find_binary "cut" && return 1
209 ! find_binary "tr" && return 1
210 if [ "a${notranslate}" != "a" ]; then
211 export notranslate=yes; unset foldwrapping; need_arg "foldwrapping"
212 return 1
213 fi
214 if [ "a${TRANSLATION}" != "a" ] && [ -f "${TRANSLATION}" ]; then
215 debug "Requested to use file %s for translations.\n" "${TRANSLATION}"
216 translatebase=`${catbin} "${TRANSLATION}" 2> /dev/null`
217 elif [ "a${PROVIDER}" != "a" ] && [ -x "${PROVIDER}" ]; then
218 translatelocale="${LC_MESSAGES}"
219 [ "a${translatelocale}" = "a" ] && translatelocale="${LC_ALL}"
220 [ "a${translatelocale}" = "a" ] && translatelocale="${LOCALE}"
221 [ "a${translatelocale}" = "a" ] && translatelocale="${LANG}"
222 if [ "a${translatelocale}" = "a" ]; then
223 debug "No locale reported by system. Will not be using translations.\n"
224 export notranslate=yes; unset foldwrapping; need_arg "foldwrapping"
225 return 1
226 fi
227 debug "Locale %s found in environment.\n" "${translatelocale}"
228 translatelocale=`echo ${translatelocale} | ${grepbin} -i "UTF\(.*\)8"`
229 if [ "a${translatelocale}" = "a" ]; then
230 debug "Reported locale is not UTF-8. Will not be using translations.\n"
231 export notranslate=yes; unset foldwrapping; need_arg "foldwrapping"
232 return 1
233 fi
234 translatelocale=`echo ${translatelocale} | ${cutbin} -d. -f1 | ${sedbin} -e "s/$/.UTF-8/g"`
235 debug "Will attempt to get translation file from package: %s.\n" "messages/${translatelocale}"
236 translatebase=`${PROVIDER} getfile "messages/${translatelocale}" 2> /dev/null`
237 else
238 debug "Unable to retrieve any translation file. Will not be using translations.\n"
239 export notranslate=yes; unset foldwrapping; need_arg "foldwrapping"
240 return 1
241 fi
242 helperfactor=`echo "${translatebase}" 2> /dev/null | ${headbin} -1 | ${grepbin} "^##\([0-9]\)$" | ${sedbin} -e "s/^##//g"`
243 [ "a${helperfactor}" = "a" ] && helperfactor=1
244 unset foldwrapping; need_arg "foldwrapping";
245 foldwrapping=`expr ${foldwrapping} \* ${helperfactor} 2> /dev/null`; foldwrapping=`echo ${foldwrapping}`
246 [ "a${foldwrapping}" = "a" ] && unset foldwrapping
247 need_arg "foldwrapping"; unset helperfactor
248 translatebase=`${printfbin} "%s" "${translatebase}" | ${grepbin} -v "^#"`
249 if [ "a${translatebase}" = "a" ]; then
250 debug "No translations retrieved from file. Will not be using translations.\n"
251 export notranslate=yes; unset foldwrapping; need_arg "foldwrapping"
252 return 1
253 fi
254 export foldwrapping
255 debug "Translations loaded. Wrapping at %d bytes.\n" "${foldwrapping}"
256 return 0
257 }
258
259 # Translates argument to locale
260 translate_text() {
261 if [ "a${notranslate}" != "a" ]; then
262 ${printfbin} "%s" "$1"
263 return 0
264 fi
265 [ "a${translatebase}" = "a" ] && translate_load
266 if [ "a${notranslate}" != "a" -o "a${translatebase}" = "a" ]; then
267 ${printfbin} "%s" "$1"
268 return 0
269 fi
270 # Safer, still slower way to translate
271 #texttomatch=`${printfbin} "%s" "$1" | ${trbin} "\\n" ".." | ${trbin} "\n" "." | ${trbin} "\t" "." | ${trbin} "\\\\\\\" "." | ${sedbin} -e "s/\\\\\\/\./g" | ${sedbin} -e "s/\"/\./g"`
272 texttomatch=`${printfbin} "%s" "$1" | ${trbin} "\\\\\\\" "." | ${trbin} "\\\\\"" "." | ${trbin} "\n" "."`
273 # Comment below is to help gedit in colouring text
274 # `"`
275 if [ -n "${showtext}" ]; then
276 debug "Text to check: %s\n" "${1}"
277 debug "Text to match: %s\n" "${texttomatch}"
278 fi
279 texttranslated=`${printfbin} "%s" "${translatebase}" | ${grepbin} -A 1 -G "^.${texttomatch}.$" | ${headbin} -2 | ${tailbin} -1 | ${sedbin} -e "s/^\"\(.*\)\"$/\1/g"`
280 unset texttomatch
281 if [ "a${texttranslated}" != "a" -a "a${texttranslated}" != "a\"" ]; then
282 [ -n "${showtext}" ] && debug "Text returned: %s\n" "${texttranslated}"
283 ${printfbin} "%s" "${texttranslated}"
284 else
285 [ -n "${showtext}" ] && debug "No translation found, returning original text: %s\n" "$1"
286 ${printfbin} "%s" "$1"
287 fi
288 unset texttranslated
289 return 0
290 }
291
292 # Safety helper
293 safe_invoke() {
294 if [ "a${NOFUNCNAME}" != "a" ]; then
295 debug "FIXME: Called %s without FUNCNAME variables available.\n" "$0"
296 return 99
297 fi
298 if [ "a${FUNCNAME[1]}" = "a" ]; then
299 debug "FIXME: %s called without FUNCNAME[1] being available.\n"
300 return 99
301 fi
302 debug "Function %s requested to call it in a safe manner.\n" "${FUNCNAME[1]}"
303 callertimeout="$1"; callertimeout=`expr ${callertimeout} + 1 - 1 2> /dev/null`
304 if [ "a${callertimeout}" = "a$1" ]; then
305 debug "Timeout set by %s to %d seconds.\n" "${FUNCNAME[1]}" "${callertimeout}"
306 shift
307 else
308 callertimeout=5
309 debug "Caller did not provide timeout. Using default (%d seconds).\n" "${callertimeout}"
310 fi
311 if [ "a${safetimeout}" != "a" ]; then
312 unset callertimeout
313 debug "FIXME: However, we are already within a safe session.\n"
314 ${FUNCNAME[1]} "safe" "$@"
315 ret=$?
316 debug "FIXME: Function %s returned from within a nested safe session.\n" "${FUNCNAME[1]}"
317 return ${ret}
318 elif [ "a${nosafety}" != "a" ]; then
319 unset callertimeout
320 debug "However, config instructs not to use safety-checks.\n"
321 ${FUNCNAME[1]} "safe" "$@"
322 ret=$?
323 unset TIMEOUTOCCURED
324 debug "Unsafe function %s returned.\n" "${FUNCNAME[1]}"
325 return ${ret}
326 fi
327 safetimeout="${callertimeout}"
328 callermethod="${FUNCNAME[1]}"
329 unset TIMEOUTOCCURED; unset callertimeout
330 if find_binary "mktemp"; then
331 debug "Using %s to store standard output and error of %s.\n" "${mktempbin}" "${callermethod}"
332 outputholder=`${mktempbin} -p /tmp -q sakis3g.safe.output.$$.XXXXXXXX`
333 errorholder=`${mktempbin} -p /tmp -q sakis3g.safe.error.$$.XXXXXXXX`
334 fi
335 if [ "a${outputholder}" = "a" ]; then
336 debug "Using backup method for creating temporary output holder.\n"
337 outputholder="/tmp/sakis3g.unsafe.output.$$"
338 fi
339 if [ "a${errorholder}" = "a" ]; then
340 debug "Using backup method for creating temporary output holder.\n"
341 errorholder="/tmp/sakis3g.unsafe.error.$$"
342 fi
343 debug "Will store output at: %s\n" "${outputholder}"
344 debug "Will store error at: %s\n" "${errorholder}"
345 debug "Initiating safe session for %s (%d seconds timeout).\n" "${callermethod}" "${safetimeout}"
346 "${callermethod}" "safe" "$@" > "${outputholder}" 2> "${errorholder}" &
347 safecallerpid=$!; eval "disown -a" > /dev/null 2> /dev/null
348 debug "Method spawned with PID %d.\n" "${safecallerpid}"
349 while ! notrunning "${safecallerpid}"
350 do
351 debug "%s still runs. %d seconds before killing.\n" "${callermethod}" "${safetimeout}"
352 if [ "a${safetimeout}" = "a0" ]; then
353 debug "Time expired with no results.\n"
354 if find_binary "kill"; then
355 debug "Will attempt to kill process with PID %d.\n" "${safecallerpid}"
356 ! notrunning "${safecallerpid}" && debug run_command "${killbin} -1 ${safecallerpid}"
357 ! notrunning "${safecallerpid}" && debug run_command "${killbin} -9 ${safecallerpid}"
358 ! notrunning "${safecallerpid}" && debug "Failed to kill it.\n"
359 fi
360 if find_binary "rm"; then
361 debug "Will attempt to unlink temporary holders.\n"
362 debug run_command "${rmbin} -f \"${outputholder}\" \"${errorholder}\""
363 fi
364 export TIMEOUTOCCURED="${callermethod}"
365 unset callermethod; unset safecallerpid; unset outputholder; unset errorholder
366 debug "Method %s failed to respond within timeout.\n"
367 unset safetimeout
368 return 99
369 fi
370 safetimeout=`expr ${safetimeout} - 1`; safetimeout=`echo ${safetimeout}`
371 sleep 1
372 done
373 debug "Method returned while %d seconds were remaining.\n" "${safetimeout}"
374 debug show_file "${outputholder}"
375 debug show_file "${errorholder}"
376 if find_binary "cat"; then
377 debug "Will now route output and error to mine.\n"
378 [ -f "${outputholder}" ] && ${catbin} "${outputholder}" 2> /dev/null
379 [ -f "${errorholder}" ] && ${catbin} "${errorholder}" >> /dev/stderr 2> /dev/null
380 fi
381 if find_binary "rm"; then
382 debug "Will attempt to unlink temporary holders.\n"
383 debug run_command "${rmbin} -f \"${outputholder}\" \"${errorholder}\""
384 fi
385 debug "Method %s responded within timeout specified.\n" "${FUNCNAME[1]}"
386 unset callermethod; unset safecallerpid; unset outputholder; unset errorholder
387 unset safetimeout
388 debug "Left safe mode.\n"
389 return 0
390 }
391
392 safe_lsusb() {
393 if [ "a$1" != "asafe" -a "a${NOFUNCNAME}" = "a" ]; then
394 safe_invoke "5" "$@"
395 return $?
396 elif [ "a${NOFUNCNAME}" = "a" ]; then
397 shift
398 fi
399 [ "a${lsusbbin}" != "a" ] && ${lsusbbin} "$@"
400 }
401
402 safe_chat() {
403 if [ "a$1" != "asafe" -a "a${NOFUNCNAME}" = "a" ]; then
404 safe_invoke "10" "$@"
405 return $?
406 elif [ "a${NOFUNCNAME}" = "a" ]; then
407 shift
408 fi
409 [ "a${chatbin}" != "a" ] && ${chatbin} "$@"
410 }
411
412 safe_cat() {
413 if [ "a$1" != "asafe" -a "a${NOFUNCNAME}" = "a" ]; then
414 safe_invoke "5" "$@"
415 return $?
416 elif [ "a${NOFUNCNAME}" = "a" ]; then
417 shift
418 fi
419 [ "a${catbin}" != "a" ] && ${catbin} "$@"
420 }
421
422 # Formats text
423 format_text() {
424 if find_binary "printf"; then
425 rfmt="$1"
426 [ "$#" -gt "0" ] && shift
427 rfmt=`translate_text "${rfmt}"`
428 if [ "$#" -ge "1" ]; then
429 ${printfbin} "${rfmt}" "${@}"
430 else
431 ${printfbin} "${rfmt}"
432 fi
433 unset rfmt
434 else
435 echo "${@}"
436 fi
437 }
438
439 # Clears terminal line if required
440 term_clearline() {
441 [ "a${COLUMNS}" != "a" ] && find_binary "printf" && [ -n "${interactive}" ] && ${printfbin} "\r%.-${COLUMNS}s\r" "" && return 0
442 [ "a${COLUMNS}" = "a" ] && find_binary "printf" && [ -n "${interactive}" ] && ${printfbin} "\r%s\r" " " && return 0
443 }
444
445 # Prints argument to terminal
446 term_print() {
447 term_clearline
448 echo "${@}"
449 }
450
451 # Sends error to terminal, colored if possible.
452 term_error() {
453 if find_binary "grep" && [ -n "${interactive}" ]; then
454 term_print "$@" | ${grepbin} --color "."
455 else
456 term_print "$@"
457 fi
458 }
459
460 term_verbose() {
461 if [ -n "${interactive}" ]; then
462 if find_binary "grep" && find_binary "tr"; then
463 currentlyverbosing=yes
464 term_print "$@" | GREP_COLOR=2 ${grepbin} --color=always "." | ${trbin} "\n" " "
465 unset currentlyverbosing; lastlineverbose=yes
466 else
467 term_print "$@"
468 fi
469 fi
470 }
471
472 term_notify() {
473 if find_binary "grep" && [ -n "${interactive}" ]; then
474 term_print "$@" | GREP_COLOR=1 ${grepbin} --color "."
475 else
476 term_print "$@"
477 fi
478 }
479
480 select_example() {
481 examplevariable=`selection_argument variable "$@"`
482 exampleoptions=`selection_argument options "$@"`
483 [ "a${exampleoptions}" != "a" ] && format_text "\nAvailable options are:\n" && format_text "%s\n" "${exampleoptions}"
484 [ "a${exampleoptions}" = "a" ] && exampleoptions="foo"
485 format_text "\nExample:\n"
486 format_text "\t$ %s [...] %s=\"%s\"\n\r\n" "${ME}" "${examplevariable}" "`echo ${exampleoptions} | ${cutbin} -d\ -f1`"
487 unset exampletitle; unset examplevariable; unset exampleoptions
488 }
489
490 term_select_example() {
491 examplevariable=`selection_argument variable "$@"`
492 exampleoptions=`selection_argument options "$@"`
493 [ "a${exampleoptions}" != "a" ] && notify "\nAvailable options are:\n" && notify "%s\n" "${exampleoptions}"
494 [ "a${exampleoptions}" = "a" ] && exampleoptions="foo"
495 notify "\nExample:\n"
496 notify "\t$ %s %s=\"%s\"\n\r\n" "${ME}" "${examplevariable}" "`echo ${exampleoptions} | ${cutbin} -d\ -f1`"
497 unset exampletitle; unset examplevariable; unset exampleoptions
498 }
499
500 term_select() {
501 options=`selection_argument options "$@" | ${wcbin} -l`; options=`echo ${options}`
502 variable=`selection_argument variable "$@"`
503 if [ "a${options}" != "a1" ]; then
504 exampletitle=`selection_argument title "$@"`
505 notify "%s by using %s variable, or by enabling interactive mode.\n" "${exampletitle}" "${variable}"
506 notify "\t$ %s --interactive %s\n" "${ME}" "${allargs}"
507 unset exampletitle
508 term_select_example "$@"
509 else
510 eval export ${variable}="`selection_argument option 1 "$@"`"
511 debug "Returning sole available option \"%s\" on behalf of user.\n" "`eval echo \\\${${variable}}`"
512 unset variable
513 return 1
514 fi
515 unset variable; unset options
516 stop_with 98
517 return 98
518 }
519
520 term_confirm() {
521 options=`selection_argument options "$@" | ${wcbin} -l`; options=`echo ${options}`
522 variable=`selection_argument variable "$@"`
523 exampletitle=`selection_argument title "$@"`
524 notify "%s by using --%syes or --%sno switches, or by enabling interactive mode.\n" "${exampletitle}" "${variable}" "${variable}"
525 notify "\t$ %s --interactive %s\n" "${ME}" "${allargs}"
526 unset exampletitle
527 stop_with 98
528 return 98
529 }
530
531 term_prompt() {
532 variable=`selection_argument variable "$@"`
533 exampletitle=`selection_argument title "$@"`
534 notify "%s by using %s variable, or by enabling interactive mode.\n" "${exampletitle}" "${variable}"
535 notify "\t$ %s --interactive %s\n" "${ME}" "${allargs}"
536 unset exampletitle
537 term_select_example "$@"
538 return 98
539 }
540
541 interactive_term_select() {
542 variable=`selection_argument variable "$@"`
543 title=`selection_argument title "$@"`
544 text=`selection_argument text "$@"`
545 options=`selection_argument options "$@" | ${wcbin} -l` ; options=`echo ${options}`
546 debug "Prompting user to select variable %s.\n" "${variable}"
547 [ "a${title}" != "a" ] && notify "%s\n\r\n" "${title}"
548 [ "a${text}" != "a" ] && ${printfbin} "%s\n\r\n" "${text}"
549 notify "Available options are:\n"
550 selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)/\1. \3/g" | GREP_COLOR=1 ${grepbin} --color=AUTO "\([0-9]*\)\."
551 selection_argument button2 "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\)/0. \2/g" | GREP_COLOR=1 ${grepbin} --color=AUTO "\([0-9]*\)\."
552 format_text "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n" "${variable}" | GREP_COLOR=2 ${grepbin} --color=ALWAYS "."
553 notify "\r\n"
554 echo -n "`format_text "Please use numbers %d-%d to perform your selection: " "0" "${options}"`"
555 read termselection
556 debug "User typed: \"%s\"\n" "${termselection}"
557 if [ "a${termselection}" = "a*" ]; then
558 debug "Showing select example through variable %s.\n" "${variable}"
559 term_select_example "$@"
560 interactive_term_select "$@"
561 selection=$?
562 else
563 selection=`${printfbin} "%d\n" "${termselection}" 2> /dev/null`
564 [ "${selection}" -gt "${options}" ] && selection=0
565 [ "${selection}" -eq "0" ] && selection=98
566 [ "${selection}" -gt "0" -a "${selection}" -le "${options}" ] && eval export ${variable}="`selection_argument option ${selection} "$@"`"
567 fi
568 debug "Considering selection: %d\n" "${selection}"
569 unset variable; unset title; unset text; unset options; unset termselection
570 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
571 return "${selection}"
572 }
573
574 interactive_term_confirm() {
575 variable=`selection_argument variable "$@"`
576 title=`selection_argument title "$@"`
577 text=`selection_argument text "$@"`
578 debug "Prompting user to select variable %s.\n" "${variable}"
579 [ "a${title}" != "a" ] && notify "%s\n\r\n" "${title}"
580 [ "a${text}" != "a" ] && ${printfbin} "%s\n\r\n" "${text}"
581 notify "Available options are:\n"
582 selection_argument button1 "$@" | ${sedbin} -e "s/^\(.*\)$/1. \1/g" | GREP_COLOR=1 ${grepbin} --color=AUTO "^\([0-9]*\)\."
583 selection_argument button2 "$@" | ${sedbin} -e "s/^\(.*\)$/2. \1/g" | GREP_COLOR=1 ${grepbin} --color=AUTO "^\([0-9]*\)\."
584 [ "a$6" != "areset" ] && format_text "You can automate this selection by setting --%syes or --%sno switches.\n" "${variable}" "${variable}" | GREP_COLOR=2 ${grepbin} --color=ALWAYS "."
585 notify "\r\n"
586 echo -n "`format_text "Please use numbers %d-%d to perform your selection: " "1" "2"`"
587 read termselection
588 debug "User typed: \"%s\"\n" "${termselection}"
589 if [ "a${termselection}" = "a1" ]; then
590 debug "User selected \"yes\".\n"
591 selection=0
592 elif [ "a${termselection}" = "a2" ]; then
593 debug "User selected \"no\".\n"
594 selection=1
595 else
596 interactive_term_confirm "$@"
597 selection=$?
598 return ${selection}
599 fi
600 unset variable; unset title; unset text; unset options; unset termselection
601 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
602 return "${selection}"
603 }
604
605 interactive_term_prompt() {
606 variable=`selection_argument variable "$@"`
607 title=`selection_argument title "$@"`
608 text=`selection_argument text "$@"`
609 debug "Prompting user to type variable %s.\n" "${variable}"
610 [ "a${title}" != "a" ] && notify "%s\n" "${title}"
611 format_text "You can automate this selection by setting %s variable.\nEnter \"*\" to discover how.\n" "${variable}" | GREP_COLOR=2 ${grepbin} --color=ALWAYS "."
612 notify "\r\n"
613 [ "a${text}" != "a" ] && ${printfbin} "%s: " "${text}"
614 read termselection
615 termselection=`sanitize "${termselection}"`
616 termselection=`echo "${termselection}" | ${sedbin} -e "s/^ *//g" | ${sedbin} -e "s/ *$//g"`
617 debug "User typed: \"%s\"\n" "${termselection}"
618 if [ "a${termselection}" = "a*" ]; then
619 debug "Showing select example through variable %s.\n" "${variable}"
620 term_select_example "$@"
621 interactive_term_prompt "$@"
622 selection=$?
623 elif [ "a${termselection}" = "a" ]; then
624 debug "User pressed enter which indicates to abort.\n"
625 selection=98
626 else
627 eval "export ${variable}=\"${termselection}\""
628 selection=0
629 fi
630 debug "Considering selection: %d\n" "${selection}"
631 unset variable; unset title; unset text; unset termselection
632 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
633 return "${selection}"
634 }
635
636 nine_verbose() {
637 term_verbose "$@"
638 }
639
640 nine_fixcolors() {
641 status_connected
642 [ "a${NINEISP}" != "a${ISPID}" -o "a${ISPID}" = "a" ] && unset NINEBGCOLOR && unset NINEFGCOLOR
643 [ "a${NINEFGCOLOR}" = "a" ] && NINEFGCOLOR=`echo ${ISP_FGCOLOR} | ${sedbin} -e "s/^\(..\)\(..\)\(..\)$/rgb:\1\/\2\/\3/g"`
644 [ "a${NINEBGCOLOR}" = "a" ] && NINEBGCOLOR=`echo ${ISP_BGCOLOR} | ${sedbin} -e "s/^\(..\)\(..\)\(..\)$/rgb:\1\/\2\/\3/g"`
645 [ "a${ISPID}" = "a" ] && unset NINEBGCOLOR && unset NINEFGCOLOR
646 [ "a${NINEFGCOLOR}" = "a" ] && NINEFGCOLOR="rgb:00/00/00"
647 [ "a${NINEBGCOLOR}" = "a" ] && NINEBGCOLOR="rgb:ec/ec/ec"
648 [ "a${NINEISP}" = "a" ] && NINEISP="${ISPID}"
649 export NINEISP; export NINEFGCOLOR; export NINEBGCOLOR
650 }
651
652 nine_notify() {
653 unset nineerrormode
654 ! find_binary "9menu" && return 1
655 if [ "a${1}" = "aerror" ]; then
656 nineerrormode=1
657 shift
658 debug "Going into error mode.\n"
659 else
660 debug "Normal notification.\n"
661 fi
662 ninetext=`echo "$@" | ${sedbin} -e "s/:/;/g"`
663 need_arg "MENUFONT"
664 need_arg "foldwrapping"
665 if find_binary "fold"; then
666 ninetext=`echo "${ninetext}" | ${foldbin} -s -w ${foldwrapping}`
667 else
668 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(............................................................\)\(.*\)$/\1\\n\2/g"`
669 fi
670 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(.*\)$/\"\1:\"/g" | ${trbin} " " " " | ${trbin} "\n" " "`
671 debug "Displaying text to user through 9menu:%s\n" " $@ "
672 debug "Displaying text to user through 9menu:%s\n" " ${ninetext} "
673 if [ "a${nineerrormode}" = "a1" ]; then
674 result=`eval "${ninemenubin} -font \"${MENUFONT}\" -bg \"rgb:ff/80/80\" -fg white -display \"${DISPLAY}\" -label \"\`translate_text "Error"\`\" ${ninetext} \":\" \"OK:exec echo OK-\"" 2> /dev/null | ${grepbin} "^OK-" | ${cutbin} -d- -f1`
675 else
676 nine_fixcolors
677 result=`eval "${ninemenubin} -font \"${MENUFONT}\" -bg ${NINEBGCOLOR} -fg ${NINEFGCOLOR} -display \"${DISPLAY}\" -label \"\`translate_text "Notification"\`\" ${ninetext} \":\" \"OK:exec echo OK-\"" 2> /dev/null | ${grepbin} "^OK-" | ${cutbin} -d- -f1`
678 fi
679 if [ "a${result}" = "aOK" ]; then
680 debug "User saw message.\n"
681 else
682 debug "9menu died or user closed it.\n"
683 fi
684 unset ninetext; unset result; unset nineerrormode
685 }
686
687 nine_error() {
688 nine_notify "error" "$@"
689 }
690
691 nine_select() {
692 ! find_binary "9menu" && return 1
693 nine_fixcolors
694 need_arg "MENUFONT"
695 need_arg "foldwrapping"
696 debug "Prompting user to select variable %s with 9menu.\n" "${variable}"
697 variable=`selection_argument variable "$@"`
698 title=`selection_argument title "$@"`
699 text=`selection_argument text "$@"`
700 options=`selection_argument options "$@" | ${wcbin} -l` ; options=`echo ${options}`
701 helptext=`format_text "You can automate this selection by setting %s variable on command line, click here to discover how.\n" "${variable}" | ${sedbin} -e "s/:/;/g"`
702 localbutton2=`selection_argument button2 "$@"`; [ "a${localbutton2}" = "a" ] && localbutton2="Cancel"
703 ninetext=`echo "${text}" | ${sedbin} -e "s/:/;/g"`
704 if find_binary "fold"; then
705 ninetext=`echo "${ninetext}" | ${foldbin} -s -w ${foldwrapping}`
706 helptext=`echo "${helptext}" | ${foldbin} -s -w ${foldwrapping}`
707 else
708 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(............................................................\)\(.*\)$/\1\\n\2/g"`
709 helptext=`echo "${helptext}" | ${sedbin} -e "s/^\(............................................................\)\(.*\)$/\1\\n\2/g"`
710 fi
711 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(.*\)$/\"\1:\"/g" | ${trbin} " " " " | ${trbin} "\n" " "`
712 helptext=`echo "${helptext}" | ${sedbin} -e "s/^\(.*\)$/\"\1:exec echo OPTION-AUTOMATE\"/g" | ${trbin} " " " " | ${trbin} "\n" " "`
713 localarguments=`selection_argument options "$@" | ${sedbin} -e "s/:/;/g" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1. \3:exec echo OPTION-\1\"/g" | ${trbin} "\n" " "`
714 termselection=`eval "${ninemenubin} -font \"${MENUFONT}\" -bg ${NINEBGCOLOR} -fg ${NINEFGCOLOR} -display \"${DISPLAY}\" -label \"${title}\" ${ninetext} \":\" ${localarguments} \":\" ${helptext} \":\" \"${localbutton2}:exec echo OPTION-9menuexit\"" 2> /dev/null | ${grepbin} "^OPTION-" | ${cutbin} -d- -f2-`
715 debug "User selected: \"%s\"\n" "${termselection}"
716 if [ "a${termselection}" = "aAUTOMATE" ]; then
717 localtext=`format_text "You can automate this selection by setting %s variable on command line.\n" "${variable}"`
718 notify "${localtext}\n`select_example "$@"`"
719 nine_select "$@"
720 selection=$?
721 return ${selection}
722 elif [ "a${termselection}" = "a9menuexit" -o "a${termselection}" = "a" ]; then
723 debug "User selected button: %s\n" "${localbutton2}"
724 selection=98
725 else
726 termselection=`echo "${termselection}" | ${trbin} -t "." ""`
727 selection=`${printfbin} "%d\n" "${termselection}" 2> /dev/null`
728 [ "${selection}" -gt "${options}" ] && selection=0
729 [ "${selection}" -eq "0" ] && selection=98
730 [ "${selection}" -gt "0" -a "${selection}" -le "${options}" ] && eval export ${variable}="`selection_argument option ${selection} "$@"`"
731 fi
732 debug "Considering selection: %d\n" "${selection}"
733 unset variable; unset title; unset text; unset ninetext; unset helptext; unset options; unset termselection; unset buttonselection; unset localtext; unset localarguments; unset localbutton2
734 return "${selection}"
735 }
736
737 nine_confirm() {
738 ! find_binary "9menu" && return 1
739 nine_fixcolors
740 need_arg "MENUFONT"
741 need_arg "foldwrapping"
742 variable=`selection_argument variable "$@"`
743 title=`selection_argument title "$@"`
744 ninetext=`selection_argument text "$@" | ${sedbin} -e "s/:/;/g"`
745 localbutton1=`selection_argument button1 "$@"`; [ "a${localbutton1}" = "a" ] && localbutton1="OK"
746 localbutton2=`selection_argument button2 "$@"`; [ "a${localbutton2}" = "a" ] && localbutton2="Cancel"
747 debug "Prompting user to confirm variable %s with 9menu.\n" "${variable}"
748 helptext=""
749 [ "a$6" != "areset" ] && helptext=`format_text "You can automate this selection by setting --%syes or --%sno switches.\n" "${variable}" "${variable}" | ${sedbin} -e "s/:/;/g"`
750 if find_binary "fold"; then
751 ninetext=`echo "${ninetext}" | ${foldbin} -s -w ${foldwrapping}`
752 helptext=`echo "${helptext}" | ${foldbin} -s -w ${foldwrapping}`
753 else
754 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(............................................................\)\(.*\)$/\1\\n\2/g"`
755 helptext=`echo "${helptext}" | ${sedbin} -e "s/^\(............................................................\)\(.*\)$/\1\\n\2/g"`
756 fi
757 ninetext=`echo "${ninetext}" | ${sedbin} -e "s/^\(.*\)$/\"\1:\"/g" | ${trbin} " " " " | ${trbin} "\n" " "`
758 helptext=`echo "${helptext}" | ${sedbin} -e "s/^\(.*\)$/\"\1:\"/g" | ${trbin} " " " " | ${trbin} "\n" " "`
759 localarguments="\"${localbutton1}:exec echo Answer-Yes\" \"${localbutton2}:exec echo Answer-No\""
760 termselection=`eval "${ninemenubin} -font \"${MENUFONT}\" -bg ${NINEBGCOLOR} -fg ${NINEFGCOLOR} -display \"${DISPLAY}\" -label \"${title}\" ${ninetext} \":\" ${localarguments} \":\" ${helptext} \":\"" 2> /dev/null | ${grepbin} "^Answer-" | ${cutbin} -d- -f2-`
761 debug "User selected: \"%s\"\n" "${termselection}"
762 if [ "a${termselection}" = "aYes" ]; then
763 selection=0
764 else
765 selection=1
766 fi
767 debug "Considering selection: %d\n" "${selection}"
768 unset variable; unset title; unset text; unset ninetext; unset helptext; unset options; unset termselection; unset buttonselection; unset localtext; unset localarguments; unset localbutton2; unset localbutton1
769 return "${selection}"
770 }
771
772 nine_prompt() {
773 ! find_binary "xterm" && return 1
774 variable=`selection_argument variable "$@"`
775 title=`selection_argument title "$@"`
776 text=`selection_argument text "$@"`
777 debug "Prompting user to type variable %s through xterm.\n" "${variable}"
778 localtext=`format_text "You can automate this selection by setting %s variable.\n" "${variable}"`
779 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\n\n%s: " "${localtext}" "${text}"`
780 locallines=`echo "${localtext}" | ${wcbin} -l`; locallines=`echo ${locallines}`; locallines=`expr ${locallines} + 10`; locallines=`echo ${locallines}`;
781 ${printfbin} "%s\n" "${localtext}" > "/tmp/sakis3g.xterm.pipe.$$"
782 ${xtermbin} -T "${title}" +cm +dc -e sh -c "${catbin} /tmp/sakis3g.xterm.pipe.$$; read XTERMANSWER; set >> /tmp/sakis3g.xterm.pipe.$$;" 2> /dev/null
783 debug show_file "/tmp/sakis3g.xterm.pipe.$$"
784 termselection=`${grepbin} "^XTERMANSWER=" "/tmp/sakis3g.xterm.pipe.$$" 2> /dev/null | ${cutbin} -d= -f2- | ${sedbin} -e "s/^\"\(.*\)\"$/\1/g" | ${sedbin} -e "s/^\'\(.*\)\'$/\1/g"`; ${rmbin} -f "/tmp/sakis3g.xterm.pipe.$$"
785 termselection=`sanitize "${termselection}"`
786 debug "User typed: \"%s\"\n" "${termselection}"
787 # TODO: Implement example
788 if [ "a${termselection}" != "a" ]; then
789 debug "User typed: %s\n" "${termselection}"
790 eval "export ${variable}=\"${termselection}\""
791 selection=0
792 elif [ "a${termselection}" = "a" ]; then
793 debug "User requested to cancel.\n"
794 selection=98
795 else
796 debug "Unknown error.\n"
797 selection=99
798 fi
799 debug "Considering selection: %d\n" "${selection}"
800 unset variable; unset title; unset text; unset termselection; unset buttonselection; unset localtext
801 return "${selection}"
802 }
803
804 dialog_error() {
805 dialog_cleanscreen
806 if [ "a${SGUI}" = "adialog" ]; then
807 ! find_binary "dialog" && return 1
808 ${dialogbin} --backtitle "Sakis3G ${MYVERSION}" --colors --title "\Z1\Zb`translate_text "Error occured"`" --ok-label `translate_text "OK"` --clear --colors --aspect 30 --msgbox "\Z1\ZB$@" 0 0
809 elif [ "a${SGUI}" = "aXdialog" ]; then
810 ! find_binary "Xdialog" && return 1
811 ${Xdialogbin} --backtitle `translate_text "Error occured"` --title "Sakis3G ${MYVERSION}" --ok-label `translate_text "OK"` --msgbox "$@ " 0 0
812 elif [ "a${SGUI}" = "azenity" ]; then
813 ! find_binary "zenity" && return 1
814 ${zenitybin} --title "`translate_text "Error occured"`" --error --text "$@ "
815 elif [ "a${SGUI}" = "akdialog" ]; then
816 ! find_binary "kdialog" && return 1
817 ${kdialogbin} --title "`translate_text "Error occured"`" --error "$@ " > /dev/null 2> /dev/null
818 elif [ "a${SGUI}" = "awhiptail" ]; then
819 ! find_binary "whiptail" && return 1
820 ${whiptailbin} --backtitle "Sakis3G ${MYVERSION}" --title "`translate_text "Error occured"`" --clear --msgbox "$@ " 0 0
821 fi
822 }
823
824 dialog_notify() {
825 dialog_cleanscreen
826 if [ "a${SGUI}" = "adialog" ]; then
827 ! find_binary "dialog" && return 1
828 ${dialogbin} --backtitle "Sakis3G ${MYVERSION}" --title `translate_text "Notification"` --ok-label `translate_text "OK"` --clear --aspect 30 --msgbox "$@" 0 0
829 elif [ "a${SGUI}" = "aXdialog" ]; then
830 ! find_binary "Xdialog" && return 1
831 ${Xdialogbin} --title "Sakis3G ${MYVERSION}" --ok-label `translate_text "OK"` --msgbox "$@" 0 0
832 elif [ "a${SGUI}" = "azenity" ]; then
833 ! find_binary "zenity" && return 1
834 ${zenitybin} --title "Sakis3G ${MYVERSION}" --info --text "$@ "
835 elif [ "a${SGUI}" = "akdialog" ]; then
836 ! find_binary "kdialog" && return 1
837 ${kdialogbin} --title "Sakis3G ${MYVERSION}" --msgbox "$@ " > /dev/null 2> /dev/null
838 elif [ "a${SGUI}" = "awhiptail" ]; then
839 ! find_binary "whiptail" && return 1
840 ${whiptailbin} --backtitle "Sakis3G ${MYVERSION}" --title `translate_text "Notification"` --clear --msgbox "$@" 0 0
841 fi
842 }
843
844 dialog_cleanscreen() {
845 if [ "a${SGUI}" = "aXdialog" ]; then
846 if [ "a${XdialogVerbose}" != "a" -a "a${XdialogVerbose}" != "a0" ]; then
847 ! notrunning "${XdialogVerbose}" && find_binary "kill" && ${killbin} -1 "${XdialogVerbose}" 2> /dev/null
848 unset XdialogVerbose
849 fi
850 unset currentlyverbosing
851 elif [ "a${SGUI}" = "azenity" ]; then
852 [ -f "/tmp/sakis3g.zenity.pipe" ] && ${printfbin} "\n100\n" >> "/tmp/sakis3g.zenity.pipe"
853 [ -f "/tmp/sakis3g.zenity.pipe" ] && debug run_command "${rmbin} -f /tmp/sakis3g.zenity.pipe"
854 [ "a${zenityverbosepid}" != "a" ] && ! notrunning "${zenityverbosepid}" && ${killbin} -1 "${zenityverbosepid}" 2> /dev/null
855 [ "a${zenityverbosepid}" != "a" ] && ! notrunning "${zenityverbosepid}" && ${killbin} -9 "${zenityverbosepid}" 2> /dev/null
856 unset zenityverbosepid
857 elif [ "a${SGUI}" = "akdialog" ]; then
858 ! find_binary "kdialog" && return 1
859 if [ "a${kdialogaddress}" != "a" ]; then
860 dcopbased=`echo ${kdialogaddress} | ${grepbin} -i "dcop"`
861 if [ "a${dcopbased}" != "a" ]; then
862 if find_binary "dcop"; then
863 debug run_command "${dcopbin} \"${kdialogaddress}\" close"
864 fi
865 else
866 ! find_binary "dbus-send" && find_binary "qdbus"
867 if [ "a${dbus_sendbin}" != "a" ]; then
868 debug run_command "${dbus_sendbin} --print-reply --dest=${kdialogaddress} \"org.kde.kdialog.ProgressDialog.close\""
869 elif [ "a${qdbusbin}" != "a" ]; then
870 debug run_command "${qdbusbin} ${kdialogaddress} \"org.kde.kdialog.ProgressDialog.close\""
871 fi
872 fi
873 else
874 term_clearline
875 fi
876 unset kdialogaddress
877 fi
878 }
879
880 dialog_verbose() {
881 if [ "a${SGUI}" = "adialog" ]; then
882 ! find_binary "dialog" && return 1
883 verbwidth=`echo "${COLUMNS}"`; verbwidth=`expr ${verbwidth} + 1 - 1`; verbwidth=`echo ${verbwidth}`
884 verbheight=0; [ "${verbwidth}" -gt "40" ] && verbheight=3
885 currentlyverbosing=yes
886 ${dialogbin} --backtitle "Sakis3G ${MYVERSION}" --title "Working" --aspect 40 --infobox "$@..." ${verbheight} ${verbwidth}
887 unset currentlyverbosing; lastlineverbose=yes; unset verbwidth; unset verbheight
888 elif [ "a${SGUI}" = "aXdialog" ]; then
889 # ! find_binary "Xdialog" && return 1
890 # ${Xdialogbin} --title "Sakis3G is working" --infobox "$@..." 0 0 30000 &
891 # XdialogVerbose=$!; currentlyverbosing=yes
892 term_verbose "$@"
893 elif [ "a${SGUI}" = "akdialog" ]; then
894 ! find_binary "kdialog" && return 1
895 if ! find_binary "dbus-send" && ! find_binary "qdbus"; then
896 term_verbose "$@"; return 0
897 fi
898 if [ "a${kdialogaddress}" = "a" ]; then
899 temptext=`translate_text Working...`
900 kdialogaddress=`${kdialogbin} --title "Sakis3G ${MYVERSION}" --progressbar "${temptext}" 100`
901 # kdialogaddress=`${kdialogbin} --title "Sakis3G ${MYVERSION}" --progressbar "${temptext}" 100 2> /dev/null`
902 debug "Returned 1\n"
903 unset temptext
904 [ "a${kdialogaddress}" != "a" ] && export kdialogaddress
905 fi
906 debug "Returned 2\n"
907 if [ "a${kdialogaddress}" != "a" ]; then
908 dcopbased=`echo ${kdialogaddress} | ${grepbin} -i "dcop"`
909 if [ "a${dcopbased}" != "a" ]; then
910 if find_binary "dcop"; then
911 debug run_command "${dcopbin} --user \"${runner}\" --all-sessions \"${kdialogaddress}\" setProgress ${verbosecurrentcount}"
912 debug run_command "${dcopbin} --user \"${runner}\" --all-sessions \"${kdialogaddress}\" setLabel \"$@\""
913 fi
914 else
915 if [ "a${kdialogaddress}" != "a" ] && [ "a${dbus_sendbin}" != "a" ]; then
916 debug run_command "${dbus_sendbin} --print-reply --dest=${kdialogaddress} \"org.freedesktop.DBus.Properties.Set\" string:'org.kde.kdialog.ProgressDialog' string:'value' variant:int32:${verbosecurrentcount}"
917 debug run_command "${dbus_sendbin} --print-reply --dest=${kdialogaddress} \"org.kde.kdialog.ProgressDialog.setLabelText\" \"string:$@\""
918 elif [ "a${kdialogaddress}" != "a" ] && [ "a${qdbusbin}" != "a" ]; then
919 debug run_command "qdbus ${kdialogaddress} \"org.kde.kdialog.ProgressDialog.setLabelText\" \"$@\""
920 debug run_command "qdbus ${kdialogaddress} \"org.freedesktop.DBus.Properties.Set\" \"\" \"value\" \"${verbosecurrentcount}\""
921 fi
922 fi
923 else
924 term_verbose "$@"
925 fi
926 elif [ "a${SGUI}" = "azenity" ]; then
927 ! find_binary "zenity" && return 1
928 [ "a${zenityverbosepid}" != "a" ] && notrunning "${zenityverbosepid}" && unset zenityverbosepid
929 [ ! -f "/tmp/sakis3g.zenity.pipe" ] && unset zenityverbosepid
930 if [ "a${zenityverbosepid}" = "a" ] && find_binary "rm" && find_binary "tail" && find_binary "kill" && find_binary "printf" && find_binary "touch" && find_binary "chmod" && find_binary "setsid"; then
931 debug "Establishing zenity verbose helper.\n"
932 [ -f "/tmp/sakis3g.zenity.pipe" ] && ${printfbin} "\n100\n" >> "/tmp/sakis3g.zenity.pipe"
933 [ -f "/tmp/sakis3g.zenity.pipe" ] && debug run_command "${rmbin} -f /tmp/sakis3g.zenity.pipe"
934 debug run_command "${touchbin} /tmp/sakis3g.zenity.pipe"
935 debug run_command "${chmodbin} 666 /tmp/sakis3g.zenity.pipe"
936 if [ -f "/tmp/sakis3g.zenity.pipe" ]; then
937 eval ${tailbin} -f "/tmp/sakis3g.zenity.pipe" "2> /dev/null" | ${zenitybin} --title="Sakis3G ${MYVERSION}" --text="`translate_text Working...`" --progress --percentage=0 --auto-close "> /dev/null 2> /dev/null" &
938 zenityverbosepid=$!
939 eval "disown -a" > /dev/null 2> /dev/null
940 export zenityverbosepid
941 fi
942 fi
943 [ "a${zenityverbosepid}" != "a" ] && notrunning "${zenityverbosepid}" && unset zenityverbosepid
944 [ "a${zenityverbosepid}" = "a" ] && term_verbose "$@" && return 1
945 ${printfbin} "\n%d\n# $@...\n\n" "${verbosecurrentcount}" >> "/tmp/sakis3g.zenity.pipe"
946 elif [ "a${SGUI}" = "awhiptail" ]; then
947 term_verbose "$@"
948 fi
949 }
950
951 dialog_confirm() {
952 dialog_cleanscreen
953 if [ "a${SGUI}" = "adialog" ]; then
954 ! find_binary "dialog" && return 1
955 elif [ "a${SGUI}" = "aXdialog" ]; then
956 ! find_binary "Xdialog" && return 1
957 elif [ "a${SGUI}" = "azenity" ]; then
958 ! find_binary "zenity" && return 1
959 elif [ "a${SGUI}" = "akdialog" ]; then
960 ! find_binary "kdialog" && return 1
961 elif [ "a${SGUI}" = "awhiptail" ]; then
962 ! find_binary "whiptail" && return 1
963 fi
964 variable=`selection_argument variable "$@"`
965 title=`selection_argument title "$@"`
966 text=`selection_argument text "$@"`
967 debug "Prompting user to select yes%s or no%s.\n" "${variable}" "${variable}"
968 localtext=""
969 [ "a$6" != "areset" ] && localtext=`format_text "You can automate this selection by setting --%syes or --%sno switches.\n" "${variable}" "${variable}"`
970 if [ "a${SGUI}" = "adialog" ]; then
971 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${text}" "${localtext}"`
972 ${dialogbin} --backtitle "Sakis3G ${MYVERSION}" --title " ${title} " --clear --cr-wrap --yesno "${localtext}" 0 0 2> /dev/null
973 buttonselection=$?
974 elif [ "a${SGUI}" = "aXdialog" ]; then
975 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${text}" "${localtext}"`
976 ${Xdialogbin} --backtitle " ${title} " --title "Sakis3G ${MYVERSION}" --wrap --fill --yesno "${localtext}" 0 0 2> /dev/null
977 buttonselection=$?
978 elif [ "a${SGUI}" = "akdialog" ]; then
979 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${text}" "${localtext}"`
980 ${kdialogbin} --title " ${title} " --yesno "${text}" 2> /dev/null
981 buttonselection=$?
982 elif [ "a${SGUI}" = "azenity" ]; then
983 need_arg "foldwrapping"
984 text=`echo "${text}" | ${sedbin} -e "s/_/__/g"`
985 localtext=`echo "${localtext}" | ${sedbin} -e "s/_/__/g"`
986 # if find_binary "fold"; then
987 # localtext=`echo "${localtext}" | ${foldbin} -s -w ${foldwrapping}`
988 # text=`echo "${text}" | ${foldbin} -s -w ${foldwrapping}`
989 # fi
990 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${text}" "${localtext}"`
991 ${zenitybin} --title " ${title} " --question --text "${localtext}" 2> /dev/null
992 buttonselection=$?
993 elif [ "a${SGUI}" = "awhiptail" ]; then
994 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${text}" "${localtext}"`
995 ${whiptailbin} --backtitle "Sakis3G ${MYVERSION}" --title " ${title} " --clear --yesno "${localtext}" 0 0 2> /dev/null
996 buttonselection=$?;
997 fi
998 if [ "a${buttonselection}" = "a0" ]; then
999 debug "User selected \"yes\" (%d).\n" "${buttonselection}"
1000 return 0
1001 else
1002 debug "User selected \"no\" (%d).\n" "${buttonselection}"
1003 return 1
1004 fi
1005 }
1006
1007 dialog_select() {
1008 dialog_cleanscreen
1009 if [ "a${SGUI}" = "adialog" ]; then
1010 ! find_binary "dialog" && return 1
1011 elif [ "a${SGUI}" = "aXdialog" ]; then
1012 ! find_binary "Xdialog" && return 1
1013 elif [ "a${SGUI}" = "azenity" ]; then
1014 ! find_binary "zenity" && return 1
1015 elif [ "a${SGUI}" = "akdialog" ]; then
1016 ! find_binary "kdialog" && return 1
1017 elif [ "a${SGUI}" = "awhiptail" ]; then
1018 ! find_binary "whiptail" && return 1
1019 fi
1020 variable=`selection_argument variable "$@"`
1021 title=`selection_argument title "$@"`
1022 text=`selection_argument text "$@"`
1023 options=`selection_argument options "$@" | ${wcbin} -l` ; options=`echo ${options}`
1024 debug "Prompting user to select variable %s.\n" "${variable}"
1025 localtext=`format_text "You can automate this selection by setting %s variable on command line.\n" "${variable}"`
1026 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\\\\\\n\\\\\\n%s\n" "${localtext}" "${text}"`
1027 localbutton2=`selection_argument button2 "$@"`; [ "a${localbutton2}" = "a" ] && localbutton2="Cancel"
1028 if [ "a${SGUI}" = "adialog" ]; then
1029 localarguments=`selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1.\" \"\3\" \"${variable}=\\\\\"\2\\\\\"\"/g"`
1030 eval ${dialogbin} --backtitle \"Sakis3G ${MYVERSION}\" --title \" ${title} \" --ok-label \"`translate_text "OK"`\" --cancel-label \"${localbutton2}\" --item-help --clear --cr-wrap --menu \"${localtext}\" 0 0 0 ${localarguments} 2> "/tmp/sakis3g.dialog.$$"
1031 buttonselection=$?
1032 elif [ "a${SGUI}" = "aXdialog" ]; then
1033 localarguments=`selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1.\" \"\3\" \"${variable}=\\\\\"\2\\\\\"\"/g"`
1034 eval ${Xdialogbin} --backtitle \" ${title} \" --title \"Sakis3G ${MYVERSION}\" --ok-label \"`translate_text "OK"`\" --cancel-label \"${localbutton2}\" --item-help --wrap --fill --menubox \""${localtext}"\" 0 0 0 ${localarguments} 2> "/tmp/sakis3g.dialog.$$"
1035 buttonselection=$?
1036 elif [ "a${SGUI}" = "akdialog" ]; then
1037 localarguments=`selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1.\" \"\3\"/g"`
1038 eval ${kdialogbin} --title \" ${title} \" --menu \""${text}"\" ${localarguments} \"AUTOMATE\" \"`translate_text "Help with this question"`\" > "/tmp/sakis3g.dialog.$$" 2> /dev/null
1039 buttonselection=$?
1040 elif [ "a${SGUI}" = "azenity" ]; then
1041 need_arg "foldwrapping"
1042 localarguments=`selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1.\" \"\3\"/g"`
1043 localtext=`echo "${text}" | ${sedbin} -e "s/_/__/g"`
1044 find_binary "fold" && localtext=`echo "${localtext}" | ${foldbin} -s -w ${foldwrapping}`
1045 eval ${zenitybin} --title \" ${title} \" --list --text \""${localtext}"\" --hide-column 1 --column Index --column `translate_text "Option"` ${localarguments} \"AUTOMATE\" \"`translate_text "Help with this question"`\" > "/tmp/sakis3g.dialog.$$"
1046 buttonselection=$?
1047 elif [ "a${SGUI}" = "awhiptail" ]; then
1048 localarguments=`selection_argument options "$@" | ${grepbin} -n "." | ${sedbin} -e "s/^\([0-9]*\):\(.*\) \(.*\)$/\"\1. \3\" \"\2\"/g"`
1049 eval ${whiptailbin} --backtitle \"Sakis3G ${MYVERSION}\" --title \" ${title} \" --noitem --clear --menu \"${localtext}\" 0 0 0 ${localarguments} 2> "/tmp/sakis3g.dialog.$$"
1050 buttonselection=$?;
1051 fi
1052 termselection=`${catbin} "/tmp/sakis3g.dialog.$$" 2> /dev/null`; ${rmbin} -f "/tmp/sakis3g.dialog.$$"
1053 debug "User selected: \"%s\"\n" "${termselection}"
1054 if [ "a${termselection}" = "aAUTOMATE" ]; then
1055 variable=`selection_argument variable "$@"`
1056 localtext=`format_text "You can automate this selection by setting %s variable on command line.\n" "${variable}"`
1057 notify "${localtext}\n`select_example "$@" | ${sedbin} -e "s/ /\\\n /g"`"
1058 dialog_select "$@"
1059 selection=$?
1060 return ${selection}
1061 elif [ "a${buttonselection}" != "a0" ]; then
1062 debug "User selected button: %d\n" "${buttonselection}"
1063 selection=98
1064 else
1065 termselection=`echo "${termselection}" | ${trbin} -t "." ""`
1066 selection=`${printfbin} "%d\n" "${termselection}" 2> /dev/null`
1067 [ "${selection}" -gt "${options}" ] && selection=0
1068 [ "${selection}" -eq "0" ] && selection=98
1069 [ "${selection}" -gt "0" -a "${selection}" -le "${options}" ] && eval export ${variable}="`selection_argument option ${selection} "$@"`"
1070 fi
1071 debug "Considering selection: %d\n" "${selection}"
1072 unset variable; unset title; unset text; unset options; unset termselection; unset buttonselection; unset localtext; unset localarguments; unset localbutton2
1073 return "${selection}"
1074 }
1075
1076 dialog_prompt() {
1077 dialog_cleanscreen
1078 if [ "a${SGUI}" = "adialog" ]; then
1079 ! find_binary "dialog" && return 1
1080 elif [ "a${SGUI}" = "aXdialog" ]; then
1081 ! find_binary "Xdialog" && return 1
1082 elif [ "a${SGUI}" = "azenity" ]; then
1083 ! find_binary "zenity" && return 1
1084 elif [ "a${SGUI}" = "akdialog" ]; then
1085 ! find_binary "kdialog" && return 1
1086 elif [ "a${SGUI}" = "awhiptail" ]; then
1087 ! find_binary "whiptail" && return 1
1088 fi
1089 variable=`selection_argument variable "$@"`
1090 title=`selection_argument title "$@"`
1091 text=`selection_argument text "$@"`
1092 debug "Prompting user to type variable %s.\n" "${variable}"
1093 localtext=`format_text "You can automate this selection by setting %s variable.\n" "${variable}"`
1094 [ "a${text}" != "a" ] && localtext=`${printfbin} "%s\n\n%s: " "${localtext}" "${text}"`
1095 locallines=`echo "${localtext}" | ${wcbin} -l`; locallines=`echo ${locallines}`; locallines=`expr ${locallines} + 10`; locallines=`echo ${locallines}`;
1096 if [ "a${SGUI}" = "adialog" ]; then
1097 ${dialogbin} --backtitle "Sakis3G ${MYVERSION}" --title " ${title} " --ok-label `translate_text "OK"` --cancel-label `translate_text "Cancel"` --clear --inputbox "${localtext}" ${locallines} 0 2> "/tmp/sakis3g.dialog.$$"
1098 buttonselection=$?
1099 elif [ "a${SGUI}" = "aXdialog" ]; then
1100 ${Xdialogbin} --backtitle " ${title} " --title "Sakis3G ${MYVERSION}" --ok-label `translate_text "OK"` --cancel-label `translate_text "Cancel"` --wrap --fill --clear --inputbox "${localtext}" ${locallines} 0 2> "/tmp/sakis3g.dialog.$$"
1101 buttonselection=$?
1102 elif [ "a${SGUI}" = "akdialog" ]; then
1103 ${kdialogbin} --title " ${title} " --inputbox "${localtext}" "" > "/tmp/sakis3g.dialog.$$" 2> /dev/null
1104 buttonselection=$?
1105 elif [ "a${SGUI}" = "azenity" ]; then
1106 need_arg "foldwrapping"
1107 localtext=`echo "${localtext}" | ${sedbin} -e "s/_/__/g"`
1108 find_binary "fold" && localtext=`echo "${localtext}" | ${foldbin} -s -w ${foldwrapping}`
1109 ${zenitybin} --title " ${title} " --entry --text "${localtext}" > "/tmp/sakis3g.dialog.$$"
1110 buttonselection=$?
1111 elif [ "a${SGUI}" = "awhiptail" ]; then
1112 ${whiptailbin} --backtitle "Sakis3G ${MYVERSION}" --title " ${title} " --clear --inputbox "${localtext}" 0 0 2> "/tmp/sakis3g.dialog.$$"
1113 buttonselection=$?
1114 fi
1115 termselection=`${catbin} "/tmp/sakis3g.dialog.$$" 2> /dev/null`; ${rmbin} -f "/tmp/sakis3g.dialog.$$"
1116 termselection=`sanitize "${termselection}"`
1117 debug "User pressed button %d while typed: \"%s\"\n" "${buttonselection}" "${termselection}"
1118 # TODO: Implement example
1119 if [ "a${buttonselection}" = "a0" ]; then
1120 debug "User pressed OK.\n"
1121 if [ "a${termselection}" != "a" ]; then
1122 debug "User typed: %s\n" "${termselection}"
1123 eval "export ${variable}=\"${termselection}\""
1124 selection=0
1125 else
1126 debug "User entered no text.\n" "${variable}"
1127 selection=98
1128 fi
1129 elif [ "a${termselection}" = "a" -o "a${buttonselection}" != "a0" ]; then
1130 debug "User requested to cancel.\n"
1131 selection=98
1132 else
1133 debug "Unknown error.\n"
1134 selection=99
1135 fi
1136 debug "Considering selection: %d\n" "${selection}"
1137 unset variable; unset title; unset text; unset termselection; unset buttonselection; unset localtext
1138 return "${selection}"
1139 }
1140
1141 dialog_clearscreen() {
1142 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
1143 return 0
1144 }
1145
1146 selection_argument() {
1147 selectarg="$1"
1148 [ "$#" -gt "0" ] && shift
1149 case "${selectarg}" in
1150 variable)
1151 echo "$1"
1152 ;;
1153 title)
1154 echo "$2"
1155 ;;
1156 text)
1157 echo "$3"
1158 ;;
1159 button1)
1160 echo "$4"
1161 ;;
1162 button2)
1163 echo "$5"
1164 ;;
1165 options)
1166 for selectind in `${seqbin} 6 2 $#`
1167 do
1168 eval selcode=\${${selectind}}
1169 selectinc=`expr ${selectind} + 1`; selectinc=`echo ${selectinc}`
1170 eval seloption=\${${selectinc}}
1171 echo "${selcode} ${seloption}"
1172 unset selcode; unset seloption; unset selectinc
1173 done
1174 unset selectind
1175 ;;
1176 option)
1177 selectind=$1
1178 [ "$#" -gt "0" ] && shift
1179 selectind=`expr ${selectind} \* 2`; selectind=`echo ${selectind}`
1180 selectind=`expr ${selectind} + 4`; selectind=`echo ${selectind}`
1181 eval selcode=\${${selectind}}
1182 echo "${selcode}"
1183 unset selcode; unset selectind
1184 ;;
1185 invalid)
1186 for selectind in `${seqbin} 7 2 $#`
1187 do
1188 eval selcode=\${${selectind}}
1189 if [ "a${selcode}" = "a$1" ]; then
1190 debug "%s==%s.\n" "$1" "${selcode}"
1191 unset selcode; unset selectarg
1192 selectind=`expr ${selectind} - 5`; selectind=`echo ${selectind}`
1193 selectind=`expr ${selectind} / 2`; selectind=`echo ${selectind}`
1194 return ${selectind}
1195 fi
1196 debug "%s!=%s\n" "${selcode}" "${1}"
1197 unset selcode
1198 done
1199 debug "Not a valid option \"%s\".\n" "$1"
1200 unset selectind
1201 return 0
1202 ;;
1203 *)
1204 debug "Unknown selection id %s.\n" "${selectarg}"
1205 ;;
1206 esac
1207 unset selectarg
1208 }
1209
1210 # Returns true if $1 is found within $2.
1211 strinstr() {
1212 [ "a$1" = "a" -o "a$2" = "a" ] && return 1
1213 if [ "a$3" = "a" ]; then
1214 strinstrsep=":"
1215 else
1216 strinstrsep="$3"
1217 fi
1218 strinstrfound=`echo "${strinstrsep}${2}${strinstrsep}" | grep "${strinstrsep}${1}${strinstrsep}"`
1219 strinstrfound=`echo "${strinstrfound}"`
1220 unset strinstrsep
1221 if [ "a${strinstrfound}" != "a" ]; then
1222 unset strinstrfound
1223 return 0
1224 fi
1225 unset strinstrfound
1226 return 1
1227 }
1228
1229 # Checks if running with root priviledges
1230 we_are_root_already() {
1231 if [ "a${UID}" = "a0" -o "a${USER}" = "aroot" -o "a${EUID}" = "a0" ]; then
1232 return 0
1233 fi
1234 debug "Not currently running with root privileges.\n"
1235 return 1
1236 }
1237
1238 # Makes sure we are root
1239 we_are_root() {
1240 if we_are_root_already; then
1241 debug "We are root already. Proceeding.\n"
1242 return 0
1243 fi
1244 state_variables
1245 verbose "Acquiring root privileges"
1246 [ -z "${SUMETHOD}" ] && check_su_software
1247 [ -z "${ME}" ] && have_me
1248 cleanscreen
1249 debug "This instance will call %s and abort.\n" "${SUMETHOD}"
1250 case "${SUMETHOD}" in
1251 "sudo")
1252 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
1253 eval ${sudobin} ${ME} ${allargs} ${statevariables}
1254 ret=$?
1255 if [ "$ret" -eq "1" ]; then
1256 echo
1257 echo If it didn\'t worked, you need to add yourself
1258 echo to sudo file: as root, type visudo and add the
1259 echo following line at the end of file:
1260 echo ${runner} ALL=\(root\) NOPASSWD: ${ME}
1261 stop_fmt_error 1 "Failed to become root."
1262 fi
1263 ;;
1264 "gksu")
1265 # Nusty workaround because gksu does not properly handle arguments containing whitespaces
1266 ${touchbin} "/tmp/sakis3g.gksu.wrapper.$$"
1267 ${chmodbin} +x "/tmp/sakis3g.gksu.wrapper.$$"
1268 ${printfbin} "#!/bin/sh\nexport PROVIDER=\"%s\"\n%s %s %s\nexit \$?\n\n" "${PROVIDER}" "${ME}" "${allargs}" "${statevariables}" > "/tmp/sakis3g.gksu.wrapper.$$"
1269 [ ! -f "/tmp/sakis3g.gksu.wrapper.$$" ] && stop_fmt_error 3 "No method for acquiring root privileges found."
1270 debug show_file "/tmp/sakis3g.gksu.wrapper.$$"
1271 ${gksubin} /tmp/sakis3g.gksu.wrapper.$$
1272 ret=$?
1273 ${rmbin} -f "/tmp/sakis3g.gksu.wrapper.$$"
1274 ;;
1275 "kdesu")
1276 ${kdesubin} "${ME} ${allargs} ${statevariables}"
1277 ret=$?
1278 ;;
1279 "su")
1280 if [ -n "${stick_to_console}" -a -z "${interactive}" ]; then
1281 notify "\nUtility \"%s\" found but cannot be used since we are not interactive.\n" "su"
1282 notify "Either enable interactive mode:\n"
1283 notify "\t%s --interactive %s\n" "${ME}" "${allargs}"
1284 notify "or, force using %s instead:\n" "sudo"
1285 notify "\t%s --sudo %s\n\r\n" "${ME}" "${allargs}"
1286 stop_fmt_error 3 "No method for acquiring root privileges found."
1287 fi
1288 [ "a${DEBUG}" = "a" ] && find_binary "clear" && ${clearbin}
1289 term_print "Please supply root password, or press enter to abort."
1290 ${subin} -c "${ME} ${allargs} ${statevariables}"
1291 ret=$?
1292 ;;
1293 esac
1294 stop_with ${ret}
1295 }
1296
1297 # Shows error
1298 show_fmt_error() {
1299 errortext=`format_text "$@"`
1300 debug "Error: %s\n" "${errortext}"
1301 if [ "a${noerror}" != "a" ]; then
1302 debug "Skipping error notification due to configuration.\n"
1303 unset errortext
1304 return 0
1305 fi
1306 guruplug_error
1307 case "${SGUI}" in
1308 whiptail|dialog|Xdialog|zenity|kdialog)
1309 dialog_error "${errortext}"
1310 ;;
1311 "9menu")
1312 nine_error "${errortext}"
1313 ;;
1314 "interactive terminal")
1315 term_error "${errortext}"
1316 ;;
1317 "terminal")
1318 term_error "${errortext}"
1319 ;;
1320 *)
1321 term_error "${errortext}"
1322 ;;
1323 esac
1324 unset errortext
1325 }
1326
1327 cleanscreen() {
1328 osd_cleanscreen
1329 case "${SGUI}" in
1330 whiptail|dialog|Xdialog|zenity|kdialog)
1331 dialog_cleanscreen
1332 term_clearline
1333 ;;
1334 "9menu")
1335 term_clearline
1336 ;;
1337 "interactive terminal")
1338 term_clearline
1339 ;;
1340 "terminal")
1341 term_clearline
1342 ;;
1343 *)
1344 term_clearline
1345 ;;
1346 esac
1347 }
1348
1349 osd_cleanscreen() {
1350 if [ "a${OSDPID}" != "a" ]; then
1351 if find_binary "kill"; then
1352 ! notrunning "${OSDPID}" && ${killbin} -1 "${OSDPID}" 2> /dev/null
1353 ! notrunning "${OSDPID}" && ${killbin} -9 "${OSDPID}" 2> /dev/null
1354 fi
1355 unset OSDPID
1356 fi
1357 return 0
1358 }
1359
1360 osd_verbose() {
1361 [ "a${OSDOUTPUT}" = "a" ] && return 1
1362 osd_cleanscreen
1363 case "${OSDOUTPUT}" in
1364 osd_cat)
1365 need_arg "XOSDFONT"
1366 if [ "a${OSDISP}" != "a${ISPID}" ]; then
1367 unset OSDFGCOLOR; unset OSDBGCOLOR;
1368 fi
1369 [ "a${OSDFGCOLOR}" = "a" ] && OSDFGCOLOR=`echo ${ISP_FG_COLOR} | ${sedbin} -e "s/^\(..\)\(..\)\(..\)$/rgb:\1\/\2\/\3/g"`
1370 [ "a${OSDBGCOLOR}" = "a" ] && OSDBGCOLOR=`echo ${ISP_BG_COLOR} | ${sedbin} -e "s/^\(..\)\(..\)\(..\)$/rgb:\1\/\2\/\3/g"`
1371 [ "a${OSDFGCOLOR}" = "a" ] && OSDFGCOLOR="rgb:80/ff/80"
1372 [ "a${OSDBGCOLOR}" = "a" ] && OSDBGCOLOR="rgb:00/40/00"
1373 OSDISP="${ISPID}"
1374 export OSDISP; export OSDFGCOLOR; export OSDBGCOLOR;
1375 ${OSDOUTPUT} -T "Sakis3G: $1" -P ${verbosecurrentcount} -b percentage -O 2 -c ${OSDFGCOLOR} -u ${OSDBGCOLOR} -f "${XOSDFONT}" -p bottom -a 0 -d 10 -A center &
1376 OSDPID=$!
1377 eval "disown -a" > /dev/null 2> /dev/null
1378 export OSDPID
1379 [ "a${verbosecurrentcount}" = "a100" ] && sleep 3
1380 ;;
1381 aosd_cat)
1382 need_arg "AOSDFONT"
1383 ${OSDOUTPUT} -n "${AOSDFONT}" -f 100 -t 2 --input=- -u 10000 -o 3000 <<endl &
1384 $1
1385 endl
1386 OSDPID=$!
1387 eval "disown -a" > /dev/null 2> /dev/null
1388 export OSDPID
1389 [ "a${verbosecurrentcount}" = "a100" ] && sleep 3
1390 ;;
1391 esac
1392 }
1393
1394 verbose() {
1395 need_binary "printf"
1396 if [ "a$1" = "a100" ]; then
1397 verbosecurrentcount=93
1398 shift
1399 fi
1400 verbosetext=`format_text "$@"`
1401 [ "${verbosecurrentcount}" = "a" ] && verbosecurrentcount=0
1402 if [ "a${verbosetext}" = "a${lastverbosetext}" ]; then
1403 verbosecurrentcount=`expr ${verbosecurrentcount} + 1`;
1404 guruplug_verbose_same
1405 else
1406 verbosecurrentcount=`expr ${verbosecurrentcount} + 7`;
1407 guruplug_verbose
1408 fi
1409 lastverbosetext="${verbosetext}"
1410 verbosecurrentcount=`echo ${verbosecurrentcount}`
1411 export lastverbosetext
1412 export verbosecurrentcount
1413 debug "Verbosing: %d%% %s\n" "${verbosecurrentcount}" "${verbosetext}"
1414 if [ "a${noverbose}" != "a" ]; then
1415 debug "Skipping verbose due to configuration.\n"
1416 unset verbosetext
1417 return 0
1418 fi
1419 if [ "a${OSDOUTPUT}" != "a" ]; then
1420 osdtext=`${printfbin} "$@"`
1421 osd_verbose "${osdtext}"
1422 unset osdtext
1423 else
1424 case "${SGUI}" in
1425 whiptail|dialog|Xdialog|zenity|kdialog)
1426 dialog_verbose "${verbosetext}"
1427 ;;
1428 "9menu")
1429 nine_verbose "${verbosetext}"
1430 ;;
1431 "interactive terminal")
1432 term_verbose "${verbosetext}"
1433 ;;
1434 "terminal")
1435 term_verbose "${verbosetext}"
1436 ;;
1437 *)
1438 term_verbose "${verbosetext}"
1439 ;;
1440 esac
1441 fi
1442 unset verbosetext
1443 }
1444
1445 notify() {
1446 notificationtext=`format_text "$@"`
1447 debug "Notify: %s\n" "${notificationtext}"
1448 if [ "a${nonotify}" != "a" ]; then
1449 debug "Skipping notification due to configuration.\n"
1450 unset notificationtext
1451 return 0
1452 fi
1453 case "${SGUI}" in
1454 whiptail|dialog|Xdialog|zenity|kdialog)
1455 dialog_notify "${notificationtext}"
1456 ;;
1457 "9menu")
1458 nine_notify "${notificationtext}"
1459 ;;
1460 "interactive terminal")
1461 term_notify "${notificationtext}"
1462 ;;
1463 "terminal")
1464 term_notify "${notificationtext}"
1465 ;;
1466 *)
1467 term_notify "${notificationtext}"
1468 ;;
1469 esac
1470 unset notificationtext
1471 }
1472
1473 balloon_notify() {
1474 notificationtext=`format_text "$@"`
1475 if [ "a${nonotify}" != "a" ]; then
1476 debug "Skipping balloon notification due to configuration: %s\n" "${notificationtext}"
1477 unset notificationtext
1478 return 0
1479 fi
1480 # File is deleted during release_X_cookie
1481 [ "a${PROVIDER}" != "a" ] && [ -x "${PROVIDER}" ] && ${PROVIDER} getfile "files/sakis3g.png" 2> /dev/null > "/tmp/sakis3g.notification.icon.$$.png"
1482 debug "Will display final message using libnotify.\n"
1483 if [ ! -f "/tmp/sakis3g.notification.icon.$$.png" ]; then
1484 debug "Notifying user without icon.\n"
1485 debug run_command "${notify_sendbin} \"Sakis3G\" \"${notificationtext}\""
1486 else
1487 debug "Notifying user with icon.\n"
1488 debug run_command "${notify_sendbin} --icon=\"/tmp/sakis3g.notification.icon.$$.png\" \"Sakis3G\" \"${notificationtext}\""
1489 debug run_command "${rmbin} -f \"/tmp/sakis3g.notification.icon.$$.png\""
1490 fi
1491 unset notificationtext
1492 }
1493
1494 finalnotify() {
1495 guruplug_notify
1496 if [ "a${prefer_osd}" != "a" -a "a${OSDOUTPUT}" != "a" ]; then
1497 verbose "100" "$@"
1498 elif [ "a${prefer_osd}" = "a" -a "a${balloons}" != "a" -a "a${stick_to_console}" = "a" ] && find_binary "notify-send" && [ "a${DBUS_SESSION_BUS_ADDRESS}" != "a" -a "a${SESSION_MANAGER}" != "a" ]; then
1499 balloon_notify "$@"
1500 else
1501 notify "$@"
1502 fi
1503 }
1504
1505 translate_selection() {
1506 unset translatedarguments
1507 localcounter=0
1508 for localargument in "$@"
1509 do
1510 localcounter=`expr ${localcounter} + 1`; localcounter=`echo ${localcounter}`
1511 if [ "${localcounter}" -eq "1" ]; then
1512 translatedarguments="\"${localargument}\""
1513 elif [ "${localcounter}" -le "5" ]; then
1514 translatedtext=`translate_text "${localargument}"`
1515 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${translatedtext}"`
1516 unset translatedtext
1517 elif [ "${localcounter}" -gt "5" ]; then
1518 verification=`expr \( ${localcounter} / 2 \) \* 2`; verification=`echo ${verification}`
1519 if [ "a${verification}" = "a${localcounter}" ]; then
1520 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${localargument}"`
1521 else
1522 translatedtext=`translate_text "${localargument}"`
1523 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${translatedtext}"`
1524 unset translatedtext
1525 fi
1526 unset verification
1527 fi
1528 done
1529 unset localcounter; unset
1530 eval "user_select \"translated\" ${translatedarguments}"
1531 translatedselection=$?
1532 unset translatedarguments
1533 return ${translatedselection}
1534 }
1535
1536 translate_confirm() {
1537 unset translatedarguments
1538 localcounter=0
1539 for localargument in "$@"
1540 do
1541 localcounter=`expr ${localcounter} + 1`; localcounter=`echo ${localcounter}`
1542 if [ "${localcounter}" -eq "1" ]; then
1543 translatedarguments="\"${localargument}\""
1544 elif [ "${localcounter}" -le "5" ]; then
1545 translatedtext=`translate_text "${localargument}"`
1546 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${translatedtext}"`
1547 unset translatedtext
1548 elif [ "${localcounter}" -gt "5" ]; then
1549 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${localargument}"`
1550 fi
1551 done
1552 unset localcounter; unset
1553 eval "user_confirm \"translated\" ${translatedarguments}"
1554 translatedselection=$?
1555 unset translatedarguments
1556 return ${translatedselection}
1557 }
1558
1559 translate_prompt() {
1560 unset translatedarguments
1561 localcounter=0
1562 for localargument in "$@"
1563 do
1564 localcounter=`expr ${localcounter} + 1`; localcounter=`echo ${localcounter}`
1565 if [ "${localcounter}" -eq "1" ]; then
1566 translatedarguments="\"${localargument}\""
1567 elif [ "${localcounter}" -le "5" ]; then
1568 translatedtext=`translate_text "${localargument}"`
1569 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${translatedtext}"`
1570 unset translatedtext
1571 elif [ "${localcounter}" -gt "5" ]; then
1572 verification=`expr \( ${localcounter} / 2 \) \* 2`; verification=`echo ${verification}`
1573 if [ "a${verification}" = "a${localcounter}" ]; then
1574 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${localargument}"`
1575 else
1576 translatedtext=`translate_text "${localargument}"`
1577 translatedarguments=`${printfbin} "%s \"%s\"" "${translatedarguments}" "${translatedtext}"`
1578 unset translatedtext
1579 fi
1580 unset verification
1581 fi
1582 done
1583 unset localcounter; unset
1584 eval "user_prompt \"translated\" ${translatedarguments}"
1585 translatedselection=$?
1586 unset translatedarguments
1587 return ${translatedselection}
1588 }
1589
1590 user_confirm() {
1591 unset selection
1592 if [ "a$1" != "atranslated" ]; then
1593 debug "Asking user to confirm: %s\n" "`echo "$@"`"
1594 translate_confirm "$@"
1595 return $?
1596 else
1597 shift
1598 debug "Asking user to confirm: %s\n" "`echo "$@"`"
1599 fi
1600 if [ "$#" -lt 3 ]; then
1601 debug "FIXME: Wrong number of arguments (%d). Returning 99.\n" "$#"
1602 return 99
1603 fi
1604 variable=`selection_argument variable "$@"`
1605 if [ "a$6" = "areset" -a "a${interactive}" != "a" ]; then
1606 eval unset ${variable}yes
1607 eval unset ${variable}no
1608 else
1609 eval alreadyset=\${${variable}yes}
1610 if [ "a${alreadyset}" != "a" ]; then
1611 debug "Switch %syes is already set.\n" "${variable}"
1612 return 0
1613 fi
1614 eval alreadyset=\${${variable}no}
1615 if [ "a${alreadyset}" != "a" ]; then
1616 debug "Switch %sno is already set.\n" "${variable}"
1617 return 1
1618 fi
1619 fi
1620 if voodoo_mode; then
1621 debug "Voodoo-mode is enabled. Will consider it a yes.\n"
1622 eval unset ${variable}no
1623 eval ${variable}yes=1
1624 eval export ${variable}yes
1625 selection=0
1626 return 0
1627 fi
1628 case "${SGUI}" in
1629 whiptail|dialog|Xdialog|zenity|kdialog)
1630 dialog_confirm "$@"
1631 selection=$?
1632 ;;
1633 "9menu")
1634 nine_confirm "$@"
1635 selection=$?
1636 ;;
1637 "interactive terminal")
1638 interactive_term_confirm "$@"
1639 selection=$?
1640 ;;
1641 "terminal")
1642 term_confirm "$@"
1643 selection=$?
1644 ;;
1645 *)
1646 term_confirm "$@"
1647 selection=$?
1648 ;;
1649 esac
1650 variable=`selection_argument variable "$@"`
1651 if [ "a${selection}" = "a0" ]; then
1652 debug "User answered \"yes\".\n"
1653 eval unset ${variable}no
1654 eval ${variable}yes=1
1655 eval export ${variable}yes
1656 selection=0
1657 else
1658 debug "User answered \"no\".\n"
1659 eval unset ${variable}yes
1660 eval ${variable}no=1
1661 eval export ${variable}no
1662 selection=1
1663 fi
1664 unset variable
1665 return ${selection}
1666 }
1667
1668 user_select() {
1669 unset selection
1670 if [ "a$1" != "atranslated" ]; then
1671 debug "Asking user to select: %s\n" "`echo "$@"`"
1672 translate_selection "$@"
1673 return $?
1674 else
1675 shift
1676 debug "Asking user to select: %s\n" "`echo "$@"`"
1677 fi
1678 if [ "$#" -lt 3 ]; then
1679 debug "FIXME: Wrong number of arguments (%d). Returning 99.\n" "$#"
1680 return 99
1681 fi
1682 variable=`selection_argument variable "$@"`
1683 eval alreadyset=\${${variable}}
1684 if [ "a${alreadyset}" != "a" ]; then
1685 debug "%s=%s\n" "${variable}" "${alreadyset}"
1686 # Check tokens first
1687 for selectioniterator in ${alreadyset}
1688 do
1689 selection_argument invalid "${selectioniterator}" "$@"
1690 selection=$?
1691 if [ "a${selection}" != "a0" -a "a${selection}" != "a" ]; then
1692 debug "User has already selected %s=\"%s\". Returning %d.\n" "${variable}" "${selectioniterator}" "${selection}"
1693 eval export ${variable}="${selectioniterator}"
1694 unset variable; unset alreadyset; unset selectioniterator
1695 return ${selection}
1696 fi
1697 unset selection;
1698 done
1699 unset selectioniterator
1700 # Check whole value then
1701 selection_argument invalid "${alreadyset}" "$@"
1702 selection=$?
1703 if [ "a${selection}" != "a0" -a "a${selection}" != "a" ]; then
1704 debug "User has already selected %s=\"%s\". Returning %d.\n" "${variable}" "${alreadyset}" "${selection}"
1705 eval export ${variable}="${alreadyset}"
1706 unset variable; unset alreadyset
1707 return ${selection}
1708 fi
1709 # Else warn
1710 show_fmt_error "Already selected value %s=\"%s\". Is not valid.\n" "${variable}" "${alreadyset}"
1711 eval unset ${variable}
1712 unset variable; unset alreadyset;
1713 else
1714 debug "Variable %s is not set already.\n" "${variable}"
1715 unset alreadyset; unset variable
1716 fi
1717 if voodoo_mode; then
1718 variable=`selection_argument variable "$@"`
1719 selectioncount=`selection_argument options "$@" | ${wcbin} -l`; selectioncount=`echo ${selectioncount}`
1720 if [ "a${selectioncount}" = "a1" ]; then
1721 selection=1
1722 eval export ${variable}="`selection_argument option 1 "$@"`"
1723 debug "Employed voodoo-mode in selecting %s from unique option: %s\n" "${variable}" "`eval echo \\${${variable}}`"
1724 unset selectioncount; unset variable
1725 return ${selection}
1726 elif [ "a${selectioncount}" = "a2" ]; then
1727 for selection in 1 2
1728 do
1729 voodoovalue=`selection_argument option ${selection} "$@" | ${grepbin} -i "custom" | ${wcbin} -l`; voodoovalue=`echo ${voodoovalue}`
1730 [ "a${voodoovalue}" = "a0" ] && voodoovalue=`selection_argument option ${selection} "$@" | ${grepbin} -i "other" | ${wcbin} -l`; voodoovalue=`echo ${voodoovalue}`
1731 if [ "a${voodoovalue}" = "a1" ]; then
1732 debug "Voodoo determined that selection %d leads to custom/other.\n" "${selection}"
1733 if [ "${selection}" -eq "1" ]; then
1734 selection=2
1735 else
1736 selection=1
1737 fi
1738 eval export ${variable}="`selection_argument option 1 "$@"`"
1739 debug "Employed voodoo-mode in selecting %s from option %d: %s\n" "${variable}" "${selection}" "`eval echo \\${${variable}}`"
1740 unset selectioncount; unset voodoovalue; unset variable
1741 return ${selection}
1742 fi
1743 unset voodoovalue
1744 done
1745 unset selection
1746 fi
1747 unset selectioncount; unset variable
1748 fi
1749 case "${SGUI}" in
1750 whiptail|dialog|Xdialog|zenity|kdialog)
1751 dialog_select "$@"
1752 selection=$?
1753 ;;
1754 "9menu")
1755 nine_select "$@"
1756 selection=$?
1757 ;;
1758 "interactive terminal")
1759 interactive_term_select "$@"
1760 selection=$?
1761 ;;
1762 "terminal")
1763 term_select "$@"
1764 selection=$?
1765 ;;
1766 *)
1767 term_select "$@"
1768 selection=$?
1769 ;;
1770 esac
1771 debug "User selection was %d.\n" "${selection}"
1772 return ${selection}
1773 }
1774
1775 # Prompts user to enter text
1776 user_prompt() {
1777 if [ "a$1" != "atranslated" ]; then
1778 debug "Asking user to enter: %s\n" "`echo "$@"`"
1779 translate_prompt "$@"
1780 return $?
1781 else
1782 shift
1783 debug "Asking user to enter: %s\n" "`echo "$@"`"
1784 fi
1785 if [ "$#" -lt 3 ]; then
1786 debug "FIXME: Wrong number of arguments (%d). Returning 99.\n" "$#"
1787 return 99
1788 fi
1789 promptvariable=`selection_argument variable "$@"`
1790 eval alreadyset=\${${promptvariable}}
1791 if [ "a${alreadyset}" != "a" ]; then
1792 selection=0
1793 debug "%s=%s\n" "${promptvariable}" "${alreadyset}"
1794 debug "User has already entered %s=\"%s\". Returning %d.\n" "${promptvariable}" "${alreadyset}" "${selection}"
1795 unset alreadyset; unset promptvariable
1796 return ${selection}
1797 else
1798 debug "Variable %s is not set already.\n" "${promptvariable}"
1799 unset alreadyset; unset promptvariable
1800 fi
1801 case "${SGUI}" in
1802 whiptail|dialog|Xdialog|zenity|kdialog)
1803 dialog_prompt "$@"
1804 selection=$?
1805 ;;
1806 "9menu")
1807 nine_prompt "$@"
1808 selection=$?
1809 ;;
1810 "interactive terminal")
1811 interactive_term_prompt "$@"
1812 selection=$?
1813 ;;
1814 "terminal")
1815 term_prompt "$@"
1816 selection=$?
1817 ;;
1818 *)
1819 term_prompt "$@"
1820 selection=$?
1821 ;;
1822 esac
1823 promptvariable=`selection_argument variable "$@"`
1824 eval "alreadyset=\"\${${promptvariable}}\""
1825 debug "New value is %s=\"%s\". Returning %d.\n" "${promptvariable}" "${alreadyset}" "${selection}"
1826 unset alreadyset; unset promptvariable
1827 return ${selection}
1828 }
1829
1830 # Stops execution with return status $1
1831 stop_with() {
1832 verbose "Cleaning"
1833 if [ "a$1" = "a" ]; then
1834 debug "Stopping operation with return status: %d\n" "99"
1835 exit 99
1836 else
1837 debug "Stopping operation with return status: %d\n" "$1"
1838 exit $1
1839 fi
1840 }
1841
1842 # Shows error and aborts execution
1843 stop_fmt_error() {
1844 errorcode="$1"
1845 [ "$#" -gt "0" ] && shift
1846 show_fmt_error "$@"
1847 stop_with ${errorcode}
1848 }
1849
1850
1851 # Make sure usual binary containing directories exist in PATH, even
1852 # if not running as root. Some distributions do not include those
1853 # folders in PATH (although they contain some useful user oriented
1854 # utilities) if not running as root, or if not running from an
1855 # interactive shell.
1856 fix_path() {
1857 [ -n "${PATHFIXXED}" ] && return 0
1858 for fixpathi in "/bin" "/usr/bin" "/sbin" "/usr/sbin"
1859 do
1860 if strinstr "${fixpathi}" "${PATH}"; then
1861 debug "Dir \"%s\" exists in PATH.\n" "${fixpathi}"
1862 else
1863 export PATH="${fixpathi}:${PATH}"
1864 debug "Added \"%s\" to PATH.\n" "${fixpathi}"
1865 fi
1866 done
1867 unset fixpathi
1868 PATHFIXXED=YES
1869 debug "Done setting up PATH.\n"
1870 }
1871
1872
1873 # Locates full path of binary specified in argument
1874 find_binary() {
1875 [ "a$1" = "a" ] && return 1
1876 binaryvariable=`echo "$1" | sed -e "s/-/_/g"`
1877 binaryvariable=`echo "${binaryvariable}" | sed -e "s/9/nine/g"`
1878 [ "a${binaryvariable}" = "a" ] && binaryvariable="$1"
1879 findbinaryfound=`eval echo \\\${${binaryvariable}bin}`
1880 if [ "a${findbinaryfound}" = "a" ]; then
1881 if [ "a${whichbin}" = "a" ]; then
1882 findbinaryfound=`which which 2> /dev/null`
1883 elif [ ! -x "${whichbin}" ]; then
1884 findbinaryfound=`which which 2> /dev/null`
1885 else
1886 findbinaryfound="${whichbin}"
1887 fi
1888 if [ "a${findbinaryfound}" = "a" ]; then
1889 debug "Unable to locate \"%s\" within PATH, because \"%s\" utility is not available.\n" "$1" "which"
1890 unset findbinaryfound
1891 return 1
1892 else
1893 if [ -z "${whichbin}" ]; then
1894 export whichbin="${findbinaryfound}"
1895 debug "Can search through PATH, \"%s\" binary found.\n" "which"
1896 fi
1897 findbinaryfound=`${findbinaryfound} "${1}" 2> /dev/null`
1898 if [ "a${findbinaryfound}" = "a" ]; then
1899 debug "Unable to locate \"%s\" within PATH.\n" "$1"
1900 unset findbinaryfound
1901 return 1
1902 elif [ -x "${findbinaryfound}" ]; then
1903 debug "Located \"%s\" within PATH (%s).\n" "$1" "${findbinaryfound}"
1904 eval export ${binaryvariable}bin="${findbinaryfound}"
1905 fi
1906 fi
1907 fi
1908 if [ -x "${findbinaryfound}" ]; then
1909 unset findbinaryfound
1910 return 0
1911 else
1912 debug "Unable to execute \"%s\" from \"%s\".\n" "$1" "${findbinaryfound}"
1913 unset findbinaryfound
1914 eval unset ${binaryvariable}bin
1915 return 1
1916 fi
1917 }
1918
1919 # Aborts execution if "$1" binary is not found.
1920 need_binary() {
1921 [ "a$1" = "a" ] && term_error "FIXME: Executed need_binary with no argument."
1922 ! find_binary "$1" && stop_fmt_error 4 "Unable to locate dependency \"%s\". Script will now abort." "$1"
1923 }
1924
1925 # Check dependencies. Only really required staff should be placed here.
1926 # We cannot yet search in PATH.
1927 check_level_one_deps() {
1928 for checkdependency in which echo grep
1929 do
1930 need_binary "${checkdependency}"
1931 done
1932 unset checkdependency
1933 debug "Level 1 dependencies met.\n"
1934 }
1935
1936 # Checks if communication software is available and aborts if not
1937 check_com_software() {
1938 ! find_binary "wvdial" && direct_pppd=yes
1939 if [ -n "${direct_pppd}" ]; then
1940 need_binary "pppd"
1941 need_arg "PPPD_PEERS"
1942 if [ ! -d "${PPPD_PEERS}" ]; then
1943 debug "Unable to locate pppd peers directory (%s)." "${pppdpeerdir}"
1944 fi
1945 fi
1946 for checkdependency in chat
1947 do
1948 need_binary "${checkdependency}"
1949 done
1950 unset checkdependency
1951 return 0
1952 }
1953
1954 # Checks if method for becoming root, exists.
1955 check_su_software() {
1956 unset SUMETHOD
1957 if [ -z "${alwayssudo}" ]; then
1958 if [ -z "${stick_to_console}" ]; then
1959 if find_binary "gksu"; then
1960 debug "Running on a GNOME system.\n"
1961 SUMETHOD="gksu"
1962 elif find_binary "kdesu"; then
1963 debug "Running on a KDE system.\n"
1964 SUMETHOD="kdesu"
1965 elif [ -x "/usr/lib/kde4/libexec/kdesu" ]; then
1966 export kdesubin="/usr/lib/kde4/libexec/kdesu"
1967 debug "Running on a KDE4 system.\n"
1968 SUMETHOD="kdesu"
1969 fi
1970 fi
1971 if [ -z "${SUMETHOD}" ]; then
1972 if find_binary "su"; then
1973 debug "Using plain text mode su.\n"
1974 SUMETHOD="su"
1975 else
1976 debug "No su method found. Will check if sudo available.\n"
1977 export alwayssudo=yes
1978 fi
1979 fi
1980 fi
1981 if [ -n "${alwayssudo}" ]; then
1982 ! find_binary "sudo" && stop_fmt_error 3 "No method for acquiring root privileges found."
1983 debug "Running with sudo configuration.\n"
1984 SUMETHOD="sudo"
1985 fi
1986 return 0
1987 }
1988
1989 # Forces use of text mode utilities for getting root privileges
1990 console_su_software() {
1991 if [ "${SUMETHOD}" = "kdesu" -o "${SUMETHOD}" = "gksu" ]; then
1992 if find_binary "su"; then
1993 debug "Reverting to plain text mode su.\n"
1994 SUMETHOD="su"
1995 else
1996 debug "No text mode su found. Will check if sudo available.\n"
1997 export alwayssudo=yes
1998 check_su_software
1999 fi
2000 fi
2001 }
2002
2003
2004 # Check dependencies. Only really required staff should be placed here.
2005 # We can now search within path.
2006 check_level_two_deps() {
2007 for checkdependency in printf wc cut cat tail head sort uniq ls sed setsid getent ps chmod chown touch expr tr seq cp rm who mv expr basename dirname
2008 do
2009 need_binary "${checkdependency}"
2010 done
2011 unset checkdependency
2012 debug "Level 2 dependencies met.\n"
2013 if [ "a${PROVIDER}" != "a" ] && [ ! -x "${PROVIDER}" ]; then
2014 debug run_command "${chmodbin} +x \"${PROVIDER}\""
2015 if [ ! -x "${PROVIDER}" ]; then
2016 stop_fmt_error 5 "Unable to determine my path.\n"
2017 fi
2018 debug "Successfully turned myself an executable.\n"
2019 fi
2020 }
2021
2022 # If running as root, checks dependencies that should be met
2023 # once running as root. If not running as root, checks if
2024 # software for becoming root, is available.
2025 check_root_deps() {
2026 if ! we_are_root_already; then
2027 check_su_software
2028 else
2029 for checkdependency in ifconfig
2030 do
2031 need_binary "${checkdependency}"
2032 done
2033 unset checkdependency
2034 fi
2035 debug "Root level dependencies met.\n"
2036 }
2037
2038 # Locate required utilities within PATH
2039 resolv_binaries() {
2040 check_level_one_deps
2041 fix_path
2042 get_me ${1}
2043 check_level_two_deps
2044 debug "Basic binaries are resolved.\n"
2045 }
2046
2047 # Provides a writable log position
2048 need_log() {
2049 need_arg "LOGPOSITION"
2050 for logcandidate in "${LOGPOSITION}" "/var/log/sakis3g.log" "sakis3g.log.$$" "/tmp/sakis3g.log.$$"
2051 do
2052 if [ "a${logcandidate}" != "a" ]; then
2053 ${touchbin} "${logcandidate}" 2> /dev/null
2054 if [ -w "${logcandidate}" ]; then
2055 export LOGPOSITION="${logcandidate}"
2056 debug "Log file is set to \"%s\".\n" "${LOGPOSITION}"
2057 return 0
2058 else
2059 unset logposition
2060 fi
2061 fi
2062 done
2063 debug "Failed to find a place to store log.\n"
2064 export LOGPOSITION="/dev/null"
2065 debug "Log file is set to \"%s\".\n" "${logposition}"
2066 return 1
2067 }
2068
2069 # Returns true(0) if process with PID given as
2070 # argument, is not running any more.
2071 notrunning() {
2072 if [ -n "$1" ]; then
2073 pidrunning=`${psbin} -p $1 -o pid= 2> /dev/null | wc -l`
2074 pidrunning=`echo ${pidrunning}`
2075 else
2076 pidrunning=1
2077 fi
2078 if [ "${pidrunning}" -ne "0" ]; then
2079 debug "PID %s is still running.\n" "$1"
2080 else
2081 debug "PID %s is not running any more.\n" "$1"
2082 fi
2083 return ${pidrunning}
2084 }
2085
2086 # Sets PPROCESS variable
2087 get_parent_process() {
2088 pidtocheck=$1
2089 [ "a${pidtocheck}" = "a" ] && pidtocheck="${PPID}"
2090 PPROCESS=`${psbin} -p ${pidtocheck} -o comm= 2> /dev/null`
2091 export PPROCESS
2092 if [ "a${PPROCESS}" = "a" ]; then
2093 debug "Unable to get parent process name.\n"
2094 unset PPROCESS; unset pidtocheck
2095 return 1
2096 fi
2097 unset pidtocheck
2098 return 0
2099 }
2100
2101 # Check if called by udevd. If yes, spawn in background
2102 # and exit this instance.
2103 check_udevd() {
2104 if [ "a${PROVIDER}" = "a" ]; then
2105 get_parent_process
2106 else
2107 pppid=`${psbin} -p ${PPID} -o ppid= 2> /dev/null`
2108 pppid=`echo ${pppid}`
2109 get_parent_process "${pppid}"
2110 unset pppid
2111 fi
2112 debug "Parent process is: %s\n" "${PPROCESS}"
2113 if [ "a${PPROCESS}" = "audevd" ]; then
2114 debug "Running by a udevd event.\n"
2115 need_log
2116 if have_me; then
2117 debug "Unconditionally setting DISPLAY to :0.\n"
2118 export DISPLAY=:0
2119 debug "Will now spawn child process in background.\n"
2120 ${ME} "$@" > "${LOGPOSITION}" 2>&1 &
2121 stop_with 0
2122 fi
2123 else
2124 debug "Running by user request.\n"
2125 fi
2126 }
2127
2128 # Get my location if possible
2129 get_me() {
2130 unset metarget
2131 [ -x "${PROVIDER}" ] && metarget="${PROVIDER}"
2132 [ -z "${metarget}" ] && metarget="$1"
2133 find_binary "readlink" && ME=`${readlinkbin} -e ${metarget} 2> /dev/null`
2134 [ -z "${ME}" ] && find_binary "which" && ME="`${whichbin} ${metarget} 2> /dev/null`"
2135 unset metarget
2136 [ -n "${ME}" ] && [ ! -x "${ME}" ] && unset ME
2137 if [ -z "${ME}" ]; then
2138 unset ME
2139 debug "Unable to determine my own location.\n"
2140 else
2141 debug "My location is \"%s\".\n" "${ME}"
2142 fi
2143
2144 }
2145
2146 # Makes sure we know our own executable
2147 have_me() {
2148 [ -n "${ME}" ] && [ -x "${ME}" ] && return 0;
2149 stop_fmt_error 5 "Unable to determine my path.\n"
2150 }
2151
2152 # If we are root, attempts to determine real user
2153 # behind it, by looking back the process tree. Goes
2154 # back 15 processes before giving up.
2155 resolv_root() {
2156 [ -z "$1" ] && pid=$$
2157 [ -z "${pid}" ] && pid=$1
2158 puser=`${psbin} -p ${pid} -o user= 2> /dev/null`
2159 if [ -z "${puser}" ]; then
2160 unset pid; unset puser
2161 return
2162 elif [ "${puser}" != "root" ]; then
2163 runner="${puser}"
2164 unset pid; unset puser
2165 return
2166 fi
2167 unset puser
2168 ppid=`${psbin} -p ${pid} -o ppid= 2> /dev/null`; unset pid
2169 if [ -z "${ppid}" ]; then
2170 unset ppid
2171 return
2172 elif [ "a${ppid}" = "a1" ]; then
2173 unset ppid
2174 return
2175 fi
2176 [ -z "$2" ] && count=0
2177 count=`expr $2 + 1`
2178 count=`echo ${count}`
2179 [ "$count" -lt 15 ] && resolv_root ${ppid} ${count}
2180 unset ppid; unset count
2181 }
2182
2183 # Locates really running user. If root, attempts to resolv
2184 # it to real user.
2185 find_user() {
2186 unset runner; unset runhome
2187 [ -n "${USER}" ] && runner="${USER}"
2188 [ -n "${LOGNAME}" ] && runner="${LOGNAME}"
2189 [ -n "${USERNAME}" ] && runner="${USERNAME}"
2190 [ -z "${runner}" ] && find_binary "who" && runner=`${whobin} -m | ${cutbin} -d\ -f1`
2191 [ -z "${runner}" ] && we_are_root_already && runner="root"
2192 [ -n "${runner}" ] && [ "${runner}" = "root" ] && resolv_root $$ 0
2193 if [ -n "${runner}" ]; then
2194 runhome=`${getentbin} passwd ${runner} 2> /dev/null | ${cutbin} -d: -f6`
2195 [ -n "${runhome}" ] && [ ! -d "${runhome}" ] && unset runhome
2196 [ -z "${runhome}" ] && unset runner
2197 [ -n "${runner}" ] && debug "Person behind screen is %s.\n" "${runner}"
2198 fi
2199 [ -z "${runner}" ] && debug "Unable to find our username.\n"
2200 }
2201
2202 # Determines if display $1 is unique local display.
2203 unique_local_display() {
2204 debug "Will check if display %s belongs to unique user logged in.\n" "$1"
2205 [ "a$1" = "a" ] && return 1
2206 ! find_binary "who" && return 1
2207 loggedusers=`${whobin} | ${grepbin} -v root | ${cutbin} -d\ -f1 | ${sortbin} | ${uniqbin} | ${wcbin} -l`
2208 loggedusers=`echo ${loggedusers}`
2209 if [ "a${loggedusers}" != "a1" ]; then
2210 debug "Found %d logged users. Cannot make sure who will really see message.\n" "${loggedusers}"
2211 unset loggedusers
2212 return 1
2213 fi
2214 unset loggedusers
2215 loggeduser=`${whobin} | ${grepbin} -v root | ${cutbin} -d\ -f1 | ${sortbin} | ${uniqbin}`
2216 confirm=`${whobin} | ${grepbin} ${1} | ${cutbin} -d\ -f1 | ${sortbin} | ${uniqbin} | ${grepbin} "^${loggeduser}$"`
2217 if [ "a${loggeduser}" = "a${confirm}" ]; then
2218 debug "Unique display %s belongs to user %s.\n" "$1" "${loggeduser}"
2219 unset confirm; unset loggeduser;
2220 return 0
2221 fi
2222 debug "Display %s does not belongs to user %s.\n" "$1" "${loggeduser}"
2223 unset confirm; unset loggeduser;
2224 return 1
2225 }
2226
2227 # Attemtps to get access to display $1
2228 access_display() {
2229 debug "Will attempt to get access to display %s.\n" "$1"
2230 [ "a$1" = "a" ] && return 1
2231 ! find_binary "xauth" && return 1
2232 [ "a${XAUTHORITY}" = "a" ] && unset XAUTHORITY
2233 gotaccess=`${xauthbin} nlist $1 2> /dev/null | ${wcbin} -l`
2234 gotaccess=`echo ${gotaccess}`
2235 if [ "a${gotaccess}" = "a0" ]; then
2236 xuser=`${whobin} -u | ${grepbin} -v "^root" | ${grepbin} ${1} | ${cutbin} -d\ -f1 | ${sortbin} | ${uniqbin}`
2237 xhome=$(${getentbin} passwd ${xuser} | ${cutbin} -d: -f6)
2238 debug "Not currently trusted to display %s belonging to %s.\n" "${1}" "${xuser}"
2239 if [ "a${LOCALAUTHORITY}" != "a" ] && [ -r "${LOCALAUTHORITY}" ]; then
2240 xholder="${LOCALAUTHORITY}"
2241 elif [ -d "${xhome}" ] && [ -r "${xhome}/.Xauthority" ]; then
2242 xholder="${xhome}/.Xauthority"
2243 else
2244 unset xholder
2245 fi
2246 if [ "a${xholder}" = "a" ]; then
2247 debug "Unable to locate Xauthority file of %s.\n" "${xuser}"
2248 else
2249 debug "Will attempt to steal cookie from %s.\n" "${xholder}"
2250 if [ "a${HOME}" = "a" ]; then
2251 rruser="${runner}"
2252 we_are_root_already && rruser="root"
2253 rrhome=$(${getentbin} passwd ${rruser} | ${cutbin} -d: -f6)
2254 if [ -d "${rrhome}" -a "a${xhome}" != "a${rrhome}" ]; then
2255 debug "HOME variable not set already. Setting HOME for %s: %s\n" "${rruser}" "${rrhome}"
2256 export HOME="${rrhome}"
2257 fi
2258 unset rruser; unset rrhome;
2259 else
2260 debug "HOME directory set already (%s).\n" "${HOME}"
2261 fi
2262 ${xauthbin} -f "${xholder}" nextract - $1 2> /dev/null | ${xauthbin} nmerge - 2> /dev/null
2263 gotaccess=`${xauthbin} nlist ${1} 2> /dev/null | ${wcbin} -l`
2264 gotaccess=`echo ${gotaccess}`
2265 if [ "a${gotaccess}" = "a0" ]; then
2266 debug "Failed to steal cookie.\n"
2267 else
2268 debug "Cookie stolen from %s(%s) to %s.\n" "${xuser}" "${1}" "${HOME}/.Xauthority"
2269 export XCOOKIE="$1"
2270 addexittrap "release_X_cookie" EXIT
2271 unset xuser; unset xhome; unset gotaccess; unset xholder
2272 return 0
2273 fi
2274 fi
2275 unset xuser; unset xhome; unset gotaccess; unset xholder
2276 else
2277 debug "Already granted access to display %s.\n" "${1}"
2278 [ "a${XAUTHORITY}" != "a" ] && export LOCALAUTHORITY="${XAUTHORITY}"
2279 unset gotaccess
2280 return 0
2281 fi
2282 return 1
2283 }
2284
2285 # Find DISPLAY
2286 find_display() {
2287 if [ -n "${stick_to_console}" ]; then
2288 unset DISPLAY; unset display;
2289 debug "Not using an X display due to stick-to-console variable.\n"
2290 else
2291 display="${DISPLAY}"
2292 # If display is not set, or is remote, attempt to find a local display of runner user.
2293 [ -z "${DISPLAY}" -o "`echo ${DISPLAY} | ${cutbin} -b1`" != ":" ] \
2294 && display="" \
2295 && [ -n "${runner}" -a "a${runner}" != "aroot" ] \
2296 && find_binary "who" \
2297 && display=`${whobin} -m | ${grepbin} "^${runner}" | ${grepbin} "(\:.*)" | ${cutbin} -d\( -f2 | ${cutbin} -d\) -f1 | ${sortbin} | ${headbin} -1`
2298 # If DISPLAY is set to a local display, but we are run
2299 # from root himself, and that X display is the unique
2300 # local X display available, use it no matter what.
2301 [ -n "${display}" -a -n "${DISPLAY}" -a "a${runner}" = "aroot" ] \
2302 && ! unique_local_display "${DISPLAY}" && unset display
2303 # Get number of display (if any)
2304 displaynum=`echo ${display} | ${cutbin} -b2- | ${cutbin} -d. -f1`
2305 display=":${displaynum}"
2306 # Validate that determined xsession exists.
2307 [ ! -S "/tmp/.X11-unix/X${displaynum}" ] && unset display
2308 unset displaynum
2309 [ -n "${display}" ] && ! access_display "${display}" && unset display
2310 if [ -z "${display}" ]; then
2311 debug "Unable to find a local X display, will stick to terminal.\n"
2312 unset DISPLAY; unset display;
2313 export stick_to_console=yes
2314 find_gui
2315 else
2316 export display
2317 export DISPLAY="${display}"
2318 fi
2319 fi
2320 if [ -z "${display}" ]; then
2321 unset DISPLAY; unset display;
2322 export stick_to_console=yes
2323 console_su_software
2324 else
2325 debug "Will be using display %s.\n" "${display}"
2326 fi
2327 }
2328
2329 # Selects GUI to be used if not already set by SGUI variable.
2330 find_gui() {
2331 debug "Selecting GUI.\n"
2332 if [ -n "${stick_to_console}" -a -n "$SGUI" ]; then
2333 debug "Validating pre-selected GUI: %s\n" "${SGUI}"
2334 [ "a$SGUI" = "azenity" ] && unset SGUI
2335 [ "a$SGUI" = "agdialog" ] && unset SGUI
2336 [ "a$SGUI" = "akdialog" ] && unset SGUI
2337 [ "a$SGUI" = "aXdialog" ] && unset SGUI
2338 [ "a$SGUI" = "a9menu" ] && unset SGUI
2339 [ "a$SGUI" = "agnome-terminal" ] && unset SGUI
2340 [ "a$SGUI" = "akonsole" ] && unset SGUI
2341 [ "a$SGUI" = "axterm" ] && unset SGUI
2342 [ -z "${SGUI}" ] && debug "Could not be used from console. Will seek an alternative.\n"
2343 fi
2344 if [ "a${SGUI}" != "a" -a "a${SGUI}" != "ainteractive terminal" -a "a${SGUI}" != "aterminal" ] && ! find_binary "${SGUI}"; then
2345 debug "%s not found. Will search for another GUI provider.\n" "${SGUI}"
2346 unset SGUI
2347 fi
2348 if [ "a${stick_to_console}" = "a" ]; then
2349 [ "a${SGUI}" = "a9menu" ] && ! find_binary "9menu" && unset SGUI
2350 [ "a${SGUI}" = "a9menu" ] && ! find_binary "xterm" && unset SGUI
2351 [ -z "${SGUI}" ] && find_binary "kdialog" && SGUI="kdialog"
2352 [ -z "${SGUI}" ] && find_binary "zenity" && SGUI="zenity"
2353 [ -z "${SGUI}" ] && find_binary "Xdialog" && SGUI="Xdialog"
2354 [ -z "${SGUI}" ] && find_binary "gnome-terminal" && SGUI="gnome-terminal"
2355 [ -z "${SGUI}" ] && find_binary "konsole" && SGUI="konsole"
2356 [ -z "${SGUI}" ] && find_binary "xterm" && SGUI="xterm"
2357 if [ -z "${SGUI}" ]; then
2358 debug "No graphical GUI found. Forced to stick to terminal.\n"
2359 export stick_to_console=yes
2360 fi
2361 fi
2362 if [ "a${interactive}" != "a" ]; then
2363 [ -z "${SGUI}" ] && find_binary "dialog" && SGUI="dialog"
2364 [ -z "${SGUI}" ] && find_binary "whiptail" && SGUI="whiptail"
2365 [ -z "${SGUI}" ] && SGUI="interactive terminal"
2366 fi
2367 [ -z "${SGUI}" ] && SGUI="terminal"
2368 # Custom setup per GUI
2369 [ "a${SGUI}" = "adialog" ] && addexittrap "dialog_clearscreen"
2370 [ "a${SGUI}" = "aXdialog" -o "a${SGUI}" = "a9menu" ] && export notranslate=yes && unset foldwrapping && need_arg "foldwrapping"
2371 [ "a${SGUI}" = "adialog" -o "a${SGUI}" = "awhiptail" -o "a${SGUI}" = "aterminal" -o "a${SGUI}" = "ainteractive terminal" ] && export stick_to_console=yes
2372 [ "a${SGUI}" = "adialog" -o "a${SGUI}" = "awhiptail" -o "a${SGUI}" = "ainteractive terminal" -o "a${SGUI}" = "aXdialog" -o "a${SGUI}" = "azenity" -o "a${SGUI}" = "akdialog" -o "a${SGUI}" = "a9menu" ] && export interactive=yes
2373 debug "%s selected as GUI.\n" "${SGUI}"
2374 # Forward to terminal if have to do so
2375 case "${SGUI}" in
2376 xterm)
2377 debug "Will spawn xterm window.\n"
2378 unset SGUI; export stick_to_console=yes; export interactive=yes;
2379 state_variables
2380 eval ${xtermbin} -T "Sakis3G" +cm +dc -e ${ME} ${allargs} ${statevariables}
2381 stop_with $?
2382 ;;
2383 gnome-terminal)
2384 debug "Will spawn gnome-terminal window.\n"
2385 unset SGUI; export stick_to_console=yes; export interactive=yes;
2386 state_variables
2387 eval ${gnome_terminalbin} -t "Sakis3G" -x ${ME} ${allargs} ${statevariables}
2388 stop_with $?
2389 ;;
2390 konsole)
2391 debug "Will spawn konsole window.\n"
2392 unset SGUI; export stick_to_console=yes; export interactive=yes;
2393 state_variables
2394 eval ${konsolebin} --title "Sakis3G" -e "${ME} ${allargs} ${statevariables}"
2395 stop_with $?
2396 ;;
2397 esac
2398 # Check for OSD
2399 unset OSDOUTPUT
2400 if [ "a${stick_to_console}" = "a" -a "a${prefer_osd}" != "a" ]; then
2401 if find_binary "osd_cat"; then
2402 export OSDOUTPUT="osd_cat"
2403 elif find_binary "aosd_cat"; then
2404 export OSDOUTPUT="aosd_cat"
2405 fi
2406 [ "a${OSDOUTPUT}" != "a" ] && debug "Will be using \"%s\" for displaying OSD messages.\n" "${OSDOUTPUT}"
2407 fi
2408 [ "a${prefer_osd}" != "a" -a "a${OSDOUTPUT}" = "a" ] && unset prefer_osd && debug "OSD will not appear.\n"
2409 return 0
2410 }
2411
2412 # Checks if module $1 is loaded
2413 module_loaded() {
2414 [ "a$1" = "a" ] && return 99
2415 unset moduleloaded
2416 debug "Checking if module \"%s\" is currently loaded.\n" "$1"
2417 if [ -r "/proc/modules" ]; then
2418 moduleloaded=`${grepbin} "^$1 " "/proc/modules" 2> /dev/null | ${sedbin} -e "s/^$1 \([0-9][0-9]*\) \([0-9][0-9]*\) \(.*\)$/\1 \3/g"`
2419 if [ "a${moduleloaded}" = "a" ]; then
2420 debug "Module \"%s\" is not currently loaded.\n" "$1"
2421 unset moduleloaded
2422 return 1
2423 elif [ "a${moduleloaded}" = "a$1 0" ]; then
2424 debug "Module \"%s\" is currently loaded having no users.\n" "$1"
2425 unset moduleloaded
2426 return 0
2427 else
2428 debug "Module \"%s\" is currently loaded and occupied.\n" "$1"
2429 unset moduleloaded
2430 return 0
2431 fi
2432 elif find_binary "lsmod"; then
2433 moduleloaded=`${lsmodbin} | ${grepbin} "^$1 " | ${wcbin} -l`; moduleloaded=`echo ${moduleloaded}`
2434 if [ "a${moduleloaded}" = "a" -o "a${moduleloaded}" = "a0" ]; then
2435 debug "Module \"%s\" is not currently loaded.\n" "$1"
2436 unset moduleloaded
2437 return 1
2438 else
2439 debug "Module \"%s\" is currently loaded.\n" "$1"
2440 unset moduleloaded
2441 return 0
2442 fi
2443 else
2444 show_fmt_error "Unable to check if module is currently loaded or if it has users.\n"
2445 return 1
2446 fi
2447 }
2448
2449 # Unloads module from system if possible
2450 module_unload() {
2451 [ "a$1" = "a" ] && return 99
2452 ! module_loaded "$1" && return 0
2453 ! find_binary "modprobe" && return 1
2454 debug "Attempting to unload module \"%s\".\n" "$1"
2455 debug run_command "${modprobebin} -r -v $1"
2456 debug "Waiting for module to vanish.\n"
2457 if module_loaded "$1"; then
2458 show_fmt_error "Failed to unload module \"%s\".\n" "$1"
2459 return 1
2460 else
2461 debug "Module \"%s\" succesfully unloaded.\n" "$1"
2462 return 0
2463 fi
2464 }
2465
2466 # Loads module $1 if possible, providing arguments for device $2 if applicable
2467 module_load() {
2468 [ "a$1" = "a" ] && return 99
2469 module_loaded "$1" && return 0
2470 ! find_binary "modprobe" && return 1
2471 debug "Attempting to load module \"%s\".\n" "$1"
2472 need_arg "SERIALDRIVERS"
2473 needsarg=`echo " ${SERIALDRIVERS} " | ${grepbin} " $1 " | ${wcbin} -l`; needsarg=`echo ${needsarg}`
2474 if [ "a${needsarg}" = "a1" -a "a$2" != "a" ]; then
2475 if usb_device_connected "$2"; then
2476 modulevend=`echo "$2" | ${cutbin} -d: -f1`
2477 moduleprod=`echo "$2" | ${cutbin} -d: -f2`
2478 modargs="vendor=0x${modulevend} product=0x${moduleprod}"
2479 unset modulevend; unset moduleprod
2480 debug "Will provide arguments to \"%s\": %s\n" "$1" "${modargs}"
2481 else
2482 debug "Warning: Module \"%s\" needs arguments, but \"%s\" does not refer to a connected device.\n" "$1" "$2"
2483 unset modargs
2484 fi
2485 elif [ "a${needsarg}" = "a1" ]; then
2486 debug "Warning: Module \"%s\" needs arguments but device was not specified.\n" "$1"
2487 unset modargs
2488 fi
2489 debug run_command "${modprobebin} $1 ${modargs}"
2490 debug "Waiting for module to get loaded.\n"
2491 unset modargs; unset needsarg
2492 counter=0
2493 while [ "${counter}" -lt "6" ]
2494 do
2495 if ! module_loaded "$1"; then
2496 debug "Module \"%s\" still not live. Waiting a second.\n" "$1"
2497 sleep 1
2498 fi
2499 if module_loaded "$1"; then
2500 debug "Module \"%s\" succesfully loaded.\n" "$1"
2501 unset counter
2502 return 0
2503 fi
2504 counter=`expr ${counter} + 1`; counter=`echo ${counter}`
2505 done
2506 unset counter
2507 show_fmt_error "Failed to load module \"%s\".\n" "$1"
2508 return 1
2509 }
2510
2511 # Attempts to detach driver $1 from device $2 interface $3
2512 # If failed to detach, attempts to completely unload $1 before failing.
2513 module_unbind() {
2514 [ "a$1" = "a" ] && return 99
2515 verbose "Unloading driver %s" "$1"
2516 if [ "a$2" = "a" -a "a$3" = "a" ]; then
2517 debug "Requested to unbind module \"%s\" without device specified. Will try to unload it.\n" "$1"
2518 module_unload "$1"
2519 return $?
2520 fi
2521 moduleattached=`usb_loaded_driver "$2" "$3" | ${tailbin} -1 | ${grepbin} "$1" | ${wcbin} -l`
2522 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
2523 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
2524 unset TIMEOUTOCCURED
2525 fi
2526 moduleattached=`echo ${moduleattached}`
2527 if [ "a${moduleattached}" = "a" -o "a${moduleattached}" = "a0" ]; then
2528 debug "Module \"%s\" does not appear to be attached to device \"%s\".\n" "$1" "$2"
2529 unset moduleattached
2530 return 0
2531 fi
2532 debug "Module \"%s\" is currently attached to \"%s\".\n" "$1" "$2"
2533 [ "a$3" != "a" ] && usb_sysfsdir_int "$2" "$3" && unbindvalue=`${basenamebin} ${sysfsintloc}`
2534 [ "a$3" = "a" ] && usb_sysfsdir && unbindvalue=`cd "${sysfsloc}"; ${lsbin} -1d \`${basenamebin} ${sysfsloc}\`*`
2535 [ "a${unbindvalue}" = "a" ] && unbindvalue=`echo "$2" | ${sedbin} -e "s/:/ /g"`
2536 sent=0
2537 [ "a$1" = "ausb_storage" ] && localdrivername="usb-storage"
2538 for endpoint in /sys/bus/usb/drivers/${localdrivername}/unbind /sys/bus/usb/drivers/$1/unbind
2539 do
2540 for destination in ${unbindvalue}
2541 do
2542 if [ -w "${endpoint}" ]; then
2543 echo -n "${destination}" > "${endpoint}" 2> /dev/null
2544 debug "Sent \"%s\" to \"%s\".\n" "${destination}" "${endpoint}"
2545 sent=1
2546 fi
2547 done
2548 unset destination
2549 done
2550 unset unbindvalue; unset endpoint; unset localdrivername
2551 if [ "${sent}" -eq "1" ]; then
2552 debug "Expecting module to detach from device.\n"
2553 while [ "${sent}" -lt "6" ]
2554 do
2555 unset moduleattached
2556 moduleattached=`usb_loaded_driver "$2" "$3" | ${tailbin} -1 | ${grepbin} "$1" | ${wcbin} -l`
2557 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
2558 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
2559 unset TIMEOUTOCCURED
2560 break
2561 fi
2562 moduleattached=`echo ${moduleattached}`
2563 if [ "a${moduleattached}" = "a" -o "a${moduleattached}" = "a0" ]; then
2564 debug "Module \"%s\" has detached from device \"%s\".\n" "$1" "$2"
2565 unset moduleattached; unset sent
2566 if find_binary "modprobe"; then
2567 if [ "a$1" != "ausb_storage" -a "a$1" != "ausb-storage" ]; then
2568 debug "Will attempt to also remove it.\n"
2569 debug run_command "${modprobebin} -r -v $1"
2570 module_loaded "$1"
2571 fi
2572 fi
2573 return 0
2574 fi
2575 debug "Module still attached. Waiting for %d second(s).\n" "${sent}"
2576 sent=`expr ${sent} + 1`; sent=`echo ${sent}`
2577 sleep 1
2578 done
2579 debug "Module \"%s\" did not detach from device \"%s\". Will try to unload it.\n" "$1" "$2"
2580 fi
2581 module_unload "$1"
2582 return $?
2583 }
2584
2585 # Attempts to bind module $1 to device $2, interface $3 (optional)
2586 module_bind() {
2587 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
2588 verbose "Loading driver %s" "$1"
2589 module_load "$1" "$2"
2590 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
2591 unset moduleattached
2592 modulename="$1"
2593 [ "a${modulename}" = "ausb-storage" ] && modulename="usb_storage"
2594 [ "a${modulename}" = "acdc-acm" ] && modulename="cdc_acm"
2595 moduleattached=`usb_loaded_driver "$2" "$3" | ${tailbin} -1 | ${grepbin} "${modulename}" | ${wcbin} -l`
2596 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
2597 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
2598 unset TIMEOUTOCCURED
2599 fi
2600 moduleattached=`echo ${moduleattached}`
2601 if [ "a${moduleattached}" != "a" -a "a${moduleattached}" != "a0" ]; then
2602 debug "Module \"%s\" attached to device \"%s\".\n" "$1" "$2"
2603 unset moduleattached; unset sent; unset modulename
2604 return 0
2605 fi
2606 unset moduleattached
2607 debug "Module \"%s\" not yet attached to \"%s\".\n" "$1" "$2"
2608 bindvalue=`echo "$2" | ${sedbin} -e "s/:/ /g"`
2609 sent=0
2610 for endpoint in /sys/module/${modulename}/drivers/usb-serial:*/new_id
2611 do
2612 if [ -w "${endpoint}" ]; then
2613 echo -n "${bindvalue}" > "${endpoint}" 2> /dev/null
2614 if [ "$?" -eq "0" ]; then
2615 debug "Sent \"%s\" to \"%s\".\n" "${bindvalue}" "${endpoint}"
2616 sent=1
2617 fi
2618 fi
2619 done
2620 if [ "a${sent}" != "a1" ]; then
2621 for endpoint in /sys/module/${modulename}/drivers/usb:*/new_id
2622 do
2623 echo -n "${bindvalue}" > "${endpoint}" 2> /dev/null
2624 if [ "$?" -eq "0" ]; then
2625 debug "Sent \"%s\" to \"%s\".\n" "${bindvalue}" "${endpoint}"
2626 sent=1
2627 fi
2628 done
2629 fi
2630 unset bindvalue; unset endpoint
2631 if [ "a${sent}" = "a1" ]; then
2632 counter=0
2633 while [ "${counter}" -lt "10" ]
2634 do
2635 moduleattached=`usb_loaded_driver "$2" "$3" | ${tailbin} -1 | ${grepbin} "${modulename}" | ${wcbin} -l`
2636 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
2637 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
2638 unset TIMEOUTOCCURED
2639 break;
2640 fi
2641 moduleattached=`echo ${moduleattached}`
2642 if [ "a${moduleattached}" != "a1" ]; then
2643 debug "Waiting one second.\n"
2644 sleep 1
2645 fi
2646 moduleattached=`usb_loaded_driver "$2" "$3" | ${tailbin} -1 | ${grepbin} "${modulename}" | ${wcbin} -l`
2647 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
2648 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
2649 unset TIMEOUTOCCURED
2650 break;
2651 fi
2652 moduleattached=`echo ${moduleattached}`
2653 if [ "a${moduleattached}" != "a" -a "a${moduleattached}" != "a0" ]; then
2654 debug "Module \"%s\" attached to device \"%s\".\n" "$1" "$2"
2655 unset moduleattached; unset sent; unset counter; unset modulename
2656 return 0
2657 fi
2658 unset moduleattached
2659 counter=`expr ${counter} + 1`; counter=`echo ${counter}`
2660 done
2661 unset counter
2662 fi
2663 debug "Module \"%s\" did not bind to device \"%s\".\n" "$1" "$2"
2664 if [ "a$4" != "anoreload" ]; then
2665 debug "Will attempt to do a reload cycle.\n"
2666 if module_unload "$1" "$2" "$3"; then
2667 if module_bind "$1" "$2" "$3" "noreload"; then
2668 unset counter; unset sent; unset moduleattached; unset modulename
2669 debug "Reload cycle did the trick.\n"
2670 debug "Module \"%s\" attached to device \"%s\".\n" "$1" "$2"
2671 return 0
2672 else
2673 return $?
2674 fi
2675 fi
2676 fi
2677 unset moduleattached; unset modulename
2678 if [ "${sent}" -eq "0" ]; then
2679 show_fmt_error "Module \"%s\" loaded but did not bind to device \"%s\".\n" "$1" "$2"
2680 else
2681 show_fmt_error "Module \"%s\" loaded but refused to bind to device \"%s\".\n" "$1" "$2"
2682 fi
2683 unset sent; unset counter
2684 return 1
2685 return 99
2686 }
2687
2688 # Unlocks a previously acquired lock to hal
2689 hal_unlock() {
2690 [ "a${nohal}" != "a" ] && return 0
2691 [ "a${HAL_LOCK}" = "a" ] && return 0
2692 debug "Releasing HAL lock %d.\n" "${HAL_LOCK}"
2693 if notrunning "${HAL_LOCK}"; then
2694 debug "Already unlocked.\n"
2695 else
2696 if [ -f "/tmp/sakis3g.hal.lock.$$" ]; then
2697 ${rmbin} -f "/tmp/sakis3g.hal.lock.$$"
2698 sleep 2
2699 fi
2700 if ! notrunning "${HAL_LOCK}"; then
2701 debug "Failed to unlock by unlinking mutex file. Will try to kill.\n"
2702 term_clearline
2703 ${killbin} -1 ${HAL_LOCK} 2> /dev/null
2704 if ! notrunning "${HAL_LOCK}"; then
2705 debug "Failed to kill PID %d.\n" "${HAL_LOCK}"
2706 return 1
2707 fi
2708 fi
2709 debug "Unlocked.\n"
2710 fi
2711 unset HAL_LOCK
2712 return 0
2713 }
2714
2715 # Attempts to establish lock of interface $1 (i.e. org.freedesktop.Hal.Device.Storage)
2716 hal_acquire_lock() {
2717 [ "a${nohal}" != "a" ] && return 0
2718 [ "a${HAL_LOCK}" != "a" ] && ! hal_unlock && return 1
2719 ! find_binary "hal-lock" && return 1
2720 ! find_binary "kill" && return 1
2721 ! find_binary "touch" && return 1
2722 ! we_are_root && return 1
2723 debug "Acquiring lock in HAL for \"%s\".\n" "$1"
2724 ${touchbin} "/tmp/sakis3g.hal.lock.$$"
2725 hal-lock --interface "$1" --exclusive --run "${ME} holdlock /tmp/sakis3g.hal.lock.$$" &
2726 halpid=$!; unset informed
2727 while ! notrunning ${halpid}
2728 do
2729 hallocksuccess=`${catbin} "/tmp/sakis3g.hal.lock.$$" 2> /dev/null`; hallocksuccess=`echo ${hallocksuccess} | ${sedbin} -e "s/ //g"`
2730 if [ "a${hallocksuccess}" = "a" ]; then
2731 unset hallocksuccess
2732 [ "a${informed}" = "a" ] && verbose "Acquiring exclusive lock to HAL"
2733 informed=`expr ${informed} + 1`; informed=`echo ${informed}`
2734 if [ "${informed}" -le "20" ]; then
2735 debug "Waiting for spawned process to acquire lock (%d secs will have passed).\n" "${informed}"
2736 sleep 1
2737 else
2738 debug "Giving up waiting for lock to occur. Will try to terminate current lock attempt.\n"
2739 export HAL_LOCK=${halpid}
2740 hal_unlock; unset HAL_LOCK
2741 break
2742 fi
2743 else
2744 debug "Exclusive lock granted to PID %d.\n" "${hallocksuccess}"
2745 break;
2746 fi
2747 done
2748 if [ "a${hallocksuccess}" != "a" ]; then
2749 export HAL_LOCK=${halpid}
2750 addexittrap hal_unlock
2751 debug "Succesfully locked HAL interface \"%s\" (hal-lock itself running with PID %d).\n" "$1" "${HAL_LOCK}"
2752 unset halpid; unset informed; unset hallocksuccess
2753 return 0
2754 fi
2755 unset halpid; unset informed; unset hallocksuccess
2756 debug "Failed to acquire exclusive lock to %s.\n" "$1"
2757 return 1
2758 }
2759
2760 # Makes sure that only one instance of $3 is contained within
2761 # list $2 of hal udi $1.
2762 hal_add_to_list() {
2763 ! find_binary "hal-get-property" && return 1
2764 ! find_binary "hal-set-property" && return 1
2765 [ "$#" -ne "3" ] && return 1
2766 halfound=0
2767 while [ "${halfound}" -ne "1" ];
2768 do
2769 contents=`hal-get-property --udi "$1" --key "$2" 2> /dev/null`
2770 halfound=0
2771 for op in ${contents}
2772 do
2773 if [ "a${op}" = "a$3" ]; then
2774 halfound=`expr ${halfound} + 1`
2775 halfound=`echo ${halfound}`
2776 fi
2777 done
2778 if [ "${halfound}" -eq "0" ]; then
2779 debug "Will attempt to add \"%s\" inside \"%s\".\n" "$3" "$2"
2780 hal-set-property --udi "$1" --key "$2" --strlist-post "$3" 2> /dev/null
2781 elif [ "${halfound}" -gt "1" ]; then
2782 debug "Will attempt to remove multiple instance of \"%s\" inside \"%s\".\n" "$3" "$2"
2783 hal-set-property --udi "$1" --key "$2" --strlist-rem "$3" 2> /dev/null
2784 fi
2785 hala=$?
2786 if [ "a${hala}" != "a0" ]; then
2787 debug "Unable to properly modify HAL.\n"
2788 break
2789 fi
2790 done
2791 [ "${halfound}" -eq "1" ] && debug "HAL is updated.\n"
2792 unset contents; unset op; unset hala
2793 if [ "a${halfound}" = "a1" ]; then
2794 unset halfound
2795 return 0
2796 fi
2797 unset halfound
2798 return 1
2799 }
2800
2801 # Makes sure modem $1 capabilities are loaded on hal
2802 hal_tty_update() {
2803 [ "a${nohal}" != "a" ] && return 0
2804 [ "a${nohalinform}" != "a" ] && return 0
2805 ! find_binary "hal-get-property" && return 1
2806 ! find_binary "hal-set-property" && return 1
2807 ! find_binary "hal-find-by-property" && return 1
2808 unset halcapabilities
2809 case "a${TTY_CAPABILITIES}" in
2810 aGSM)
2811 halcapabilities="GSM-07.07 GSM-07.05"
2812 ;;
2813 a)
2814 debug "No capabilities found. Don't know what to tell to HAL.\n"
2815 ;;
2816 *)
2817 debug "FIX ME: Unknown capabilities %s. Don't know what to tell to HAL.\n" "${TTY_CAPABILITIES}"
2818 ;;
2819 esac
2820 [ "a${halcapabilities}" = "a" ] && unset halcapabilities && return 1
2821 debug "Capabilities of %s are: %s\n" "$1" "${halcapabilities}"
2822 haludi=`hal-find-by-property --key "linux.device_file" --string "$1" 2> /dev/null | ${tailbin} -1`
2823 if [ "a${haludi}" = "a" ]; then
2824 unset haludi; unset halcapabilities
2825 debug "No HAL device referring to %s was found.\n" "$1"
2826 return 1
2827 fi
2828 debug "Found device in HAL: %s\n" "${haludi}"
2829 verbose "Updating HAL"
2830 hal_add_to_list "${haludi}" info.capabilities "modem"
2831 for cap in ${halcapabilities}
2832 do
2833 hal_add_to_list "${haludi}" modem.command_sets "${cap}"
2834 done
2835 debug "HAL was updated that %s is a modem.\n" "$1"
2836 find_binary "hal-device" && debug run_command "hal-device \"${haludi}\""
2837 unset cap; unset halcapabilities; unset haludi
2838 return 0
2839 }
2840
2841 # If $1 node does not exist, creates it with major $2 and minor $3
2842 dev_create_node() {
2843 [ "a$1" = "a" -o "a$2" = "a" -o "a$3" = "a" ] && return 99
2844 if [ ! -c "$1" ]; then
2845 debug "Device node \"%s\" does not exist.\n" "$1"
2846 if ! find_binary "mknod"; then
2847 show_fmt_error "Unable to create device node \"%s\"." "$1"
2848 return 1
2849 fi
2850 debug run_command "${mknodbin} \"$1\" c $2 $3"
2851 if [ ! -c "$1" ]; then
2852 show_fmt_error "Failed to create device node \"%s\"." "$1"
2853 return 1
2854 fi
2855 debug "Made node \"%s (%d,%d)\" ourselves.\n" "$1" "$2" "$3"
2856 return 0
2857 else
2858 debug "Device node \"%s\" already exists.\n" "$1"
2859 return 0
2860 fi
2861 }
2862
2863 pin_valid() {
2864 [ "a$1" = "a" ] && return 1
2865 need_binary "expr"
2866 givenpin=`echo $1`
2867 mathpin=`${exprbin} 1${givenpin} + 1 - 1 2> /dev/null`; mathpin=`echo ${mathpin}`
2868 if [ "a${mathpin}" = "a1${givenpin}" ]; then
2869 if [ "1${givenpin}" -ge "10000" -a "1${givenpin}" -le "19999" ]; then
2870 debug "Valid PIN %s.\n" "$1"
2871 return 0
2872 fi
2873 fi
2874 debug "Invalid PIN %s.\n" "$1"
2875 return 1
2876 }
2877
2878 pin_prompt() {
2879 user_prompt "SIM_PIN" "Modem needs PIN" "Please enter PIN number, or leave empty to abort" "OK" "Cancel"
2880 case "a${SIM_PIN}" in
2881 a)
2882 debug "User did not provide PIN.\n"
2883 unset SIM_PIN
2884 return 98
2885 ;;
2886 *)
2887 if ! pin_valid "${SIM_PIN}"; then
2888 debug "PIN supplied by user was not a valid PIN number (%s).\n" "${SIM_PIN}"
2889 unset SIM_PIN
2890 pin_prompt
2891 ret=$?
2892 fi
2893 export SIM_PIN
2894 return 0
2895 ;;
2896 esac
2897 }
2898
2899
2900 # Makes sure tty $1 is not busy
2901 tty_not_busy() {
2902 [ "a$1" = "a" ] && return 1
2903 [ ! -c "$1" ] && return 1
2904 if we_are_root; then
2905 ttyusers=`${lsbin} -l /proc/*/fd/* 2> /dev/null | ${grepbin} "${1}$" | ${sedbin} -e "s/\(.*\)\/proc\/\([0-9][0-9]*\)\/fd\/\(.*\)/\2/g" | ${sortbin} | ${uniqbin} | ${wcbin} -l` ; ttyusers=`echo ${ttyusers}`
2906 if [ "a${ttyusers}" = "a0" ]; then
2907 unset ttyusers
2908 debug "Device %s is not busy.\n" "$1"
2909 [ "a$2" != "a" ] && verbose "Resuming"
2910 return 0
2911 fi
2912 debug "Device %s is currently occupied by %d process(es).\n" "$1" "${users}"
2913 ttyusers=`${lsbin} -l /proc/*/fd/* 2> /dev/null | ${grepbin} "${1}$" | ${sedbin} -e "s/\(.*\)\/proc\/\([0-9][0-9]*\)\/fd\/\(.*\)/\2/g" | ${sortbin} | ${uniqbin}` ; ttyusers=`echo ${ttyusers}`
2914 debug "PID(s) are: %s\n" "${ttyusers}"
2915 for ttyp in ${ttyusers}
2916 do
2917 debug run_command "${psbin} -p ${ttyp} -o pid,comm= | ${tailbin} -1"
2918 ttyusers="${ttyusers} `${psbin} -p ${ttyp} -o comm= 2> /dev/null`"
2919 done
2920 unset ttyp
2921 if [ "a$2" = "a" ]; then
2922 debug "Will wait for 10 seconds in case port is freed.\n"
2923 verbose "Waiting %s to be released by PID %s." "$1" "${ttyusers}"
2924 ttycount=11
2925 else
2926 ttycount=$2
2927 fi
2928 ttycount=`expr ${ttycount} - 1`
2929 if [ "a${ttycount}" = "a0" ]; then
2930 show_fmt_error "Port %s is currently occupied by %s." "$1" "${ttyusers}"
2931 unset ttyusers; unset ttycount;
2932 return 1
2933 else
2934 debug "Wait for another %d seconds in case port %s is freed.\n" "${ttycount}" "$1"
2935 sleep 1
2936 if tty_not_busy $1 $ttycount; then
2937 unset ttyusers; unset ttycount;
2938 return 0
2939 else
2940 unset ttyusers; unset ttycount;
2941 return 1
2942 fi
2943 fi
2944 unset ttyusers; unset ttycount;
2945 else
2946 show_fmt_error "Unable to check if %s is occupied. Not root." "$1"
2947 fi
2948 return 1
2949 }
2950
2951 at_default_commands() {
2952 unset ttycommands
2953 [ "a$1" = "a" ] && return 1
2954 case "a$1" in
2955 aPROBEGSM)
2956 ttycommands="ATI OK 'AT+GCAP' OK 'AT+CGSN' OK"
2957 ;;
2958 aIDENTIFY)
2959 ttycommands="AT+CGMM OK"
2960 ;;
2961 aSTAGE0)
2962 if [ "a${INIT_STAGE0}" != "a" ]; then
2963 ttycommands="${INIT_STAGE0}"
2964 fi
2965 ;;
2966 aSTAGE1)
2967 if [ "a${INIT_STAGE1}" != "a" ]; then
2968 ttycommands="${INIT_STAGE1}"
2969 fi
2970 ;;
2971 aPINCHECK)
2972 if [ "a${INIT_STAGE2}" != "a" ]; then
2973 ttycommands="${INIT_STAGE2}"
2974 debug "Using instructed PINCHECK.\n"
2975 else
2976 ttycommands="'AT+CPIN?' OK"
2977 debug "Using default PINCHECK.\n"
2978 fi
2979 ;;
2980 aPINSUPPLY)
2981 if pin_valid "${2}"; then
2982 if [ "a${INIT_STAGE3}" != "a" ]; then
2983 ttycommands=`${printfbin} "${INIT_STAGE3}\n" "${2}"`
2984 debug "Using instructed PINSUPPLY.\n"
2985 else
2986 ttycommands=`${printfbin} "'AT+CPIN=\"%s\"' OK\n" "${2}"`
2987 debug "Using default PINSUPPLY.\n"
2988 fi
2989 fi
2990 ;;
2991 aSTAGE4)
2992 if [ "a${INIT_STAGE4}" != "a" ]; then
2993 ttycommands="${INIT_STAGE4}"
2994 fi
2995 ;;
2996 aOPERATOR)
2997 ttycommands="AT+COPS=3,2 OK 'AT+COPS?' OK"
2998 ;;
2999 aOPERATORS)
3000 ttycommands="AT+COPS=3,2 OK 'AT+COPS=?' TIMEOUT 120 OK"
3001 ;;
3002 aOPERATORNAME)
3003 ttycommands="AT+COPS=3,0 OK 'AT+COPS?' OK"
3004 ;;
3005 aSIMOPERATORNAME)
3006 ttycommands="'AT+CRSM=176,28486,0,0,17' OK"
3007 ;;
3008 aSETOPERATOR)
3009 ttycommands=`${printfbin} "'AT+COPS=1,2,\"%s\"' OK\n" "${2}"`
3010 ;;
3011 aSTAGE5)
3012 if [ "a${INIT_STAGE5}" != "a" ]; then
3013 ttycommands="${INIT_STAGE5}"
3014 fi
3015 ;;
3016 aDETECTAPN)
3017 ttycommands="AT+CGDCONT? OK"
3018 ;;
3019 aINITIALIZE)
3020 if [ "a${APN}" != "a" ]; then
3021 apnpart=`echo "${APN}" | ${cutbin} -d: -f1`
3022 [ "a${apnpart}" = "aCUSTOM_APN" ] && apnpart="${CUSTOM_APN}"
3023 if [ "a${INIT_STAGE6}" != "a" ]; then
3024 ttycommands=`${printfbin} "${INIT_STAGE6}\n" "${apnpart}"`
3025 debug "Using instructed INITIALIZE.\n"
3026 else
3027 ttycommands=`${printfbin} "ATZ OK 'AT&F' OK 'ATQ0 V1 E1' OK 'AT&D2 &C1' OK AT+FCLASS=0 OK ATS0=0 OK 'AT+CGDCONT=1,\"IP\",\"%s\"' OK\n" "${apnpart}"`
3028 debug "Using default INITIALIZE.\n"
3029 fi
3030 unset apnpart
3031 fi
3032 ;;
3033 aSTAGE7)
3034 if [ "a${INIT_STAGE7}" != "a" ]; then
3035 ttycommands="${INIT_STAGE7}"
3036 fi
3037 ;;
3038 aSTAGE8)
3039 if [ "a${INIT_STAGE8}" != "a" ]; then
3040 ttycommands="${INIT_STAGE8}"
3041 fi
3042 ;;
3043 aDIAL)
3044 dialphone="${ISP_DIAL}"
3045 [ "a${dialphone}" = "a" ] && dialphone="*99#"
3046 ttycommands=`${printfbin} "ATD%s\n" "${dialphone}"`
3047 unset dialphone
3048 ;;
3049 esac
3050 [ "a${ttycommands}" != "a" ] && debug "Command \"%s\" refers to AT commands: %s\n" "$1" "${ttycommands}" && return 0
3051 debug "Unknown command \"%s\".\n" "$1"
3052 return 1
3053 }
3054
3055 # Send command $2 to tty $1
3056 tty_send_command() {
3057 unset LASTTTYLOG
3058 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
3059 if [ ! -c "$1" ]; then
3060 debug "Device node %s did not exist while trying \"%s\" command.\n" "$1" "$2"
3061 if [ "a${informedspurious}" != "a1" ] && [ "a${usbdevice}" != "a" ] && usb_device_connected "${usbdevice}" && usb_has_storage "$1" && [ "a${killstorage}" = "a" ]; then
3062 show_fmt_error "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability." "$1"
3063 export informedspurious=1
3064 fi
3065 if [ "a${informedspurious}" != "a1" ]; then
3066 show_fmt_error "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver." "$1"
3067 export informedspurious=1
3068 fi
3069 [ ! -c "$1" ] && debug "Waiting one second in case it appears.\n" && sleep 1
3070 [ ! -c "$1" ] && debug "Device still missing. Aborting.\n" && return 1
3071 debug "Device %s appeared. Will proceed sending %s commands.\n" "$1" "$2"
3072 fi
3073 ! find_binary "chat" && return 4
3074 need_arg "CHAT_ABORT_STRINGS"
3075 ! at_default_commands "$2" "$3" && return 1
3076 ttycommands="\"\" '\pAT' OK ${ttycommands} '\pAT' OK"
3077 debug "Will send %s commands to tty %s: %s\n" "$2" "$1" "${ttycommands}"
3078 ! tty_not_busy "$1" && return 1
3079 timestamp_before=`${lsbin} --full-time -G1 $1 2> /dev/null`; timestamp_before=`echo ${timestamp_before}`
3080 sh -c "${chatbin} -t 2 -e ${CHAT_ABORT_STRINGS} ${ttycommands} >> ${1} < ${1} 2> /tmp/sakis3g.chat.$$.log"
3081 timestamp_after=`${lsbin} --full-time -G1 $1 2> /dev/null`; timestamp_before=`echo ${timestamp_after}`
3082 if [ "a${timestamp_before}" != "a${timestamp_after}" ]; then
3083 debug "Spurious changes in tty %s.\n" "$1"
3084 if [ "a${usbdevice}" != "a" ] && usb_device_connected "${usbdevice}" && usb_has_storage "$1" && [ "a${killstorage}" = "a" ] && [ "a${informedspurious}" != "a1" ]; then
3085 show_fmt_error "Spurious changes in tty %s. Consider using \"killstorage\" switch in case it improves stability." "$1"
3086 export informedspurious=1
3087 fi
3088 if [ "a${informedspurious}" != "a1" ]; then
3089 show_fmt_error "Spurious changes in tty %s. Problem may be solved by upgrading your kernel or by choosing another driver." "$1"
3090 export informedspurious=1
3091 fi
3092 fi
3093 unset ttycommands
3094 if [ -f "/tmp/sakis3g.chat.$$.log" ]; then
3095 LASTTTYLOG=`${catbin} "/tmp/sakis3g.chat.$$.log"`
3096 debug "Got response from tty:\n%s\n" "${LASTTTYLOG}"
3097 rm -f "/tmp/sakis3g.chat.$$.log"
3098 return 0
3099 else
3100 debug "No response from tty %s.\n" "$1"
3101 return 1
3102 fi
3103 }
3104
3105 # Finds capabilities of tty $1 and sets TTY_CAPABILITIES variable
3106 tty_get_caps() {
3107 unset TTY_CAPABILITIES
3108 [ "a$1" = "a" ] && return 1
3109 ! tty_send_command "$1" "PROBEGSM" && return 1
3110 gsmfound=`echo "${LASTTTYLOG}" | ${grepbin} "+CGSM" | wc -l`; gsmfound=`echo ${gsmfound}`
3111 if [ "a${gsmfound}" = "a0" ]; then
3112 debug "No GSM capabilities were advertised.\n"
3113 gsmfound=`echo "${LASTTTYLOG}" | ${grepbin} "^\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)$" | wc -l` ; gsmfound=`echo ${gsmfound}`
3114 if [ "a${gsmfound}" = "a1" ]; then
3115 debug "However, IMEI information was provided. Will consider it GSM capable.\n"
3116 fi
3117 fi
3118 [ "a${gsmfound}" = "a0" -o "a${gsmfound}" = "a" ] && [ "a${NOPROBEGSM}" != "a" ] && debug "Forced by user to consider tty %s GSM capable.\n" "$1" && gsmfound=1
3119 if [ "a${gsmfound}" != "a0" ]; then
3120 export TTY_CAPABILITIES="GSM"
3121 debug "Found GSM capabilities on tty %s.\n" "$1"
3122 return 0
3123 fi
3124 # TODO: Implement support for non GSM devices.
3125 debug "Device did not report GSM capabilities.\n"
3126 if [ "a$2" != "anoretry" ]; then
3127 debug "Will check one more time.\n"
3128 tty_get_caps "$1" "noretry"
3129 return $?
3130 fi
3131 show_fmt_error "Device did not report GSM capabilities. You can skip this by adding --noprobe command line switch.\n"
3132 return 1
3133 }
3134
3135 # Sets MODEM_VARIANT, if possible, for tty $1
3136 tty_identify() {
3137 unset MODEM_VARIANT
3138 [ "a$1" = "a" ] && return 1
3139 ! tty_send_command "$1" "IDENTIFY" && return 1
3140 MODEM_VARIANT=`echo "${LASTTTYLOG}" | ${grepbin} -v "^AT" | ${sedbin} -e "s/AT//g" | ${sedbin} -e "s/OK//g" | ${sedbin} -e "s/ERROR//g" | ${trbin} "\n" " " | ${trbin} "\t" " " | ${sedbin} -e "s/ */ /g" | ${sedbin} -e "s/^ *//g" | ${sedbin} -e "s/ *$//g"`
3141 MODEM_VARIANT=`echo ${MODEM_VARIANT}`
3142 if [ "a${MODEM_VARIANT}" = "a" ]; then
3143 debug "Modem did not report a name.\n"
3144 unset MODEM_VARIANT
3145 else
3146 debug "Modem on tty identified itself as: %s\n" "${MODEM_VARIANT}"
3147 base_modem "${usbdevice}" "${MODEM_VARIANT}"
3148 fi
3149 return 0
3150 }
3151
3152 # Checks if tty $1 needs PIN.
3153 tty_needspin() {
3154 unset pinrequirement
3155 [ "a$1" = "a" ] && return 1
3156 ! tty_send_command "$1" "PINCHECK" && return 1
3157 pinrequirement=`echo "${LASTTTYLOG}" | ${grepbin} "ERROR"`
3158 [ "a${pinrequirement}" != "a" ] && pinrequirement="ERROR"
3159 [ "a${pinrequirement}" = "a" ] && pinrequirement=`echo "${LASTTTYLOG}" | ${grepbin} "^.CPIN: " | ${cutbin} -d\ -f2-`
3160 [ "a${pinrequirement}" = "a" ] && pinrequirement="ERROR"
3161 [ "a${pinrequirement}" = "aREADY" ] && debug "Modem on %s does not need PIN.\n" "$1" && return 1
3162 [ "a${pinrequirement}" = "aSIM PIN" ] && debug "Modem on %s needs PIN.\n" "$1" && return 0
3163 debug "Got \"%s\" while checking modem on %s for PIN requirement.\n" "${pinrequirement}" "$1"
3164 return 0
3165 }
3166
3167 # Unlocks tty $1 from PIN.
3168 tty_pin_unlock() {
3169 [ "a$1" = "a" ] && return 1
3170 ! tty_needspin "$1" && unset pinrequirement && return 0
3171 if [ "a${pinrequirement}" = "a" ]; then
3172 show_fmt_error "Failed to get valid response from modem while checking for PIN."
3173 unset pinrequirement
3174 return 1
3175 elif [ "a${pinrequirement}" != "aSIM PIN" ]; then
3176 show_fmt_error "Modem responded \"%s\" while checking for PIN." "${pinrequirement}"
3177 unset pinrequirement
3178 return 1
3179 fi
3180 unset pinrequirement
3181 if ! pin_valid "${SIM_PIN}"; then
3182 unset SIM_PIN
3183 ! pin_prompt && return 98
3184 ! pin_valid "${SIM_PIN}" && return 1
3185 fi
3186 verbose "Sending PIN"
3187 ! tty_send_command "$1" "PINSUPPLY" "${SIM_PIN}" && return 1
3188 debug "PIN sent to %s. Waiting 3 seconds before checking success.\n" "$1"
3189 sleep 3
3190 if ! tty_needspin "$1"; then
3191 unset pinrequirement
3192 debug "SIM is now READY.\n"
3193 return 0
3194 fi
3195 unset SIM_PIN
3196 stop_fmt_error 12 "WRONG PIN. Aborting to prevent you from locking your SIM card."
3197 return 1
3198 }
3199
3200 tty_detect_apn() {
3201 unset MODEM_APN
3202 [ "a${MODEM_TTY}" = "a" ] && return 1
3203 ! tty_send_command "${MODEM_TTY}" "DETECTAPN" && return 1
3204 MODEM_APN=`echo "${LASTTTYLOG}" | ${grepbin} "^+CGDCONT" | ${sedbin} -e "s/^\(.*\)IP\",\"\(.*\)\",\"\(.*\)$/\2/g" | ${grepbin} -v "^+CGDCONT"`
3205 export MODEM_APN
3206 debug "APN stored in modem was: %s\n" "${MODEM_APN}"
3207 [ "a${MODEM_APN}" = "a" ] && unset MODEM_APN && return 1
3208 return 0
3209 }
3210
3211 tty_sim_provider_name() {
3212 unset ISPSIMNAME
3213 [ "a$1" = "a" ] && return 1
3214 if tty_send_command "$1" "SIMOPERATORNAME"; then
3215 ISPSIMNAME=`echo "${LASTTTYLOG}" | ${grepbin} "^+CRSM:\( *\)144," | ${sedbin} -e "s/^.CRSM:\( *\)144,\(.*\),\"\(.*\)\"\(.*\)$/ISPSIMNAME=\3/g" | ${grepbin} "^ISPSIMNAME=" | ${cutbin} -d= -f2-`
3216 [ "a${ISPSIMNAME}" = "a" ] && unset ISPSIMNAME && return 1
3217 ISPSIMNAME=`${printfbin} "\`echo "${ISPSIMNAME}" | ${sedbin} -e "s/\([0-9A-Fa-f][0-9A-Fa-f]\)/\\\\\\\\\\x\1/g" | ${sedbin} -e "s/\\\\\\\\\\xFF//g" | ${sedbin} -e "s/\\\\\\\\\\x01//g" | ${sedbin} -e "s/\\\\\\\\\\x02//g"\`\n"`
3218 ISPSIMNAME=`echo ${ISPSIMNAME}`
3219 [ "a${ISPSIMNAME}" = "a" ] && unset ISPSIMNAME && return 1
3220 debug "SIM contains \"service provider\" name: %s\n" "${ISPSIMNAME}"
3221 export ISPSIMNAME
3222 return 0
3223 fi
3224 return 1
3225 }
3226
3227 tty_select_network() {
3228 unset FORCE_ISP
3229 verbose "Scanning networks"
3230 ! tty_send_command "$1" "OPERATORS" && return 1
3231 networks=`echo "${LASTTTYLOG}" | ${grepbin} "^+COPS:" | ${cutbin} -d: -f2- -s | ${sedbin} -e "s/(/\\\n(/g" | ${sedbin} -e "s/)/)\\\n/g" | ${grepbin} "^([1-3],\"\(.*\)\",\"\(.*\)\",\"\([0-9][0-9]*\)\",0)$" | ${sedbin} -e "s/^(1,/(Allowed,/g" | ${sedbin} -e "s/^(2,/(Current,/g" | ${sedbin} -e "s/^(3,/(Forbidden,/g" | ${sedbin} -e "s/^(\(.*\),\"\(.*\)\",\"\(.*\)\",\"\([0-9][0-9]*\)\",0)$/\"\4\" \"\2 (\1\)\" /g"`
3232 eval user_select \"FORCE_ISP\" \"Please select a network\" \"Select network for modem to register.\" \"Select\" \"Cancel\" ${networks}
3233 # in
3234 case "$?" in
3235 0)
3236 unset FORCE_ISP; unset networks
3237 return 98
3238 ;;
3239 98)
3240 unset FORCE_ISP; unset networks
3241 return 98
3242 ;;
3243 99)
3244 unset FORCE_ISP; unset networks
3245 return 99
3246 ;;
3247 *)
3248 case "a${FORCE_ISP}" in
3249 a)
3250 unset FORCE_ISP; unset networks
3251 return 98
3252 ;;
3253 *)
3254 debug "User selected %s.\n" "${FORCE_ISP}"
3255 return 0
3256 ;;
3257 esac
3258 ;;
3259 esac
3260 return 1
3261 }
3262
3263 tty_registered_network() {
3264 unset ISPID; unset ISPNAME; unset ISPTEXT
3265 [ "a$1" = "a" ] && return 1
3266 ! tty_send_command "$1" "OPERATOR" && return 1
3267 ISPID=`echo "${LASTTTYLOG}" | ${grepbin} "^+COPS:" | ${cutbin} -d\" -f2`; ISPID=`echo ${ISPID}`
3268 if [ "a${ISPID}" = "a+COPS: 0" -o "a${ISPID}" = "a" ]; then
3269 debug "Modem not registered to a network yet.\n"
3270 unset ISPID
3271 return 1
3272 fi
3273 debug "Modem registered to network ID \"%s\".\n" "${ISPID}"
3274 if [ -n "${FORCE_ISP}" ]; then
3275 if [ "a${ISPID}" != "a${FORCE_ISP}" ]; then
3276 debug "FORCE_ISP variable instructs to use \"%s\" instead.\n" "${FORCE_ISP}"
3277 fi
3278 debug "Will attempt to manually set %s and prevent roaming.\n" "${FORCE_ISP}"
3279 ! tty_send_command "$1" "SETOPERATOR" "${FORCE_ISP}"
3280 if [ "a$2" != "aFORCE_ISP" ]; then
3281 tty_registered_network "$1" "FORCE_ISP"
3282 else
3283 if [ "a${ISPID}" != "a" ]; then
3284 show_fmt_error "Modem refused to register operator \"%s\" (currently registered to \"%s\").\n" "${FORCE_ISP}" "${ISPID}"
3285 else
3286 show_fmt_error "Modem refused to register operator \"%s\".\n" "${FORCE_ISP}"
3287 fi
3288 unset ISPID
3289 return 1
3290 fi
3291 unset ISPID
3292 return $?
3293 fi
3294 export ISPID
3295 if tty_send_command "$1" "OPERATORNAME"; then
3296 ISPNAME=`echo "${LASTTTYLOG}" | ${grepbin} "^+COPS:" | ${sedbin} -e "s/^.COPS: 0,0,\"\(.*\)\"\(.*\)$/ISPNAME=\1/g" | ${grepbin} "^ISPNAME=" | ${cutbin} -d= -f2-`
3297 if tty_sim_provider_name "$1" && [ "a${ISPSIMNAME}" != "a" -a "a${ISPSIMNAME}" != "a${ISPNAME}" ]; then
3298 debug "SIM card instructs to use \"%s\" as service provider name, instead of \"%s\".\n" "${ISPSIMNAME}" "${ISPNAME}"
3299 ISPNAME="${ISPSIMNAME}"
3300 fi
3301 # Some modems return numeric ID, even if instructed to display name.
3302 [ "a${ISPNAME}" = "a${ISPID}" ] && unset ISPNAME
3303 # Some SIMs incorrectly confuse modem to display FFs as service provider name.
3304 [ "a`echo ${ISPNAME} | ${cutbin} -b1-8`" = "aFFFFFFFF" ] && unset ISPNAME
3305 # Huawei E160 does not correctly report operator name.
3306 # This is not true. Was a SIM issue. This is not true.
3307 #[ "a${MODEM_VARIANT}" = "aE160" ] && unset ISPNAME
3308 export ISPNAME
3309 [ "a${ISPNAME}" = "a" ] && net_info "${ISPID}"
3310 [ "a${ISPNAME}" = "a" ] && unset ISPNAME
3311 fi
3312 export ISPTEXT="${ISPID}"
3313 [ "a${ISPNAME}" != "a" ] && export ISPTEXT="${ISPNAME}"
3314 return 0
3315 }
3316
3317 tty_register_network() {
3318 [ "a$1" = "a" ] && return 1
3319 wat=0
3320 if [ -n "${FORCE_ISP}" ]; then
3321 debug "FORCE_ISP variable instructs to enter network \"%s\".\n" "${FORCE_ISP}"
3322 debug "Will attempt to manually set %s and prevent roaming.\n" "${FORCE_ISP}"
3323 ! tty_send_command "$1" "SETOPERATOR" "${FORCE_ISP}"
3324 fi
3325 while ! tty_registered_network $1;
3326 do
3327 if [ "${wat}" -gt "20" ]; then
3328 debug "Giving up after %d seconds have passed.\n" "${wat}"
3329 break
3330 else
3331 wat=`expr ${wat} + 4`
3332 wat=`echo ${wat}`
3333 fi
3334 debug "Waiting modem to register network (%d seconds).\n" "${wat}"
3335 verbose "Registering network"
3336 sleep 4
3337 done
3338 unset wat
3339 if [ "a${ISPID}" = "a" ]; then
3340 show_fmt_error "Modem unable to register a network."
3341 unset ISPID
3342 if user_confirm "scan" "Scan for network" "Modem was unable to register a network. Would you like to manually select a network?" "Yes" "No" "reset"; then
3343 if tty_select_network "$@"; then
3344 tty_register_network "$@"
3345 return $?
3346 fi
3347 fi
3348 return 13
3349 else
3350 debug "Modem on %s has registered %s.\n" "$1" "${ISPID}"
3351 return 0
3352 fi
3353 }
3354
3355 # Makes sure tty $1 is ready for connection to be established.
3356 tty_prepare() {
3357 check_com_software
3358 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
3359 [ "a$1" = "a" ] && return 1
3360 verbose "Preparing modem"
3361 tty_send_command "$1" "STAGE0"
3362 ! tty_get_caps "$@" && return 1
3363 ! tty_identify "$@" && return 1
3364 tty_send_command "$1" "STAGE1"
3365 ! tty_pin_unlock "$@" && return 1
3366 tty_send_command "$1" "STAGE4"
3367 tty_register_network "$@"; ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
3368 tty_send_command "$1" "STAGE5"
3369 hal_tty_update "$@"
3370 debug "Modem on device node %s is now ready for connection.\n" "$1"
3371 return 0
3372 }
3373
3374 # Attempts to get connected USB devices, exiting if it fails.
3375 usb_connected_devices() {
3376 unset usb_devices
3377 need_binary "sort"; need_binary "uniq"; need_binary "sed"
3378 if [ -r "/proc/bus/usb/devices" ]; then
3379 debug "Fetching connected USB devices by using \"%s\".\n" "/proc/bus/usb/devices"
3380 usb_devices=`safe_cat "/proc/bus/usb/devices" | ${grepbin} -A 4 "^P:" | ${sedbin} -e "s/^\(.*\)Ven\(.*\)=\(....\) Pro\(.*\)=\(....\) \(.*\)$/\3:\5:/g" | ${sedbin} -e "s/^S:\(.*\)Pro\(.*\)=\(.*\)$/\3/g" | ${sedbin} -e "s/^.:\(.*\)$//g" | ${grepbin} -v "^$"`
3381 usb_devices=`echo ${usb_devices} | ${sedbin} -e "s/: */:/g" | ${sedbin} -e "s/ -- /\\\n/g" | ${sortbin} | ${uniqbin} | ${grepbin} -v "HCI Host Controller"`
3382 elif [ -d "/sys/bus/usb/devices" ]; then
3383 debug "Fetching connected USB devices by using \"%s\".\n" "/sys/bus/usb/devices"
3384 usb_devices=`cd /sys/bus/usb/devices/; ${grepbin} . */idProduct */idVendor */product */uevent | ${sortbin} | ${sedbin} -e "s/idProduct:\(.*\)$/idProduct:\1:/g" | ${sedbin} -e "s/idVendor:\(.*\)$/idVendor:\1:/g" | ${grepbin} -A 2 "idProduct" | ${sedbin} -e "s/^\(.*\):\(..*\):*$/\2/g"`
3385 usb_devices=`echo ${usb_devices} | ${sedbin} -e "s/: */:/g" | ${sedbin} -e "s/ -- /\\\n/g" | ${sortbin} | ${uniqbin} | ${sedbin} -e "s/^\(....\):\(....\):/\2:\1:/g" | ${sortbin} | ${uniqbin} | ${grepbin} -v "HCI Host Controller"`
3386 elif find_binary "lsusb"; then
3387 debug "Fetching connected USB devices by using \"%s\".\n" "${lsusbbin}"
3388 usb_devices=`safe_lsusb | ${sedbin} -e "s/\(.*\)ID \(....\):\(....\) \(.*\)$/\2:\3:\4/g" | ${sortbin} | ${uniqbin} | ${grepbin} -v "root hub"`
3389 else
3390 stop_fmt_error 7 "Unable to discover connected USB devices. Script will now abort."
3391 fi
3392 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
3393 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
3394 unset TIMEOUTOCCURED
3395 fi
3396 debug "Connected USB devices are:\n%s\n" "${usb_devices}"
3397 return 0
3398 }
3399
3400 # Helper method. Prints equivalent of usb_devices only for those devices in $1
3401 usb_device_list() {
3402 for condevice in $@
3403 do
3404 echo "${usb_devices}" | ${grepbin} "^${condevice}:"
3405 done
3406 }
3407
3408 # Does scoring things to determine if which usb device looks like a sure candidate for being a modem.
3409 # On success, returns 0 and sets usb_modems.
3410 # On failure, returns 1
3411 voodoo_connected_modems() {
3412 unset usb_modems
3413 need_binary "uname"
3414 debug "Voodoo mode employed to discover a possible modem.\n"
3415 debug "Attempting to enumerate interfaces.\n"
3416 uevents=`cd /sys/bus/usb/devices; ${grepbin} . [0-9]*/uevent 2> /dev/null`
3417 interfaces=`echo "${uevents}" | ${cutbin} -d/ -f1 -s | ${grepbin} ":" | ${sortbin} | ${uniqbin}` ; interfaces=`echo ${interfaces}`
3418 debug "uevent contents are:\n%s\n" "${uevents}"
3419 debug "Interfaces are:\n%s\n" "${interfaces}"
3420 unset orphaninterfaces; unset storageinterfaces; unset communicationdevices; unset suspectdevices; unset serialinterfaces; unset interruptinterfaces
3421 for intstr in ${interfaces}
3422 do
3423 intclass=`echo "${uevents}" | ${grepbin} "^${intstr}\/" | ${grepbin} "uevent:INTERFACE=" | ${cutbin} -d= -f2 -s | ${cutbin} -d/ -f1`
3424 [ "a${intclass}" = "a9" ] && continue
3425 intdriver=`echo "${uevents}" | ${grepbin} "^${intstr}\/" | ${grepbin} "uevent:DRIVER=" | ${cutbin} -d= -f2 -s | ${sedbin} -e "s/-/_/g"`
3426 intserial=0; [ "a${intdriver}" != "a" ] && intserial=`usb_serial_drivers ${intdriver} 2> /dev/null | ${wcbin} -w`; intserial=`echo ${intserial}`
3427 intpoint=`cd /sys/bus/usb/devices; ${grepbin} . ${intstr}/ep_*/type 2> /dev/null | ${grepbin} -i "interrupt$" | ${wcbin} -l`; intpoint=`echo ${intpoint}`
3428 intdevice=`echo "${intstr}" | ${cutbin} -d: -f1 -s`
3429 intvendor=`${catbin} /sys/bus/usb/devices/${intdevice}/idVendor 2> /dev/null`
3430 intmodemmaker=`${grepbin} -i "usb:v${intvendor}" /lib/modules/\`${unamebin} -r\`/modules.alias 2> /dev/null | ${cutbin} -d\ -f3 -s | ${sortbin} | ${uniqbin}`
3431 intmodemmaker=`usb_serial_drivers ${intmodemmaker} 2> /dev/null`
3432 intbrothers=`echo "${interfaces}" | ${trbin} " " "\n" | ${sedbin} -e "s/^\( *\)//g" | ${grepbin} "^${intdevice}:" | ${wcbin} -l`; intbrothers=`echo ${intbrothers}`
3433 if [ "a${intdriver}" = "a" ]; then
3434 orphaninterfaces="${orphaninterfaces} ${intstr} ${intstr} ${intstr}"
3435 debug "Added interface %s to orphan interfaces.\n" "${intstr}"
3436 fi
3437 if [ "a${intpoint}" = "a1" ]; then
3438 interruptinterfaces="${interruptinterfaces} ${intstr} ${intstr} ${intstr}"
3439 debug "Added interface %s to interrupt interfaces.\n" "${intstr}"
3440 fi
3441 if [ "a${intdriver}" = "ausb-storage" -o "a${intdriver}" = "ausb_storage" -o "a${intclass}" = "a8" ]; then
3442 storageinterfaces="${storageinterfaces} ${intstr} ${intstr} ${intstr} ${intstr}"
3443 debug "Added interface %s to storage interfaces.\n" "${intstr}"
3444 if [ "a${intbrothers}" = "a1" ]; then
3445 storageinterfaces="${storageinterfaces} ${intstr} ${intstr}"
3446 debug "+2 for being unique interface of device %s.\n" "${intdevice}"
3447 fi
3448 if [ "a${intbrothers}" = "a1" ] && [ "a${intmodemmaker}" != "a" ]; then
3449 storageinterfaces="${storageinterfaces} ${intstr} ${intstr} ${intstr}"
3450 debug "+3 for vendor %s being a modem maker.\n" "${intvendor}"
3451 fi
3452 fi
3453 if [ "a${intclass}" = "a2" ]; then
3454 communicationdevices="${communicationdevices} ${intstr} ${intstr}"
3455 debug "Added interface %s to communication interfaces.\n" "${intstr}"
3456 fi
3457 if [ "a${intclass}" = "a255" -o "a${intclass}" = "a224" ]; then
3458 suspectdevices="${suspectdevices} ${intstr}"
3459 debug "Added interface %s to suspect interfaces.\n" "${intstr}"
3460 fi
3461 if [ "a${intserial}" = "a1" ]; then
3462 serialinterfaces="${serialinterfaces} ${intstr} ${intstr} ${intstr} ${intstr} ${intstr}"
3463 debug "Added interface %s to serial interfaces.\n" "${intstr}"
3464 fi
3465 done
3466 unset interfaces; unset uevents
3467 unset intstr; unset intclass; unset intdriver; unset intserial; unset intpoint; unset intdevice; unset intvendor; unset intmodemmaker; unset intbrothers
3468 devicescore=`echo ${serialinterfaces} ${suspectdevices} ${communicationdevices} ${storageinterfaces} ${orphaninterfaces} ${interruptinterfaces} | ${trbin} " " "\n" | ${sedbin} -e "s/ //g" | ${grepbin} -v "^$" | ${cutbin} -d: -f1 -s | ${sortbin} | ${uniqbin} -c | ${sedbin} -e "s/^\( *\)//g" | ${sedbin} -e "s/\( *\)/ /g" | ${sedbin} -e "s/^\([0-9]\) /0\1 /g" | ${sedbin} -e "s/^\([0-9][0-9]\) /0\1 /g" | ${sedbin} -e "s/^\([0-9][0-9][0-9]\) /0\1 /g" | ${sortbin} -r`
3469 interfacescore=`echo ${serialinterfaces} ${suspectdevices} ${communicationdevices} ${storageinterfaces} ${orphaninterfaces} ${interruptinterfaces} | ${trbin} " " "\n" | ${sedbin} -e "s/ //g" | ${grepbin} -v "^$" | ${sortbin} | ${uniqbin} -c | ${sedbin} -e "s/^\( *\)//g" | ${sedbin} -e "s/\( *\)/ /g" | ${sedbin} -e "s/^\([0-9]\) /0\1 /g" | ${sedbin} -e "s/^\([0-9][0-9]\) /0\1 /g" | ${sedbin} -e "s/^\([0-9][0-9][0-9]\) /0\1 /g" | ${sortbin} -r`
3470 unset serialinterfaces; unset suspectdevices; unset communicationdevices; unset storageinterfaces; unset orphaninterfaces; unset interruptinterfaces;
3471 debug "Device score is:\n%s\n" "${devicescore}"
3472 debug "Interface score is:\n%s\n" "${interfacescore}"
3473 besttwo=`echo "${interfacescore}" | ${headbin} -2 | ${cutbin} -d\ -f2 -s | ${cutbin} -d: -f1 -s | ${uniqbin}`
3474 besttwocount=`echo "${besttwo}" | ${wcbin} -w`; besttwocount=`echo ${besttwocount}`
3475 if [ "a${besttwocount}" != "a" ] && [ "${besttwocount}" -eq "1" ]; then
3476 intvendor=`${catbin} /sys/bus/usb/devices/${besttwo}/idVendor 2> /dev/null`
3477 intproduct=`${catbin} /sys/bus/usb/devices/${besttwo}/idProduct 2> /dev/null`
3478 if usb_device_connected "${intvendor}:${intproduct}"; then
3479 export usb_modems="${intvendor}:${intproduct}"
3480 unset intvendor; unset intproduct
3481 debug "Voodoo operations determined device %s (%s) is a modem.\n" "${usb_modems}" "${besttwo}"
3482 unset besttwocount; unset besttwo; unset interfacescore; unset devicescore
3483 return 0
3484 fi
3485 unset intvendor; unset intproduct
3486 fi
3487 debug "No device is the absolute winner. Will check for dominating score.\n"
3488 firstscore=`echo "${interfacescore}" | ${headbin} -1 | ${cutbin} -d\ -f1 -s | ${sedbin} -e "s/^\(0*\)//g" | ${sedbin} -e "s/^$/0/g"`
3489 firstscore=`${printfbin} "%d\n" "${firstscore}" 2> /dev/null`; [ "a${firstscore}" = "a" ] && firstscore=0
3490 secondscore=`echo "${interfacescore}" | ${headbin} -2 | ${tailbin} -1 | ${cutbin} -d\ -f1 -s | ${sedbin} -e "s/^\(0*\)//g" | ${sedbin} -e "s/^$/0/g"`
3491 secondscore=`${printfbin} "%d\n" "${secondscore}" 2> /dev/null`; [ "a${secondscore}" = "a" ] && secondscore=0
3492 if [ "a${firstscore}" != "a" -a "a${secondscore}" != "a" ] && [ "a${firstscore}" != "a${secondscore}" ] && [ "${firstscore}" -gt "0" -a "${firstscore}" -gt "${secondscore}" ]; then
3493 secondscore=`expr ${secondscore} + ${secondscore}`; secondscore=`echo ${secondscore}`
3494 if [ "${firstscore}" -gt "${secondscore}" ]; then
3495 besttwo=`echo "${interfacescore}" | ${headbin} -1 | ${cutbin} -d\ -f2 -s | ${cutbin} -d: -f1 -s | ${uniqbin}`
3496 intvendor=`${catbin} /sys/bus/usb/devices/${besttwo}/idVendor 2> /dev/null`
3497 intproduct=`${catbin} /sys/bus/usb/devices/${besttwo}/idProduct 2> /dev/null`
3498 if usb_device_connected "${intvendor}:${intproduct}"; then
3499 export usb_modems="${intvendor}:${intproduct}"
3500 unset intvendor; unset intproduct
3501 debug "Device %s (%s) out-numbered second candidate and will be considered a modem.\n" "${usb_modems}" "${besttwo}"
3502 unset firstscore; unset secondscore
3503 unset besttwocount; unset besttwo; unset interfacescore; unset devicescore
3504 return 0
3505 fi
3506 fi
3507 fi
3508 unset firstscore; unset secondscore
3509 debug "No device dominates the other in score. Cannot decide.\n"
3510 unset besttwo; unset besttwocount; unset interfacescore; unset devicescore
3511 return 1
3512 }
3513
3514 # Attempts to get connected modems, and sets usb_modems and usb_modem_devices variables
3515 usb_connected_modems() {
3516 unset usb_modems; unset usb_modem_devices
3517 [ "a${KNOWN_devices}" = "a" ] && ! modeswitch_load && return 1
3518 ! usb_connected_devices && return 1
3519 connectedevices=`echo "${usb_devices}" | ${cutbin} -d: -f1,2`
3520 for condevice in ${connectedevices}
3521 do
3522 devfound=`${printfbin} "%s\n%s\n%s\n" "${KNOWN_devices}" "${MODEM}" "${USBMODEM}" | ${grepbin} "${condevice}"`
3523 [ "a${devfound}" != "a" ] && usb_modems="${usb_modems} ${condevice}"
3524 unset devfound
3525 done
3526 unset condevice; unset connectedevices
3527 usb_modems=`echo ${usb_modems}`
3528 export usb_modems
3529 if [ "a${usb_modems}" = "a" ] && unset usb_modems; then
3530 debug "No plugged modems found.\n"
3531 ! voodoo_mode && return 1
3532 ! voodoo_connected_modems && return 1
3533 fi
3534 usb_modem_devices=`usb_device_list ${usb_modems}`
3535 export usb_modem_devices
3536 debug "Connected USB modems are:\n%s\n" "${usb_modem_devices}"
3537 return 0
3538 }
3539
3540 # Returns true if device $1 is currently connected
3541 usb_device_connected() {
3542 [ "a$1" = "a" ] && return 99
3543 usb_connected_devices
3544 usbconnected=`echo "${usb_devices}" | ${cutbin} -d: -f1,2 | ${grepbin} "^$1"`
3545 [ "a${usbconnected}" = "a$1" ] && unset usbconnected && return 0
3546 unset usbconnected
3547 debug "Device \"%s\" is not connected.\n" "$1"
3548 return 1
3549 }
3550
3551 # Parses /proc/bus/usb/devices and only returns block referring to $1.
3552 usb_device_block() {
3553 unset usbdeviceblock
3554 [ "a$1" = "a" ] && return 1
3555 if [ -r "/proc/bus/usb/devices" ]; then
3556 usbvend=`echo "$1" | ${cutbin} -d: -f1`
3557 usbprod=`echo "$1" | ${cutbin} -d: -f2`
3558 usbdevcat=`safe_cat /proc/bus/usb/devices`
3559 usblines=`${printfbin} "%s\n\n" "${usbdevcat}" | ${grepbin} -A 60 "=${usbvend} \(.*\)=${usbprod}" | ${grepbin} -n "^$" | ${headbin} -1 | ${sedbin} -e "s/:$//g"`; usblines=`echo ${usblines}`
3560 [ "a${usblines}" = "a" ] && usblines=0
3561 [ "${usblines}" -gt "0" ] && usbdeviceblock=`echo "${usbdevcat}" | ${grepbin} -A 60 "Vendor=${usbvend} ProdID=${usbprod}" | ${headbin} -${usblines}`
3562 unset usblines; unset usbvend; unset usbprod; unset usbdevcat
3563 echo "${usbdeviceblock}" | ${grepbin} -v "^$"
3564 return 0
3565 fi
3566 return 1
3567 }
3568
3569 # Filters arguments and returns back only those that usb serial drivers
3570 usb_serial_drivers() {
3571 [ "a${kernel}" = "a" ] && find_binary "uname" && kernel=`${unamebin} -r`
3572 [ "a${kernel}" = "a" ] && return 1
3573 export kernel
3574 for driver in $@
3575 do
3576 [ -f "/lib/modules/${kernel}/kernel/drivers/usb/serial/${driver}.ko" ] && echo "${driver}" && continue
3577 [ "a${driver}" = "acdc_acm" ] && [ -f "/lib/modules/${kernel}/kernel/drivers/usb/class/cdc-acm.ko" ] && echo "${driver}"
3578 done
3579 }
3580
3581 # Attempts to find appropriate driver for USB device $1, and sets USBDRIVER
3582 usb_serial_detect_driver() {
3583 unset USBDRIVER
3584 [ "a$1" = "a" ] && return 99
3585 serialvend=`echo "$1" | ${cutbin} -d: -f1`
3586 serialprod=`echo "$1" | ${cutbin} -d: -f2`
3587 if ! find_binary "uname"; then
3588 debug "Failed to locate running kernel's modules. Uname missing.\n"
3589 else
3590 kernel=`${unamebin} -r`
3591 if [ -f "/lib/modules/${kernel}/modules.alias" ]; then
3592 drivercandidates=`${grepbin} -i "usb:v${serialvend}p${serialprod}" "/lib/modules/${kernel}/modules.alias" | ${cutbin} -d\ -f3 | ${sortbin} | ${uniqbin}`;
3593 drivercandidates=`usb_serial_drivers ${drivercandidates}`
3594 if [ "a${drivercandidates}" = "a" ]; then
3595 debug "No perfect match found for device \"%s\".\n" "$1"
3596 debug "Will seek if exists a driver for other devices from vendor \"%s\".\n" "${serialvend}"
3597 drivercandidates=`${grepbin} -i "usb:v${serialvend}p" "/lib/modules/${kernel}/modules.alias" | ${cutbin} -d\ -f3 | ${sortbin} | ${uniqbin}`;
3598 drivercandidates=`usb_serial_drivers ${drivercandidates}`
3599 if [ "a${drivercandidates}" = "a" ]; then
3600 debug "No candidates were found.\n"
3601 else
3602 debug "Found driver(s) for other devices of same vendor: %s\n" "${drivercandidates}"
3603 fi
3604 drivercandidates=`echo "${drivercandidates}" | ${trbin} " " "\n" | ${sedbin} -e "s/ //g" | ${sortbin} | ${uniqbin}`
3605 else
3606 debug "Found driver(s) available for \"%s\": %s\n" "$1" "${drivercandidates}"
3607 fi
3608 fi
3609 unset kernel
3610 fi
3611 if base_drivers "${serialvend}" "${serialprod}"; then
3612 drivercandidates=`echo ${drivercandidates} ${basedrivercandidates}`
3613 unset basedrivercandidates
3614 fi
3615 drivercandidates=`echo ${drivercandidates} | ${trbin} " " "\n" | ${sedbin} -e "s/ //g" | ${sortbin} | ${uniqbin}`
3616 candidatenum=`echo ${drivercandidates} | ${wcbin} -w`; candidatenum=`echo ${candidatenum}`
3617 if [ "a${candidatenum}" = "a1" ]; then
3618 USBDRIVER=`echo ${drivercandidates}`
3619 export USBDRIVER
3620 debug "Only one candidate, will use it unconditionally: %s\n" "${USBDRIVER}"
3621 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3622 return 0
3623 elif [ "a${candidatenum}" = "a0" ]; then
3624 drivercandidates="option"
3625 debug "No driver found, will propose \"%s\" driver.\n" "${drivercandidates}"
3626 if usb_usable_interfaces "$1" && [ "a${usableinterfacecount}" != "a" ] && [ "${usableinterfacecount}" -gt "1" ]; then
3627 debug "Device has %d usable interfaces. Will propose cdc_acm also.\n"
3628 drivercandidates="cdc_acm option"
3629 fi
3630 fi
3631 debug "Driver candidates are: %s\n" "${drivercandidates}"
3632 if voodoo_mode; then
3633 for safetoprobe in cdc_acm
3634 do
3635 debug "Will try safe to probe driver %s.\n" "${safetoprobe}"
3636 if module_bind "${safetoprobe}" "$1"; then
3637 debug "Appropriate driver %s determined.\n" "${safetoprobe}"
3638 export USBDRIVER="${safetoprobe}"
3639 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3640 return 0
3641 else
3642 debug "Determined %s is not a valid candidate. Will make sure is not within list of candidates either.\n" "${safetoprobe}"
3643 drivercandidates=`echo ${drivercandidates} | ${sedbin} -e "s/\( *\)${safetoprobe}\( *\)/ /g" | ${sedbin} -e "s/ / /g"`
3644 drivercandidates=`echo ${drivercandidates}`
3645 debug "Driver candidates are: %s\n" "${drivercandidates}"
3646 fi
3647 done
3648 fi
3649 drivers=`echo ${drivercandidates} | ${trbin} " " "\n" | ${sedbin} -e "s/^\( *\)\(.*\)\( *\)$/\2/g" | ${sortbin} | ${uniqbin} | ${sedbin} -e "s/^\(.*\)$/\"\1\" \"\1 kernel module\"/g"`
3650 eval user_select \"USBDRIVER\" \"Please select appropriate driver\" \"Select kernel module that should be used.\" \"Select\" \"Cancel\" ${drivers} \"OTHER\" \"Other driver...\"
3651 case "$?" in
3652 0)
3653 unset drivers
3654 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3655 return 98
3656 ;;
3657 98)
3658 unset drivers
3659 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3660 return 98
3661 ;;
3662 99)
3663 unset drivers
3664 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3665 return 99
3666 ;;
3667 *)
3668 case "a${USBDRIVER}" in
3669 aOTHER)
3670 unset USBDRIVER
3671 user_prompt "USBDRIVER" "Please enter name of driver" "Enter name of appropriate kernel module that should be used, or leave empty to abort" "OK" "Cancel"
3672 if [ "a${USBDRIVER}" != "a" ]; then
3673 unset drivers
3674 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3675 return 0
3676 fi
3677 usb_serial_detect_driver "$@"
3678 return $?
3679 ;;
3680 *)
3681 unset drivers
3682 unset candidatenum; unset drivercandidates; unset serialvend; unset serialprod
3683 return 0
3684 ;;
3685 esac
3686 ;;
3687 esac
3688 return 99
3689 }
3690
3691 # Returns driver attached to interface $2 of device $1
3692 usb_loaded_driver() {
3693 [ "a$1" = "a" ] && return 99
3694 if [ -r "/proc/bus/usb/devices" ]; then
3695 usbblock=`usb_device_block "$1"`; [ "a${usbblock}" = "a" ] && return 7
3696 if [ "a$2" != "a" ]; then
3697 usbdriver=`echo "${usbblock}" | ${grepbin} "^I:\(.*\)If.=\( *\)$2 " | ${sedbin} -e "s/^I:\(.*\)If.=\( *\)$2 \(.*\) Driver=\(.*\)/\4/g"`
3698 else
3699 usbdriver=`echo "${usbblock}" | ${grepbin} "^I:\(.*\)If.=" | ${sedbin} -e "s/^I:\(.*\)If.=\( *\) \(.*\) Driver=\(.*\)/\4/g"`
3700 fi
3701 case "a${usbdriver}" in
3702 a)
3703 usbdriver="FAIL"
3704 echo ${usbdriver}
3705 unset usbdriver
3706 return 1
3707 ;;
3708 "a(none)")
3709 usbdriver="NONE"
3710 echo ${usbdriver}
3711 unset usbdriver
3712 return 0
3713 ;;
3714 *)
3715 usbdriver=`echo ${usbdriver} | ${trbin} "-" "_"`
3716 usbdriver=`echo ${usbdriver} | ${sedbin} -e "s/usbserial_generic/usbserial/g"`
3717 echo ${usbdriver}
3718 unset usbdriver
3719 return 1
3720 esac
3721 elif usb_sysfsdir "$1"; then
3722 if [ "a$2" != "a" ]; then
3723 usbdriver=`${grepbin} . ${sysfsloc}/*-*\:*.$2/uevent | ${grepbin} -i DRIVER= | ${cutbin} -d= -f2 -s`
3724 else
3725 usbdriver=`${grepbin} . ${sysfsloc}/*-*\:*.*/uevent | ${grepbin} -i DRIVER= | ${cutbin} -d= -f2 -s`; usbdriver=`echo ${usbdriver}`
3726 fi
3727 usbdriver=`echo ${usbdriver} | ${trbin} "-" "_"`
3728 usbdriver=`echo ${usbdriver} | ${sedbin} -e "s/usbserial_generic/usbserial/g"`
3729 [ "a${usbdriver}" = "a" ] && usbdriver="NONE"
3730 echo ${usbdriver}
3731 unset usbdriver
3732 return 0
3733 else
3734 debug "Unable to determine driver attached to interface %s of device %s.\n" "$2" "$1"
3735 usbdriver="FAIL"
3736 echo ${usbdriver}
3737 unset usbdriver
3738 return 1
3739 fi
3740 }
3741
3742 usb_usable_interfaces() {
3743 unset usableinterfaces; usableinterfacecount=0
3744 [ "a$1" = "a" ] && return 99
3745 if [ -r "/proc/bus/usb/devices" ]; then
3746 debug "Using information of %s to determine usable interfaces.\n" "/proc/bus/usb/devices"
3747 usbblock=`usb_device_block "$1"`
3748 usbinter=`echo "${usbblock}" | ${grepbin} "^I:" | ${wcbin} -l`; usbinter=`echo ${usbinter}`
3749 debug "USB Device %s provides %d interface(s).\n" "$1" "${usbinter}"
3750 usbinter=`echo "${usbblock}" | ${grepbin} "(I)\(.*\)Atr=...Int\.. " | ${wcbin} -l`; usbinter=`echo ${usbinter}`
3751 debug "USB Device %s provides %d interruptable endpoint(s).\n" "$1" "${usbinter}"
3752 if [ "a${usbinter}" = "a0" -o "a${usbinter}" = "a" ]; then
3753 debug "USB device block output was:\n%s\n" "${usbblock}"
3754 debug "No modem lines on USB device \"%s\". Device may need switching.\n" "$1"
3755 else
3756 usbinter=`echo "${usbblock}" | ${grepbin} "(I)\(.*\)Atr=...Int\.. " | ${sedbin} -e "s/^E:\(.*\)Ad=\(.*\)(I)\(.*\)Atr=...Int\..\(.*\)$/\2/g"`; usbinter=`echo ${usbinter}`
3757 debug "Interruptable endpoint(s) are: %s\n" "${usbinter}"
3758 unset USB_INTERFACE
3759 for endpoint in ${usbinter}
3760 do
3761 localinter=`echo "${usbblock}" | ${grepbin} -B 10 "^E\(.*\)Ad=${endpoint}(I)" | ${grepbin} "^I" | ${tailbin} -1 | ${sedbin} -e "s/^\(.*\)If.=\( *\)\([0-9][0-9]*\) \(.*\)$/\3/g"`
3762 if [ "a${localinter}" != "a" ]; then
3763 localinter=`${printfbin} "%d\n" ${localinter} 2> /dev/null`
3764 if [ "a${localinter}" != "a" ]; then
3765 debug "Added interface %s, containing endpoint %s.\n" "${localinter}" "${endpoint}"
3766 usableinterfaces="${usableinterfaces} ${localinter}"
3767 fi
3768 fi
3769 unset localinter
3770 done
3771 unset localinter; unset endpoint
3772 fi
3773 unset usbinter; unset usbblock
3774 usableinterfaces=`echo ${usableinterfaces}`
3775 export usableinterfaces
3776 debug "Interfaces collected from %s are: %s\n" "/proc/bus/usb/devices" "${usableinterfaces}"
3777 fi
3778 if find_binary "lsusb"; then
3779 debug "Using information of %s to determine usable interfaces.\n" "lsusb"
3780 usbvend=`echo "$1" | ${cutbin} -d: -f1`; usbprod=`echo "$1" | ${cutbin} -d: -f2`
3781 usbblock=`safe_lsusb -v -d ${usbvend}:${usbprod}`
3782 usbinter=`echo "${usbblock}" | ${sedbin} -e "s/ */ /g" | ${grepbin} -i "transfer type interrupt" | ${wcbin} -l`; usbinter=`echo ${usbinter}`
3783 debug "USB Device %s provides %d interruptable endpoint(s).\n" "$1" "${usbinter}"
3784 if [ "a${usbinter}" = "a0" -o "a${usbinter}" = "a" ]; then
3785 debug "lsusb output was:\n%s\n" "${usbblock}"
3786 debug "No modem lines on USB device \"%s\". Device may need switching.\n" "$1"
3787 unset usbinter
3788 else
3789 # Enter character after "interrupt" word on following line IS NOT a mistake
3790 usbinter=`echo "${usbblock}" | ${sedbin} -e "s/ */ /g" | ${grepbin} -F -i "transfer type interrupt
3791 binterfacenumber" | ${grepbin} -B 1 -i interrupt | ${grepbin} -i "binterfacenumber" | ${cutbin} -d\ -f3 -s`; usbinter=`echo ${usbinter}`
3792 fi
3793 debug "Interfaces collected from %s are: %s\n" "lsusb" "${usbinter}"
3794 [ "a${usbinter}" != "a" ] && usableinterfaces=`echo "${usableinterfaces} ${usbinter}"`
3795 export usableinterfaces
3796 unset usbvend; unset usbprod; unset usbblock; unset usbinter;
3797 elif [ ! -r "/proc/bus/usb/devices" ]; then
3798 debug "Failed to read USB information.\n"
3799 show_fmt_error "Both \"%s\" and \"%s\" are missing." "lsusb" "/proc/bus/usb/devices"
3800 return 7
3801 fi
3802 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
3803 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
3804 unset TIMEOUTOCCURED
3805 fi
3806 usableinterfaces=`echo ${usableinterfaces} | ${trbin} " " "\n" | ${sedbin} -e "s/ //g" | ${sortbin} | ${uniqbin}`
3807 usableinterfaces=`echo ${usableinterfaces}`
3808 usableinterfacecount=`echo ${usableinterfaces} | ${wcbin} -w`; usableinterfacecount=`echo ${usableinterfacecount}`
3809 return 0
3810 }
3811
3812 usb_get_interface() {
3813 unset USB_INTERFACE
3814 [ "a$1" = "a" ] && return 99
3815 usb_usable_interfaces "$1"
3816 ret=$?; [ "a${ret}" != "a0" ] && return ${ret}
3817 USB_INTERFACE=`echo ${usableinterfaces}`
3818 export USB_INTERFACE
3819 if [ "a${USB_INTERFACE}" = "a" -o "a${usableinterfacecount}" = "a0" ]; then
3820 debug "Failed to locate any usable interface for device %s.\n" "$1"
3821 unset USB_INTERFACE
3822 return 8
3823 fi
3824 debug "Collected %d interface(s): %s\n" "${usableinterfacecount}" "${USB_INTERFACE}"
3825 if [ "a${usableinterfacecount}" = "a1" ]; then
3826 debug "Only one interface available. Will use that one unconditionally.\n"
3827 return 0
3828 fi
3829 usbvend=`echo "$1" | ${cutbin} -d: -f1 -s`
3830 usbprod=`echo "$1" | ${cutbin} -d: -f2 -s`
3831 if base_drivers "${usbvend}" "${usbprod}"; then
3832 if [ "a${baseintercandidates}" != "a" ]; then
3833 ifvalid=`echo ${USB_INTERFACE} | ${trbin} " " "\n" | ${grepbin} "^${baseintercandidates}$"`
3834 if [ "a${ifvalid}" = "a${baseintercandidates}" ]; then
3835 if [ "a${USBINTERFACE}" = "a" ]; then
3836 export USB_INTERFACE="${baseintercandidates}"
3837 debug "Will use interface #%d derived by config.\n" "${USB_INTERFACE}"
3838 unset ifvalid; unset usbvend; unset usbprod; unset baseintercandidates
3839 return 0
3840 else
3841 debug "However, will not use it in favor of already selected USBINTERFACE: %s\n" "${USBINTERFACE}"
3842 fi
3843 else
3844 debug "However, this interface is not available from device.\n"
3845 fi
3846 unset ifvalid
3847 else
3848 debug "Config does not specify interface for device %s.\n" "$1"
3849 fi
3850 unset baseintercandidates
3851 else
3852 debug "No configuration for device %s.\n" "$1"
3853 fi
3854 unset usbvend; unset usbprod
3855 if flow_select_interface "$1" "${USB_INTERFACE}"; then
3856 [ "a${USBINTERFACE}" = "a" ] && return 98
3857 export USB_INTERFACE="${USBINTERFACE}"
3858 debug "Will use interface #%d of USB device \"%s\".\n" "${USB_INTERFACE}" "$1"
3859 return 0
3860 else
3861 unset USB_INTERFACE
3862 debug "User did not provide an interface.\n"
3863 return 98
3864 fi
3865 return 99
3866 }
3867
3868 usb_sysfsdir() {
3869 unset sysfsloc
3870 [ "a$1" = "a" ] && return 1
3871 ! find_binary "dirname" && return 1
3872 usbven=`echo "$1" | ${cutbin} -d: -f1`; usbpro=`echo "$1" | ${cutbin} -d: -f2`
3873 venentry=`${grepbin} -H . /sys/bus/usb/devices/*/*/idVendor 2> /dev/null | ${grepbin} ":${usbven}$"`
3874 if [ "a${venentry}" != "a" ]; then
3875 for ff in ${venentry}
3876 do
3877 unset dirloc
3878 dirloc=`${dirnamebin} \`echo ${ff} | ${sedbin} -e "s/:${usbven}$//g"\` 2> /dev/null`
3879 if [ "a${dirloc}" != "a" ]; then
3880 if [ -d "${dirloc}" ]; then
3881 dirpro=`${catbin} ${dirloc}/idProduct`
3882 if [ "a${dirpro}" = "a${usbpro}" ]; then
3883 export sysfsloc="${dirloc}"
3884 debug "Device %s sysfs dir found: %s\n" "$1" "${sysfsloc}"
3885 unset dirpro; unset dirloc; unset venentry; unset usbven; unset usbpro
3886 return 0
3887 fi
3888 unset dirpro
3889 fi
3890 fi
3891 unset dirloc
3892 done
3893 fi
3894 debug "No device %s located in sysfs.\n" "$1"
3895 unset venentry; unset usbven; unset usbpro
3896 return 1
3897 }
3898
3899 usb_sysfsdir_int() {
3900 unset sysfsintloc
3901 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
3902 ! usb_sysfsdir "$1" && return 1
3903 intnum="$2"; [ "${intnum}" -lt "10" ] && intnum="0$2"
3904 intdir=`${grepbin} "." ${sysfsloc}/*/bInterfaceNumber | ${grepbin} "bInterfaceNumber:${intnum}$" | ${sedbin} -e "s/bInterfaceNumber:${intnum}$/bInterfaceNumber/g"`; intdir=`${dirnamebin} "${intdir}" 2> /dev/null`; unset intnum
3905 if [ "a${intdir}" = "a" ]; then
3906 unset intdir; debug "Failed to retrieve sysfs directory of interface #%d.\n" "$2"
3907 return 1
3908 elif [ ! -d "${intdir}" ]; then
3909 unset intdir; debug "Unable to retrieve sysfs directory of interface #%d.\n" "$2"
3910 return 1
3911 fi
3912 debug "Interface #%d sysfs dir is: %s\n" "$2" "${intdir}"
3913 export sysfsintloc="${intdir}"
3914 unset intdir
3915 return 0
3916 }
3917
3918 # Finds tty which resides on interface $2 of usb device $1 and sets USBTTY
3919 usb_sysfs_locate_tty() {
3920 unset USBTTY
3921 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
3922 ! usb_sysfsdir_int "$1" "$2" && return 1
3923 intstr=`cd ${sysfsintloc} ; ${grepbin} -H "." tty*/dev tty*/tty*/dev tty*/tty*/tty*/dev 2> /dev/null | ${sortbin} | ${uniqbin}`; unset intdir
3924 if [ "a${intstr}" = "a" ]; then
3925 unset intstr; debug "Failed to retrieve sysfs tty for interface #%d.\n" "$2"
3926 return 1
3927 fi
3928 debug "Interface #%d tty string is: %s\n" "$2" "${intstr}"
3929 unset ttynode
3930 [ "a${ttynode}" = "a" ] && ttynode=`echo "${intstr}" | ${sedbin} -e "s/^\(.*\)ttyUSB\([0-9][0-9]*\)\(.*\)$/ttyUSB\2/g" | ${grepbin} "^ttyUSB"`
3931 [ "a${ttynode}" = "a" ] && ttynode=`echo "${intstr}" | ${sedbin} -e "s/^\(.*\)ttyACM\([0-9][0-9]*\)\(.*\)$/ttyACM\2/g" | ${grepbin} "^ttyACM"`
3932 [ "a${ttynode}" = "a" ] && ttynode=`echo "${intstr}" | ${sedbin} -e "s/^\(.*\)ttyHS\([0-9][0-9]*\)\(.*\)$/ttyHS\2/g" | ${grepbin} "^ttyHS"`
3933 devicenode=`echo "${intstr}" | ${sedbin} -e "s/^\(.*\)dev:\([0-9][0-9]*\):\([0-9][0-9]*\)$/\2:\3/g"`
3934 ttymajor=`echo "${devicenode}" | ${cutbin} -d: -f1`
3935 ttyminor=`echo "${devicenode}" | ${cutbin} -d: -f2`
3936 unset intstr; unset devicenode
3937 debug "Will check if \"%s\" exists, or will create it with major %d and minor %d.\n" "/dev/${ttynode}" "${ttymajor}" "${ttyminor}"
3938 if dev_create_node "/dev/${ttynode}" "${ttymajor}" "${ttyminor}"; then
3939 export USBTTY="/dev/${ttynode}"
3940 unset ttynode; unset ttymajor; unset ttyminor
3941 debug "Found tty device node of interface #%d from device \"%s\": %s\n" "$2" "$1" "${USBTTY}"
3942 return 0
3943 else
3944 debug "Failed to create tty device of interface #%d from device \"%s\".\n" "$2" "$1"
3945 unset ttynode; unset ttymajor; unset ttyminor
3946 return 8
3947 fi
3948 unset ttynode; unset ttymajor; unset ttyminor
3949 return 99
3950 }
3951
3952 usb_sysfsattr() {
3953 unset SYSFS_USB_Manufacturer
3954 unset SYSFS_USB_Product
3955 unset SYSFS_USB_Serial
3956 [ "a$1" = "a" ] && return 1
3957 ! usb_sysfsdir "$1" && return 1
3958 [ "a${sysfsloc}" = "a" ] && return 1
3959 [ ! -d "${sysfsloc}" ] && return 1
3960 SYSFS_USB_Manufacturer=`${sedbin} -e "s/ /_/g" "${sysfsloc}/manufacturer" 2> /dev/null`
3961 SYSFS_USB_Product=`${sedbin} -e "s/ /_/g" "${sysfsloc}/product" 2> /dev/null`
3962 SYSFS_USB_Serial=`${sedbin} -e "s/ /_/g" "${sysfsloc}/serial" 2> /dev/null`
3963 debug "Information from sysfs:\nUSB Manufacturer: %s\nUSB Product: %s\nUSB Serial: %s\n" "${SYSFS_USB_Manufacturer}" "${SYSFS_USB_Product}" "${SYSFS_USB_Serial}"
3964 return 0
3965 }
3966
3967 usb_scsisysfsattr() {
3968 unset scsidir
3969 unset SYSFS_SCSI_Vendor
3970 unset SYSFS_SCSI_Model
3971 unset SYSFS_SCSI_Revision
3972 [ "a$1" = "a" ] && return 1
3973 ! usb_sysfsattr "$1" && return 1
3974 ! find_binary "dirname" && return 1
3975 # How many seconds to wait for SCSI device to settle
3976 counter=30
3977 while [ "a${scsidir}" = "a" ];
3978 do
3979 if [ "a$2" = "a" ]; then
3980 debug "Checking interface #%d of device %s.\n" "0" "$1"
3981 target=`${lsbin} -1d ${sysfsloc}/*.0/host*/target*/*/vendor 2> /dev/null`
3982 else
3983 debug "Checking interface #%d of device %s.\n" "$2" "$1"
3984 target=`${lsbin} -1d ${sysfsloc}/*.$2/host*/target*/*/vendor 2> /dev/null | ${tailbin} -1`
3985 fi
3986 [ "a${target}" != "a" ] && scsidir=`${dirnamebin} "${target}" 2> /dev/null`
3987 [ "a${scsidir}" = "a" ] && unset scsidir
3988 [ "a${scsidir}" != "a" ] && [ ! -d "${scsidir}" ] && unset scsidir
3989 unset target
3990 if [ "a${scsidir}" = "a" ]; then
3991 if [ "${counter}" -gt "0" ]; then
3992 debug "Device not yet settled. Will be waiting for another %d second(s).\n" "${counter}"
3993 [ "${counter}" -eq "30" ] && verbose "Waiting device to settle"
3994 sleep 1
3995 else
3996 debug "Giving up. SCSI device did not settle, or is switched already.\n"
3997 break
3998 fi
3999 counter=`expr ${counter} - 1`; counter=`echo ${counter}`
4000 fi
4001 done
4002 unset counter
4003 [ "a${scsidir}" = "a" ] && unset scsidir && return 1
4004 SYSFS_SCSI_Vendor=`${sedbin} -e "s/ /_/g" "${scsidir}/vendor" 2> /dev/null`
4005 SYSFS_SCSI_Model=`${sedbin} -e "s/ /_/g" "${scsidir}/model" 2> /dev/null`
4006 SYSFS_SCSI_Revision=`${sedbin} -e "s/ /_/g" "${scsidir}/rev" 2> /dev/null`
4007 debug "SCSI device is settled:\nSCSI Vendor: %s\nSCSI Model: %s\nSCSI Revision: %s\n" "${SYSFS_SCSI_Vendor}" "${SYSFS_SCSI_Model}" "${SYSFS_SCSI_Revision}"
4008 return 0
4009 }
4010
4011 # Returns true if device $1 has a storage interface
4012 usb_has_storage() {
4013 unset STORAGEIF
4014 [ "a$1" = "a" ] && return 99
4015 if [ -r "/proc/bus/usb/devices" ]; then
4016 usbblock=`usb_device_block "$1"`
4017 if [ "a${usbblock}" = "a" ]; then
4018 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
4019 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
4020 unset TIMEOUTOCCURED
4021 fi
4022 debug "No information for device was available. Is device really connected?\n"
4023 debug "Will consider storage part does not exist.\n"
4024 debug "However, this may lead into problems later.\n"
4025 unset usbblock
4026 return 1
4027 fi
4028 storageclass=`echo "${usbblock}" | ${grepbin} "Cls=08.stor."`
4029 [ "a${storageclass}" = "a" ] && storageclass=`echo "${usbblock}" | ${grepbin} "river=usb_storage"`
4030 [ "a${storageclass}" = "a" ] && storageclass=`echo "${usbblock}" | ${grepbin} "river=usb-storage"`
4031 if [ "a${storageclass}" = "a" ]; then
4032 debug "Device \"%s\" has no storage part.\n" "$1"
4033 unset usbblock; unset storageclass
4034 return 1
4035 fi
4036 storageclass=`echo "${storageclass}" | ${sedbin} -e "s/^I:\(.*\)If.=\( *\)\([0-9][0-9]*\) \(.*\)$/\3/g"`
4037 debug "Device has storage part on interface #%s.\n" "${storageclass}"
4038 STORAGEIF=`echo "${storageclass}" | ${headbin} -1 | ${cutbin} "-d " -f1`
4039 export STORAGEIF
4040 unset usbblock; unset storageclass
4041 return 0
4042 elif find_binary "lsusb"; then
4043 storageclass=`safe_lsusb -d "$1" -v | ${grepbin} -B 10 -A 10 -i storage | ${grepbin} -i "bInterfaceNumber" | ${tailbin} -1 | ${sedbin} -e "s/ */ /g" | ${sedbin} -e "s/^ //g" | ${cutbin} -d\ -f2`
4044 if [ "a${storageclass}" = "a" ]; then
4045 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
4046 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
4047 unset TIMEOUTOCCURED
4048 fi
4049 debug "Device \"%s\" has no storage part.\n" "$1"
4050 unset storageclass
4051 return 1
4052 fi
4053 debug "Device has storage part on interface #%s.\n" "${storageclass}"
4054 # TODO: What happens when more storage interfaces exist?
4055 STORAGEIF=`echo "${storageclass}" | ${headbin} -1 | ${cutbin} -d\ -f1`
4056 export STORAGEIF
4057 unset storageclass
4058 return 0
4059 else
4060 debug "Both %s and %s are not available.\n" "/proc/bus/usb/devices" "lsusb"
4061 debug "Failed to determine if device %s has a storage interface.\n" "$1"
4062 debug "Will consider storage part does not exist.\n"
4063 debug "However, this may lead into problems later.\n"
4064 return 1
4065 fi
4066 }
4067
4068 # Newer kernels provide this feature
4069 usb_stabilize() {
4070 [ "a$1" = "a" ] && return 1
4071 ! usb_sysfsdir "$1" && return 1
4072 [ "a${sysfsloc}" = "a" ] && return 1
4073 [ ! -d "${sysfsloc}" ] && return 1
4074 [ ! -w "${sysfsloc}/avoid_reset_quirk" ] && return 1
4075 debug "Kernel provides AVOID_RESET_QUIRK for device %s.\n" "$1"
4076 echo "1" > "${sysfsloc}/avoid_reset_quirk" 2> /dev/null
4077 ret=$?
4078 [ "a${ret}" = "a0" ] && debug "Succesfully enabled AVOID_RESET_QUIRK for device %s.\n" "$1"
4079 [ "a${ret}" = "a0" ] && debug "Failed to enable AVOID_RESET_QUIRK for device %s.\n" "$1"
4080 return ${ret}
4081 }
4082
4083 # Makes sure that if device $1 has a storage part, this part
4084 # is settled.
4085 usb_storage_settled() {
4086 if ! usb_has_storage "$1"; then
4087 hal_unlock
4088 return 0
4089 fi
4090 debug "Device %s, provides storage interface #%s.\n" "$1" "${STORAGEIF}"
4091 storageloaded=`usb_loaded_driver "$1" "${STORAGEIF}" | ${tailbin} -1`
4092 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
4093 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
4094 unset TIMEOUTOCCURED
4095 fi
4096 if [ "a${storageloaded}" != "ausb-storage" -a "a${storageloaded}" != "ausb_storage" ]; then
4097 debug "Interface %s of device %s is bound to driver: %s\n" "${STORAGEIF}" "$1" "${storageloaded}"
4098 debug "No need to wait for storage interface to settle.\n"
4099 unset storageloaded
4100 hal_unlock
4101 return 0
4102 fi
4103 debug "Storage interface #%s is binded by %s driver.\n" "${STORAGEIF}" "${storageloaded}"
4104 if [ "a${killstorage}" != "a" ]; then
4105 debug "User has set \"%s\" switch. Will try to unbind %s driver from interface #%d.\n" "killstorage" "${storageloaded}" "${STORAGEIF}"
4106 if module_unbind "${storageloaded}" "$1" "${STORAGEIF}"; then
4107 debug "Storage interface has been freed as instructed.\n"
4108 debug "No need to wait for storage interface to settle.\n"
4109 unset storageloaded
4110 hal_unlock
4111 return 0
4112 else
4113 debug "Failed to unbind it. Too bad.\n"
4114 show_fmt_error "Failed to unbind driver %s. I am sorry." "${storageloaded}"
4115 fi
4116 fi
4117 unset storageloaded
4118 if ! usb_scsisysfsattr "$1" "${STORAGEIF}"; then
4119 debug "Will consider storage part is settled.\n"
4120 debug "However, this may lead into problems later.\n"
4121 fi
4122 storagedevices=`${grepbin} . ${sysfsloc}/*.${STORAGEIF}/host*/target*/*/block*/size 2> /dev/null | ${grepbin} -v ":0$" | ${sedbin} -e "s/^\(.*\)\/block:\(.*\)\/size:\(.*\)$/\2/g" | ${trbin} "\n" " "`; storagedevices=`echo ${storagedevices}`
4123 if [ "a${storagedevices}" = "a" ]; then
4124 debug "No storage device(s) with inserted media exist. Safe to unlock HAL.\n"
4125 hal_unlock
4126 unset storagedevices; unset STORAGEIF
4127 return 0
4128 fi
4129 debug "Media found on following device(s) provided by interface #%s of device %s: %s\n" "${STORAGEIF}" "$1" "${storagedevices}"
4130 if [ "a${HAL_LOCK}" != "a" ]; then
4131 hal_unlock
4132 debug "HAL is unlocked. Checking if HAL will kick in.\n"
4133 pausecounter=21
4134 while [ "${pausecounter}" -gt "0" ]
4135 do
4136 blocking=""
4137 for blockdevice in ${storagedevices}
4138 do
4139 poller=`${psbin} -Af | ${grepbin} "hald" | ${grepbin} "storage" | ${grepbin} "polling \(.*\)${blockdevice}" | ${grepbin} -v "${grepbin}"`
4140 if [ "a${poller}" = "a" ]; then
4141 debug "No polling process exists for %s.\n" "${blockdevice}"
4142 continue
4143 fi
4144 debug "Polling process exists for %s: %s\n" "${blockdevice}" "${poller}"
4145 poller=`${grepbin} "\/${blockdevice} " "/proc/mounts" 2> /dev/null`
4146 if [ "a${poller}" != "a" ]; then
4147 debug "Device %s mounted: %s\n" "${blockdevice}" "${poller}"
4148 else
4149 debug "Device %s still not mounted.\n" "${blockdevice}"
4150 blocking="${blocking} ${blockdevice}"
4151 fi
4152 done
4153 unset blockdevice; unset poller; blocking=`echo ${blocking}`
4154 if [ "a${blocking}" = "a" ]; then
4155 debug "HAL has finished mounting media on device(s): %s\n" "${storagedevices}"
4156 break
4157 fi
4158 pausecounter=`expr ${pausecounter} - 1`; pausecounter=`echo ${pausecounter}`
4159 if [ "${pausecounter}" -eq "0" ]; then
4160 debug "Giving up waiting for HAL to mount devices.\n"
4161 debug "This may lead into problems later on.\n"
4162 else
4163 [ "${pausecounter}" -eq "20" ] && verbose "Waiting HAL to mount device(s)"
4164 debug "Waiting for HAL to mount all devices. %d second(s) to abort.\n" "${pausecounter}"
4165 sleep 1
4166 fi
4167 done
4168 unset poller; unset blockdevice
4169 unset pausecounter; unset blocking
4170 else
4171 debug "HAL was not locked. Will skip waiting for device mount.\n"
4172 fi
4173 unset storagedevices; unset STORAGEIF
4174 return 0
4175 }
4176
4177
4178 # Scans for bluetooth devices
4179 bluetooth_scan_devices() {
4180 ! find_binary "hcitool" && return 1
4181 verbose "Scanning bluetooth devices"
4182 bluetooth_devices=`${hcitoolbin} scan 2> /dev/null | ${grepbin} "^ " | ${sedbin} -e "s/^ \(.*\) \(.*\)/\1 \2/g"`
4183 debug "Found bluetooth devices:\n%s\n" "${bluetooth_devices}"
4184 return 0
4185 }
4186
4187 # Returns rfcomm channel for service $2 for device $1
4188 bluetooth_rfcomm_channel() {
4189 ! find_binary "sdptool" && return 0
4190 rfchannel=`${sdptoolbin} search --raw --bdaddr "$1" "$2" 2> /dev/null | ${grepbin} -A 1 --binary-files=text "RFCOMM" | ${grepbin} "UINT8" | ${sedbin} -e "s/^\(.*\)UINT8 \(.*\)/\2/g"`
4191 rfchannel=`echo ${rfchannel}`
4192 debug "Found RFCOMM channel \"%s\" of service \"%s\" on device \"%s\".\n" "${rfchannel}" "$2" "$1"
4193 [ "a${rfchannel}" != "a" ] && rfchannel=`${printfbin} "%d\n" ${rfchannel} 2> /dev/null`
4194 [ "a${rfchannel}" = "a" ] && rfchannel="0"
4195 debug "Returning RFCOMM channels \"%s\".\n" "`echo ${rfchannel}`"
4196 return `echo ${rfchannel} | ${cutbin} -d\ -f1`
4197 }
4198
4199 # Returns true if device $1, channel $2 is on tty $3
4200 # NOTE: Does not depend on bluetooth_rfcomm_dev because
4201 # bluetooth_rfcomm_dev only returns 1st valid
4202 # channel
4203 bluetooth_rfcomm_match() {
4204 ! find_binary "rfcomm" && return 1
4205 [ "a${3}" != "a" ] && [ ! -c "${3}" ] && return 1
4206 bluematch=`${rfcommbin} -a --raw | ${grepbin} --binary-files=text " $1 " | ${grepbin} --binary-files=text " channel $2 " | ${grepbin} "^\`${basenamebin} $3\`:" | ${wcbin} -l`; bluematch=`echo ${bluematch}`
4207 if [ "a${bluematch}" = "a1" ]; then
4208 debug "%s refers to RFCOMM channel %d of device %s.\n" "$3" "$2" "$1"
4209 unset bluematch
4210 return 0
4211 fi
4212 debug "%s does not refer to RFCOMM channel %d of device %s.\n" "$3" "$2" "$1"
4213 unset bluematch
4214 return 1
4215 }
4216
4217 # Returns tty where device $1, channel $2 resides (if any)
4218 bluetooth_rfcomm_dev() {
4219 ! find_binary "rfcomm" > /dev/null && return 1
4220 bluematch=`${rfcommbin} -a --raw 2> /dev/null | ${grepbin} --binary-files=text " $1 " | ${grepbin} --binary-files=text " channel $2 " | ${headbin} -1 | ${cutbin} -d: -f1`
4221 if [ "a${bluematch}" = "a" ]; then
4222 unset bluematch
4223 return 1
4224 fi
4225 echo "${bluematch}"
4226 unset bluematch
4227 return 0
4228 }
4229
4230 # Creates rfcomm device for device $1, channel $2 and sets RFCOMM_TTY
4231 bluetooth_create_dev() {
4232 ! we_are_root_already && debug "Need root privileges to create rfcomm nodes.\n"
4233 ! we_are_root && return 1
4234 need_binary "rfcomm"
4235 for devindex in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
4236 do
4237 unset occupied
4238 occupied=`${rfcommbin} show ${devindex} 2> /dev/null`
4239 [ "a${occupied}" = "a" ] && break
4240 done
4241 if [ "a${occupied}" != "a" ]; then
4242 unset occupied
4243 unset devindex
4244 show_fmt_error "Unable to find available rfcomm device index. Minors occupied."
4245 return 1
4246 fi
4247 unset occupied
4248 debug "Found available rfcomm device node %d.\n" "${devindex}"
4249 debug run_command "${rfcommbin} bind ${devindex} \"$1\" \"$2\""
4250 if ! bluetooth_rfcomm_match "$1" "$2" "/dev/rfcomm${devindex}"; then
4251 show_fmt_error "Unable to create rfcomm node %s." "rfcomm${devindex}"
4252 unset devindex
4253 return 1
4254 fi
4255 if [ ! -c "/dev/rfcomm${devindex}" ]; then
4256 debug "Device node \"%s\" was not automatically created.\n" "/dev/rfcomm${devindex}"
4257 if ! dev_create_node "/dev/rfcomm${devindex}" "216" "${devindex}"; then
4258 show_fmt_error "Unable to create rfcomm device node \"%s\"." "/dev/rfcomm${devindex}"
4259 unset devindex
4260 return 1
4261 fi
4262 debug "Made node \"%s\" ourselves.\n" "/dev/rfcomm${devindex}"
4263 fi
4264 export RFCOMM_TTY="/dev/rfcomm${devindex}"
4265 unset devindex
4266 }
4267
4268 # Setups rfcomm device for device $1, channel $2 and sets RFCOMM_TTY
4269 bluetooth_setup_rfcomm() {
4270 if [ "a${RFCOMM_TTY}" != "a" ]; then
4271 if bluetooth_rfcomm_match "$1" "$2" "${RFCOMM_TTY}"; then
4272 debug "Will use already set RFCOMM_TTY (%s).\n" "${RFCOMM_TTY}"
4273 return 0
4274 else
4275 debug "Already set RFCOMM_TTY does not refer to a tty of \"%s\": \"%s\"\n" "$1" "${RFCOMM_TTY}"
4276 unset RFCOMM_TTY
4277 fi
4278 fi
4279 RFCOMM_TTY=`bluetooth_rfcomm_dev "$1" "$2"`
4280 if [ "a${RFCOMM_TTY}" != "a" ]; then
4281 export RFCOMM_TTY="/dev/${RFCOMM_TTY}"
4282 if [ -c "${RFCOMM_TTY}" ]; then
4283 debug "Found already binded rfcomm tty %s.\n" "${RFCOMM_TTY}"
4284 return 0
4285 fi
4286 unset RFCOMM_TTY
4287 fi
4288 unset RFCOMM_TTY
4289 if bluetooth_create_dev "$1" "$2"; then
4290 debug "Succesfully binded to rfcomm tty %s.\n" "${RFCOMM_TTY}"
4291 return 0
4292 fi
4293 debug "Failed to setup rfcomm tty for device \"%s\".\n" "$1"
4294 return 1
4295 }
4296
4297 # Method invoked when "status" action was requested.
4298 ppp_fast_status() {
4299 need_binary "grep"
4300 need_arg "pppint"
4301 unset status
4302 [ -f "/proc/net/dev" ] && [ -r "/proc/net/dev" ] && status=`${grepbin} "${pppint}:" /proc/net/dev`
4303 [ -z "${status}" ] && find_binary "ifconfig" && status=`${ifconfigbin} ${pppint} 2> /dev/null | ${grepbin} " UP "`
4304 if [ "a${status}" = "a" ]; then
4305 unset status
4306 return 1
4307 else
4308 unset status
4309 return 0
4310 fi
4311 }
4312
4313 # Called by ispconnect to determine if connection is established
4314 ppp_slow_status() {
4315 need_arg "pppint"
4316 need_binary "netstat"
4317 [ "a${pppint}" = "a" ] && pppint="ppp0"
4318 pppcon=`${catbin} /proc/net/dev | ${grepbin} "^\( *\)${pppint}:" | ${wcbin} -l`; pppcon=`echo ${pppcon}`
4319 [ "a${pppcon}" = "a0" ] && unset pppcon && return 1
4320 debug "Interface %s is up.\n" "${pppint}"
4321 pppcon=`${netstatbin} -rn | ${grepbin} " ${pppint}$" | ${grepbin} -v "^0.0.0.0" | ${wcbin} -l`; pppcon=`echo ${pppcon}`
4322 [ "a${pppcon}" = "a0" ] && unset pppcon && return 1
4323 debug "Default route through %s is established.\n" "${pppint}"
4324 debug "Really connected.\n"
4325 return 0
4326 }
4327
4328 # Shows version
4329 show_version() {
4330 if find_binary "printf"; then
4331 format_text "Sakis 3G All-in-one script - Version %s\n" "${MYVERSION}"
4332 format_text "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2\n\n"
4333 else
4334 need_binary "echo"
4335 echo "Sakis 3G All-in-one script - Version ${MYVERSION}"
4336 echo "(c) Sakis Dimopoulos 2009, 2010 under GNU GPL v2"
4337 echo
4338 fi
4339 }
4340
4341 # Shows usage help
4342 show_help() {
4343 helptext=`raw_help`
4344 notify "%s\n" "${helptext}"
4345 return 0
4346 }
4347
4348 raw_help() {
4349 [ "a${PROVIDER}" = "a" ] && return 1
4350 [ ! -x "${PROVIDER}" ] && return 1
4351 show_version
4352 echo
4353 "${PROVIDER}" getfile "files/help.txt" 2> /dev/null
4354 }
4355
4356 modeswitch_load_realtime() {
4357 debug "Loading system supplied device database.\n"
4358 for dep in sed rm grep tr sort uniq cut printf basename
4359 do
4360 ! find_binary "${dep}" && return 1
4361 done
4362 unset dep; unset realtime_switchable; unset realtime_switched;
4363 unset CheckSuccess; unset Configuration;
4364 unset GCTMode; unset HuaweiMode; unset SierraMode; unset SonyMode;
4365 unset Interface; unset MessageContent; unset ResponseNeeded
4366 unset DefaultProduct; unset DefaultVendor;
4367 unset TargetClass; unset TargetProduct; unset TargetProductList; unset TargetVendor
4368 for filename in /etc/usb_modeswitch.d/* /etc/usb_modeswitch.d/*
4369 do
4370 current_device=`${basenamebin} ${filename} | ${cutbin} -d: -f1,2 -s`
4371 [ "a${current_device}" = "a" ] && unset current_device && continue
4372 realtime_switchable="${realtime_switchable} ${current_device}"
4373 ${sedbin} -e "s/ //g" "${filename}" > "/tmp/$$.tmp" 2> /dev/null
4374 . "/tmp/$$.tmp" > /dev/null 2> /dev/null
4375 ${rmbin} -f "/tmp/$$.tmp" > /dev/null 2> /dev/null
4376 for ven in ${TargetVendor}
4377 do
4378 if [ -n "${TargetProductList}" ]; then
4379 list=`echo ${TargetProductList} | ${sedbin} -e "s/,/ /g"`
4380 for pro in $list
4381 do
4382 realtime_switched="${realtime_switched} ${ven}:${pro}"
4383 done
4384 unset list
4385 elif [ -n "${TargetProduct}" ]; then
4386 realtime_switched="${realtime_switched} ${ven}:${TargetProduct}"
4387 fi
4388 done
4389 unset current_device
4390 unset CheckSuccess; unset Configuration;
4391 unset GCTMode; unset HuaweiMode; unset SierraMode; unset SonyMode;
4392 unset Interface; unset MessageContent; unset ResponseNeeded
4393 unset DefaultProduct; unset DefaultVendor;
4394 unset TargetClass; unset TargetProduct; unset TargetProductList; unset TargetVendor
4395 done
4396 realtime_switched=`echo ${realtime_switched} | ${sedbin} -e "s/0x//g" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4397 realtime_switched=`echo ${realtime_switched}`
4398 realtime_switchable=`echo ${realtime_switchable} | ${sedbin} -e "s/0x//g" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4399 realtime_switchable=`echo ${realtime_switchable}`
4400 debug "Switchable devices within system device database:\n%s\n" "${realtime_switchable}"
4401 debug "Switched devices within system device database:\n%s\n" "${realtime_switched}"
4402 ${printfbin} "%s\n%s\n" "${realtime_switchable}" "${realtime_switched}"
4403 unset realtime_switched; unset realtime_switchable
4404 return 0
4405 }
4406
4407 # Loads Usb-ModeSwitch device database, both embedded and system supplied
4408 modeswitch_load() {
4409 unset SWITCHABLE_devices; unset SWITCHED_devices; unset KNOWN_devices
4410 debug "Loading Usb-ModeSwitch device database.\n"
4411 # Check if possible to include embedded database
4412 if [ "a${PROVIDER}" = "a" ]; then
4413 debug "Unable to locate package provider.\n"
4414 elif [ ! -x "${PROVIDER}" ]; then
4415 debug "Unable to execute package provider.\n"
4416 else
4417 "${PROVIDER}" getfile "build/switchconfig" > "/tmp/sakis3g.$$.sw"
4418 if [ ! -f "/tmp/sakis3g.$$.sw" ]; then
4419 debug "Unable to find device database.\n"
4420 elif [ ! -s "/tmp/sakis3g.$$.sw" ]; then
4421 rm -f "/tmp/sakis3g.$$.sw"
4422 debug "Embedded device database contains 0 entries.\n"
4423 else
4424 . "/tmp/sakis3g.$$.sw"
4425 rm -f "/tmp/sakis3g.$$.sw"
4426 getswitchabledevices 2> /dev/null
4427 # TODO: Comment following line to render embedded device database unusable.
4428 #unset usbswitchabledevices && unset usbswitcheddevices && debug "DELETED DATABASE TO EMULATE VOODOO MODE.\n"
4429 ret=$?;
4430 if [ "${ret}" -ne "0" ]; then
4431 debug "Failed to load embedded Usb-ModeSwitch device database.\n"
4432 else
4433 debug "Embedded device database loaded.\n"
4434 export SWITCHABLE_devices="${usbswitchabledevices}"
4435 export SWITCHED_devices="${usbswitcheddevices}"
4436 debug "Switchable devices within embedded device database:\n%s\n" "${SWITCHABLE_devices}"
4437 debug "Switched devices within embedded device database:\n%s\n" "${SWITCHED_devices}"
4438 KNOWN_devices=`echo "${SWITCHABLE_devices} ${SWITCHED_devices}" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4439 KNOWN_devices=`echo "${KNOWN_devices}"`
4440 export KNOWN_devices
4441 devicecount=`echo "${KNOWN_devices}" | ${wcbin} -w`; devicecount=`echo ${devicecount}`; [ "a${devicecount}" = "a" ] && devicecount=0
4442 debug "Embedded Usb-ModeSwitch device database contains %d entries.\n" "${devicecount}"
4443 unset devicecount
4444 fi
4445 fi
4446 fi
4447 # Check if system supplied Usb-ModeSwitch database exists
4448 if [ -d "/etc/usb_modeswitch.d" ]; then
4449 debug "Folder \"%s\" exists. Will check if it contains configuration files.\n" "/etc/usb_modeswitch.d"
4450 realtime_devices=`modeswitch_load_realtime`
4451 if [ "a${realtime_devices}" != "a" ]; then
4452 usbswitchabledevices=`echo "${realtime_devices}" | ${tailbin} -2 | ${headbin} -1`
4453 usbswitcheddevices=`echo "${realtime_devices}" | ${tailbin} -1`
4454 SWITCHABLE_devices="${SWITCHABLE_devices} ${usbswitchabledevices}"
4455 SWITCHED_devices="${SWITCHED_devices} ${usbswitcheddevices}"
4456 SWITCHABLE_devices=`echo "${SWITCHABLE_devices}" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4457 SWITCHED_devices=`echo "${SWITCHED_devices}" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4458 SWITCHABLE_devices=`echo ${SWITCHABLE_devices}`
4459 SWITCHED_devices=`echo ${SWITCHED_devices}`
4460 KNOWN_devices=`echo "${SWITCHABLE_devices} ${SWITCHED_devices}" | ${trbin} " " "\n" | ${sortbin} | ${uniqbin}`
4461 KNOWN_devices=`echo "${KNOWN_devices}"`
4462 export SWITCHABLE_devices
4463 export SWITCHED_devices
4464 export KNOWN_devices
4465 devicecount=`echo "${KNOWN_devices}" | ${wcbin} -w`; devicecount=`echo ${devicecount}`; [ "a${devicecount}" = "a" ] && devicecount=0
4466 debug "Device database now contains %d entries.\n" "${devicecount}"
4467 unset devicecount
4468 fi
4469 unset realtime_devices
4470 fi
4471 unset usbswitchabledevices; unset usbswitcheddevices
4472 return 0
4473 }
4474
4475 # Returns 0 if device $1 is switchable
4476 modeswitch_is_switchable() {
4477 [ "a${KNOWN_devices}" = "a" ] && ! modeswitch_load && return 1
4478 isswitchable=`echo "${SWITCHABLE_devices}" | ${grepbin} "$1" | ${wcbin} -l`; isswitchable=`echo ${isswitchable}`
4479 [ "a${isswitchable}" = "a" ] && isswitchable="0"
4480 if [ "a${isswitchable}" = "a0" ]; then
4481 if [ -f "/etc/usb_modeswitch.d/$1" ]; then
4482 debug "Since file \"%s\" exists, will consider device \"%s\" switchable.\n" "/etc/usb_modeswitch.d/$1" "$1"
4483 unset isswitchable
4484 return 0
4485 fi
4486 debug "Device \"%s\" is not switchable.\n" "$1"
4487 unset isswitchable
4488 return 1
4489 else
4490 unset isswitchable
4491 return 0
4492 fi
4493 }
4494
4495 modeswitch_switchable_devices() {
4496 ! usb_connected_modems && return 1
4497 for condevice in ${usb_modems}
4498 do
4499 if modeswitch_is_switchable "${condevice}"; then
4500 debug "There is at least one (%s) switchable device plugged.\n" "${condevice}"
4501 unset condevice
4502 return 0
4503 fi
4504 done
4505 unset condevice
4506 debug "No switchable device plugged.\n" "${condevice}"
4507 return 1
4508 }
4509
4510 modeswitch_conf_realtime() {
4511 unset modeswitch_config
4512 debug "Seeking a system supplied configuration file for switching device %s.\n" "$1"
4513 [ ! -d "/etc/usb_modeswitch.d" -a ! -d "/etc/usb-modeswitch.d" ] && return 1
4514 # Check if exists a candidate which needs SCSI information
4515 needscsi=`${lsbin} -1r /etc/usb_modeswitch.d/$1:s* /etc/usb-modeswitch.d/$1:s* 2> /dev/null | ${wcbin} -l`
4516 needscsi=`echo ${needscsi}`
4517 if [ "a${needscsi}" != "a0" -a "a${needscsi}" != "a" ]; then
4518 debug "Will need SCSI information for finding appropriate file.\n"
4519 usb_scsisysfsattr "$1"
4520 fi
4521 unset needscsi
4522 # Iterate through files
4523 files=`${lsbin} -1r /etc/usb_modeswitch.d/$1* /etc/usb-modeswitch.d/$1* 2> /dev/null`
4524 for filename in ${files}
4525 do
4526 debug "Checking if file \"%s\" matches.\n" "${filename}"
4527 bn=`${basenamebin} "${filename}"`
4528 crit=`echo "${bn}" | ${cutbin} -d: -f3-`; crit=`echo ${crit}`
4529 if [ "a${crit}" != "a" ]; then
4530 field=`echo "${crit}" | ${cutbin} -d= -f1 -s`
4531 value=`echo "${crit}" | ${cutbin} -d= -f2 -s`
4532 if [ "a${field}" = "a" ]; then
4533 debug "File %s does not specify criteria to match. Skipping it." "${bn}"
4534 unset bn; unset crit; unset field; unset value
4535 continue
4536 fi
4537 if [ "a${value}" = "a" ]; then
4538 debug "File %s does not specify value for attribute %s. Skipping it." "${bn}" "${field}"
4539 unset bn; unset crit; unset field; unset value
4540 continue
4541 fi
4542 len=`echo "${value}" | ${wcbin} -c`; len=`echo ${len}`; len=`expr ${len} - 1 2> /dev/null`; len=`echo ${len}`
4543 if [ "a${len}" = "a" ] || [ "${len}" -eq "0" ]; then
4544 debug "Value \"%s\" to be checked is not valid. Skipping file %s." "${value}" "${bn}"
4545 unset bn; unset crit; unset field; unset value
4546 continue
4547 fi
4548 unset attribute
4549 case "${field}" in
4550 sVe)
4551 attribute=`echo ${SYSFS_SCSI_Vendor}`
4552 ;;
4553 sMo)
4554 attribute=`echo ${SYSFS_SCSI_Model}`
4555 ;;
4556 sRe)
4557 attribute=`echo ${SYSFS_SCSI_Revision}`
4558 ;;
4559 uMa)
4560 attribute=`echo ${SYSFS_USB_Manufacturer}`
4561 ;;
4562 uPr)
4563 attribute=`echo ${SYSFS_USB_Product}`
4564 ;;
4565 uSe)
4566 attribute=`echo ${SYSFS_USB_Serial}`
4567 ;;
4568 *)
4569 debug "FIXME: Unknown field \"%s\". Try downloading a newer Sakis3G version.\n" "${field}"
4570 ;;
4571 esac
4572 if [ "a${attribute}" = "a" ]; then
4573 debug "No value for field %s exists for device %s.\n" "${field}" "$1"
4574 unset attribute; unset len; unset field; unset value; unset bn; unset crit
4575 continue
4576 fi
4577 debug "Found %s.%s=\"%s\".\n" "$1" "${field}" "${attribute}"
4578 attribute=`echo ${attribute} | ${cutbin} -b1-${len} 2> /dev/null`
4579 if [ "a${attribute}" != "a" -a "a${attribute}" = "a${value}" ]; then
4580 debug "File %s matches information derived from device.\n" "${bn}"
4581 modeswitch_config="${filename}"
4582 unset attribute; unset len; unset field; unset value; unset bn; unset crit
4583 break;
4584 fi
4585 debug "File %s does not match.\n" "${bn}"
4586 unset attribute; unset len; unset field; unset value;
4587 else
4588 debug "Found an exact match file: %s\n" "${filename}"
4589 modeswitch_config="${filename}"
4590 fi
4591 unset crit; unset bn
4592 done
4593 filename="${modeswitch_config}"
4594 unset modeswitch_config
4595 if [ "a${filename}" != "a" ] && [ -f "${filename}" ]; then
4596 ${catbin} "${filename}" > "/tmp/sakis3g.sw.dev.$$" 2> /dev/null
4597 if [ -s "/tmp/sakis3g.sw.dev.$$" ]; then
4598 export modeswitch_config="/tmp/sakis3g.sw.dev.$$"
4599 unset filename
4600 return 0
4601 else
4602 ${rmbin} -f "/tmp/sakis3g.sw.dev.$$"
4603 fi
4604 fi
4605 unset filename
4606 debug "No system supplied configuration file found for switching device \"%s\".\n" "$1"
4607 return 1
4608 }
4609
4610 # Returns location of extracted configuration file that should be used to switch device $1 within modeswitch_config variable
4611 modeswitch_conf_embedded() {
4612 unset modeswitch_config
4613 debug "Seeking embedded configuration file for switching device %s.\n" "$1"
4614 switchfunc="usbswitchconf_`echo "$1" | ${sedbin} -e "s/:/_/g"`"
4615 unset modeswitchconf
4616 eval ${switchfunc} 2> /dev/null
4617 ret=$?; unset switchfunc
4618 if [ "${ret}" -ne "0" ]; then
4619 debug "Failed to retrieve configuration for switching device \"%s\".\n" "$1"
4620 return 1
4621 fi
4622 [ "a${modeswitchconf}" = "a" ] && debug "No configuration file found for switching device \"%s\".\n" "$1" && return 1
4623 [ "a${PROVIDER}" = "a" ] && debug "Unable to locate package provider.\n" && unset modeswitchconf && return 1
4624 [ ! -x "${PROVIDER}" ] && debug "Unable to execute package provider.\n" && unset modeswitchconf && return 1
4625 eval "${PROVIDER}" getfile "${modeswitchconf}" > "/tmp/sakis3g.sw.dev.$$"
4626 [ ! -f "/tmp/sakis3g.sw.dev.$$" ] && debug "Configuration file \"%s\" for switching device \"%s\" not found within package.\n" "${modeswitchconf}" "$1" && unset modeswitchconf && return 1
4627 if [ ! -s "/tmp/sakis3g.sw.dev.$$" ]; then
4628 ${rmbin} -f "/tmp/sakis3g.sw.dev.$$"
4629 debug "Configuration file \"%s\" for switching device \"%s\" not found within package.\n" "${modeswitchconf}" "$1"
4630 unset modeswitchconf
4631 return 1
4632 fi
4633 unset modeswitchconf
4634 export modeswitch_config="/tmp/sakis3g.sw.dev.$$"
4635 return 0
4636 }
4637
4638 modeswitch_conf() {
4639 unset modeswitch_config
4640 debug "Seeking configuration file for switching device %s.\n" "$1"
4641 [ "a${KNOWN_devices}" = "a" ] && ! modeswitch_load && return 1
4642 ! modeswitch_conf_embedded "$1" && modeswitch_conf_realtime "$1"
4643 if [ "a${modeswitch_config}" = "a" ] || [ ! -f "${modeswitch_config}" ] || [ ! -s "${modeswitch_config}" ]; then
4644 unset modeswitch_config
4645 show_fmt_error "Unable to locate a configuration file for switching device %s.\n" "$1"
4646 return 1
4647 fi
4648 debug run_command "${catbin} \"${modeswitch_config}\""
4649 debug "Configuration file for switching device \"%s\" at: %s\n" "$1" "${modeswitch_config}"
4650 return 0
4651 }
4652
4653 # Executed when binary Usb-ModeSwitch is binary incompatible on running platform.
4654 modeswitch_emergency() {
4655 ! usb_has_storage "$1" && return 1
4656 debug "Will attempt to switch device by detaching usb-storage driver.\n"
4657 storageloaded=`usb_loaded_driver "$1" "${STORAGEIF}" | ${tailbin} -1`
4658 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
4659 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
4660 unset TIMEOUTOCCURED
4661 fi
4662 [ "a${storageloaded}" = "aNONE" ] && ! module_bind "usb_storage" "$1" "${STORAGEIF}"
4663 ! module_unbind "usb_storage" "$1" "${STORAGEIF}"
4664 unset STORAGEIF
4665 return 0
4666 }
4667
4668 # Switches device $1. Caller should check NEWIDS variable, because device most likely will change its ID.
4669 modeswitch_switch() {
4670 [ "a$1" = "a" ] && return 1
4671 ! modeswitch_is_switchable "$1" && return 1
4672 ! modeswitch_conf "$1" && return 1
4673 [ ! -f "${modeswitch_config}" ] && debug "Configuration file \"%s\" disappeared.\n" "${modeswitch_config}"
4674 # Block hal from messing with us
4675 hal_acquire_lock "org.freedesktop.Hal.Device.Storage"
4676 verbose "Switching modem"
4677 debug "Connected devices before switching.\n"
4678 usb_connected_devices
4679 previously=`echo "${usb_devices}" | ${grepbin} -v "^$1:" | ${cutbin} -d: -f1,2`
4680 if [ "a${binaryfree}" = "a" ]; then
4681 debug run_command "${PROVIDER} usb_modeswitch -W -I -c \"${modeswitch_config}\""
4682 ret=$?
4683 else
4684 ret=95
4685 fi
4686 if [ "${ret}" -eq "95" ]; then
4687 [ "a${binaryfree}" = "a" ] && debug "Binary incompatibility of package provided usb-modeswitch.\n"
4688 if find_binary "usb_modeswitch"; then
4689 debug "Will try system provided binary, hoping it is a recent one: %s\n" "${usb_modeswitchbin}"
4690 verbose "Switching modem (using %s)" "${usb_modeswitchbin}"
4691 debug run_command "${usb_modeswitchbin} --version"
4692 debug run_command "${usb_modeswitchbin} -W -I -c \"${modeswitch_config}\""
4693 ret=$?
4694 elif [ "a${binaryfree}" = "a" ]; then
4695 show_fmt_error "Embedded Usb-ModeSwitch binary is not valid for your architect. You need to recompile for devices to switch properly. Start by issueing: %s recompile" "${PROVIDER}"
4696 debug "Will try emergency mode.\n"
4697 verbose "Trying emergency switch"
4698 modeswitch_emergency "$1"
4699 ret=$?
4700 else
4701 show_fmt_error "%s is not installed on your system.\n" "Usb-ModeSwitch"
4702 return 4
4703 fi
4704 fi
4705 rm -f "${modeswitch_config}"; unset modeswitch_config
4706 counter=0
4707 while [ "${counter}" -lt "20" ]
4708 do
4709 usb_connected_devices
4710 after=`echo "${usb_devices}" | ${grepbin} "^$1:"`
4711 if [ "a${after}" != "a" -a "${counter}" -eq "0" ]; then
4712 debug "Device \"%s\" still there. Lets hope it has switched.\n" "$1"
4713 unset after; unset previously
4714 export NEWIDS="$1"
4715 return 0
4716 fi
4717 after="`echo "${usb_devices}" | ${cutbin} -d: -f1,2`"
4718 for device in ${after}
4719 do
4720 newdevice=`echo "${previously}" | ${grepbin} "^${device}"`
4721 if [ "a${newdevice}" = "a" ]; then
4722 export NEWIDS="${device}"
4723 debug "New device \"%s\" appeared.\n" "${NEWIDS}"
4724 unset device; unset after; unset previously
4725 return 0
4726 fi
4727 done
4728 unset device
4729 counter=`expr ${counter} + 1`; counter=`echo ${counter}`
4730 [ "${counter}" -lt "20" ] && debug "Waiting a second for device to appear.\n" && sleep 1
4731 done
4732 debug "Giving up waiting for new device to appear after %d seconds.\n" "${counter}"
4733 unset after; unset previously; unset counter
4734 return 1
4735 }
4736
4737 # Detects usable interface of device $1 and sets USB_INTERFACE variable. Device will get switched if required.
4738 # Callers should check NEWIDS variable
4739 modem_usb_detect_int() {
4740 [ "a$1" = "a" ] && return 99
4741 usb_get_interface "$1"; ret=$?
4742 case "${ret}" in
4743 7)
4744 debug "Failed to get USB interface.\n"
4745 return 7
4746 ;;
4747 98)
4748 debug "Failed to get USB interface, by user request.\n"
4749 return 98
4750 ;;
4751 8)
4752 debug "Failed to get an interface for device.\n"
4753 if modeswitch_is_switchable "$1"; then
4754 if [ "a$2" != "aNOSWITCH" ]; then
4755 debug "This is normal, device \"%s\" is switchable.\n" "$1"
4756 modeswitch_switch "$1"
4757 ret=$?
4758 if [ "${ret}" -eq "0" -a "a${NEWIDS}" != "a" -a "a$2" != "aNOSWITCH" ]; then
4759 debug "Device \"%s\" is now switched to \"%s\". Will attempt to setup this one instead.\n" "$1" "${NEWIDS}"
4760 modem_usb_detect_int "${NEWIDS}" "NOSWITCH"
4761 ret=$?
4762 return ${ret}
4763 else
4764 debug "Failed to switch device \"%s\".\n" "$1"
4765 return ${ret}
4766 fi
4767 else
4768 debug "However, device \"%s\" is already switched.\n" "$1"
4769 return 8
4770 fi
4771 fi
4772 debug "Failed setting up USB modem \"%s\".\n" "$1"
4773 return 8
4774 ;;
4775 0)
4776 debug "Got valid USB interface %d of USB modem \"%s\".\n" "${USB_INTERFACE}" "$1"
4777 return 0
4778 ;;
4779 *)
4780 debug "Unknown error %d while retrieving interface number of USB Device.\n" "${ret}"
4781 return ${ret}
4782 ;;
4783 esac
4784 }
4785
4786 # Sets USBTTY one way or another
4787 modem_usb_locate_tty() {
4788 verbose "Locating tty"
4789 lcounter=0
4790 while ! usb_sysfs_locate_tty "$1" "$2" "$3"
4791 do
4792 lcounter=`expr ${lcounter} + 1`; lcounter=`echo ${lcounter}`
4793 if [ "${lcounter}" -le "20" ]; then
4794 if [ "a$3" != "a" ]; then
4795 debug "Waiting for driver %s to create tty of device %s (interface #%d). [%d second(s) will have pass]\n" "$3" "$1" "$2" "${lcounter}"
4796 else
4797 debug "Waiting for tty of device %s (interface #%d). [%d second(s) will have pass]\n" "$1" "$2" "${lcounter}"
4798 fi
4799 sleep 1
4800 else
4801 if [ "a$3" != "a" ]; then
4802 debug "Driver %s failed to create a tty node for interface #%d of device %s.\n" "$3" "$2" "$1"
4803 else
4804 debug "No tty node created for interface #%d of device %s.\n" "$2" "$1"
4805 fi
4806 debug "Failed to locate tty device of interface #%d from device \"%s\".\n" "$2" "$1"
4807 unset lcounter
4808 return 8
4809 fi
4810 done
4811 return 0
4812 }
4813
4814 modem_usb_fix_driver() {
4815 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
4816 usb_stabilize "$1"
4817 # Make sure storage part (if exists), is settled before
4818 # we start playing with drivers. This should eliminate
4819 # cases that appeared on 2.6.31+ kernels.
4820 usb_storage_settled "$1"
4821 # Retrieve loaded driver
4822 usbdriver=`usb_loaded_driver "$1" "$2" | ${tailbin} -1`
4823 if [ "a${TIMEOUTOCCURED}" != "a" ]; then
4824 show_fmt_error "Seems like an electrical/USB bus error occured. You may need to replug your modem for it to properly work.\n"
4825 unset TIMEOUTOCCURED
4826 fi
4827 # Check value
4828 if [ "a${usbdriver}" = "a" -o "a${usbdriver}" = "aFAIL" ]; then
4829 show_fmt_error "Failed to detect driver of interface %d.\n" "$2"
4830 unset usbdriver
4831 return 7
4832 elif [ "a${usbdriver}" = "aNONE" ]; then
4833 debug "No driver attached to interface #%d of \"%s\".\n" "$2" "$1"
4834 else
4835 debug "Found already loaded driver \"%s\".\n" "${usbdriver}"
4836 fi
4837 # If driver mismatch, unload wrong driver
4838 if [ "a${USBDRIVER}" != "a" -a "a${usbdriver}" != "a" -a "a${usbdriver}" != "a${USBDRIVER}" -a "a${usbdriver}" != "aNONE" ]; then
4839 debug "USBDRIVER variable instructs to use \"%s\" instead.\n" "${USBDRIVER}"
4840 if ! module_unbind "${usbdriver}" "$1" "$2"; then
4841 show_fmt_error "Failed to detach wrong driver \"%s\". Please do it yourself and retry.\n" "${usbdriver}"
4842 unset usbdriver
4843 return 9
4844 fi
4845 usbdriver="NONE"
4846 fi
4847 # If no driver, attempt to detect one
4848 [ "a${USBDRIVER}" = "a" -a "a${usbdriver}" != "aNONE" ] && USBDRIVER="${usbdriver}"
4849 if [ "a${USBDRIVER}" = "a" -a "a${usbdriver}" = "aNONE" ]; then
4850 if [ "a${USB_INTERFACE}" != "a" ]; then
4851 usb_serial_detect_driver "$1" "$2"
4852 if [ "a${USB_INTERFACE}" = "a" ]; then
4853 # "usb_serial_detect_driver" call above, called "usb_usable_interfaces" which reset USB_INTERFACE
4854 USB_INTERFACE="$2" ; export USB_INTERFACE
4855 debug "Interface of device \"%s\" is still #%d.\n" "$1" "${USB_INTERFACE}"
4856 fi
4857 else
4858 usb_serial_detect_driver "$1" "$2"
4859 fi
4860 fi
4861 # We should know a driver now
4862 if [ "a${USBDRIVER}" = "a" ]; then
4863 unset usbdriver
4864 show_fmt_error "Unable to locate driver to use for device \"%s\"" "$1"
4865 return 10
4866 fi
4867 # Load driver (if required)
4868 if [ "${USBDRIVER}" = "${usbdriver}" ]; then
4869 debug "Driver \"%s\" already attached to interface #%d of device \"%s\".\n" "${USBDRIVER}" "$2" "$1"
4870 unset usbdriver
4871 return 0
4872 elif module_bind "${USBDRIVER}" "$1" "$2"; then
4873 debug "Driver \"%s\" loaded for interface #%d of device \"%s\".\n" "${USBDRIVER}" "$2" "$1"
4874 unset usbdriver
4875 return 0
4876 else
4877 show_fmt_error "Unable to load driver \"%s\" for device \"%s\"" "${USBDRIVER}" "$1"
4878 unset usbdriver
4879 return 11
4880 fi
4881 }
4882
4883 modem_usb() {
4884 unset MODEM_TTY
4885 [ "a$1" = "a" ] && return 99
4886 ! usb_device_connected "$1" && debug "Device \"%s\" not found.\n" "$1" && return 7
4887 export usbdevice="$1"
4888
4889 # Find appropriate interface, switching if required
4890 modem_usb_detect_int "${usbdevice}"
4891 ret=$?; [ "${ret}" -ne "0" ] && unset usbdevice && return ${ret}
4892 # Check if device is switched
4893 [ "a${NEWIDS}" != "a" ] && export usbdevice="${NEWIDS}"
4894 # Load driver
4895 modem_usb_fix_driver "${usbdevice}" "${USB_INTERFACE}"
4896 ret=$?; [ "${ret}" -ne "0" ] && unset usbdevice && return ${ret}
4897 # Locate tty
4898 modem_usb_locate_tty "${usbdevice}" "${USB_INTERFACE}" "${USBDRIVER}"
4899 ret=$?; [ "${ret}" -ne "0" ] && unset usbdevice && return ${ret}
4900 if [ "a${USBTTY}" != "a" ]; then
4901 if [ -c "${USBTTY}" ]; then
4902 debug "Nothing more to do for setting it up device \"%s\".\n" "$1"
4903 export MODEM_TTY="${USBTTY}"
4904 return 0
4905 fi
4906 fi
4907 unset USB_INTERFACE
4908 unset USBTTY
4909 unset MODEM_TTY
4910 unset usbdevice
4911 return 99
4912 }
4913
4914 modem_bluetooth() {
4915 unset MODEM_TTY
4916 [ "a$1" = "a" -o "a$2" = "a" ] && return 99
4917 debug "Attempting to setup bluetooth modem \"%s\" on channel \"%s\".\n" "$1" "$2"
4918 bluetooth_setup_rfcomm "$1" "$2"
4919 ret=$?
4920 if [ "a${ret}" = "a0" ]; then
4921 if [ "a${RFCOMM_TTY}" = "a" ]; then
4922 debug "No RFCOMM tty returned.\n"
4923 elif [ ! -c "${RFCOMM_TTY}" ]; then
4924 debug "RFCOMM tty returned (%s), does exist.\n" "${RFCOMM_TTY}"
4925 else
4926 debug "Nothing more to do for setting it up %s(channel #%d).\n" "$1" "$2"
4927 export MODEM_TTY="${RFCOMM_TTY}"
4928 return 0
4929 fi
4930 fi
4931 return 8
4932 }
4933
4934 modem_custom() {
4935 [ "a$1" = "a" ] && return 99
4936 debug "Attempting to setup custom tty modem on \"%s\".\n" "$1"
4937 if [ -c "$1" ]; then
4938 debug "Custom tty \"%s\" exists. Nothing more to do for setting it up.\n" "$1"
4939 export MODEM_TTY="$1"
4940 return 0
4941 else
4942 debug "Custom tty \"%s\" does not exist. Unable to proceed.\n" "$1"
4943 show_fmt_error "Device node \"%s\" does not exist. Setup failed." "$1"
4944 unset MODEM_TTY
4945 return 8
4946 fi
4947 }
4948
4949 modem_setup() {
4950 unset MODEM_TTY
4951 debug "Setting up modem.\n"
4952 ! we_are_root && return 3
4953 [ "a${MODEM}" = "a" ] && ! flow_select_modem "$@" && return 98
4954 if [ "a${MODEM}" = "aOTHER" ]; then
4955 [ "a${OTHER}" = "a" ] && ! flow_other_modem "$@" && return 98
4956 if [ "a${OTHER}" = "aUSBMODEM" ]; then
4957 [ "a${USBMODEM}" = "a" ] && ! flow_usb_modem "$@" && return 98
4958 if [ "a${USBMODEM}" != "a" ]; then
4959 debug "Setting up USB modem %s.\n" "${USBMODEM}"
4960 modem_usb "${USBMODEM}" "$@"
4961 ret=$?
4962 [ "a${usbdevice}" != "a" -a "a${usbdevice}" = "a${NEWIDS}" ] && export USBMODEM="${USBMODEM} ${usbdevice}"
4963 return ${ret}
4964 fi
4965 elif [ "a${OTHER}" = "aBLUETOOTH" ]; then
4966 [ "a${BLUETOOTH}" = "a" ] && ! flow_blue_modem "$@" && return 98
4967 if [ "a${BLUETOOTH}" = "aUNDISCOVERABLE" ]; then
4968 [ "a${UNDISCOVERABLE}" = "a" ] && ! flow_undiscoverable "$@" && return 98
4969 if [ "a${UNDISCOVERABLE}" != "a" ]; then
4970 [ "a${RFSERVICE}" = "a" ] && ! flow_rfchannel "$@" && return 98
4971 if [ "a${RFSERVICE}" = "aRFCHANNEL" ]; then
4972 [ "a${RFCHANNEL}" = "a" ] && ! flow_manual_rfcomm "$@" && return 98
4973 if [ "a${RFCHANNEL}" != "a" ]; then
4974 debug "Setting up Bluetooth modem %s on channel %s.\n" "${UNDISCOVERABLE}" "${RFCHANNEL}"
4975 modem_bluetooth "${UNDISCOVERABLE}" "${RFCHANNEL}" "$@"
4976 return $?
4977 fi
4978 elif [ "a${RFSERVICE}" != "a" ]; then
4979 debug "Setting up Bluetooth modem %s on channel %s.\n" "${UNDISCOVERABLE}" "${RFSERVICE}"
4980 modem_bluetooth "${UNDISCOVERABLE}" "${RFSERVICE}" "$@"
4981 return $?
4982 fi
4983 fi
4984 elif [ "a${BLUETOOTH}" != "a" ]; then
4985 [ "a${RFSERVICE}" = "a" ] && ! flow_rfchannel "$@" && return 98
4986 if [ "a${RFSERVICE}" = "aRFCHANNEL" ]; then
4987 [ "a${RFCHANNEL}" = "a" ] && ! flow_manual_rfcomm "$@" && return 98
4988 if [ "a${RFCHANNEL}" != "a" ]; then
4989 debug "Setting up Bluetooth modem %s on channel %s.\n" "${BLUETOOTH}" "${RFCHANNEL}"
4990 modem_bluetooth "${BLUETOOTH}" "${RFCHANNEL}" "$@"
4991 return $?
4992 fi
4993 elif [ "a${RFSERVICE}" != "a" ]; then
4994 debug "Setting up Bluetooth modem %s on channel %s.\n" "${BLUETOOTH}" "${RFSERVICE}"
4995 modem_bluetooth "${BLUETOOTH}" "${RFSERVICE}" "$@"
4996 return $?
4997 fi
4998 fi
4999 elif [ "a${OTHER}" = "aCUSTOM_TTY" ]; then
5000 [ "a${CUSTOM_TTY}" = "a" ] && ! flow_custom_tty "$@" && return 98
5001 if [ "a${CUSTOM_TTY}" != "a" ]; then
5002 debug "Setting up custom modem on %s.\n" "${CUSTOM_TTY}"
5003 modem_custom "${CUSTOM_TTY}" "$@"
5004 return $?
5005 fi
5006 fi
5007 elif [ "a${MODEM}" != "a" ]; then
5008 debug "Setting up USB modem %s.\n" "${MODEM}"
5009 modem_usb "${MODEM}" "$@"
5010 ret=$?
5011 [ "a${usbdevice}" != "a" -a "a${usbdevice}" = "a${NEWIDS}" ] && export MODEM="${MODEM} ${usbdevice}"
5012 return ${ret}
5013 fi
5014 debug "Failed to setup any modem.\n"
5015 return 99
5016 }
5017
5018 # Gets entries from file $1 that start with $2:$3
5019 base_fetch() {
5020 unset BASERESULT
5021 [ "a$1" = "a" ] && return 1
5022 [ "a${PROVIDER}" = "a" ] && debug "Unable to locate package provider.\n" && return 1
5023 [ ! -x "${PROVIDER}" ] && debug "Unable to execute package provider.\n" && return 1
5024 baseentries=`"${PROVIDER}" getfile "$1" | ${grepbin} -v "^#" | ${grepbin} -i "^$2:"`
5025 if [ "a${baseentries}" = "a" ]; then
5026 unset baseentries
5027 debug "No information found for %s within %s database.\n" "$2" "$1"
5028 return 1
5029 fi
5030 [ "a$3" != "a" ] && BASERESULT=`echo "${baseentries}" | ${grepbin} -i "^$2:$3:"`
5031 [ "a${BASERESULT}" = "a" ] && BASERESULT=`echo "${baseentries}" | ${grepbin} -i "^$2::"`
5032 export BASERESULT
5033 unset baseentries
5034 if [ "a${BASERESULT}" = "a" ]; then
5035 unset BASERESULT
5036 [ "a$3" != "a" ] && debug "No information found for \"%s:%s:\" within %s.\n" "$2" "$3" "$1"
5037 [ "a$3" = "a" ] && debug "No default entry \"%s::\" found within %s.\n" "$2" "$1"
5038 return 1
5039 fi
5040 debug "Loaded entries from %s:\n%s\n" "$1" "${BASERESULT}"
5041 return 0
5042 }
5043
5044 base_drivers() {
5045 unset basedrivercandidates; unset baseintercandidates
5046 [ "a$1" = "a" ] && return 1
5047 ! base_fetch "files/usb_devices.db" "$1" "$2" && return 1
5048 [ "a${BASERESULT}" = "a" ] && return 1
5049 BASERESULT=`echo "${BASERESULT}" | ${headbin} -1`
5050 basedrivercandidates=`echo "${BASERESULT}" | ${cutbin} -f2 -s`
5051 baseintercandidates=`echo "${BASERESULT}" | ${cutbin} -f3 -s`
5052 [ "a${basedrivercandidates}" != "a" ] && debug "Device database indicates to use \"%s\" driver(s) for device %s.\n" "${basedrivercandidates}" "$1"
5053 [ "a${baseintercandidates}" != "a" ] && debug "Device database indicates to use interface #%d for device %s.\n" "${baseintercandidates}" "$1"
5054 unset BASERESULT
5055 return 0
5056 }
5057
5058 # Sets INIT_STAGES of modem $1 with optional name $2.
5059 # Parses files/modem_init.db.
5060 base_modem() {
5061 unset INIT_STAGE0; unset INIT_STAGE1; unset INIT_STAGE2; unset INIT_STAGE3; unset INIT_STAGE4; unset INIT_STAGE5; unset INIT_STAGE6; unset INIT_STAGE7; unset INIT_STAGE8;
5062 [ "a$1" = "a" -a "a$2" = "a" ] && return 1
5063 ! base_fetch "files/modem_init.db" "$1" "$2" && return 1
5064 [ "a${BASERESULT}" = "a" ] && return 1
5065 BASERESULT=`echo "${BASERESULT}" | ${headbin} -1`
5066 for item in 0 1 2 3 4 5 6 7 8
5067 do
5068 plusone=`expr ${item} + 1`; plusone=`echo ${plusone}`
5069 if [ "${item}" -le "7" -a "${item}" -ge "1" ]; then
5070 contents=`${printfbin} "%s\n" "${BASERESULT}" | ${cutbin} -f${plusone}`
5071 elif [ "${item}" -eq "8" ]; then
5072 contents=`${printfbin} "%s\n" "${MODEM_INIT}"`
5073 elif [ "${item}" -eq "0" ]; then
5074 contents=`${printfbin} "%s\n" "${MODEM_PREPARE}"`
5075 fi
5076 if [ "a${contents}" != "a" ]; then
5077 replacement=`${printfbin} "%s\n" "${contents}" | ${sedbin} -e "s/AT/\\nAT/g" | ${sedbin} -e "s/ *$//g" | ${grepbin} -v "^$" | ${grepbin} "^AT" | ${sedbin} -e "s/^\(.*\)$/\\\'\1\\\' OK/g" | ${trbin} "\n" " "`
5078 eval "INIT_STAGE${item}=\${replacement}"
5079 eval export INIT_STAGE${item}
5080 unset replacement
5081 if [ "a$1" != "a" ]; then
5082 if [ "a$2" != "a" ]; then
5083 debug "Loaded INIT Stage #%d for %s(%s): %s\n" "${item}" "$1" "$2" "`eval echo \\"\\${INIT_STAGE${item}}\\"`"
5084 else
5085 debug "Loaded INIT Stage #%d for %s: %s\n" "${item}" "$1" "`eval echo \\"\\${INIT_STAGE${item}}\\"`"
5086 fi
5087 else
5088 debug "Loaded INIT Stage #%d for %s: %s\n" "${item}" "$2" "`eval echo \\"\\${INIT_STAGE${item}}\\"`"
5089 fi
5090 else
5091 eval unset INIT_STAGE${item}
5092 fi
5093 unset contents; unset plusone
5094 done
5095 debug run_command "set | ${grepbin} \"^INIT_STAGE\""
5096 unset item
5097 return 0
5098 }
5099
5100 # Sets NETINFO of ISP $1 with optional name $2. If $1==$ISPID sets ISP_ fields also
5101 # Parses files/operators.db.
5102 base_net() {
5103 unset NETINFO
5104 [ "a$1" = "a" ] && return 1
5105 ! base_fetch "files/operators.db" "$1" "$2" && return 1
5106 [ "a${BASERESULT}" = "a" ] && return 1
5107 BASERESULT=`echo "${BASERESULT}" | ${headbin} -1`
5108 ISP_NAME=`echo "${BASERESULT}" | ${cutbin} -f2`
5109 ISP_PRODUCT=`echo "${BASERESULT}" | ${cutbin} -f3`
5110 ISP_FGCOLOR=`echo "${BASERESULT}" | ${cutbin} -f4`
5111 ISP_BGCOLOR=`echo "${BASERESULT}" | ${cutbin} -f5`
5112 ISP_DIAL=`echo "${BASERESULT}" | ${cutbin} -f6`
5113 ISP_APNS=`echo "${BASERESULT}" | ${cutbin} -f7 | ${trbin} " " "\n"`
5114 ISP_ICON=`echo "${BASERESULT}" | ${cutbin} -f8`
5115 export ISP_NAME
5116 export ISP_PRODUCT
5117 export ISP_FGCOLOR
5118 export ISP_BGCOLOR
5119 export ISP_DIAL
5120 export ISP_APNS
5121 export ISP_ICON
5122 return 0
5123 }
5124
5125 # Gathers information about ISP $1 with optional name $2
5126 net_info() {
5127 [ "a$1" != "a" ] && base_net "$@"
5128 [ "a$1" != "a${ISPID}" -a "a$1" != "a" ] && return 0
5129 [ "a${ISP_NAME}" = "a" ] && export ISP_NAME="${ISPNAME}"
5130 [ "a${ISP_NAME}" = "a" ] && export ISP_NAME="Unknown operator ${ISPID}"
5131 [ "a${ISPNAME}" = "a${ISPID}" -o "a${ISPNAME}" = "a" ] && export ISPNAME="${ISP_NAME}"
5132 [ "a${ISPNAME}" = "a${ISPID}" -o "a${ISPNAME}" = "a" ] && export ISPNAME="${ISP_NAME}"
5133 export ISPTEXT="${ISPNAME}"
5134 [ "a${ISP_PRODUCT}" = "a" ] && export ISP_PRODUCT="${ISP_NAME} Internet"
5135 [ "a${ISP_FGCOLOR}" = "a" ] && export ISP_FGCOLOR="ffffff"
5136 [ "a${ISP_BGCOLOR}" = "a" ] && export ISP_BGCOLOR="000000"
5137 [ "a${ISP_DIAL}" = "a" ] && export ISP_DIAL="*99#"
5138 [ "a${ISP_ICON}" = "a" ] && export ISP_ICON="files/sakis3g.png"
5139 if [ "a${CUSTOM_DIAL}" != "a" -a "a${CUSTOM_DIAL}" != "a${ISP_DIAL}" ]; then
5140 debug "Will dial \"%s\" specified by user instead of \"%s\" found in database.\n" "${CUSTOM_DIAL}" "${ISP_DIAL}"
5141 export ISP_DIAL="${CUSTOM_DIAL}"
5142 fi
5143 debug "ISPID: %s / ISPNAME: %s / ISPTEXT: %s\n" "${ISPID}" "${ISPNAME}" "${ISPTEXT}"
5144 return 0
5145 }
5146
5147
5148 # Select a device interface
5149 flow_select_interface() {
5150 usbinterfaces=`echo "$2" | ${trbin} " " "\n" | ${sedbin} -e "s/^\(.*\)$/\"\1\" \"Interface #\1\"/g" | ${trbin} "\n" " "`
5151 eval user_select \"USBINTERFACE\" \"Please appropriate interface\" \"Select modem interface of USB device that provides modem capabilities.\" \"Select\" \"Cancel\" ${usbinterfaces}
5152 case "$?" in
5153 0)
5154 unset usbinterfaces
5155 return 98
5156 ;;
5157 98)
5158 unset usbinterfaces
5159 return 98
5160 ;;
5161 99)
5162 unset usbinterfaces
5163 return 99
5164 ;;
5165 *)
5166 unset usbinterfaces
5167 return 0
5168 ;;
5169 esac
5170 return 99
5171 }
5172
5173
5174 # Makes sure one USB modem exists
5175 flow_usb_modem() {
5176 usb_connected_devices
5177 usbmodems=`echo "${usb_devices}" | ${sedbin} -e "s/^\(....\):\(....\):\(.*\)$/\"\1:\2\" \"\3\"/g"`
5178 eval user_select \"USBMODEM\" \"Please select USB modem\" \"Select USB device that provides modem capabilities.\" \"Select\" \"Cancel\" ${usbmodems}
5179 case "$?" in
5180 0)
5181 unset usbmodems
5182 return 98
5183 ;;
5184 98)
5185 unset usbmodems
5186 return 98
5187 ;;
5188 99)
5189 unset usbmodems
5190 return 99
5191 ;;
5192 *)
5193 unset usbmodems
5194 usb_connected_devices
5195 usbmodems=`echo "${usb_devices}" | ${sedbin} -e "s/^\(....\):\(....\):\(.*\)$/ \1:\2 /g" | ${grepbin} " ${USBMODEM} "`; usbmodems=`echo ${usbmodems}`
5196 if [ "a${usbmodems}" = "a${USBMODEM}" ]; then
5197 debug "User selected USB modem \"%s\".\n" "${USBMODEM}"
5198 unset usbmodems
5199 return 0
5200 else
5201 debug "USB modem \"%s\" is not currently plugged.\n" "${USBMODEM}"
5202 unset usbmodems; unset USBMODEM
5203 flow_usb_modem "$@"
5204 return "$?"
5205 fi
5206 ;;
5207 esac
5208 return 99
5209 }
5210
5211 flow_manual_rfcomm() {
5212 user_prompt "RFCHANNEL" "Please enter RFCOMM channel" "Enter RFCOMM channel that should be used, or leave empty to abort [1-255]" "OK" "Cancel"
5213 case "a${RFCHANNEL}" in
5214 a)
5215 return 98
5216 ;;
5217 *)
5218 RFCHANNEL=`${printfbin} "%d\n" "${RFCHANNEL}" 2> /dev/null`
5219 [ "a$RFCHANNEL" = "a" ] && RFCHANNEL=0
5220 [ "$RFCHANNEL" -gt "255" ] && RFCHANNEL=0
5221 export RFCHANNEL
5222 if [ "$RFCHANNEL" -eq "0" ]; then
5223 unset RFCHANNEL
5224 return 98
5225 fi
5226 return 0
5227 ;;
5228 esac
5229 }
5230
5231 flow_custom_tty() {
5232 user_prompt "CUSTOM_TTY" "Please enter tty" "Enter tty node where your 3G modem resides, or leave empty to abort" "OK" "Cancel"
5233 case "a${CUSTOM_TTY}" in
5234 a)
5235 unset CUSTOM_TTY
5236 return 98
5237 ;;
5238 *)
5239 [ ! -c "${CUSTOM_TTY}" ] && [ -c "/dev/${CUSTOM_TTY}" ] && CUSTOM_TTY="/dev/${CUSTOM_TTY}"
5240 [ ! -c "${CUSTOM_TTY}" ] && [ -c "/dev${CUSTOM_TTY}" ] && CUSTOM_TTY="/dev${CUSTOM_TTY}"
5241 if [ ! -c "${CUSTOM_TTY}" ]; then
5242 show_fmt_error "Device node \"%s\" does not exist.\n" "${CUSTOM_TTY}"
5243 unset CUSTOM_TTY
5244 flow_custom_tty "$@"
5245 return $?
5246 else
5247 debug "Using device node \"%s\".\n" "${CUSTOM_TTY}"
5248 export CUSTOM_TTY
5249 return 0
5250 fi
5251 ;;
5252 esac
5253 }
5254
5255 flow_rfchannel() {
5256 [ "a${BLUETOOTH}" = "a" ] && ! flow_blue_modem "$@" && return $?
5257 if [ "a${RFSERVICE}" = "aRFCHANNEL" ]; then
5258 if ! flow_manual_rfcomm; then
5259 unset RFSERVICE
5260 flow_rfchannel "$@"
5261 return "$?"
5262 fi
5263 return 0
5264 fi
5265 verbose "Seeking %s" "${BLUETOOTH}"
5266 if bluetooth_rfcomm_channel "${BLUETOOTH}" "DUN"; then
5267 debug "No DUN rfcomm channels returned from \"%s\".\n" "${BLUETOOTH}"
5268 bluetooth_rfcomm_channel "${BLUETOOTH}" "SP"
5269 rfchannels=`echo "${rfchannel}" | ${sedbin} -e "s/^\([0-9][0-9]*\)$/\"\1\" \"Serial Port from RFCOMM channel #\1\"/g"`
5270 else
5271 rfchannels=`echo "${rfchannel}" | ${sedbin} -e "s/^\([0-9][0-9]*\)$/\"\1\" \"Dialup Networking from RFCOMM channel #\1\"/g"`
5272 bluetooth_rfcomm_channel "${BLUETOOTH}" "SP"
5273 rfchannels="${rfchannels} `echo \"${rfchannel}\" | ${sedbin} -e \"s/^\\\([0-9][0-9]*\\\)$/\\\"\\\1\\\" \\\"Serial Port from RFCOMM channel #\\\1\\\"/g\"`"
5274 fi
5275 eval user_select \"RFSERVICE\" \"Please select RFCOMM service\" \"Select RFCOMM service of Bluetooth device that provides 3G modem capabilities.\" \"Select\" \"Cancel\" \"RESCAN\" \"Scan device again\" ${rfchannels} \"RFCHANNEL\" \"Manually enter non-discovered channel...\"
5276 case "$?" in
5277 0)
5278 unset rfchannels
5279 return 98
5280 ;;
5281 98)
5282 unset rfchannels
5283 return 98
5284 ;;
5285 99)
5286 unset rfchannels
5287 return 99
5288 ;;
5289 *)
5290 unset rfchannels
5291 case "a${RFSERVICE}" in
5292 aRESCAN)
5293 unset RFSERVICE
5294 flow_rfchannel "$@"
5295 return "$?"
5296 ;;
5297 aRFCHANNEL)
5298 if ! flow_manual_rfcomm; then
5299 unset RFSERVICE
5300 flow_rfchannel "$@"
5301 return "$?"
5302 fi
5303 return 0
5304 ;;
5305 *)
5306 export RFCHANNEL="${RFSERVICE}"
5307 return 0
5308 ;;
5309 esac
5310 ;;
5311 esac
5312 return 99
5313
5314
5315 }
5316
5317 # Makes sure one UNDISCOVERABLE BLUETOOTH modem exists
5318 flow_undiscoverable() {
5319 user_prompt "UNDISCOVERABLE" "Enter Bluetooth address" "Enter Bluetooth address of undiscoverable device, or leave empty to abort" "OK" "Cancel"
5320 case "a${UNDISCOVERABLE}" in
5321 a)
5322 return 98
5323 ;;
5324 *)
5325 export BLUETOOTH="${UNDISCOVERABLE}"
5326 if ! flow_rfchannel; then
5327 unset UNDISCOVERABLE; unset BLUETOOTH
5328 return 98
5329 fi
5330 export BLUETOOTH="UNDISCOVERABLE"
5331 return 0
5332 ;;
5333 esac
5334 }
5335
5336
5337 # Makes sure one BLUETOOTH modem exists
5338 flow_blue_modem() {
5339 if [ "a${BLUETOOTH}" = "aUNDISCOVERABLE" ]; then
5340 if ! flow_undiscoverable; then
5341 unset BLUETOOTH
5342 flow_blue_modem "$@"
5343 return "$?"
5344 fi
5345 return 0
5346 fi
5347 bluetooth_scan_devices
5348 bluemodems=`echo "${bluetooth_devices}" | ${sedbin} -e "s/^\(.*\) \(.*\)$/\"\1\" \"\2 (\1)\"/g"`
5349 eval user_select \"BLUETOOTH\" \"Please select Bluetooth device\" \"Select Bluetooth device that provides 3G modem capabilities.\" \"Select\" \"Cancel\" \"RESCAN\" \"Scan devices again\" ${bluemodems} \"UNDISCOVERABLE\" \"Manually enter undiscoverable device...\"
5350 case "$?" in
5351 0)
5352 unset bluemodems
5353 return 98
5354 ;;
5355 98)
5356 unset bluemodems
5357 return 98
5358 ;;
5359 99)
5360 unset bluemodems
5361 return 99
5362 ;;
5363 *)
5364 unset bluemodems
5365 case "a${BLUETOOTH}" in
5366 aRESCAN)
5367 unset BLUETOOTH
5368 flow_blue_modem "$@"
5369 return "$?"
5370 ;;
5371 aUNDISCOVERABLE)
5372 if ! flow_undiscoverable; then
5373 unset BLUETOOTH
5374 flow_blue_modem "$@"
5375 return "$?"
5376 fi
5377 return 0
5378 ;;
5379 *)
5380 if ! flow_rfchannel; then
5381 unset BLUETOOTH
5382 flow_blue_modem "$@"
5383 return "$?"
5384 fi
5385 return 0
5386 ;;
5387 esac
5388 ;;
5389 esac
5390 return 99
5391 }
5392
5393 # Makes sure one other modem is selected
5394 flow_other_modem() {
5395 user_select "OTHER" "Please select modem type" "Select modem category that best fits your 3G modem." "Select" "Cancel" "USBMODEM" "USB device" "BLUETOOTH" "Bluetooth modem" "CUSTOM_TTY" "Custom tty..."
5396 case "$?" in
5397 0)
5398 return 98
5399 ;;
5400 98)
5401 return 98
5402 ;;
5403 99)
5404 return 99
5405 ;;
5406 *)
5407 case "a${OTHER}" in
5408 aUSBMODEM)
5409 if ! flow_usb_modem; then
5410 unset OTHER
5411 flow_other_modem "$@"
5412 return "$?"
5413 fi
5414 return 0
5415 ;;
5416 aBLUETOOTH)
5417 if ! flow_blue_modem; then
5418 unset OTHER
5419 flow_other_modem "$@"
5420 return "$?"
5421 fi
5422 return 0
5423 ;;
5424 aCUSTOM_TTY)
5425 if ! flow_custom_tty; then
5426 unset OTHER
5427 flow_other_modem "$@"
5428 return "$?"
5429 fi
5430 return 0
5431 ;;
5432 *)
5433 return 99
5434 ;;
5435 esac
5436 ;;
5437 esac
5438 return 99
5439 }
5440
5441
5442 # Makes sure one selected modem exists
5443 flow_select_modem() {
5444 verbose "Locating device"
5445 usb_connected_modems
5446 modems=`echo "${usb_modem_devices}" | ${sedbin} -e "s/^\(....\):\(....\):\(.*\)$/\"\1:\2\" \"\3\"/g"`
5447 if [ "a${modems}" != "a" ]; then
5448 modemscount=`echo "${usb_modem_devices}" | ${wcbin} -l`; modemscount=`echo ${modemscount}`
5449 if [ "a${modemscount}" = "a1" -a "a${MODEM}" = "a" ]; then
5450 MODEM=`echo "${usb_modem_devices}" | ${headbin} -1 | ${sedbin} -e "s/^\(....\):\(....\):\(.*\)$/\1:\2/g"`
5451 export MODEM
5452 debug "Autoselecting unique USB modem plugged: %s\n" "${MODEM}"
5453 ret=1
5454 else
5455 eval user_select \"MODEM\" \"Please select modem\" \"Select modem that will be used for establishing 3G connection.\" \"Select\" \"Cancel\" ${modems} \"OTHER\" \"Other...\"
5456 # in
5457 ret=$?
5458 fi
5459 unset modemscount
5460 else
5461 export MODEM="OTHER"
5462 ret=97
5463 fi
5464 case "${ret}" in
5465 0)
5466 return 98
5467 ;;
5468 98)
5469 return 98
5470 ;;
5471 99)
5472 return 99
5473 ;;
5474 *)
5475 case "a${MODEM}" in
5476 aOTHER)
5477 if [ "${ret}" -eq "97" ]; then
5478 flow_other_modem "$@"
5479 ret=$?
5480 [ "${ret}" -ne "0" ] && unset MODEM
5481 return ${ret}
5482 else
5483 if ! flow_other_modem "$@"; then
5484 unset MODEM
5485 flow_select_modem "$@"
5486 return "$?"
5487 fi
5488 fi
5489 return 0
5490 ;;
5491 a)
5492 return 98
5493 ;;
5494 *)
5495 return 0
5496 ;;
5497 esac
5498 return 99
5499 ;;
5500 esac
5501 return 0
5502 }
5503
5504 flow_custom_apn() {
5505 user_prompt "CUSTOM_APN" "Please enter APN" "Enter correct APN, or leave empty to abort. Contact your operator if unsure" "OK" "Cancel"
5506 case "a${CUSTOM_APN}" in
5507 a)
5508 unset CUSTOM_APN
5509 return 98
5510 ;;
5511 *)
5512 export CUSTOM_APN
5513 return 0
5514 ;;
5515 esac
5516 }
5517
5518
5519 # Makes selected APN exists
5520 flow_select_apn() {
5521 net_info "${ISPID}" "${ISPNAME}"
5522 [ "a${FORCE_APN}" != "a" ] && export ISP_APNS="${FORCE_APN}"
5523 [ "a${ISP_APNS}" = "a" ] && tty_detect_apn && export ISP_APNS="${MODEM_APN}"
5524 if [ "a${ISP_APNS}" != "a" -a "a${FORCE_APN}" = "a" ]; then
5525 apnoptions=""
5526 for apnoption in ${ISP_APNS}
5527 do
5528 apnname=`echo "${apnoption}" | ${cutbin} -d: -f1 -s`
5529 if [ "a${apnname}" = "a" ]; then
5530 apnname="${apnoption}"
5531 apndesc="${apnoption}"
5532 apnuser="" ; apnpass=""
5533 else
5534 apndesc=`echo "${apnoption}" | ${cutbin} -d: -f2 | ${sedbin} -e "s/_/ /g"`
5535 apndesc="${apndesc} (${apnname})"
5536 apnuser=`echo "${apnoption}" | ${cutbin} -d: -f3`
5537 apnpass=`echo "${apnoption}" | ${cutbin} -d: -f4`
5538 fi
5539 if [ "a${apnname}" = "a${MODEM_APN}" -a "a${MODEM_APN}" != "a" ]; then
5540 apndesc=`format_text "Reported by your modem (%s)" "${apnname}"`
5541 fi
5542 apnoptions="${apnoptions} \"${apnname}\" \"${apndesc}\""
5543 unset apnname; unset apndesc; unset apnuser; unset apnpass
5544 done
5545 unset apnoption
5546 eval user_select \"APN\" \"Please select APN\" \"Select APN that best describes your connection. Contact your operator if unsure. This information, along with APN username and password, is usually easily retrieved through a fast call to customer support\" \"Select\" \"Cancel\" ${apnoptions} \"CUSTOM_APN\" \"Custom APN...\"
5547 ret=$?
5548 unset apnoptions
5549 elif [ "a${FORCE_APN}" != "a" ]; then
5550 debug "Selected APN by FORCE_APN: %s\n" "${FORCE_APN}"
5551 APN=`echo "${FORCE_APN}" | ${cutbin} -d: -f1`
5552 export APN
5553 ret=1
5554 else
5555 export APN="CUSTOM_APN"
5556 ret=97
5557 fi
5558 case "${ret}" in
5559 0)
5560 return 98
5561 ;;
5562 98)
5563 return 98
5564 ;;
5565 99)
5566 return 99
5567 ;;
5568 *)
5569 case "a${APN}" in
5570 aCUSTOM_APN)
5571 if [ "${ret}" -eq "97" ]; then
5572 if ! flow_custom_apn "$@"; then
5573 unset APN
5574 return 98
5575 fi
5576 else
5577 if ! flow_custom_apn "$@"; then
5578 unset APN
5579 flow_select_apn "$@"
5580 return "$?"
5581 fi
5582 fi
5583 return 0
5584 ;;
5585 a)
5586 return 98
5587 ;;
5588 *)
5589 APN=`echo "${ISP_APNS}" | ${grepbin} "^${APN}\(:*\)" | ${cutbin} -d: -f1`
5590 export APN
5591 if [ "a${APN}" = "a" ]; then
5592 unset APN
5593 flow_select_apn "$@"
5594 return "$?"
5595 else
5596 apnuser=`echo "${ISP_APNS}" | ${grepbin} "^${APN}\(:*\)" | ${cutbin} -d: -f3 -s`
5597 [ "a${apnuser}" != "a" -a "a${APN_USER}" = "a" ] && export APN_USER="${apnuser}"
5598 apnpass=`echo "${ISP_APNS}" | ${grepbin} "^${APN}\(:*\)" | ${cutbin} -d: -f4 -s`
5599 [ "a${apnuser}" != "a" -a "a${APN_PASS}" = "a" ] && export APN_PASS="${apnpass}"
5600 unset apnuser; unset apnpass
5601 fi
5602 return 0
5603 ;;
5604 esac
5605 return 99
5606 ;;
5607 esac
5608 return 0
5609 }
5610
5611 flow_apn_user() {
5612 [ "a${APN}" = "a" ] && return 98
5613 if [ "a${APN_USER}" = "a" ]; then
5614 if [ "a${APN}" != "a" ]; then
5615 if [ "a${APN}" = "aCUSTOM_APN" -a "a${CUSTOM_APN}" != "a" ]; then
5616 APN_USER=`echo "${CUSTOM_APN}" | ${cutbin} -d: -s -f3`
5617 else
5618 APN_USER=`echo "${APN}" | ${cutbin} -d: -s -f3`
5619 fi
5620 fi
5621 fi
5622 [ "a${APN_USER}" = "a" ] && unset APN_USER
5623 if [ "a${APN}" = "aCUSTOM_APN" -a "a${CUSTOM_APN}" != "a" ]; then
5624 apntitle=`echo "${CUSTOM_APN}" | ${cutbin} -d: -f1`
5625 elif [ "a${APN}" != "a" ]; then
5626 apntitle=`echo "${APN}" | ${cutbin} -d: -f1`
5627 fi
5628 user_prompt "APN_USER" "APN: ${apntitle}" "Enter username required by APN, or leave empty to abort. Contact your operator if unsure. This information, along with APN password, is usually easily retrieved through a fast call to customer support" "OK" "Cancel"
5629 case "a${APN_USER}" in
5630 a)
5631 unset APN_USER
5632 return 98
5633 ;;
5634 *)
5635 export APN_USER
5636 return 0
5637 ;;
5638 esac
5639 }
5640
5641 flow_apn_pass() {
5642 [ "a${APN}" = "a" ] && return 98
5643 if [ "a${APN_PASS}" = "a" ]; then
5644 if [ "a${APN}" != "a" ]; then
5645 if [ "a${APN}" = "aCUSTOM_APN" -a "a${CUSTOM_APN}" != "a" ]; then
5646 APN_PASS=`echo "${CUSTOM_APN}" | ${cutbin} -d: -s -f4`
5647 else
5648 APN_PASS=`echo "${APN}" | ${cutbin} -d: -s -f4`
5649 fi
5650 fi
5651 fi
5652 [ "a${APN_PASS}" = "a" ] && unset APN_PASS
5653 if [ "a${APN}" = "aCUSTOM_APN" -a "a${CUSTOM_APN}" != "a" ]; then
5654 apntitle=`echo "${CUSTOM_APN}" | ${cutbin} -d: -f1`
5655 elif [ "a${APN}" != "a" ]; then
5656 apntitle=`echo "${APN}" | ${cutbin} -d: -f1`
5657 fi
5658 user_prompt "APN_PASS" "APN: ${apntitle}" "Enter password required by APN, or leave empty to abort. Contact your operator if unsure. This information is usually easily retrieved through a fast call to customer support" "OK" "Cancel"
5659 case "a${APN_PASS}" in
5660 a)
5661 unset APN_PASS
5662 return 98
5663 ;;
5664 *)
5665 export APN_PASS
5666 return 0
5667 ;;
5668 esac
5669 }
5670
5671 flow_switch() {
5672 flow_select_modem "$@"
5673 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5674 unset NEWIDS
5675 if modeswitch_is_switchable "${MODEM}" && usb_device_connected "${MODEM}"; then
5676 modeswitch_switch "${MODEM}"
5677 ret=$?
5678 if [ "a${NEWIDS}" != "a" -a "a${NEWIDS}" != "a${MODEM}" ]; then
5679 debug "Device changed ID. From \"%s\" to \"%s\".\n" "${MODEM}" "${NEWIDS}"
5680 export MODEM="${NEWIDS}"
5681 fi
5682 localdev="${MODEM}"
5683 elif modeswitch_is_switchable "${USBMODEM}" && usb_device_connected "${USBMODEM}"; then
5684 modeswitch_switch "${USBMODEM}"
5685 ret=$?
5686 if [ "a${NEWIDS}" != "a" -a "a${NEWIDS}" != "a${USBMODEM}" ]; then
5687 debug "Device changed ID. From \"%s\" to \"%s\".\n" "${USBMODEM}" "${NEWIDS}"
5688 export USBMODEM="${NEWIDS}"
5689 fi
5690 localdev="${USBMODEM}"
5691 else
5692 debug "Currently selected modem cannot be switched. No need to switch anything.\n"
5693 return 0
5694 fi
5695 # Should normally unlock HAL here. But we don't.
5696 # If we will stay within program, it will get unlocked during driver setup.
5697 # If stand-alone action, exit trap will unlock it.
5698 # So, line below should be commented out.
5699 #hal_unlock
5700 return ${ret}
5701 }
5702
5703 flow_setup() {
5704 flow_select_modem "$@"
5705 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5706 if modem_setup "$@"; then
5707 debug "Modem is now setup and resides on %s.\n" "${MODEM_TTY}"
5708 return 0
5709 else
5710 return $?
5711 fi
5712 }
5713
5714 flow_prepare() {
5715 flow_setup "$@"
5716 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5717 if tty_prepare "${MODEM_TTY}" "$@"; then
5718 debug "Device %s is now prepared and registered to %s.\n" "${MODEM_TTY}" "${ISPTEXT}"
5719 else
5720 return $?
5721 fi
5722 }
5723
5724 pppd_config() {
5725 need_binary "pppd"
5726 need_arg "PPPD_OPTIONS"; need_arg "BAUD"
5727 unset CONNECTION_CONF; unset CONNECTION_COMMAND
5728 ${touchbin} "/tmp/pppd.tmp.$$"
5729 if [ ! -w "/tmp/pppd.tmp.$$" ]; then
5730 show_fmt_error "Unable to create temporary pppd config file within %s directory.\n" "/tmp"
5731 return 99
5732 fi
5733 CONNECTION_CONF="/tmp/pppd.tmp.$$"
5734 find_binary "chmod" && ${chmodbin} 600 "${CONNECTION_CONF}"
5735 ${catbin} > "${CONNECTION_CONF}" <<endl
5736 ABORT "NO CARRIER"
5737 ABORT "NO DIALTONE"
5738 ABORT "BUSY"
5739 ABORT "ERROR"
5740 ABORT "NO ANSWER"
5741 "" ATZ
5742 endl
5743 #initstrings=`echo "${INIT_COMMANDS}" "ATDT${ISP_DIAL}" | ${sedbin} -e "s/AT/\\nAT/g" | ${grepbin} "^AT" | ${sedbin} -e "s/ *$//g" | ${grepbin} -v "^$" | ${sedbin} -e "s/^\(.*\)$/OK '\1'/g"`
5744 initstrings=`echo "${DIAL_COMMANDS}" | ${sedbin} -e "s/AT/\\nAT/g" | ${grepbin} "^AT" | ${sedbin} -e "s/ *$//g" | ${grepbin} -v "^$" | ${sedbin} -e "s/^\(.*\)$/OK '\1'/g"`
5745 debug "Init strings are:\n%s\n" "${initstrings}"
5746 echo "${initstrings}" >> "${CONNECTION_CONF}"
5747 unset initstrings
5748 if [ ! -s "${CONNECTION_CONF}" ]; then
5749 ${rmbin} -f "${CONNECTION_CONF}"
5750 show_fmt_error "Failure to write on %s.\n" "${CONNECTION_CONF}"
5751 unset CONNECTION_CONF
5752 return 99
5753 fi
5754 debug "Config file that will be used is: \"%s\".\n" "${CONNECTION_CONF}"
5755 debug show_file "${CONNECTION_CONF}"
5756 pppdoptions="${PPPD_OPTIONS}"
5757 [ "a${pppdoptions}" = "a" ] && pppdoptions="modem crtscts -detach defaultroute dump noipdefault usepeerdns usehostname ktune logfd 2 noauth name sakis3g lock maxfail 3"
5758 if [ "a${PPPD_PEERS}" != "a" ]; then
5759 if [ -d "${PPPD_PEERS}" ]; then
5760 if [ -f "${PPPD_PEERS}/sakis3g" ]; then
5761 debug "Found peers file %s.\n" "${PPPD_PEERS}/sakis3g"
5762 pppdoptions="-detach dump logfd 2 name sakis3gpeer maxfail 3 call sakis3g"
5763 fi
5764 fi
5765 fi
5766 export CONNECTION_COMMAND="${setsidbin} ${pppdbin} ${MODEM_TTY} ${BAUD} ${pppdoptions} connect \"${chatbin} -v -f ${CONNECTION_CONF}\" user \"${APN_USER}\" password \"${APN_PASS}\""
5767 unset pppdoptions
5768 debug "Connection command that will be used is: %s\n" "${CONNECTION_COMMAND}"
5769 return 0
5770 }
5771
5772 wvdial_config() {
5773 need_binary "wvdial"
5774 need_arg "BAUD"
5775 unset CONNECTION_CONF; unset CONNECTION_COMMAND
5776 ${touchbin} "/tmp/wvdial.tmp.$$"
5777 if [ ! -w "/tmp/wvdial.tmp.$$" ]; then
5778 show_fmt_error "Unable to create temporary wvdial config file within %s directory.\n" "/tmp"
5779 return 99
5780 fi
5781 CONNECTION_CONF="/tmp/wvdial.tmp.$$"
5782 find_binary "chmod" && ${chmodbin} 600 "${CONNECTION_CONF}"
5783 ${catbin} > "${CONNECTION_CONF}" <<endl
5784 [Dialer Defaults]
5785 Modem = ${MODEM_TTY}
5786 Modem Type = Analog Modem
5787 ISDN = 0
5788 Baud = ${BAUD}
5789 Dial Attempts = 3
5790 Username = ${APN_USER}
5791 Password = ${APN_PASS}
5792 Phone = ${ISP_DIAL}
5793 Auto Reconnect = off
5794 Stupid Mode = 1
5795 endl
5796 echo "Init1 = ATZ" >> "${CONNECTION_CONF}"
5797 if [ ! -s "${CONNECTION_CONF}" ]; then
5798 ${rmbin} -f "${CONNECTION_CONF}"
5799 show_fmt_error "Failure to write on %s.\n" "${CONNECTION_CONF}"
5800 unset CONNECTION_CONF
5801 return 99
5802 fi
5803 debug "Config file that will be used is: \"%s\".\n" "${CONNECTION_CONF}"
5804 debug show_file "${CONNECTION_CONF}"
5805 export CONNECTION_COMMAND="${setsidbin} ${wvdialbin} --config \"${CONNECTION_CONF}\""
5806 debug "Connection command that will be used is: %s\n" "${CONNECTION_COMMAND}"
5807 return 0
5808 }
5809
5810 ispconnect() {
5811 [ "a${CONNECTION_COMMAND}" = "a" ] && return 95
5812 if ppp_fast_status; then
5813 debug "Already connected.\n"
5814 return 0
5815 fi
5816 ! we_are_root && return 1
5817 debug run_command "${rmbin} -f \"/tmp/sakis3g.3gnet\""
5818 ! tty_not_busy "${MODEM_TTY}" && return 1
5819 if [ "a$1" = "anoretry" ]; then
5820 verbose "Connecting (second attempt)"
5821 else
5822 verbose "Connecting"
5823 fi
5824 logpid=0
5825 if [ -n "${DEBUG}" ]; then
5826 eval "${CONNECTION_COMMAND} &"
5827 logpid=$!
5828 else
5829 eval "${CONNECTION_COMMAND} <&- >&- 2>&- &"
5830 logpid=$!
5831 fi
5832 passed=0
5833 while ! notrunning "${logpid}"
5834 do
5835 ppp_slow_status && break
5836 debug "Waiting for interface to go up (%d seconds passed).\n" "${passed}"
5837 passed=`expr ${passed} + 1`; passed=`echo ${passed}`
5838 if [ "a${passed}" = "a21" ]; then
5839 debug "Giving up waiting for connection to occur.\n"
5840 if find_binary "kill"; then
5841 ${killbin} -1 ${logpid} 2> /dev/null
5842 ! notrunning "${logpid}" && sleep 1
5843 ! notrunning "${logpid}" && sleep 1
5844 fi
5845 break
5846 fi
5847 sleep 1
5848 done
5849 if notrunning "${logpid}" && [ "a$1" != "anoretry" ]; then
5850 unset logpid
5851 ispconnect "noretry"
5852 return $?
5853 fi
5854 unset passed
5855 if ! ppp_slow_status; then
5856 debug "Failed to connect.\n"
5857 unset logpid
5858 return 95
5859 fi
5860 debug "Connection is established.\n"
5861 ${printfbin} "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" "${ISPID}" "${ISPTEXT}" "${MODEM_VARIANT}" "${USBDRIVER}" "${MODEM_TTY}" "${MODEM}" "${OTHER}" "${APN}" "${CUSTOM_APN}" "${APN_USER}" "${APN_PASS}" "${logpid}" > "/tmp/sakis3g.3gnet"
5862 [ -f "/tmp/sakis3g.3gnet" ] && ${chmodbin} 644 "/tmp/sakis3g.3gnet"
5863 unset logpid
5864 return 0
5865 }
5866
5867 # Deletes all currently existing default gateways.
5868 routing_delete_gateways() {
5869 ! we_are_root && return 1
5870 ! find_binary "netstat" && return 1
5871 ! find_binary "route" && return 1
5872 while [ "1" = "1" ];
5873 do
5874 gatehost=`${netstatbin} -rn | ${grepbin} "^0.0.0.0 " | ${tailbin} -1 | ${sedbin} -e "s/ */ /g" | ${cutbin} -d\ -f2`
5875 if [ "a${gatehost}" != "a" ]; then
5876 debug "Deleting default gateway %s.\n" "${gatehost}"
5877 debug run_command "${routebin} del default gw ${gatehost}"
5878 else
5879 debug "Deleted all default gateways.\n"
5880 break
5881 fi
5882 done
5883 unset gatehost
5884 return 0
5885 }
5886
5887 # Makes sure only our pppint(ppp0) peer is used as default gateway.
5888 routing_fix() {
5889 ! find_binary "netstat" && return 1
5890 ! find_binary "route" && return 1
5891 need_arg "pppint"
5892 hostpeer=`${netstatbin} -rn | ${grepbin} " ${pppint}$" | ${grepbin} -v "^0.0.0.0 " | ${cutbin} -d\ -f1`
5893 if [ "a${hostpeer}" != "a" ]; then
5894 routing_delete_gateways
5895 debug run_command "${routebin} add default gw ${hostpeer}"
5896 debug "Added correct default gateway: %s.\n" "${hostpeer}"
5897 debug run_command "${netstatbin} -rn"
5898 fi
5899 unset hostpeer
5900 return 0
5901 }
5902
5903 dns_fix() {
5904 debug "Checking if required to fix DNS settings.\n"
5905 unset needdnsfix
5906 if [ ! -f "/etc/resolv.conf" ]; then
5907 needdnsfix=1
5908 debug "No %s exists. Will make it ourselves.\n" "/etc/resolv.conf"
5909 else
5910 debug show_file "/etc/resolv.conf"
5911 baddns=`${grepbin} "10.11.12.13" "/etc/resolv.conf" | ${wcbin} -l`; baddns=`echo ${baddns}`
5912 [ "a${baddns}" = "a0" ] && baddns=`${grepbin} "10.11.12.14" "/etc/resolv.conf" | ${wcbin} -l`
5913 baddns=`echo ${baddns}`
5914 if [ "a${baddns}" != "a0" ]; then
5915 needdnsfix=1
5916 debug "File %s contains bad DNS servers. Will fix it.\n" "/etc/resolv.conf"
5917 fi
5918 unset baddns
5919 fi
5920 if [ "a${DNS}" != "a" ]; then
5921 needdnsfix=1
5922 debug "Will fix DNS due to DNS servers being set: %s\n" "${DNS}"
5923 fi
5924 if [ "a${needdnsfix}" != "a1" ]; then
5925 debug "No need to fix DNS servers. Skipping it.\n"
5926 unset needdnsfix
5927 return 0
5928 fi
5929 if [ "a${DNS}" = "a" ]; then
5930 debug "No DNS servers where set. Will use Google DNS.\n"
5931 export DNS="8.8.8.8 8.8.4.4"
5932 fi
5933 ${rmbin} -f "/etc/resolv.conf"
5934 ${touchbin} "/etc/resolv.conf"
5935 ${chmodbin} 644 "/etc/resolv.conf"
5936 for dnsserver in ${DNS}
5937 do
5938 ${printfbin} "nameserver %s\n" "${dnsserver}" >> "/etc/resolv.conf"
5939 debug "Added name server %s to %s.\n" "${dnsserver}" "/etc/resolv.conf"
5940 done
5941 unset dnsserver
5942 ${printfbin} "\n# This file was autogenerated by %s.\n\n" "Sakis3G script" >> "/etc/resolv.conf"
5943 debug "Done setting up custom DNS server(s).\n"
5944 return 0
5945 }
5946
5947
5948 flow_post_connection() {
5949 if [ "a${NOSMART}" != "a" ]; then
5950 debug "Requested not to smart-fix connection.\n"
5951 return 0
5952 fi
5953 verbose "Fixing connection"
5954 debug "Running post-connection setup.\n"
5955 routing_fix
5956 dns_fix
5957 }
5958
5959 flow_connect() {
5960 ppp_fast_status && return 0
5961 flow_prepare "$@"
5962 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5963 verbose "Resolving connection details"
5964 flow_select_apn "$@"
5965 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5966 flow_apn_user "$@"
5967 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5968 flow_apn_pass "$@"
5969 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5970 [ "a${MODEM_TTY}" = "a" ] && return 99
5971 [ ! -c "${MODEM_TTY}" ] && return 99
5972 [ "a${APN}" = "a" -o "a${APN_USER}" = "a" -o "a${APN_PASS}" = "a" -o "a${ISP_DIAL}" = "a" ] && return 99
5973 ! at_default_commands "DIAL" && return 99
5974 [ "a${ttycommands}" = "a" ] && return 99
5975 export DIAL_COMMANDS="${ttycommands}"
5976 if [ "a${direct_pppd}" != "a" ]; then
5977 pppd_config "$@"
5978 ret=$?
5979 else
5980 wvdial_config "$@"
5981 ret=$?
5982 fi
5983 unset DIAL_COMMANDS
5984 [ "${ret}" -ne "0" ] && return ${ret}
5985 verbose "Initializing modem"
5986 tty_send_command "${MODEM_TTY}" "INITIALIZE"
5987 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
5988 tty_send_command "${MODEM_TTY}" "STAGE7"
5989 tty_send_command "${MODEM_TTY}" "STAGE8"
5990 ispconnect "$@"
5991 ret=$?
5992 [ "a${CONNECTION_CONF}" != "a" ] && [ -f "${CONNECTION_CONF}" ] && ${rmbin} -f "${CONNECTION_CONF}"
5993 unset CONNECTION_CONF; unset CONNECTION_COMMAND
5994 [ "${ret}" -ne "0" ] && return ${ret}
5995 flow_post_connection "$@"
5996 if [ "a${CONNECTION_HOOK}" != "a" ]; then
5997 debug "Will now execute CONNECTION_HOOK: %s.\n" "${CONNECTION_HOOK}"
5998 term_clearline
5999 debug run_command "${CONNECTION_HOOK}"
6000 debug "Connection hook returned.\n"
6001 fi
6002 ! ppp_slow_status && return 99
6003 return ${ret}
6004 }
6005
6006 flow_disconnect() {
6007 ! ppp_fast_status && return 0
6008 ! we_are_root && return 1
6009 verbose "Disconnecting"
6010 if find_binary "killall"; then
6011 ${killallbin} -q -1 pppd
6012 sleep 1
6013 ppp_fast_status && ${killallbin} -q -9 pppd
6014 elif find_binary "ps" && find_binary "kill"; then
6015 ppppid=`${psbin} -C "pppd" -o pid= 2> /dev/null | ${grepbin} -i "PID"`; ppppid=`echo ${ppppid}`
6016 for propid in ${ppppid}
6017 do
6018 debug run_command "kill -1 ${propid}"
6019 done
6020 ppppid=`${psbin} -C "pppd" -o pid= 2> /dev/null | ${grepbin} -i "PID"`; ppppid=`echo ${ppppid}`
6021 for propid in ${ppppid}
6022 do
6023 debug run_command "kill -9 ${propid}"
6024 done
6025 unset ppppid; unset propid
6026 else
6027 show_fmt_error "Unable to stop running pppd session. Both %s and % were not found.\n" "kill" "killall"
6028 return 1
6029 fi
6030 sleep 1
6031 if ppp_fast_status; then
6032 debug "Failed to disconnect.\n"
6033 return 1
6034 fi
6035 debug "Disconnected.\n"
6036 return 0
6037 }
6038
6039 compile_check_local_requirements() {
6040 if [ "a${PROVIDER}" = "a" ]; then
6041 show_fmt_error "Not running from within package.\n"
6042 return 1
6043 fi
6044 if [ ! -x "${PROVIDER}" ]; then
6045 show_fmt_error "Reported package location is not executable: %s\n" "${PROVIDER}"
6046 return 1
6047 fi
6048 if [ ! -w "${PROVIDER}" ] && we_are_root; then
6049 show_fmt_error "Unable to overwrite existing package %s. Check if on read-only filesystem.\n" "${PROVIDER}"
6050 return 1
6051 fi
6052 return 0
6053 }
6054
6055 compile_check_dependencies() {
6056 unset missing
6057 for localdependency in bzip2 bunzip2 pwd basename dirname gcc tar dd stat cp chmod rm mkdir mv find rmdir printf grep expr ls sort uniq cut sed tr cat touch
6058 do
6059 ! find_binary "${localdependency}" && missing="${missing} ${localdependency}"
6060 done
6061 missing=`echo ${missing}`
6062 if [ "a${missing}" != "a" ]; then
6063 show_fmt_error "Following dependencies not found within path: %s\n" "${missing}"
6064 unset missing
6065 return 1
6066 fi
6067 unset missing
6068 return 0
6069 }
6070
6071 compile_compilation_dependencies() {
6072 [ "a${PROVIDER}" = "a" ] && return 1
6073 [ ! -x "${PROVIDER}" ] && return 1
6074 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" > /dev/null 2> /dev/null
6075 ${touchbin} "/tmp/sakis3g.source.$$.combined.c" > /dev/null 2> /dev/null
6076 if [ ! -f "/tmp/sakis3g.source.$$.combined.c" ]; then
6077 show_fmt_error "Unable to create file %s.\n" "/tmp/sakis3g.source.$$.combined.c"
6078 return 1
6079 fi
6080 ${PROVIDER} getfile usb_modeswitch.c 2> /dev/null > "/tmp/sakis3g.source.$$.c"
6081 ${PROVIDER} getfile usb_modeswitch.h 2> /dev/null > "/tmp/sakis3g.source.$$.h"
6082 ${catbin} "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > "/tmp/sakis3g.source.$$.combined.c"
6083 if [ ! -s "/tmp/sakis3g.source.$$.combined.c" ]; then
6084 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6085 show_fmt_error "Unable to extract %s source from package.\n" "Usb-ModeSwitch"
6086 return 1
6087 fi
6088 headerfiles=`${grepbin} "^#include <" "/tmp/sakis3g.source.$$.combined.c" | ${sedbin} -e "s/\( *\)/ /g" | ${cutbin} -d\ -f2 -s | ${sedbin} -e "s/^<\(.*\)>$/INCLUDE:\1/g" | ${grepbin} "^INCLUDE:" | ${cutbin} -d: -f2- -s`
6089 if [ "a${headerfiles}" = "a" ]; then
6090 unset headerfiles
6091 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6092 show_fmt_error "Problem while parsing %s sources.\n" "Usb-ModeSwitch"
6093 return 1
6094 fi
6095 debug "Header files are:\n%s\n" "${headerfiles}"
6096 accumulative=""
6097 for header in ${headerfiles}
6098 do
6099 debug "Probing: %s\n" "${header}"
6100 accumulative=`${printfbin} "%s\n%s\n" "${accumulative}" "${header}" | ${grepbin} -v "^$"`
6101 echo "${accumulative}" | ${sedbin} -e "s/^\(.*\)$/#include <\1\>/g" > "/tmp/sakis3g.source.$$.combined.c"
6102 ${printfbin} "int main(int argc, char **argv) {\nreturn 22;\n}\n\n" >> "/tmp/sakis3g.source.$$.combined.c"
6103 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6104 if [ -f "/tmp/sakis3g.object.$$" ]; then
6105 unset headerfiles; unset header; unset accumulative;
6106 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6107 show_fmt_error "Unable to delete \"%s\".\n" "/tmp/sakis3g.object.$$"
6108 return 1
6109 fi
6110 debug run_command "${gccbin} -Wall -o \"/tmp/sakis3g.object.$$\" \"/tmp/sakis3g.source.$$.combined.c\""
6111 if [ ! -x "/tmp/sakis3g.object.$$" ]; then
6112 if [ "a${header}" != "ausb.h" ]; then
6113 show_fmt_error "Header file %s missing from your system.\n" "${header}"
6114 else
6115 show_fmt_error "Header file %s missing from your system. This usually indicates libusb (or libusb-compat) development kit missing.\n" "${header}"
6116 fi
6117 unset headerfiles; unset header; unset accumulative;
6118 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6119 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6120 return 1
6121 fi
6122 debug run_command "/tmp/sakis3g.object.$$"
6123 ret=$?
6124 if [ "${ret}" -ne "22" ]; then
6125 show_fmt_error "Unusable binary after including \"%s\".\n" "${header}"
6126 unset headerfiles; unset header; unset accumulative;
6127 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6128 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6129 return 1
6130 fi
6131 debug "No problem encountered when including \"%s\".\n" "${header}"
6132 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6133 done
6134 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" > /dev/null 2> /dev/null
6135 unset header; unset headerfiles;
6136 debug "Will now attempt linking.\n"
6137 echo "${accumulative}" | ${sedbin} -e "s/^\(.*\)$/#include <\1\>/g" > "/tmp/sakis3g.source.$$.combined.c"
6138 ${catbin} "/tmp/sakis3g.source.$$.h" "/tmp/sakis3g.source.$$.c" | ${grepbin} -v "^#include" >> "/tmp/sakis3g.source.$$.combined.c"
6139 debug show_file "/tmp/sakis3g.source.$$.combined.c"
6140 debug run_command "${gccbin} -Wall -lusb -o \"/tmp/sakis3g.object.$$\" \"/tmp/sakis3g.source.$$.combined.c\""
6141 unset accumulative;
6142 ${rmbin} -f "/tmp/sakis3g.source.$$.combined.c" "/tmp/sakis3g.source.$$.c" "/tmp/sakis3g.source.$$.h" > /dev/null 2> /dev/null
6143 if [ ! -x "/tmp/sakis3g.object.$$" ]; then
6144 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6145 show_fmt_error "Failed to link %s. This usually indicates libusb (or libusb-compat) development kit missing.\n" "Usb-ModeSwitch"
6146 return 1
6147 fi
6148 ${rmbin} -f "/tmp/sakis3g.object.$$" > /dev/null 2> /dev/null
6149 debug "Linking test was successful.\n"
6150 return 0
6151 }
6152
6153 compile_perform() {
6154 [ "a${PROVIDER}" = "a" ] && return 1
6155 [ ! -x "${PROVIDER}" ] && return 1
6156 tempdestination="/tmp/sakis3g.recompile.$$"
6157 debug run_command "${rmbin} -rf \"${tempdestination}\""
6158 debug run_command "${mkdirbin} \"${tempdestination}\""
6159 if [ ! -d "${tempdestination}" ]; then
6160 show_fmt_error "Unable to create temporary folder \"%s\".\n" "${tempdestination}"
6161 unset tempdestination
6162 return 1
6163 fi
6164 debug run_command "${touchbin} \"${tempdestination}/test.$$\""
6165 if [ ! -w "${tempdestination}/test.$$" ]; then
6166 debug run_command "${rmbin} -rf \"${tempdestination}\""
6167 show_fmt_error "No write access to temporary folder \"%s\".\n" "${tempdestination}"
6168 unset tempdestination
6169 return 1
6170 fi
6171 debug run_command "${rmbin} -rf \"${tempdestination}/\"*"
6172 if [ ! -d "${tempdestination}" ]; then
6173 show_fmt_error "Oops. Weird \"%s\" version. Deleted temporary folder \"%s\".\n" "${rmbin}" "${tempdestination}"
6174 unset tempdestination
6175 return 1
6176 fi
6177 debug run_command "${PROVIDER} disassemble \"${tempdestination}/.\""
6178 if [ ! -x "${tempdestination}/sakis3g-${MYVERSION}/compile" ]; then
6179 debug run_command "${rmbin} -rf \"${tempdestination}\""
6180 show_fmt_error "Failed to disassemble Sakis3G package.\n" "${tempdestination}"
6181 unset tempdestination
6182 return 1
6183 fi
6184 debug run_command "${rmbin} -f \"${tempdestination}/sakis3g-${MYVERSION}/build/sakis3gz\""
6185 compilation_error=`cd "${tempdestination}/sakis3g-${MYVERSION}"; ./compile 2>&1`
6186 debug "Compilation output:\n%s\n" "${compilation_error}"
6187 if [ ! -x "${tempdestination}/sakis3g-${MYVERSION}/build/sakis3gz" -o ! -s "${tempdestination}/sakis3g-${MYVERSION}/build/sakis3gz" ]; then
6188 debug run_command "${rmbin} -rf \"${tempdestination}\""
6189 show_fmt_error "Failed to compile. Compilation output:\n%s\n" "${compilation_error}"
6190 unset compilation_error; unset tempdestination
6191 return 1
6192 fi
6193 unset compilation_error
6194 verification=`"${tempdestination}/sakis3g-${MYVERSION}/build/sakis3gz" usb_modeswitch --version 2> /dev/null | ${grepbin} -i "josua" | ${wcbin} -l`; verification=`echo ${verification}`
6195 if [ "a${verification}" = "a" -o "a${verification}" = "a0" ]; then
6196 unset verification
6197 debug run_command "${rmbin} -rf \"${tempdestination}\""
6198 show_fmt_error "Failed to verify result of compilation.\n"
6199 unset tempdestination
6200 return 1
6201 fi
6202 unset verification
6203 debug run_command "${rmbin} -f \"${PROVIDER}.backup\""
6204 if [ -f "${PROVIDER}.backup" ]; then
6205 debug run_command "${rmbin} -rf \"${tempdestination}\""
6206 show_fmt_error "Unable to delete previously existing \"%s\".\n" "${PROVIDER}.backup"
6207 unset tempdestination
6208 return 1
6209 fi
6210 debug run_command "${cpbin} \"${PROVIDER}\" \"${PROVIDER}.backup\""
6211 if [ ! -f "${PROVIDER}.backup" ]; then
6212 debug run_command "${rmbin} -rf \"${tempdestination}\""
6213 show_fmt_error "Unable to create a safe backup to \"%s\".\n" "${PROVIDER}.backup"
6214 unset tempdestination
6215 return 1
6216 fi
6217 debug run_command "${lsbin} -l \"${PROVIDER}\""
6218 # No rm, or we loose owner and rights information
6219 #debug run_command "${rmbin} -f \"${PROVIDER}\""
6220 #debug run_command "${lsbin} -l \"${PROVIDER}\""
6221 debug run_command "${cpbin} \"${tempdestination}/sakis3g-${MYVERSION}/build/sakis3gz\" \"${PROVIDER}\""
6222 debug run_command "${lsbin} -l \"${PROVIDER}\""
6223 debug run_command "${rmbin} -rf \"${tempdestination}\""
6224 unset tempdestination
6225 verification=`"${PROVIDER}" usb_modeswitch --version 2> /dev/null | ${grepbin} -i "josua" | ${wcbin} -l`; verification=`echo ${verification}`
6226 if [ "a${verification}" = "a" -o "a${verification}" = "a0" ]; then
6227 debug "Verification failed. Restoring previous version.\n"
6228 debug run_command "${cpbin} \"${PROVIDER}.backup\" \"${PROVIDER}\""
6229 unset verification
6230 if [ -x "${PROVIDER}" ]; then
6231 show_fmt_error "Failed to succesfully place new version. You are still using old version.\n"
6232 elif [ -x "${PROVIDER}.backup" ]; then
6233 show_fmt_error "Failed to succesfully create new version. Old version is still available at \"%s\".\n" "${PROVIDER}.backup"
6234 else
6235 show_fmt_error "Something really bad happened. I am really sorry. You may need to re-download Sakis3G.\n"
6236 fi
6237 return 1
6238 fi
6239 unset verification
6240 debug run_command "${rmbin} -f \"${PROVIDER}.backup\""
6241 debug run_command "${lsbin} -l \"${PROVIDER}.backup\""
6242 debug "Succesfully recompiled.\n"
6243 return 0
6244 }
6245
6246 flow_compile() {
6247 if [ "a${binaryfree}" != "a" ]; then
6248 show_fmt_error "You are running a binary free version of Sakis3G. Unable to recompile %s.\n" "Usb-ModeSwitch"
6249 return 99
6250 fi
6251 verbose "Checking tools availability"
6252 compile_check_local_requirements
6253 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
6254 verbose "Checking dependencies"
6255 compile_check_dependencies
6256 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
6257 verbose "Testing compiler"
6258 compile_compilation_dependencies
6259 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
6260 verbose "Compiling"
6261 compile_perform
6262 ret=$?; [ "${ret}" -ne "0" ] && return ${ret}
6263 return 0
6264 }
6265
6266 flow_report() {
6267 if ! status_connected; then
6268 show_fmt_error "You need to be connected for generating report.\n"
6269 return 6
6270 fi
6271 unset report_text
6272 old_translation=${notranslate}
6273 export notranslate=1
6274 report_text="Sakis3G version: ${MYVERSION}"
6275 if [ "a${PROVIDER}" = "a" ]; then
6276 report_text=`${printfbin} "%s\nNot running from within package.\n" "${report_text}"`
6277 elif [ ! -x "${PROVIDER}" ]; then
6278 report_text=`${printfbin} "%s\nPackage is not executable.\n" "${report_text}"`
6279 else
6280 if [ "a${binaryfree}" != "a" ]; then
6281 if [ "a${stripped}" != "a" ]; then
6282 report_text=`${printfbin} "%s\nRunning a binary free version.\n" "${report_text}"`
6283 else
6284 report_text=`${printfbin} "%s\nRunning a stripped version.\n" "${report_text}"`
6285 fi
6286 switchversion="95"
6287 else
6288 switchversion=`${PROVIDER} usb_modeswitch --version 2> /dev/null || echo $?`
6289 fi
6290 if [ "a${switchversion}" = "a95" ]; then
6291 if find_binary "usb_modeswitch"; then
6292 switchversion=`${usb_modeswitchbin} --version 2> /dev/null`
6293 report_text=`${printfbin} "%s\nSystem provided Usb-ModeSwitch:\n%s\n" "${report_text}" "${switchversion}"`
6294 else
6295 report_text=`${printfbin} "%s\nUsb-ModeSwitch is not available.\n" "${report_text}"`
6296 fi
6297 else
6298 switchversion=`${printfbin} "%s\n" "${switchversion}" | ${grepbin} -i version`
6299 report_text=`${printfbin} "%s\nUsing embedded Usb-ModeSwitch version:\n%s\n" "${report_text}" "${switchversion}"`
6300 fi
6301 fi
6302 if find_binary "uname"; then
6303 report_text=`${printfbin} "%s\nKernel version: %s\nArchitect: %s\n" "${report_text}" "\`${unamebin} -r\`" "\`${unamebin} -m\`"`
6304 else
6305 report_text=`${printfbin} "%s\nUtility uname is not available.\n" "${report_text}"`
6306 fi
6307 report_text=`${printfbin} "%s\nSelected UI is: %s\n" "${report_text}" "${SGUI}"`
6308 info_text=`action_info report | ${grepbin} -v "^$" | ${grepbin} -v "^ $"`
6309 report_text=`${printfbin} "%s\n%s\n" "${report_text}" "${info_text}"`
6310 state_variables "APN_USER APN_PASS SIM_PIN SGUI UNDISCOVERABLE BLUETOOTH MENU MOREMENU BALOONIZER"
6311 report_text=`${printfbin} "%s\nVariables: %s\n" "${report_text}" "${statevariables}"`
6312 unset info_text
6313 export notranslate="${old_translation}"
6314 [ "a${notranslate}" = "a" ] && unset notranslate
6315 unset old_translation
6316 trtext=`format_text "Please report following text:\n"`
6317 notify "%s\n\n%s\n" "${trtext}" "${report_text}"
6318 unset trtext; unset switchversion; unset report_text
6319 return 0
6320 }
6321
6322
6323 # Returns 0 if connected, 1 if not connected.
6324 # Sets as much of the following information:
6325 # - statusnet containing numeric ID of ISP
6326 # - statusname containing text of ISP or nothing
6327 # - statusicon if statusnet exists within operator database and contains icon.
6328 # Sets ISPID only if not set already.
6329 # It is possible that it returns 0 and not set variables. This happens
6330 # if ppp interface was initiated by another application.
6331 status_connected() {
6332 unset statusnet; unset statusname; unset statusicon; unset localpid
6333 ! ppp_fast_status && return 1
6334 if [ -r "/tmp/sakis3g.3gnet" ]; then
6335 statusnet=`${headbin} -1 "/tmp/sakis3g.3gnet"`
6336 statusname=`${headbin} -2 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6337 debug "Retrieved from %s: \"%s\" - \"%s\"\n" "/tmp/sakis3g.3gnet" "${statusnet}" "${statusname}"
6338 statusnet=`echo "${statusnet}" | ${grepbin} "^[0-9][0-9][0-9][0-9][0-9]"`
6339 if [ "a${statusnet}" != "a" ]; then
6340 [ "a${statusname}" = "a${statusnet}" ] && unset statusname
6341 debug "Retrieved ISP ID from %s: %s\n" "/tmp/sakis3g.3gnet" "${statusnet}"
6342 [ "a${statusname}" != "a" ] && debug "Also retrieved ISP name: %s\n" "${statusname}"
6343 else
6344 unset statusname; unset statusnet
6345 debug "Invalid or not existing %s within %s.\n" "ISPID" "/tmp/sakis3g.3gnet"
6346 fi
6347 if [ "a${statusnet}" != "a" ] && [ "a${ISPID}" = "a" -o "a${ISPID}" = "a${statusnet}" ]; then
6348 if [ "a${MODEM_VARIANT}" = "a" ]; then
6349 MODEM_VARIANT=`${headbin} -3 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6350 [ "a${MODEM_VARIANT}" != "a" ] && export MODEM_VARIANT && debug "Also read: %s\n" "${MODEM_VARIANT}"
6351 fi
6352 if [ "a${USBDRIVER}" = "a" ]; then
6353 USBDRIVER=`${headbin} -4 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6354 [ "a${USBDRIVER}" != "a" ] && export USBDRIVER && debug "Also read: %s\n" "${USBDRIVER}"
6355 fi
6356 if [ "a${MODEM_TTY}" = "a" ]; then
6357 MODEM_TTY=`${headbin} -5 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6358 [ "a${MODEM_TTY}" != "a" ] && export MODEM_TTY && debug "Also read: %s\n" "${MODEM_TTY}"
6359 fi
6360 if [ "a${MODEM}" = "a" ]; then
6361 MODEM=`${headbin} -6 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6362 [ "a${MODEM}" != "a" ] && export MODEM && debug "Also read: %s\n" "${MODEM}"
6363 fi
6364 if [ "a${OTHER}" = "a" ]; then
6365 OTHER=`${headbin} -7 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6366 [ "a${OTHER}" != "a" ] && export OTHER && debug "Also read: %s\n" "${OTHER}"
6367 fi
6368 if [ "a${APN}" = "a" ]; then
6369 APN=`${headbin} -8 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6370 [ "a${APN}" != "a" ] && export APN && debug "Also read: %s\n" "${APN}"
6371 fi
6372 if [ "a${CUSTOM_APN}" = "a" -a "a${APN}" = "aCUSTOM_APN" ]; then
6373 CUSTOM_APN=`${headbin} -9 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6374 [ "a${CUSTOM_APN}" != "a" ] && export CUSTOM_APN && debug "Also read: %s\n" "${CUSTOM_APN}"
6375 fi
6376 if [ "a${APN_USER}" = "a" ]; then
6377 APN_USER=`${headbin} -10 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6378 [ "a${APN_USER}" != "a" ] && export APN_USER && debug "Also read: %s\n" "${APN_USER}"
6379 fi
6380 if [ "a${APN_PASS}" = "a" ]; then
6381 APN_PASS=`${headbin} -11 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6382 [ "a${APN_PASS}" != "a" ] && export APN_PASS && debug "Also read: %s\n" "${APN_PASS}"
6383 fi
6384 localpid=`${headbin} -12 "/tmp/sakis3g.3gnet" | ${tailbin} -1`
6385 if [ "a${localpid}" != "a" ]; then
6386 localprocess=`${psbin} -p ${localpid} -o comm= 2> /dev/null`
6387 if [ "a${localprocess}" != "a" ]; then
6388 debug "Process ID %s is: %s\n" "${localpid}" "${localprocess}"
6389 [ "${localprocess}" != "pppd" -a "${localprocess}" != "wvdial" ] && unset localprocess
6390 elif notrunning "${localpid}"; then
6391 debug "Process ID %s is not running.\n" "${localpid}"
6392 elif [ "a${localprocess}" = "a" ]; then
6393 debug "Process ID %s is not valid.\n" "${localpid}"
6394 fi
6395 if [ "a${localprocess}" = "a" -a "a${ISPID}" = "a" ]; then
6396 debug "Status file %s is stalled. Will discard information read from it.\n" "/tmp/sakis3g.3gnet"
6397 unset statusnet; unset statusname
6398 fi
6399 fi
6400 unset localpid; unset localprocess
6401 fi
6402 else
6403 debug "Invalid or not existing %s.\n" "/tmp/sakis3g.3gnet"
6404 fi
6405 if [ "a${ISPID}" != "a" ]; then
6406 debug "%s is set to: %s\n" "ISPID" "${ISPID}"
6407 if [ "a${statusnet}" = "a" ]; then
6408 statusnet="${ISPID}"
6409 debug "Was adapted since file not available.\n" "statusnet"
6410 if [ "a${ISPTEXT}" != "a" -a "a${ISPTEXT}" != "a${ISPID}" ]; then
6411 statusname="${ISPTEXT}"
6412 debug "Also adapted %s: %s\n" "ISPTEXT" "${ISPTEXT}"
6413 fi
6414 elif [ "a${statusnet}" = "a${ISPID}" ]; then
6415 debug "It matches value retrieved from file.\n"
6416 if [ "a${ISPTEXT}" != "a" -a "a${ISPTEXT}" != "a${ISPID}" -a "a${statusname}" = "a" ]; then
6417 statusname="${ISPTEXT}"
6418 debug "Also adapted %s since networks match: %s\n" "ISPTEXT" "${ISPTEXT}"
6419 fi
6420 else
6421 debug "Does not match value retrieved from file.\n"
6422 debug "Will trust file.\n"
6423 fi
6424 else
6425 debug "%s is not set.\n" "ISPID"
6426 if [ "a${statusnet}" = "a" ]; then
6427 debug "Unable to determine on which network we are connected.\n"
6428 else
6429 export ISPID="${statusnet}"
6430 debug "All information derived from file.\n"
6431 debug "Also set %s from file contents.\n" "ISPID"
6432 fi
6433 fi
6434 if net_info "${statusnet}" "${statusname}" && [ "a${BASERESULT}" != "a" ]; then
6435 statusproduct=`echo "${BASERESULT}" | ${cutbin} -f3 -s`
6436 [ "a${statusproduct}" != "a" ] && export statusproduct
6437 statusicon=`echo "${BASERESULT}" | ${cutbin} -f8 -s`
6438 [ "a${statusicon}" != "a" ] && export statusicon
6439 if [ "a${statusname}" = "a" ]; then
6440 statusname=`echo "${BASERESULT}" | ${cutbin} -d: -f2 -s`
6441 [ "a${statusname}" != "a" ] && debug "Retrieved %s name from database: %s\n" "${statusnet}" "${statusname}"
6442 fi
6443 fi
6444 if [ "a${statusnet}" = "a" ]; then
6445 unset statusnet; unset statusname
6446 else
6447 export statusnet
6448 if [ "a${statusname}" = "a" ]; then
6449 unset statusname
6450 else
6451 export statusname
6452 fi
6453 fi
6454 return 0
6455 }
6456
6457 # Method invoked when "status" action was requested.
6458 action_status() {
6459 unset verbosecurrentcount
6460 if ! ppp_fast_status; then
6461 show_fmt_error "Not connected.\n"
6462 return 6
6463 fi
6464 status_connected
6465 if [ "a${statusnet}" != "a" ]; then
6466 if [ "a${statusnet}" != "a${statusname}" -a "a${statusname}" != "a" ]; then
6467 if [ "a${MODEM_VARIANT}" != "a" ]; then
6468 finalnotify "%s connected to %s (%s)." "${MODEM_VARIANT}" "${statusname}" "${statusnet}"
6469 else
6470 finalnotify "Connected to %s (%s)." "${statusname}" "${statusnet}"
6471 fi
6472 else
6473 if [ "a${MODEM_VARIANT}" != "a" ]; then
6474 finalnotify "%s connected to %s." "${MODEM_VARIANT}" "${statusnet}"
6475 else
6476 finalnotify "Connected to %s." "${statusnet}"
6477 fi
6478 fi
6479 else
6480 finalnotify "Connected."
6481 fi
6482 return 0
6483 }
6484
6485 action_info() {
6486 unset verbosecurrentcount
6487 if ! ppp_fast_status; then
6488 notify "Not connected.\n"
6489 return 0
6490 fi
6491 status_connected
6492 if [ "a${statusnet}" = "a" ]; then
6493 notify "Unable to gather connection information.\n"
6494 return 0
6495 fi
6496 if [ "a$1" != "areport" ]; then
6497 infotext=`translate_text "Connection Information"`
6498 infotext=`${printfbin} "%s\n \n" "${infotext}"`
6499 fi
6500 [ "a${pppint}" != "a" ] && localtext=`format_text "Interface:\t\t\tP-t-P (%s)\n" "${pppint}"`
6501 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6502 infotext=`${printfbin} "%s\n \n" "${infotext}"`
6503 if [ "a$1" != "areport" ]; then
6504 if find_binary "stat"; then
6505 upsince=`${statbin} --printf="%z" "/tmp/sakis3g.3gnet" | ${cutbin} -d: -f1,2 -s`
6506 if [ "a${upsince}" != "a" ]; then
6507 localtext=`format_text "Connected since:\t%s\n" "${upsince}"`
6508 infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6509 fi
6510 unset upsince
6511 fi
6512 if [ -r "/proc/net/dev" -a "a${pppint}" != "a" ]; then
6513 traffic=`${sedbin} -e "s/ */ /g" "/proc/net/dev" | ${grepbin} "^\( *\)${pppint}:" | ${headbin} -1 | ${cutbin} -d: -f2- | ${sedbin} -e "s/^ *//g" | ${cutbin} -d\ -f1,9`
6514 debug "Traffic details are: %s\n" "${traffic}"
6515 bytesreceived=`echo ${traffic} | ${cutbin} -d\ -f1 -s`
6516 [ "a${bytesreceived}" != "a" ] && bytesreceived=`expr \( ${bytesreceived} + 512 \) / 1024 2> /dev/null`
6517 [ "a${bytesreceived}" != "a" ] && localtext=`format_text "Kilobytes received:\t%d\n" ${bytesreceived}`
6518 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6519 bytessent=`echo ${traffic} | ${cutbin} -d\ -f2 -s`
6520 [ "a${bytessent}" != "a" ] && bytessent=`expr \( ${bytessent} + 512 \) / 1024 2> /dev/null`
6521 [ "a${bytessent}" != "a" ] && localtext=`format_text "Kilobytes sent:\t%d\n" ${bytessent}`
6522 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6523 unset traffic; unset bytesreceived; unset bytessent
6524 fi
6525 fi
6526 localtext=`format_text "Network ID:\t\t%s" "${statusnet}"`
6527 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6528 [ "a${statusname}" != "a" ] && localtext=`format_text "Operator name:\t%s" "${statusname}"`
6529 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6530 if [ "a${APN}" != "a" ]; then
6531 if [ "a${APN}" = "aCUSTOM_APN" -a "a${CUSTOM_APN}" != "a" ]; then
6532 localtext=`format_text "APN:\t\t\t%s" "${CUSTOM_APN}"`
6533 elif [ "a${APN}" != "aCUSTOM_APN" ]; then
6534 localtext=`format_text "APN:\t\t\t%s" "${APN}"`
6535 fi
6536 fi
6537 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6538 infotext=`${printfbin} "%s\n \n" "${infotext}"`
6539 [ "a${MODEM_VARIANT}" != "a" ] && localtext=`format_text "Modem:\t\t\t%s\n" "${MODEM_VARIANT}"`
6540 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6541 if [ "a${MODEM}" != "a" ]; then
6542 if [ "a${MODEM}" != "a" -a "a${MODEM}" != "aOTHER" ]; then
6543 localtext=`format_text "Modem type:\t\tUSB\n"`
6544 elif [ "a${MODEM}" = "aOTHER" ]; then
6545 if [ "a${OTHER}" = "aUSBMODEM" ]; then
6546 localtext=`format_text "Modem type:\t\tUSB\n"`
6547 elif [ "a${OTHER}" = "aBLUETOOTH" ]; then
6548 localtext=`format_text "Modem type:\t\tBluetooth\n"`
6549 else
6550 localtext=`format_text "Modem type:\t\tCustom\n"`
6551 fi
6552 else
6553 localtext=`format_text "Modem type:\t\tUnknown\n"`
6554 fi
6555 else
6556 localtext=`format_text "Modem type:\t\tUnspecified\n"`
6557 fi
6558 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6559 [ "a${USBDRIVER}" != "a" ] && localtext=`format_text "Kernel driver:\t\t%s\n" "${USBDRIVER}"`
6560 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6561 [ "a${MODEM_TTY}" != "a" ] && localtext=`format_text "Device:\t\t\t%s\n" "${MODEM_TTY}"`
6562 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6563 infotext=`${printfbin} "%s\n \n" "${infotext}"`
6564 if [ "a$1" != "areport" ]; then
6565 if find_binary "ifconfig" && [ "a${pppint}" != "a" ]; then
6566 ipaddress=`${ifconfigbin} ${pppint} | ${sedbin} -e "s/^.*:\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\) .*:\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\) \(.*\):\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)$/IPADDRESSES: \1.\2.\3.\4 \5.\6.\7.\8/g" | ${grepbin} "^IPADDRESSES:" | ${cutbin} -d: -f2- -s`
6567 if [ "a${ipaddress}" != "a" ]; then
6568 localip=`echo ${ipaddress} | ${cutbin} -d\ -f1 -s`
6569 localpeer=`echo ${ipaddress} | ${cutbin} -d\ -f2 -s`
6570 localmask="255.255.255.255"
6571 [ "a${localip}" != "a" ] && localtext=`format_text "IP Address:\t\t%s\n" "${localip}"`
6572 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6573 [ "a${localip}" != "a" ] && localtext=`format_text "Subnet Mask:\t\t%s\n" "${localmask}"`
6574 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6575 [ "a${localpeer}" != "a" ] && localtext=`format_text "Peer IP Address:\t%s\n" "${localpeer}"`
6576 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6577 unset localip; unset localpeer; unset localmask
6578 fi
6579 unset ipaddress
6580 fi
6581 if find_binary "netstat" && [ "a${pppint}" != "a" ]; then
6582 localpeer=`${netstatbin} -rn | ${grepbin} "^0.0.0.0 " | ${sedbin} -e "s/ */ /g" | ${cutbin} -d\ -f2 -s`; localpeer=`echo ${localpeer}`
6583 [ "a${localpeer}" != "a" ] && localtext=`format_text "Default route(s):\t%s\n" "${localpeer}"`
6584 [ "a${localtext}" != "a" ] && infotext=`${printfbin} "%s\n%s\n" "${infotext}" "${localtext}"`; unset localtext
6585 unset localpeer
6586 fi
6587 [ "a${SGUI}" != "azenity" ] && infotext=`echo "${infotext}" | ${sedbin} -e "s/\( *\)/ /g"`
6588 notify "%s\n" "${infotext}"
6589 else
6590 infotext=`echo "${infotext}" | ${sedbin} -e "s/\( *\)/ /g"`
6591 ${printfbin} "%s\n" "${infotext}"
6592 fi
6593 unset localtext; unset infotext
6594 return 0
6595 }
6596
6597 action_desktop() {
6598 # Retrieve icon information if possible
6599 [ "a${runner}" = "a" ] && return 1
6600 [ "a${runhome}" = "a" ] && return 1
6601 [ ! -d "${runhome}" ] && return 1
6602 need_binary "touch"; need_binary "mkdir"; need_binary "chown"; need_binary "chmod"; need_binary "cat"
6603 unset desktopdestination
6604 if [ "a${DESKTOP}" = "a" ] && find_binary "xdg-user-dir"; then
6605 DESKTOP=`${xdg_user_dirbin} DESKTOP`
6606 [ "a${DESKTOP}" = "a" ] && DESKTOP=`${xdg_user_dirbin} desktop`
6607 if [ "a${DESKTOP}" != "a" ]; then
6608 DESKTOP=`echo "${DESKTOP}" | ${sedbin} -e "s/\/$//g"`
6609 DESKTOP=`${basenamebin} "${DESKTOP}"`
6610 fi
6611 fi
6612 if [ "a${DESKTOP}" != "a" ] && [ -d "${DESKTOP}" ]; then
6613 desktopdestination="${DESKTOP}"
6614 elif [ -d "${runhome}/Desktop" ]; then
6615 desktopdestination="${runhome}/Desktop"
6616 elif [ -d "${runhome}/desktop" ]; then
6617 desktopdestination="${runhome}/desktop"
6618 elif [ "a${HOME}" != "a" -a "a${DESKTOP}" != "a" ] && [ -d "${HOME}/${DESKTOP}" ]; then
6619 desktopdestination="${HOME}/${DESKTOP}"
6620 elif find_binary "pwd"; then
6621 desktopdestination="`${pwdbin} 2> /dev/null`"
6622 else
6623 desktopdestination="."
6624 fi
6625 [ "a${desktopdestination}" = "a" ] && desktopdestination="."
6626 debug "Destination of shortcut is: %s\n" "${desktopdestination}"
6627 if status_connected && [ "a${statusicon}" != "a" -a "a${statusname}" != "a" ] && find_binary "wget" && find_binary "basename"; then
6628 user_select "DESKTOPICON" "Desktop icon" "Select icon to use for shortcut" "OK" "Cancel" "SAKIS3G" "Sakis3G tux icon" "OPERATOR" "${statusname} icon"
6629 selection=$?
6630 case "${selection}" in
6631 1)
6632 DESKTOPICON="SAKIS3G"
6633 ;;
6634 2)
6635 DESKTOPICON="OPERATOR"
6636
6637
6638 ;;
6639 98)
6640 return 98
6641 ;;
6642 *)
6643 return 99
6644 ;;
6645 esac
6646 else
6647 debug "${statusicon} ${statusname}\n"
6648 debug "Automatically selecting %s icon.\n" "Sakis3G"
6649 DESKTOPICON="SAKIS3G"
6650 fi
6651 if [ "a${DESKTOPICON}" = "aOPERATOR" ]; then
6652 extension=`${basenamebin} "${statusicon}" | ${cutbin} -d. -f2-`
6653 verbose "Retrieving operator icon"
6654 debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6655 debug run_command "${wgetbin} -O \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\" \"${statusicon}\""
6656 if [ ! -s "/tmp/sakis3g.$$.${ISPID}_logo.${extension}" ]; then
6657 debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6658 show_fmt_error "Unable to get %s icon, unknown reason." "${statusname}"
6659 DESKTOPICON="SAKIS3G"
6660 else
6661 debug "Successfully retrieved %s icon.\n" "operator"
6662 fi
6663 fi
6664 if [ "a${DESKTOPICON}" = "aSAKIS3G" ] && [ "a${PROVIDER}" != "a" ] && [ -x "${PROVIDER}" ]; then
6665 extension="png"
6666 "${PROVIDER}" getfile "files/sakis3g.png" > "/tmp/sakis3g.$$.${ISPID}_logo.${extension}" 2> /dev/null
6667 if [ ! -s "/tmp/sakis3g.$$.${ISPID}_logo.${extension}" ]; then
6668 debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6669 show_fmt_error "Unable to get %s icon, unknown reason." "Sakis3G"
6670 DESKTOPICON=""
6671 else
6672 debug "Successfully retrieved %s icon.\n" "Sakis3G"
6673 fi
6674 fi
6675 if [ -s "/tmp/sakis3g.$$.${ISPID}_logo.${extension}" ]; then
6676 debug run_command "${mkdirbin} -p \"${runhome}/.local\""
6677 debug run_command "${chownbin} ${runner} \"${runhome}/.local\""
6678 debug run_command "${mkdirbin} -p \"${runhome}/.local/share\""
6679 debug run_command "${chownbin} ${runner} \"${runhome}/.local/share\""
6680 debug run_command "${mkdirbin} -p \"${runhome}/.local/share/icons\""
6681 debug run_command "${chownbin} ${runner} \"${runhome}/.local/share/icons\""
6682 if [ "a${extension}" = "agif" -o "a${extension}" = "aGIF" -o "a${extension}" = "aGif" ]; then
6683 debug run_command "${mvbin} \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\" \"${runhome}/.local/share/icons/sakis3g.png\""
6684 debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6685 extension="png"
6686 else
6687 debug run_command "${mvbin} \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\" \"${runhome}/.local/share/icons/sakis3g.${extension}\""
6688 debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6689 fi
6690 if [ -s "${runhome}/.local/share/icons/sakis3g.${extension}" ]; then
6691 debug run_command "${chownbin} ${runner} \"${runhome}/.local/share/icons/sakis3g.${extension}\""
6692 debug run_command "${chmodbin} 644 \"${runhome}/.local/share/icons/sakis3g.${extension}\""
6693 icon="${runhome}/.local/share/icons/sakis3g.${extension}"
6694 debug "Successfully installed icon to \"%s\".\n" "${runhome}/.local/share/icons/sakis3g.${extension}"
6695 fi
6696 else
6697 debug "File %s does not exist or is empty.\n" "/tmp/sakis3g.$$.${ISPID}_logo.${extension}"
6698 [ -f "/tmp/sakis3g.$$.${ISPID}_logo.${extension}" ] && debug run_command "${rmbin} -f \"/tmp/sakis3g.$$.${ISPID}_logo.${extension}\""
6699 if [ -f "/usr/share/icons/gnome/scalable/status/nm-device-wireless.svg" ]; then
6700 debug "Selecting default GNOME icon.\n"
6701 icon="/usr/share/icons/gnome/scalable/status/nm-device-wireless.svg"
6702 else
6703 debug "Unable to locate any icon.\n"
6704 icon=""
6705 fi
6706 fi
6707 debug "Icon selected is: %s\n" "${icon}"
6708 shortcuttitle="Sakis3G"
6709 [ "a${DESKTOPICON}" = "aOPERATOR" ] && shortcuttitle="${statusproduct}" && [ "a${shortcuttitle}" = "a" ] && shortcuttitle="${statusname} Internet"
6710 [ "a${shortcuttitle}" = "a" ] && shortcuttitle="Sakis3G"
6711 commenttext=`format_text "Manages 3G internet connection and 3G USB modems"`
6712 ${catbin} > "${desktopdestination}/sakis3g.desktop" <<endl
6713 [Desktop Entry]
6714 Version=1.0
6715 Encoding=UTF-8
6716 Type=Application
6717 Terminal=false
6718 Name=${shortcuttitle}
6719 Name[en_US]=${shortcuttitle}
6720 Exec=${ME} clicked
6721 Comment=${commenttext}
6722 Comment[en_US]=${commenttext}
6723 Icon=${icon}
6724 Icon[en_US]=${icon}
6725 GenericName=
6726 GenericName[en_US]=
6727 endl
6728 debug run_command "${catbin} \"${desktopdestination}/sakis3g.desktop\""
6729 unset commenttext; unset shortcuttitle
6730 if [ -s "${desktopdestination}/sakis3g.desktop" ]; then
6731 debug run_command "${chownbin} ${runner} \"${desktopdestination}/sakis3g.desktop\""
6732 debug run_command "${chmodbin} 750 \"${desktopdestination}/sakis3g.desktop\""
6733 debug run_command "${lsbin} \"${desktopdestination}/sakis3g.desktop\""
6734 finalnotify "Desktop shortcut created at %s." "${desktopdestination}/sakis3g.desktop"
6735 unset desktopdestination
6736 return 0
6737 else
6738 debug run_command "${rmbin} -f \"${desktopdestination}/sakis3g.desktop\""
6739 unset desktopdestination
6740 return 1
6741 fi
6742 }
6743
6744 action_modem() {
6745 unset verbosecurrentcount
6746 flow_select_modem "$@"
6747 ret=$?
6748 if [ "a${ret}" = "a0" ]; then
6749 finalnotify "Modem selected.\n"
6750 return 0
6751 else
6752 show_fmt_error "No modem selected.\n"
6753 return ${ret}
6754 fi
6755 }
6756
6757 action_switch() {
6758 unset verbosecurrentcount
6759 flow_switch "$@"
6760 ret=$?
6761 if [ "a${ret}" = "a0" ]; then
6762 if [ "a${NEWIDS}" = "a" ]; then
6763 finalnotify "Modem switched.\n"
6764 else
6765 finalnotify "Modem switched to %s.\n" "${NEWIDS}"
6766 fi
6767 return 0
6768 else
6769 show_fmt_error "Failed to switch.\n"
6770 return ${ret}
6771 fi
6772 }
6773
6774 action_setup() {
6775 unset verbosecurrentcount
6776 flow_setup "$@"
6777 ret=$?
6778 if [ "a${ret}" = "a0" ]; then
6779 finalnotify "Modem setup residing on %s.\n" "${MODEM_TTY}"
6780 return 0
6781 else
6782 show_fmt_error "Failed to setup modem.\n"
6783 return ${ret}
6784 fi
6785 }
6786
6787 action_prepare() {
6788 unset verbosecurrentcount
6789 flow_prepare "$@"
6790 ret=$?
6791 if [ "a${ret}" = "a0" ]; then
6792 finalnotify "Modem on %s is registered to %s.\n" "${MODEM_TTY}" "${ISPTEXT}"
6793 return 0
6794 else
6795 show_fmt_error "Failed to prepare modem.\n"
6796 return ${ret}
6797 fi
6798 }
6799
6800 action_connect() {
6801 unset verbosecurrentcount
6802 flow_connect "$@"
6803 ret=$?
6804 if [ "a${ret}" = "a0" ]; then
6805 action_status "$@"
6806 return 0
6807 else
6808 show_fmt_error "Failed to connect.\n"
6809 return ${ret}
6810 fi
6811 }
6812
6813 action_compile() {
6814 unset verbosecurrentcount
6815 flow_compile "$@"
6816 ret=$?
6817 if [ "a${ret}" = "a0" ]; then
6818 finalnotify "Succesfully recompiled.\n"
6819 return 0
6820 else
6821 return ${ret}
6822 fi
6823 }
6824
6825 action_disconnect() {
6826 unset verbosecurrentcount
6827 if ! ppp_fast_status; then
6828 finalnotify "Not connected.\n"
6829 return 0
6830 fi
6831 flow_disconnect "$@"
6832 ret=$?
6833 if [ "a${ret}" = "a0" ]; then
6834 finalnotify "Disconnected.\n"
6835 return 0
6836 else
6837 show_fmt_error "Failed to disconnect.\n"
6838 return ${ret}
6839 fi
6840 }
6841
6842 action_reconnect() {
6843 unset verbosecurrentcount
6844 unset disconnectedbefore
6845 if ppp_fast_status; then
6846 status_connected
6847 flow_disconnect "$@"
6848 ret=$?
6849 if [ "${ret}" -ne "0" ]; then
6850 show_fmt_error "Failed to disconnect.\n"
6851 return ${ret}
6852 fi
6853 disconnectedbefore=1
6854 fi
6855 flow_connect "$@"
6856 ret=$?
6857 if [ "a${ret}" = "a0" -a "a${disconnectedbefore}" = "a1" ]; then
6858 unset disconnectedbefore
6859 finalnotify "Reconnected to %s.\n" "${ISPTEXT}"
6860 return 0
6861 elif [ "a${ret}" = "a0" ]; then
6862 action_status "$@"
6863 return 0
6864 else
6865 unset disconnectedbefore
6866 show_fmt_error "Failed to connect.\n"
6867 return ${ret}
6868 fi
6869 }
6870
6871 action_toggle() {
6872 unset verbosecurrentcount
6873 unset disconnectedbefore
6874 if ppp_fast_status; then
6875 action_disconnect "$@"
6876 ret=$?
6877 else
6878 action_connect "$@"
6879 ret=$?
6880 fi
6881 return ${ret}
6882 }
6883
6884 action_clicked() {
6885 unset verbosecurrentcount
6886 unset ret; unset tester
6887 tester="${SGUI}"; [ "a${tester}" = "a" ] && tester="terminal"
6888 case "${SGUI}" in
6889 zenity|dialog|Xdialog|whiptail|kdialog)
6890 action_menu "$@"
6891 ret=$?
6892 ;;
6893 "9menu")
6894 action_menu "$@"
6895 ret=$?
6896 ;;
6897 terminal|"interactive terminal")
6898 if [ "a${interactive}" = "a" ]; then
6899 action_toggle "$@"
6900 ret=$?
6901 else
6902 unset interactive
6903 action_toggle "$@"
6904 ret=$?
6905 export interactive=yes
6906 fi
6907 ;;
6908 esac
6909 return ${ret}
6910 }
6911
6912 # Method invoked when "more" action was requested.
6913 action_more() {
6914 unset verbosecurrentcount
6915 unset usboptions; [ "a${binaryfree}" = "a" ] && usboptions="\"COMPILE\" \"Compile embedded Usb-ModeSwitch\""
6916 alwaysoptions="\"DESKTOP\" \"Create desktop shortcut\" \"ABOUT\" \"About Sakis3G\" \"HELP\" \"Show help\" \"EXIT\" \"Exit\""
6917 if ppp_fast_status; then
6918 stateoptions="\"DISCONNECT\" \"Disconnect\" \"RECONNECT\" \"Disconnect and then connect again\" \"INFO\" \"Connection information\" \"REPORT\" \"Generate success report\""
6919 else
6920 stateoptions="\"CONNECT\" \"Connect with 3G\" \"PREPARE\" \"Only prepare modem (Setup + PIN unlock + Register Network + Update HAL)\" \"SETUP\" \"Only setup modem (Switch + Load module + Setup tty)\" \"SWITCH\" \"Only switch modem (if applicable)\""
6921 fi
6922 eval user_select \"MOREMENU\" \"Please select an action\" \"Choose action for Sakis3G script to follow.\" \"OK\" \"Cancel\" ${stateoptions} ${usboptions} ${alwaysoptions}
6923 # in
6924 ret=$?
6925 unset usboptions; unset alwaysoptions; unset stateoptions
6926 case "${ret}" in
6927 99)
6928 return 99
6929 ;;
6930 98)
6931 debug "No action selected.\n"
6932 # Instead of returning 98, returns 0 to allow chaining of actors
6933 # EXIT menu item is used from breaking chain
6934 unset MOREMENU
6935 return 0
6936 ;;
6937 *)
6938 case "a${MOREMENU}" in
6939 aCONNECT)
6940 action_connect "$@"
6941 ;;
6942 aDISCONNECT)
6943 action_disconnect "$@"
6944 ;;
6945 aRECONNECT)
6946 action_reconnect "$@"
6947 ;;
6948 aPREPARE)
6949 action_prepare "$@"
6950 ;;
6951 aSETUP)
6952 action_setup "$@"
6953 ;;
6954 aSWITCH)
6955 action_switch "$@"
6956 ;;
6957 aCOMPILE)
6958 action_compile "$@"
6959 ;;
6960 aDESKTOP)
6961 action_desktop "$@"
6962 ;;
6963 aINFO)
6964 action_info "$@"
6965 ;;
6966 aREPORT)
6967 action_report "$@"
6968 ;;
6969 aHELP)
6970 show_help
6971 ;;
6972 aABOUT)
6973 action_about "$@"
6974 ;;
6975 aEXIT)
6976 unset MOREMENU
6977 return 98
6978 ;;
6979 a)
6980 unset MOREMENU
6981 return 98
6982 ;;
6983 *)
6984 show_fmt_error "Option %s not implemented.\n" "${MOREMENU}"
6985 ;;
6986 esac
6987 ;;
6988 esac
6989 unset MOREMENU
6990 action_more "$@"
6991 return $?
6992 }
6993
6994 # Method invoked when "menu" action was requested.
6995 action_menu() {
6996 unset verbosecurrentcount
6997 if ppp_fast_status; then
6998 menuoptions="\"DISCONNECT\" \"Disconnect\" \"INFO\" \"Connection information\" \"DESKTOP\" \"Create shortcut\""
6999 else
7000 menuoptions="\"CONNECT\" \"Connect with 3G\""
7001 fi
7002 menuoptions="${menuoptions} \"MOREMENU\" \"More options...\" \"ABOUT\" \"About Sakis3G\""
7003 menuoptions="${menuoptions} \"EXIT\" \"Exit\""
7004 eval user_select \"MENU\" \"Please select an action\" \"Choose action for Sakis3G script to follow.\" \"OK\" \"Cancel\" ${menuoptions}
7005 # in
7006 ret=$?; unset menuoptions
7007 case "${ret}" in
7008 99)
7009 return 99
7010 ;;
7011 98)
7012 debug "No action selected.\n"
7013 # Instead of returning 98, returns 0 to allow chaining of actors
7014 # EXIT menu item is used from breaking chain
7015 return 0
7016 ;;
7017 *)
7018 case "a${MENU}" in
7019 aCONNECT)
7020 action_connect "$@"
7021 ;;
7022 aDISCONNECT)
7023 action_disconnect "$@"
7024 ;;
7025 aMOREMENU)
7026 action_more "$@"
7027 ret=$?; [ "a${ret}" = "a98" ] && unset MENU && return 98
7028 ;;
7029 aINFO)
7030 action_info "$@"
7031 ;;
7032 aDESKTOP)
7033 action_desktop "$@"
7034 ;;
7035 aHELP)
7036 show_help
7037 ;;
7038 aABOUT)
7039 action_about "$@"
7040 ;;
7041 aEXIT)
7042 debug "Breaking chain.\n"
7043 unset MENU
7044 return 98
7045 ;;
7046 a)
7047 unset MENU
7048 return 98
7049 ;;
7050 *)
7051 show_fmt_error "Option %s not implemented.\n" "${MENU}"
7052 ;;
7053 esac
7054 ;;
7055 esac
7056 unset MENU
7057 action_menu "$@"
7058 return $?
7059 }
7060
7061 helper_cleaner() {
7062 [ -f "/tmp/sakis3g.helper.icon.green.$$.png" ] && ${rmbin} -f "/tmp/sakis3g.helper.icon.green.$$.png"
7063 [ -f "/tmp/sakis3g.helper.icon.red.$$.png" ] && ${rmbin} -f "/tmp/sakis3g.helper.icon.red.$$.png"
7064 [ -f "/tmp/sakis3g.helper.icon.yellow.$$.png" ] && ${rmbin} -f "/tmp/sakis3g.helper.icon.yellow.$$.png"
7065 [ "a${helperpid}" != "a" ] && ! notrunning "${helperpid}" && ${killbin} -1 ${helperpid} 2> /dev/null > /dev/null
7066 [ "a${helperpid}" != "a" ] && ! notrunning "${helperpid}" && ${killbin} -9 ${helperpid} 2> /dev/null > /dev/null
7067 if [ "a${balloons}" != "a" ] && [ "a${BALOONIZERPID}" != "a" -o "a${BALOONIZER}" != "a" ]; then
7068 [ "a${BALOONIZER}" != "a" ] && [ -f "${BALOONIZER}" ] && debug run_command "${rmbin} -f \"${BALOONIZER}\""
7069 [ "a${BALOONIZERPID}" != "a" ] && ! notrunning "${BALOONIZERPID}" && debug run_command "${killbin} -1 ${BALOONIZERPID}"
7070 [ "a${BALOONIZERPID}" != "a" ] && ! notrunning "${BALOONIZERPID}" && debug run_command "${killbin} -9 ${BALOONIZERPID}"
7071 find_binary "ps" && tailpid=`${psbin} -A -o pid,command | ${grepbin} "${tailbin} -f ${BALOONIZER}" | ${grepbin} -v "${grepbin}" | ${cutbin} -d\ -f1`
7072 [ "a${tailpid}" != "a" ] && ! notrunning "${tailpid}" && debug run_command "${killbin} -1 ${tailpid}"
7073 [ "a${tailpid}" != "a" ] && ! notrunning "${tailpid}" && debug run_command "${killbin} -9 ${tailpid}"
7074 unset BALOONIZERPID; unset BALOONIZER
7075 fi
7076 }
7077
7078 action_helper() {
7079 if ! find_binary "zenity"; then
7080 show_fmt_error "Unable to install tray icon to system notification area. You need to install %s.\n" "zenity"
7081 return 0
7082 fi
7083 need_binary "kill"
7084 [ "a${PROVIDER}" = "a" ] && return 1
7085 [ ! -x "${PROVIDER}" ] && return 1
7086 if we_are_root_already && [ "a${MENU}" != "a" ]; then
7087 debug "Calling menu since state variable MENU is set.\n"
7088 action_menu "$@"
7089 unset MENU
7090 debug "MENU actor returned. Will now run as helper.\n"
7091 fi
7092 debug run_command "${rmbin} -f /tmp/sakis3g.helper.icon.red.$$.png /tmp/sakis3g.helper.icon.green.$$.png /tmp/sakis3g.helper.icon.yellow.$$.png"
7093 addexittrap helper_cleaner
7094 ${PROVIDER} getfile files/sakis3g.red.png > "/tmp/sakis3g.helper.icon.red.$$.png" 2> /dev/null
7095 ${PROVIDER} getfile files/sakis3g.green.png > "/tmp/sakis3g.helper.icon.green.$$.png" 2> /dev/null
7096 ${PROVIDER} getfile files/sakis3g.yellow.png > "/tmp/sakis3g.helper.icon.yellow.$$.png" 2> /dev/null
7097 if [ ! -s "/tmp/sakis3g.helper.icon.green.$$.png" ]; then
7098 debug "Failed to retrieve green/connected state icon.\n"
7099 return 1
7100 elif [ ! -s "/tmp/sakis3g.helper.icon.red.$$.png" ]; then
7101 debug "Failed to retrieve red/no hardware state icon.\n"
7102 return 1
7103 elif [ ! -s "/tmp/sakis3g.helper.icon.yellow.$$.png" ]; then
7104 debug "Failed to retrieve yellow/not connected state icon.\n"
7105 return 1
7106 fi
7107 debug run_command "${chmodbin} 644 \"/tmp/sakis3g.helper.icon.red.$$.png\""
7108 debug run_command "${chmodbin} 644 \"/tmp/sakis3g.helper.icon.green.$$.png\""
7109 debug run_command "${chmodbin} 644 \"/tmp/sakis3g.helper.icon.yellow.$$.png\""
7110 if [ "a${balloons}" != "a" ]; then
7111 # Establish balloon helper now that will be accessible from root session later
7112 if [ "a${BALOONIZER}" = "a" ]; then
7113 BALOONIZER="/tmp/sakis3g.baloon.pipe.$$"
7114 debug run_command "${rmbin} -f \"${BALOONIZER}\""
7115 debug run_command "${touchbin} -f \"${BALOONIZER}\""
7116 if [ -w "${BALOONIZER}" ]; then
7117 ${printfbin} "\n\n\n\n\nvisible:false\n" >> "${BALOONIZER}"
7118 export BALOONIZER
7119 eval ${tailbin} -f "${BALOONIZER}" "2> /dev/null" | ${zenitybin} --notification --listen > /dev/null 2> /dev/null &
7120 BALOONIZERPID=$!; eval "disown -a" > /dev/null 2> /dev/null
7121 export BALOONIZERPID
7122 ${printfbin} "visible:false\n" >> "${BALOONIZER}"
7123 ${printfbin} "visible:false\nvisible:false\n" >> "${BALOONIZER}"
7124 debug "Balloon pipe created. Location is \"%s\" and runs with PID %d.\n" "${BALOONIZER}" "${BALOONIZERPID}"
7125 else
7126 debug "Error while creating pipe for balloons.\n"
7127 debug run_command "${rmbin} -f \"${BALOONIZER}\""
7128 unset BALOONIZER
7129
7130 fi
7131 elif [ -w "${BALOONIZER}" ]; then
7132 debug "Will be using already existing balloon pipe: %s\n" "${BALOONIZER}"
7133 elif [ ! -w "${BALOONIZER}" ]; then
7134 debug "Balloons pipe \"%s\" exists but no write access granted.\n" "${BALOONIZER}"
7135 fi
7136 [ "a${BALOONIZER}" = "a" ] && debug "No balloons will be appearing.\n"
7137 fi
7138 debug "All set. Going into helper mode.\n"
7139 while [ "1" = "1" ]
7140 do
7141 if ppp_slow_status && status_connected; then
7142 helpertext="`translate_text "Connected"`"
7143 [ "a${statusname}" != "a" ] && helpertext="${statusname}"
7144 helperconnected=2
7145 else
7146 usb_connected_modems
7147 if [ "a${usb_modem_devices}" != "a" ]; then
7148 helpertext="`translate_text "Not connected"`"
7149 helperconnected=1
7150 helpermodems=`echo "${usb_modem_devices}" | ${cutbin} -d: -f3- | ${trbin} "\n" " "`
7151 else
7152 helpertext="`translate_text "No USB modem"`"
7153 helperconnected=0
7154 fi
7155 fi
7156 # Check if something was changed not by us. Then balloon user.
7157 if [ "a${balloons}" != "a" ]; then
7158 if [ "a${BALOONIZER}" != "a" ] && [ "a${previousstatus}" != "a" -a "a${previousstatus}" != "a${helperconnected}" ]; then
7159 debug "Status changed. Not by us.\n"
7160 notificationtext=`translate_text "Notification"`
7161 if [ "a${helperconnected}" = "a2" ]; then
7162 iconpath="/tmp/sakis3g.helper.icon.green.$$.png"
7163 elif [ "a${helperconnected}" = "a1" ]; then
7164 iconpath="/tmp/sakis3g.helper.icon.yellow.$$.png"
7165 elif [ "a${helperconnected}" = "a0" ]; then
7166 iconpath="/tmp/sakis3g.helper.icon.red.$$.png"
7167 else
7168 iconpath="/tmp/sakis3g.helper.icon.yellow.$$.png"
7169 fi
7170 unset largetext; unset smalltext
7171 if [ "a${previousstatus}" = "a0" -a "a${helperconnected}" = "a1" ]; then
7172 largetext=`translate_text "USB Modem plugged"`
7173 smalltext=`format_text "USB Modem %s is now plugged on computer." "${helpermodems}"`
7174 elif [ "a${helperconnected}" = "a2" ]; then
7175 largetext=`translate_text "Connected"`
7176 if [ "a${MODEM_VARIANT}" != "a" -a "a${statusname}" != "a" ]; then
7177 smalltext=`format_text "Modem %s is now connected to %s." "${MODEM_VARIANT}" "${statusname}"`
7178 elif [ "a${MODEM_VARIANT}" != "a" ]; then
7179 smalltext=`format_text "Modem %s is now connected." "${MODEM_VARIANT}"`
7180 elif [ "a${statusname}" != "a" ]; then
7181 smalltext=`format_text "You are now connected to %s." "${statusname}"`
7182 else
7183 smalltext=`translate_text "Computer is now connected.\n"`
7184 fi
7185 elif [ "a${previousstatus}" = "a1" -a "a${helperconnected}" = "a0" ]; then
7186 largetext=`translate_text "USB Modem Unplugged"`
7187 smalltext=`translate_text "No USB modem is anymore plugged on computer."`
7188 elif [ "a${previousstatus}" = "a2" ]; then
7189 largetext=`translate_text "Disconnected"`
7190 if [ "a${helperconnected}" = "a0" ]; then
7191 smalltext=`translate_text "You were disconnected due to modem being unplugged."`
7192 elif [ "a${helperconnected}" = "a1" ]; then
7193 smalltext=`translate_text "You are now disconnected from operator."`
7194 fi
7195 fi
7196 debug "Will display baloon:\nIcon: %s\nTitle: %s\nMessage: %s\n" "${iconpath}" "${largetext}" "${smalltext}"
7197 if [ "a${smalltext}" != "a" -a "a${largetext}" != "a" ]; then
7198 ${printfbin} "icon:%s\n" "${iconpath}" >> "${BALOONIZER}" 2> /dev/null
7199 ${printfbin} "tooltip:%s\n" "${notificationtext}" >> "${BALOONIZER}" 2> /dev/null
7200 ${printfbin} "visible:true\n" >> "${BALOONIZER}" 2> /dev/null
7201 ${printfbin} "message:%s\\\n<small>%s</small>\n" "${largetext}" "${smalltext}" >> "${BALOONIZER}" 2> /dev/null
7202 ${printfbin} "visible:false\n" >> "${BALOONIZER}" 2> /dev/null
7203 fi
7204 unset iconpath; unset smalltext; unset largetext; unset notificationtext
7205 fi
7206 previousstatus="${helperconnected}"
7207 fi
7208 if [ "a${helpertext}" != "a${announcedtext}" -a "a${helperpid}" != "a" ] && ! notrunning "${helperpid}"; then
7209 [ "a${helperpid}" != "a" ] && ! notrunning "${helperpid}" && ${killbin} -1 ${helperpid} 2> /dev/null > /dev/null
7210 [ "a${helperpid}" != "a" ] && ! notrunning "${helperpid}" && ${killbin} -9 ${helperpid} 2> /dev/null > /dev/null
7211 notrunning "${helperpid}" && unset helperpid
7212 fi
7213 if [ "a${helperpid}" = "a" ]; then
7214 if [ "a${helperconnected}" = "a2" ]; then
7215 ${zenitybin} --notification --window-icon=/tmp/sakis3g.helper.icon.green.$$.png --text="${helpertext}" > /dev/null 2> /dev/null &
7216 elif [ "a${helperconnected}" = "a1" ]; then
7217 ${zenitybin} --notification --window-icon=/tmp/sakis3g.helper.icon.yellow.$$.png --text="${helpertext}" > /dev/null 2> /dev/null &
7218 elif [ "a${helperconnected}" = "a0" ]; then
7219 ${zenitybin} --notification --window-icon=/tmp/sakis3g.helper.icon.red.$$.png --text="${helpertext}" > /dev/null 2> /dev/null &
7220 else
7221 ${zenitybin} --notification --text="${helpertext}" > /dev/null 2> /dev/null &
7222 fi
7223 helperpid=$!;
7224 eval "disown -a" > /dev/null 2> /dev/null
7225 announcedtext="${helpertext}"
7226 export helperpid
7227 elif notrunning "${helperpid}"; then
7228 unset helperpid; unset previousstatus
7229 debug "User clicked on icon.\n"
7230 action_menu "$@"; ret=$?
7231 if [ "${ret}" -eq "98" ]; then
7232 if [ "a${forever}" != "a" ]; then
7233 debug "User selected exit on MENU. However, \"forever\" is set.\n"
7234 unset MENU; unset MOREMENU;
7235 else
7236 debug "User selected exit on MENU. Will ask for confirmation to exit.\n"
7237 #${zenitybin} --question --title="`translate_text "Confirm exit"`" --text="`translate_text "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?"`"
7238 #ret=$?
7239 #if [ "a${ret}" = "a0" ]; then
7240 if user_confirm "helperexit" "Confirm exit" "Exiting will also remove tray icon. Are you sure you want to exit Sakis3G?" "Yes" "No" "reset"; then
7241 debug "User confirmed he wants to exit. Helper will die.\n"
7242 break
7243 else
7244 debug "User did not confirm.\n"
7245 unset MENU; unset MOREMENU
7246 fi
7247 fi
7248 fi
7249 debug "Resuming helper operation.\n"
7250 else
7251 debug "Helper is sleeping for a second.\n"
7252 sleep 1
7253 fi
7254 done
7255 helper_cleaner
7256 return 98
7257 }
7258
7259 # Method called when called as a helper to hold HAL lock
7260 action_holdlock() {
7261 unset verbosecurrentcount
7262 [ "a$2" != "a" ] && [ -f "$2" ] && checkfile="$2" && echo "$$" > "${checkfile}"
7263 unset TRAPS
7264 while [ "1" = "1" ]
7265 do
7266 if [ "a${PROVIDER}" = "a" ]; then
7267 ppppp=`ps -p $$ -o ppid=`
7268 else
7269 ppppp=`ps -p $$ -o ppid=`
7270 ppppp=`ps -p ${ppppp} -o ppid=`
7271 fi
7272 ppppp=`echo $ppppp`
7273 [ "a${ppppp}" = "a1" ] && exit 0
7274 [ "a${ppppp}" = "a${PPID}" ] && exit 0
7275 [ "a${checkfile}" != "a" ] && [ ! -f "${checkfile}" ] && exit 0
7276 #echo $ppppp
7277 sleep 1
7278 done
7279 }
7280
7281 action_state() {
7282 unset verbosecurrentcount
7283 state_variables "SGUI interactive stick_to_console DEBUG LOCALAUTHORITY BALOONIZER"
7284 notify "To automatically repeat result of last action, use following command line:\n%s\n" "${ME} ${actors} ${statevariables}"
7285 return 0
7286 }
7287
7288 action_udevrule() {
7289 unset verbosecurrentcount
7290 state_variables "SGUI MODEM interactive stick_to_console USBMODEM OTHER DEBUG LOCALAUTHORITY BALOONIZER"
7291 # statevariables=`echo "${statevariables}" | ${sedbin} -e "s/\"/\\\\\\\\\"/g"`
7292 statevariables=`echo "${statevariables}" | ${sedbin} -e "s/\"//g"`
7293 unset content
7294 candidates="${MODEM}"
7295 [ "a${candidates}" = "aOTHER" ] && unset candidates
7296 [ "a${candidates}" = "aOTHER" -a "a${OTHER}" = "aUSBMODEM" -a "a${USBMODEM}" != "a" ] && candidates="${USBMODEM}"
7297 localactors=`echo ${actors}`
7298 for candidate in ${candidates}
7299 do
7300 modemvendor=`echo ${candidate} | ${cutbin} -d: -f1 -s`
7301 modemproduct=`echo ${candidate} | ${cutbin} -d: -f2 -s`
7302 if [ "a${modemvendor}" != "a" -a "a${modemproduct}" != "a" ]; then
7303 content=`${printfbin} "%s\nACTION==\"add\", SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%s\", ATTRS{idProduct}==\"%s\", ATTRS{bInterfaceNumber}==\"00\", RUN+=\"%s %s %s MODEM=OTHER OTHER=USBMODEM USBMODEM=%s:%s\"\n\n" "${content}" "${modemvendor}" "${modemproduct}" "${ME}" "${localactors}" "${statevariables}" "${modemvendor}" "${modemproduct}"`
7304 break;
7305 fi
7306 done
7307 unset localactors; unset modemvendor; unset modemproduct; unset candidate; unset candidates; unset statevariables
7308 term_clearline
7309 if [ "a${content}" != "a" ]; then
7310 format_text "To automatically repeat result of last action, immediately upon device connection, include following line within a %s file within \"%s\" directory:\n%s\n" ".rules" "/etc/udev/rules.d/" "${content}"
7311 else
7312 format_text "No USB modem was selected. No need for a udev example.\n"
7313 fi
7314 unset content
7315 return 0
7316 }
7317
7318 action_about() {
7319 unset verbosecurrentcount
7320 notify "%s\n" "`show_version`"
7321 return 0
7322 }
7323
7324 show_man() {
7325 destination="$1"
7326 case "a${destination}" in
7327 ausb_modeswitch|ausb-modeswitch)
7328 destination="dependencies/usb-modeswitch/usb_modeswitch.1"
7329 ;;
7330 asakis3g.conf)
7331 destination="man/sakis3g.conf.5"
7332 ;;
7333 *)
7334 destination="man/sakis3g.1"
7335 ;;
7336 esac
7337 debug "Destination man page is: %s\n" "${destination}"
7338 [ "a${PROVIDER}" = "a" ] && return 1
7339 [ ! -x "${PROVIDER}" ] && return 1
7340 need_binary "man"
7341 need_binary "rm"
7342 "${PROVIDER}" getfile "${destination}" > "/tmp/sakis3g.man.$$"
7343 debug "Will now display man page %s.\n" "${destination}"
7344 [ -s "/tmp/sakis3g.man.$$" ] && ${manbin} -l "/tmp/sakis3g.man.$$"
7345 ${rmbin} -f "/tmp/sakis3g.man.$$"
7346 return 0
7347 }
7348
7349 action_report() {
7350 unset verbosecurrentcount
7351 flow_report "$@"
7352 ret=$?
7353 if [ "a${ret}" = "a0" ]; then
7354 return 0
7355 else
7356 return ${ret}
7357 fi
7358 }
7359
7360 # Executes actor $1 with the arguments
7361 run_action() {
7362 actioncandidate=$1
7363 [ "$#" -gt "0" ] && shift
7364 unset verbosecurrentcount
7365 newactors="${actors} ${actioncandidate}"
7366 case "${actioncandidate}" in
7367 about)
7368 action_about "$@"
7369 actionresult=$?
7370 ;;
7371 desktop)
7372 action_desktop "$@"
7373 actionresult=$?
7374 ;;
7375 helper)
7376 action_helper "$@"
7377 actionresult=$?
7378 ;;
7379 status)
7380 action_status "$@"
7381 actionresult=$?
7382 ;;
7383 connected)
7384 ppp_fast_status
7385 actionresult=$?
7386 ;;
7387 disconnected)
7388 if ppp_fast_status; then
7389 actionresult=99
7390 else
7391 actionresult=0
7392 fi
7393 ;;
7394 plugged)
7395 if usb_connected_modems; then
7396 actionresult=0
7397 else
7398 actionresult=99
7399 fi
7400 ;;
7401 unplugged)
7402 if usb_connected_modems; then
7403 actionresult=99
7404 else
7405 actionresult=0
7406 fi
7407 ;;
7408 switched)
7409 if usb_connected_modems; then
7410 if modeswitch_switchable_devices; then
7411 actionresult=99
7412 else
7413 actionresult=0
7414 fi
7415 else
7416 actionresult=0
7417 fi
7418 ;;
7419 switchable)
7420 if modeswitch_switchable_devices; then
7421 actionresult=0
7422 else
7423 actionresult=99
7424 fi
7425 ;;
7426 wait|sleep)
7427 debug "Sleeping for 1 second.\n"
7428 sleep 1
7429 actionresult=0
7430 ;;
7431 info)
7432 action_info "$@"
7433 actionresult=$?
7434 ;;
7435 clicked)
7436 action_clicked "$@"
7437 actionresult=$?
7438 ;;
7439 modem|select)
7440 action_modem "$@"
7441 actionresult=$?
7442 ;;
7443 switchonly)
7444 action_switch "$@"
7445 actionresult=$?
7446 ;;
7447 setup)
7448 action_setup "$@"
7449 actionresult=$?
7450 ;;
7451 prepare|init)
7452 action_prepare "$@"
7453 actionresult=$?
7454 ;;
7455 connect|start)
7456 action_connect "$@"
7457 actionresult=$?
7458 ;;
7459 toggle)
7460 action_toggle "$@"
7461 actionresult=$?
7462 ;;
7463 reconnect|restart)
7464 action_reconnect "$@"
7465 actionresult=$?
7466 ;;
7467 disconnect|stop)
7468 action_disconnect "$@"
7469 actionresult=$?
7470 ;;
7471 more|moremenu|menumore)
7472 action_more "$@"
7473 actionresult=$?
7474 ;;
7475 menu)
7476 action_menu "$@"
7477 actionresult=$?
7478 ;;
7479 state)
7480 action_state "$@"
7481 actionresult=$?
7482 ;;
7483 udevrule)
7484 action_udevrule "$@"
7485 actionresult=$?
7486 ;;
7487 compile|recompile)
7488 action_compile "$@"
7489 actionresult=$?
7490 ;;
7491 report)
7492 action_report "$@"
7493 actionresult=$?
7494 ;;
7495 *)
7496 newactors="${actors}"
7497 unset actioncandidate
7498 actionresult=0
7499 ;;
7500 esac
7501 actors="${newactors}"
7502 unset actioncandidate; unset newactors
7503 [ "a${actionresult}" = "a" ] && actionresult=99
7504 return ${actionresult}
7505 }
7506
7507 # Executes actors in the order defined
7508 action_command() {
7509 unset actors
7510 while [ "$#" -gt "0" ]
7511 do
7512 if [ "a${1}" = "anot" -o "a${1}" = "aNot" -o "a${1}" = "a!" ]; then
7513 [ "$#" -gt "0" ] && shift
7514 actors="${actors} not"
7515 run_action "$@"
7516 actionresult=$?
7517 if [ "${actionresult}" -eq "0" ]; then
7518 actionresult=99
7519 debug "Actor \"%s\" returned %d, \"not\" operator instructs to abort.\n" "${1}" "${actionresult}"
7520 break
7521 else
7522 debug "Actor \"%s\" returned %d, but was inverted by \"not\" operator.\n" "${1}" "${actionresult}"
7523 actionresult=0
7524 fi
7525 elif [ "a${1}" = "aignore" -o "a${1}" = "aIgnore" -o "a${1}" = "aignoring" -o "a${1}" = "aIgnoring" -o "a${1}" = "a|" ]; then
7526 [ "$#" -gt "0" ] && shift
7527 actors="${actors} ignore"
7528 run_action "$@"
7529 actionresult=$?
7530 if [ "${actionresult}" -ne "0" ]; then
7531 debug "Actor \"%s\" returned %d, \"ignore\" operator instructs to continue.\n" "${1}" "${actionresult}"
7532 actionresult=0
7533 fi
7534 elif [ "a${1}" != "a" ] && ! run_action "$@"; then
7535 debug "Aborting execution chain due to actor \"%s\" returning %d.\n" "${1}" "${actionresult}"
7536 break
7537 fi
7538 [ "$#" -gt "0" ] && shift
7539 done
7540 unset arg
7541 actors=`echo ${actors}`
7542 if [ "a${actors}" = "a" ]; then
7543 debug "No actors defined.\n"
7544 unset actors
7545 return 1
7546 else
7547 debug "Following actors executed: %s\n" "${actors}"
7548 unset actors
7549 return 0
7550 fi
7551 }
7552
7553 # Checks if arguments defined a dummy action and aborts if it does
7554 no_action_command() {
7555 for arg in $@
7556 do
7557 case "$arg" in
7558 --help|help)
7559 unset arg
7560 if find_binary "fold"; then
7561 if [ "a${COLUMNS}" != "a" ]; then
7562 raw_help | ${foldbin} -s -w "${COLUMNS}"
7563 else
7564 raw_help | ${foldbin} -s -w "80"
7565 fi
7566 else
7567 raw_help
7568 fi
7569 return 0
7570 ;;
7571 --version|version)
7572 unset arg
7573 show_version
7574 return 0
7575 ;;
7576 --holdlock|holdlock)
7577 unset arg
7578 action_holdlock "$@"
7579 return 0
7580 ;;
7581 usb_modeswitch)
7582 if [ "a${binaryfree}" != "a" ]; then
7583 show_fmt_error "You are running a binary free version of Sakis3G. This action is not available.\n"
7584 fi
7585 return 0
7586 ;;
7587 man)
7588 if [ "a${stripped}" != "a" ]; then
7589 show_fmt_error "You are running a stripped version of Sakis3G. This action is not available.\n"
7590 else
7591 shift
7592 show_man "$@"
7593 fi
7594 unset arg
7595 return 0
7596 ;;
7597 esac
7598 done
7599 unset arg
7600 return 1
7601 }
7602
7603 # When no actor defined, executes default actor of GUI selected.
7604 default_actor() {
7605 debug "Executing default actor for \"%s\".\n" "${SGUI}"
7606 if voodoo_mode; then
7607 debug "Voodoo actions will happen.\n"
7608 if action_connect "$@"; then
7609 actors="connect"
7610 action_state "$@"
7611 return $?
7612 else
7613 return $?
7614 fi
7615 fi
7616 case "${SGUI}" in
7617 whiptail|dialog|Xdialog|zenity|kdialog)
7618 action_menu "$@"
7619 return $?
7620 ;;
7621 "9menu")
7622 action_menu "$@"
7623 return $?
7624 ;;
7625 "interactive terminal")
7626 action_menu "$@"
7627 return $?
7628 ;;
7629 "terminal")
7630 show_help
7631 return $?
7632 ;;
7633 *)
7634 debug "No default actor for this GUI. Showing help.\n"
7635 show_help
7636 return $?
7637 ;;
7638 esac
7639 }
7640
7641 voodoo_mode() {
7642 [ "a${voodoo}" != "a" ] && return 0
7643 return 1
7644 }
7645
7646 guruplug_led() {
7647 if [ "a$1" = "anoexecute" ]; then
7648 noexecute=1
7649 shift
7650 elif [ "a$1" = "aall" ]; then
7651 shift
7652 guruplug_leds "$@"
7653 return 0
7654 else
7655 noexecute=0
7656 fi
7657 ledcolor=""; ledname=""; othercolor=""; otherled=""; ledblink=""; ledon=""; ledoff=""
7658 for ledarg in "$@"
7659 do
7660 case "a${ledarg}" in
7661 ared|aRED|aRed|aR|ar|"a${redcolor}")
7662 ledcolor="${redcolor}"
7663 othercolor="${othercolor} ${greencolor}"
7664 ;;
7665 agreen|aGREEN|aGreen|aG|ag|"a${greencolor}")
7666 ledcolor="${greencolor}"
7667 othercolor="${othercolor} ${redcolor}"
7668 ;;
7669 ablack|aBLACK|aBlack|aB|ab|anone|aNONE|aNone|aN|an|aNO|aNo|ano|aReset|aRESET|areset)
7670 ledcolor=""
7671 othercolor="${othercolor} ${redcolor} ${greencolor}"
7672 ;;
7673 aorange|aOrange|aORANGE|aO|ao|ayellow|aYellow|aYellow|aY|ay|aBOTH|aBoth|aboth)
7674 ledcolor="${ledcolors}"
7675 othercolor=""
7676 ;;
7677 aleft|aLEFT|aLeft|aL|al|"a${leftled}")
7678 ledname="${leftled}"
7679 otherled="${otherled}"
7680 ;;
7681 aright|aRIGHT|aRight|"a${rightled}")
7682 ledname="${rightled}"
7683 otherled="${otherled}"
7684 ;;
7685 ablink|aBlink|aBLINK)
7686 ledblink=1;
7687 ;;
7688 anand|aNAND|assd|aSSD|adisk|aDISK|aDisk|aNand|aSsd|anand-disk|ananddisk|assddisk|assd-disk)
7689 ledblink=2;
7690 ;;
7691 ammc|ammc0|aMMC|aMmc|aMMC0|acard|aCard|aCARD)
7692 ledblink=3;
7693 ;;
7694 *)
7695 ledcheck=`expr ${ledarg} + 1 - 1 2> /dev/null`
7696 if [ "a${ledcheck}" = "a${ledarg}" ]; then
7697 if [ "a${ledon}" = "a" ]; then
7698 ledon="${ledarg}"
7699 elif [ "a${ledoff}" = "a" ]; then
7700 ledoff="${ledarg}"
7701 fi
7702 fi
7703 ;;
7704 esac
7705 done
7706 if [ "a${ledcolor}${othercolor}" = "a" -o "a${ledname}" = "a" ]; then
7707 unset noexecute; unset ledarg; unset ledcolor; unset ledname; unset othercolor; unset otherled;
7708 unset color; unset oled; unset ledcommand; unset ledblink; unset ledmode; unset ledon; unset ledoff;
7709 return 1
7710 fi
7711 ledcommand=""
7712 for oled in ${otherled}
7713 do
7714 for color in ${ledcolors}
7715 do
7716 ledcommand="${ledcommand} echo \"none\" > \"${ledpath}/${color}:${oled}/trigger\";"
7717 ledcommand="${ledcommand} echo \"0\" > \"${ledpath}/${color}:${oled}/brightness\";"
7718 done
7719 done
7720 if [ "a${ledblink}" = "a1" ]; then
7721 unset othercolor
7722 ledmode="timer"
7723 [ "a${ledon}" = "a" ] && ledon=500
7724 [ "a${ledoff}" = "a" ] && ledoff=500
7725 if [ "a${ledcolor}" = "a" ]; then
7726 ttt="${ledon}"; ledon="${ledoff}"; ledoff="${ttt}"; unset ttt
7727 ledcheck=`guruplug_led_getstate "${ledname}" | ${grepbin} "_brightness=1" | ${sedbin} -e "s/^${ledname}_\(.*\)_brightness=1$/\1/g" | tr "\n" " "`
7728 ledcheck=`echo ${ledcheck}`
7729 for color in ${ledcolors}
7730 do
7731 colorname=`echo "${color}" | ${sedbin} -e "s/:/_/g"`
7732 if strinstr "${colorname}" "${ledcheck}" " "; then
7733 ledcolor="${ledcolor} ${color}"
7734 else
7735 othercolor="${othercolor} ${color}"
7736 fi
7737 done
7738 unset color; unset colorname; unset ledcheck
7739 fi
7740 [ "a${ledcolor}" = "a" ] && unset othercolor
7741 elif [ "a${ledblink}" = "a2" ]; then
7742 ledmode="nand-disk"
7743 elif [ "a${ledblink}" = "a3" ]; then
7744 ledmode="mmc0"
7745 else
7746 ledmode="none"
7747 fi
7748 for color in ${othercolor}
7749 do
7750 ledcommand="${ledcommand} echo \"none\" > \"${ledpath}/${color}:${ledname}/trigger\";"
7751 ledcommand="${ledcommand} echo \"0\" > \"${ledpath}/${color}:${ledname}/brightness\";"
7752 done
7753 if [ "a${ledcolor}" != "a" ]; then
7754 for color in ${ledcolor}
7755 do
7756 ledcommand="${ledcommand} echo \"${ledmode}\" > \"${ledpath}/${color}:${ledname}/trigger\";"
7757 [ "a${ledmode}" = "anone" ] && ledcommand="${ledcommand} echo \"1\" > \"${ledpath}/${color}:${ledname}/brightness\";"
7758 if [ "a${ledblink}" = "a1" ]; then
7759 ledcommand="${ledcommand} echo \"${ledon}\" > \"${ledpath}/${color}:${ledname}/delay_on\";"
7760 ledcommand="${ledcommand} echo \"${ledoff}\" > \"${ledpath}/${color}:${ledname}/delay_off\";"
7761 fi
7762 done
7763 unset color
7764 fi
7765 if [ "a${noexecute}" = "a1" ]; then
7766 echo "${ledcommand}"
7767 else
7768 unset LEDSCLEAN
7769 eval ${ledcommand}
7770 fi
7771 unset noexecute; unset ledarg; unset ledcolor; unset ledname; unset othercolor; unset otherled;
7772 unset color; unset oled; unset ledcommand; unset ledblink; unset ledmode; unset ledon; unset ledoff;
7773 return 0
7774 }
7775
7776 guruplug_leds() {
7777 ledscommands=""
7778 for ledi in ${allleds}
7779 do
7780 ledscommands="${ledscommands} `guruplug_led noexecute "${ledi}" "$@"`"
7781 done
7782 unset LEDSCLEAN
7783 eval ${ledscommands}
7784 unset ledscommands; unset ledi
7785 return 0
7786 }
7787
7788 guruplug_verbose() {
7789 [ "a${guruplug}" = "a" ] && return 0
7790 if [ "a${gurucycle}" = "a" -o "a${gurucycle}" = "a0" ]; then
7791 gurucycle="1"
7792 led1="left"
7793 led2="right"
7794 elif [ "a${gurucycle}" = "a1" ]; then
7795 gurucycle="0"
7796 led1="right"
7797 led2="left"
7798 fi
7799 export gurucycle
7800 ledscommands=""
7801 ledscommands="${ledscommands} `guruplug_led noexecute ${led1} reset`"
7802 ledscommands="${ledscommands} `guruplug_led noexecute ${led2} reset`"
7803 ledscommands="${ledscommands} `guruplug_led noexecute ${led1} green`"
7804 ledscommands="${ledscommands} `guruplug_led noexecute ${led2} blink green`"
7805 eval ${ledscommands}
7806 unset led1; unset led2; unset ledscommands
7807 return 0
7808 }
7809
7810 guruplug_verbose_same() {
7811 [ "a${guruplug}" = "a" ] && return 0
7812 if [ "a${gurucycle}" = "a" -o "a${gurucycle}" = "a0" ]; then
7813 led1="left"
7814 led2="right"
7815 elif [ "a${gurucycle}" = "a1" ]; then
7816 led1="right"
7817 led2="left"
7818 fi
7819 export gurucycle
7820 ledscommands=""
7821 ledscommands="${ledscommands} `guruplug_led noexecute ${led1} reset`"
7822 ledscommands="${ledscommands} `guruplug_led noexecute ${led2} reset`"
7823 ledscommands="${ledscommands} `guruplug_led noexecute ${led1} green`"
7824 ledscommands="${ledscommands} `guruplug_led noexecute ${led2} green`"
7825 ledscommands="${ledscommands} `guruplug_led noexecute ${led2} blink red`"
7826 eval ${ledscommands}
7827 unset led1; unset led2; unset ledscommands
7828 return 0
7829 }
7830
7831 guruplug_notify() {
7832 [ "a${guruplug}" = "a" ] && return 0
7833 guruplug_leds black
7834 guruplug_leds blink green
7835 [ "a${interactive}" = "a" ] && sleep 5
7836 }
7837
7838 guruplug_error() {
7839 [ "a${guruplug}" = "a" ] && return 0
7840 guruplug_leds black
7841 guruplug_leds blink red
7842 [ "a${interactive}" = "a" ] && sleep 5
7843 }
7844
7845 guruplug_led_exists() {
7846 [ "a${guruplug}" = "a" ] && return 1
7847 [ "a$1" = "a" ] && return 1
7848 for color in ${ledcolors}
7849 do
7850 [ ! -d "${ledpath}/${color}:$1" ] && return 1
7851 done
7852 unset color
7853 return 0
7854 }
7855
7856 guruplug_led_getstate() {
7857 [ "a${guruplug}" = "a" ] && return 0
7858 ! guruplug_led_exists "$@" && return 1
7859 for color in ${ledcolors}
7860 do
7861 colorname=`echo ${color} | ${sedbin} -e "s/:/_/g"`
7862 for file in ${ledvariables}
7863 do
7864 if [ -r "${ledpath}/${color}:${1}/${file}" ]; then
7865 value=`${catbin} "${ledpath}/${color}:$1/${file}"`
7866 eval "$1_${colorname}_${file}=\"${value}\""
7867 eval "export $1_${colorname}_${file}"
7868 else
7869 eval "unset $1_${colorname}_${file}"
7870 fi
7871 done
7872 value=`${catbin} "${ledpath}/${color}:$1/trigger" | ${sedbin} -e "s/^\(.*\)\[\(.*\)\]\(.*\)$/\2/g"`
7873 eval "$1_${colorname}_trigger=\"${value}\""
7874 eval "export $1_${colorname}_trigger"
7875 [ "a${value}" != "anone" ] && eval "unset $1_${colorname}_brightness"
7876 done
7877 unset colorname; unset color; unset value; unset file;
7878 debug "Led $1 saved.\n"
7879 set | ${grepbin} "^$1_"
7880 return 0
7881 }
7882
7883 guruplug_state() {
7884 [ "a${guruplug}" = "a" ] && return 0
7885 for ledi in ${allleds}
7886 do
7887 ! guruplug_led_getstate ${ledi} && return 1
7888 done
7889 unset ledi
7890 debug "All leds are saved.\n"
7891 return 0
7892 }
7893
7894 guruplug_restore() {
7895 [ "a${guruplug}" = "a" ] && return 0
7896 command=""
7897 for ledi in ${allleds}
7898 do
7899 for color in ${ledcolors}
7900 do
7901 colorname=`echo ${color} | ${sedbin} -e "s/:/_/g"`
7902 for file in trigger ${ledvariables}
7903 do
7904 value=`echo "$1" | ${grepbin} "^${ledi}_${colorname}_${file}=" | ${cutbin} -d= -f2- -s`
7905 if [ "a${value}" != "a" ]; then
7906 debug "echo \"${value}\" > \"${ledpath}/${color}:${ledi}/${file}\"\n"
7907 command="${command} echo \"${value}\" > \"${ledpath}/${color}:${ledi}/${file}\";"
7908 fi
7909 done
7910 done
7911 done
7912 unset LEDSCLEAN
7913 eval ${command}
7914 unset command
7915 unset value; unset file; unset colorname; unset color; unset ledi;
7916 return 0
7917 }
7918
7919 guruplug_restore_state() {
7920 [ "a${guruplug}" = "a" ] && return 0
7921 [ "a${guruplug_original_state}" != "a" ] && guruplug_restore "${guruplug_original_state}" && debug "Original state of GuruPlug leds is now restored.\n" && return 0
7922 debug "Failed to restore GuruPlug leds into original state.\n"
7923 return 1
7924 }
7925
7926 guruplug_save_state() {
7927 [ "a${guruplug}" = "a" ] && return 0
7928 ! guruplug_state > /dev/null && return 1
7929 guruplug_original_state=`guruplug_state`
7930 export guruplug_original_state
7931 addexittrap guruplug_restore_state
7932 debug "Original state of GuruPlug leds is saved.\n"
7933 return 0
7934 }
7935
7936 guruplug_probe() {
7937 [ "a${guruplug}" = "a" ] && return 1
7938 [ ! -w "/sys/class/leds/guruplug:green:health/trigger" ] && unset guruplug
7939 [ ! -w "/sys/class/leds/guruplug:green:health/brightness" ] && unset guruplug
7940 [ ! -w "/sys/class/leds/guruplug:red:health/trigger" ] && unset guruplug
7941 [ ! -w "/sys/class/leds/guruplug:red:health/brightness" ] && unset guruplug
7942 [ ! -w "/sys/class/leds/guruplug:green:wmode/trigger" ] && unset guruplug
7943 [ ! -w "/sys/class/leds/guruplug:green:wmode/brightness" ] && unset guruplug
7944 [ ! -w "/sys/class/leds/guruplug:red:wmode/trigger" ] && unset guruplug
7945 [ ! -w "/sys/class/leds/guruplug:red:wmode/brightness" ] && unset guruplug
7946 if [ "a${guruplug}" = "a" ]; then
7947 debug "GuruPlug leds not found, or not accessible.\n"
7948 return 1
7949 else
7950 ##############################################
7951 export ledpath="/sys/class/leds"
7952 ##############################################
7953 export redcolor="guruplug:red"
7954 export greencolor="guruplug:green"
7955 export ledcolors="${redcolor} ${greencolor}"
7956 ##############################################
7957 export leftled="health"
7958 export rightled="wmode"
7959 export allleds="${leftled} ${rightled}"
7960 ##############################################
7961 export ledvariables="brightness delay_off delay_on"
7962 ##############################################
7963 debug "GuruPlug leds found.\n"
7964 fi
7965 if ! guruplug_save_state; then
7966 unset guruplug
7967 debug "Failed to retrieve state of leds.\n"
7968 return 1
7969 fi
7970 }
7971
7972 config_args_read() {
7973 for arg in "$@"
7974 do
7975 debug "Parsing configuration value: %s.\n" "${arg}"
7976 parse_eval "readconfig" "${arg}" && continue
7977 parse_switches "${arg}"
7978 done
7979 unset arg
7980 }
7981
7982 config_load() {
7983 # If no PIN supplied from command line and $HOME/.3gnet exists, use PIN from there.
7984 [ "a${SIM_PIN}" = "a" -a "a${runhome}" != "a" ] && [ -d "${runhome}" ] && [ -r "${runhome}/.3gpin" ] && SIM_PIN=`${headbin} -1 "${runhome}/.3gpin" 2> /dev/null | ${cutbin} -b1-4` && [ "a${SIM_PIN}" != "a" ] && export SIM_PIN && debug "Loaded PIN value from %s.\n" "${runhome}/.3gpin" && ! pin_valid "${SIM_PIN}" && unset SIM_PIN && debug "PIN supplied was not valid.\n"
7985 # Load PIN from system-wide PIN suppliers
7986 for pinsupplier in "/etc/default/3gpin" "/etc/sysconfig/3gpin" "/etc/3gpin" "/etc/default/sakis3g.3gpin" "/etc/sysconfig/sakis3g.3gpin" "/etc/sakis3g.3gpin"
7987 do
7988 [ -r "${pinsupplier}" ] && unset SIM_PIN && SIM_PIN=`${headbin} -1 "${pinsupplier}" 2> /dev/null | ${cutbin} -b1-4` && [ "a${SIM_PIN}" != "a" ] && export SIM_PIN && debug "Loaded PIN value from %s.\n" "${pinsupplier}" &&! pin_valid "${SIM_PIN}" && unset SIM_PIN && debug "PIN supplied was not valid.\n"
7989 done
7990 unset pinsupplier
7991 # If system-wide configuration exists, load it overriding anything (user configuration/arguments/everything)
7992 for configfile in "/etc/default/sakis3g" "/etc/sysconfig/sakis3g" "/etc/sakis3g.conf"
7993 do
7994 if [ -r "${configfile}" ]; then
7995 debug "Loading system-wide configuration file %s.\n" "${configfile}"
7996 debug show_file "${configfile}"
7997 configargs=`${grepbin} -v "^#" "${configfile}" | ${grepbin} -v "^$" | ${sedbin} -e "s/^\(.*\)$/\"\1\"/g" | ${sedbin} -e "s/^\"\([A-Za-z_]*\)=\"\(.*\)\"\"$/\"\1=\2\"/g" | ${trbin} "\n" " "`
7998 debug "Configuration arguments are: %s\n" "${configargs}"
7999 eval config_args_read ${configargs}
8000 unset configargs
8001 debug "Finished loading file %s.\n" "${configfile}"
8002 else
8003 debug "Configuration file %s does not exist or is not readable.\n" "${configfile}"
8004 fi
8005 done
8006 unset configfile
8007 debug "Configuration file(s) loaded.\n"
8008 }
8009
8010 # Parses command line switch arguments
8011 parse_switch() {
8012 if [ "a$1" = "a$2" -o "a$1" = "a--$2" -o "a$1" = "a-$2" ]; then
8013 debug "Command line switch defined: %s\n" "$1"
8014 return 0
8015 fi
8016 return 1
8017 }
8018
8019 # Parses command line variable settings
8020 parse_eval() {
8021 ! find_binary "cut" && return 1
8022 ! find_binary "grep" && return 1
8023 if [ "a$1" = "areadconfig" ]; then
8024 readconfig=1
8025 shift
8026 [ "a$1" = "a" ] && unset readconfig && return 1
8027 else
8028 readconfig=0
8029 fi
8030 [ "a`echo "$1" | ${grepbin} "="`" = "a" ] && unset readconfig && return 1
8031 variable=`echo "${1}" | ${cutbin} -d= -f1`
8032 [ "a${variable}" = "a" ] && unset variable && unset readconfig && return 1
8033 value=`echo "${1}" | ${cutbin} -d= -f2-`
8034 [ "a${value}" = "a" ] && unset variable && unset value && unset readconfig && return 1
8035 case "${variable}" in
8036 pppint|PPPINT)
8037 export pppint="${value}"
8038 ;;
8039 CHAT_ABORT_STRINGS)
8040 # Abort strings that chat program may encounter
8041 export CHAT_ABORT_STRINGS="${value}"
8042 ;;
8043 BAUD)
8044 # Baud rate
8045 if [ "a${value}" = "aMAX" -o "a${value}" = "amax" ]; then
8046 export BAUD="4000000"
8047 elif [ "a${value}" = "aMIN" -o "a${value}" = "amin" ]; then
8048 export BAUD="115200"
8049 elif [ "a${value}" = "aDEFAULT" -o "a${value}" = "adefault" -o "a${value}" = "aNORMAL" -o "a${value}" = "anormal" ]; then
8050 export BAUD="460800"
8051 else
8052 export BAUD="${value}"
8053 fi
8054 ;;
8055 PPPD_OPTIONS)
8056 # Options passed to pppd when called directly
8057 export PPPD_OPTIONS="${value}"
8058 ;;
8059 PPPD_PEERS)
8060 # Directory where pppd keeps its peers
8061 export PPPD_PEERS="${value}"
8062 ;;
8063 XOSDFONT)
8064 # Font that will be used when displaying messages through XOSD (osd_cat)
8065 export XOSDFONT="${value}"
8066 ;;
8067 AOSDFONT)
8068 # Font that will be used when displaying messages through XOSD (osd_cat)
8069 export AOSDFONT="${value}"
8070 ;;
8071 MENUFONT|menufont)
8072 # Font that will be used when using 9menu
8073 export MENUFONT="${value}"
8074 ;;
8075 OSDFONT)
8076 # Font that will be used when displaying messages through XOSD (osd_cat)
8077 export AOSDFONT="${value}"
8078 export XOSDFONT="${value}"
8079 ;;
8080 LOGPOSITION|logposition)
8081 # Directory where pppd keeps its peers
8082 export LOGPOSITION="${value}"
8083 ;;
8084 DESKTOPICON)
8085 # Directory where pppd keeps its peers
8086 export DESKTOPICON="${value}"
8087 ;;
8088 DCOPSERVER)
8089 # Directory where pppd keeps its peers
8090 export DCOPSERVER="${value}"
8091 ;;
8092 connection_hook|CONNECTION_HOOK|HOOK)
8093 # Enabling this is a security issue.
8094 # Users can pass argument to do whatever they want.
8095 if [ "a${readconfig}" = "a1" ]; then
8096 export CONNECTION_HOOK="${value}"
8097 else
8098 echo "Ignoring ${variable} variable for security reasons." > /dev/stderr
8099 echo "This variable is only usable through global configuration." > /dev/stderr
8100 echo "Consult documentation." > /dev/stderr
8101 fi
8102 ;;
8103 DNS)
8104 export DNS="${value}"
8105 ;;
8106 MODEM_PREPARE|PREPARE)
8107 export MODEM_PREPARE="${value}"
8108 INIT_STAGE0=`${printfbin} "%s\n" "${value}" | ${sedbin} -e "s/AT/\\nAT/g" | ${sedbin} -e "s/ *$//g" | ${grepbin} -v "^$" | ${grepbin} "^AT" | ${sedbin} -e "s/^\(.*\)$/\\\'\1\\\' OK/g" | ${trbin} "\n" " "`
8109 export INIT_STAGE0
8110 ;;
8111 MODEM_INIT|INIT)
8112 export MODEM_INIT="${value}"
8113 ;;
8114 DIAL|CUSTOM_DIAL)
8115 export CUSTOM_DIAL="${value}"
8116 ;;
8117 FORCE_APN)
8118 export FORCE_APN="${value}"
8119 ;;
8120 CUSTOM_APN)
8121 export CUSTOM_APN="${value}"
8122 ;;
8123 APN)
8124 export APN="${value}"
8125 ;;
8126 APN_USER)
8127 export APN_USER="${value}"
8128 ;;
8129 APN_PASS)
8130 export APN_PASS="${value}"
8131 ;;
8132 FORCE_ISP)
8133 export FORCE_ISP="${value}"
8134 ;;
8135 SIM_PIN)
8136 export SIM_PIN="${value}"
8137 ;;
8138 RFCOMM_TTY)
8139 export RFCOMM_TTY="${value}"
8140 ;;
8141 CUSTOM_TTY)
8142 export CUSTOM_TTY="${value}"
8143 ;;
8144 RFSERVICE)
8145 export RFSERVICE="${value}"
8146 ;;
8147 RFCHANNEL)
8148 export RFCHANNEL="${value}"
8149 ;;
8150 UNDISCOVERABLE)
8151 export UNDISCOVERABLE="${value}"
8152 ;;
8153 BLUETOOTH)
8154 export BLUETOOTH="${value}"
8155 ;;
8156 USBINTERFACE)
8157 export USBINTERFACE="${value}"
8158 ;;
8159 USBDRIVER)
8160 export USBDRIVER="${value}"
8161 ;;
8162 USBMODEM)
8163 export USBMODEM="${value}"
8164 ;;
8165 OTHER)
8166 export OTHER="${value}"
8167 ;;
8168 MODEM)
8169 export MODEM="${value}"
8170 ;;
8171 MOREMENU)
8172 export MOREMENU="${value}"
8173 ;;
8174 MENU)
8175 export MENU="${value}"
8176 ;;
8177 DISPLAY)
8178 export DISPLAY="${value}"
8179 ;;
8180 XAUTHORITY|LOCALAUTHORITY)
8181 export LOCALAUTHORITY="${value}"
8182 ;;
8183 BALOONIZER|BALLOONIZER)
8184 export BALOONIZER="${value}"
8185 ;;
8186 DESKTOP)
8187 export DESKTOP="${value}"
8188 ;;
8189 SGUI)
8190 export SGUI="${value}"
8191 ;;
8192 TRANSLATION)
8193 export TRANSLATION="${value}"
8194 ;;
8195 *)
8196 debug "Unknown variable %s specified in command line.\n" "${variable}"
8197 unset variable
8198 ;;
8199 esac
8200 unset readconfig
8201 if [ "a${variable}" != "a" ]; then
8202 debug "Command line set variable %s to \"%s\".\n" "${variable}" "`eval echo \\\${${variable}}`"
8203 unset variable; unset value;
8204 return 0
8205 fi
8206 unset variable; unset value
8207 return 1
8208 }
8209
8210 parse_switches() {
8211 parse_switch "${1}" "balloons" && export balloons=yes
8212 parse_switch "${1}" "balloon" && export balloons=yes
8213 parse_switch "${1}" "baloons" && export balloons=yes
8214 parse_switch "${1}" "baloon" && export balloons=yes
8215 parse_switch "${1}" "ballons" && export balloons=yes
8216 parse_switch "${1}" "ballon" && export balloons=yes
8217 parse_switch "${1}" "balons" && export balloons=yes
8218 parse_switch "${1}" "balon" && export balloons=yes
8219 parse_switch "${1}" "b" && export balloons=yes
8220
8221 parse_switch "${1}" "console" && export stick_to_console=yes
8222 parse_switch "${1}" "stick_to_console" && export stick_to_console=yes
8223 parse_switch "${1}" "c" && export stick_to_console=yes
8224
8225 parse_switch "${1}" "debug" && export DEBUG=on
8226 parse_switch "${1}" "DEBUG" && export DEBUG=on
8227 parse_switch "${1}" "d" && export DEBUG=on
8228
8229 parse_switch "${1}" "NOSMART" && export NOSMART=yes
8230 parse_switch "${1}" "NOFIX" && export NOSMART=yes
8231 parse_switch "${1}" "nosmart" && export NOSMART=yes
8232 parse_switch "${1}" "nofix" && export NOSMART=yes
8233 parse_switch "${1}" "smart" && export NOSMART=yes
8234 parse_switch "${1}" "fix" && export NOSMART=yes
8235 parse_switch "${1}" "f" && export NOSMART=yes
8236
8237 parse_switch "${1}" "GOOGLEDNS" && export DNS="8.8.8.8 8.8.4.4"
8238 parse_switch "${1}" "GOOGLE" && export DNS="8.8.8.8 8.8.4.4"
8239 parse_switch "${1}" "googledns" && export DNS="8.8.8.8 8.8.4.4"
8240 parse_switch "${1}" "google" && export DNS="8.8.8.8 8.8.4.4"
8241 parse_switch "${1}" "g" && export DNS="8.8.8.8 8.8.4.4"
8242
8243 parse_switch "${1}" "GURUPLUG" && export guruplug=yes
8244 parse_switch "${1}" "guruplug" && export guruplug=yes
8245 parse_switch "${1}" "GURU" && export guruplug=yes
8246 parse_switch "${1}" "guru" && export guruplug=yes
8247 parse_switch "${1}" "G" && export guruplug=yes
8248
8249 parse_switch "${1}" "nohal" && export nohal=yes
8250 parse_switch "${1}" "hal" && export nohal=yes
8251 parse_switch "${1}" "h" && export nohal=yes
8252
8253 parse_switch "${1}" "interactive" && export interactive=yes
8254 parse_switch "${1}" "i" && export interactive=yes
8255
8256 parse_switch "${1}" "killstorage" && export killstorage=yes
8257 parse_switch "${1}" "nostorage" && export killstorage=yes
8258 parse_switch "${1}" "storage" && export killstorage=yes
8259 parse_switch "${1}" "k" && export killstorage=yes
8260
8261 parse_switch "${1}" "nohalinform" && export nohalinform=yes
8262 parse_switch "${1}" "noinform" && export nohalinform=yes
8263 parse_switch "${1}" "l" && export nohalinform=yes
8264
8265 parse_switch "${1}" "NOPROBE" && export NOPROBEGSM=yes
8266 parse_switch "${1}" "NOPROBEGSM" && export NOPROBEGSM=yes
8267 parse_switch "${1}" "noprobe" && export NOPROBEGSM=yes
8268 parse_switch "${1}" "noprobegsm" && export NOPROBEGSM=yes
8269 parse_switch "${1}" "GSM" && export NOPROBEGSM=yes
8270 parse_switch "${1}" "gsm" && export NOPROBEGSM=yes
8271 parse_switch "${1}" "n" && export NOPROBEGSM=yes
8272
8273 parse_switch "${1}" "prefer_osd" && export prefer_osd=yes
8274 parse_switch "${1}" "preferosd" && export prefer_osd=yes
8275 parse_switch "${1}" "osd" && export prefer_osd=yes
8276 parse_switch "${1}" "OSD" && export prefer_osd=yes
8277 parse_switch "${1}" "o" && export prefer_osd=yes
8278
8279 parse_switch "${1}" "forever" && export forever=yes
8280 parse_switch "${1}" "persist" && export forever=yes
8281 parse_switch "${1}" "P" && export forever=yes
8282
8283 parse_switch "${1}" "directpppd" && export direct_pppd=yes
8284 parse_switch "${1}" "direct_pppd" && export direct_pppd=yes
8285 parse_switch "${1}" "ppp" && export direct_pppd=yes
8286 parse_switch "${1}" "pppd" && export direct_pppd=yes
8287 parse_switch "${1}" "p" && export direct_pppd=yes
8288
8289 parse_switch "${1}" "noverbose" && export noverbose=yes
8290 parse_switch "${1}" "noinformation" && export nonotify=yes
8291 parse_switch "${1}" "nonotifications" && export nonotify=yes
8292 parse_switch "${1}" "nonotify" && export nonotify=yes
8293 parse_switch "${1}" "noerrors" && export noerror=yes
8294 parse_switch "${1}" "noerror" && export noerror=yes
8295 if parse_switch "${1}" "silent" || parse_switch "${1}" "quiet" || parse_switch "${1}" "q"; then
8296 export noerror=yes
8297 export nonotify=yes
8298 export noverbose=yes
8299 fi
8300
8301 parse_switch "${1}" "sudo" && export alwayssudo=yes
8302 parse_switch "${1}" "alwayssudo" && export alwayssudo=yes
8303 parse_switch "${1}" "always_sudo" && export alwayssudo=yes
8304 parse_switch "${1}" "s" && export alwayssudo=yes
8305
8306 parse_switch "${1}" "showtext" && export showtext=yes
8307 parse_switch "${1}" "T" && export showtext=yes
8308
8309 parse_switch "${1}" "notranslate" && export notranslate=yes
8310 parse_switch "${1}" "t" && export notranslate=yes
8311
8312 parse_switch "${1}" "nosafety" && export nosafety=yes
8313 parse_switch "${1}" "unsafe" && export nosafety=yes
8314 parse_switch "${1}" "u" && export nosafety=yes
8315
8316 parse_switch "${1}" "voodoo" && export voodoo=yes
8317 parse_switch "${1}" "please" && export voodoo=yes
8318 parse_switch "${1}" "magic" && export voodoo=yes
8319 parse_switch "${1}" "Voodoo" && export voodoo=yes
8320 parse_switch "${1}" "Please" && export voodoo=yes
8321 parse_switch "${1}" "Magic" && export voodoo=yes
8322 parse_switch "${1}" "v" && export voodoo=yes
8323
8324 parse_switch "${1}" "whiptail" && export SGUI="whiptail"
8325 parse_switch "${1}" "dialog" && export SGUI="dialog"
8326 parse_switch "${1}" "Xdialog" && export SGUI="Xdialog"
8327 parse_switch "${1}" "xdialog" && export SGUI="Xdialog"
8328 parse_switch "${1}" "zenity" && export SGUI="zenity"
8329 parse_switch "${1}" "kdialog" && export SGUI="kdialog"
8330 parse_switch "${1}" "9menu" && export SGUI="9menu"
8331 parse_switch "${1}" "xterm" && export SGUI="xterm"
8332 parse_switch "${1}" "gnome-terminal" && export SGUI="gnome-terminal"
8333 parse_switch "${1}" "konsole" && export SGUI="konsole"
8334 parse_switch "${1}" "interactiveterminal" && export SGUI="interactive terminal"
8335 parse_switch "${1}" "iterm" && export SGUI="interactive terminal"
8336 parse_switch "${1}" "terminal" && export SGUI="terminal"
8337 parse_switch "${1}" "term" && export SGUI="terminal"
8338 if parse_switch "${1}" "legacy"; then
8339 export SGUI="9menu"
8340 export prefer_osd="yes"
8341 fi
8342
8343 parse_switch "${1}" "scanyes" && export scanyes="1"
8344 parse_switch "${1}" "scanno" && export scanno="1"
8345 }
8346
8347 state_variables() {
8348 unset statevariables
8349 for flagvariable in stick_to_console:console interactive:interactive DEBUG:debug NOSMART:nofix killstorage:nostorage NOPROBEGSM:noprobegsm prefer_osd:osd direct_pppd:pppd alwayssudo:sudo forever:forever balloons:balloons
8350 do
8351 variablename=`echo "${flagvariable}" | cut -d: -f1`
8352 strinstr "${variablename}" "${1}" " " && debug "Variable %s excluded from state variables.\n" "${variablename}" && continue
8353 variablearg=`echo "${flagvariable}" | cut -d: -f2`
8354 variablevalue=`eval echo \\\${${variablename}}`
8355 [ "a${variablevalue}" != "a" ] && statevariables="${statevariables} --${variablearg}"
8356 done
8357 unset flagvariable; unset variablename; unset variablearg; unset variablevalue
8358 [ "a${DNS}" = "a8.8.8.8 8.8.4.4" ] && statevariables="${statevariables} --googledns"
8359 [ "a${DNS}" != "a8.8.8.8 8.8.4.4" -a "a${DNS}" != "a" ] && statevariables="${statevariables} DNS=\"${DNS}\""
8360 for valuevariable in MODEM_INIT FORCE_APN APN APN_USER APN_PASS FORCE_ISP SIM_PIN SGUI RFCOMM_TTY CUSTOM_TTY RFSERVICE RFCHANNEL UNDISCOVERABLE BLUETOOTH USBINTERFACE USBDRIVER USBMODEM OTHER MODEM MENU MOREMENU DISPLAY DESKTOP DCOPSERVER LOCALAUTHORITY BALOONIZER
8361 do
8362 strinstr "${valuevariable}" "${1}" " " && debug "Variable %s excluded from state variables.\n" "${valuevariable}" && continue
8363 variablevalue=`eval echo \\\${${valuevariable}}`
8364 [ "a${variablevalue}" != "a" ] && statevariables="${statevariables} ${valuevariable}=\"${variablevalue}\""
8365 done
8366 unset valuevariable; unset variablevalue
8367 statevariables=`echo ${statevariables}`
8368 export statevariables
8369 debug "State variables are: %s\n" "${statevariables}"
8370 return 0
8371 }
8372
8373 # Parses command line arguments
8374 parse_arguments() {
8375 need_binary "tr"
8376 unset allargs
8377 for arg in "$@"
8378 do
8379 varg=`sanitize "${arg}"`
8380 allargs="${allargs} \"${varg}\""
8381 parse_eval "${varg}" && continue
8382 parse_switches "${varg}"
8383 unset varg
8384 done
8385 unset arg
8386 allargs=`echo ${allargs}`
8387 export allargs
8388 }
8389
8390 # Unsets binary variables if running as root. This eliminates the chance
8391 # that a malicious user has succeed into setting a "trojan" binary helper
8392 # that will be executed with root privileges.
8393 secure_path() {
8394 PATH="/bin:/sbin:/usr/bin:/usr/sbin"
8395 export PATH
8396 unset whichbin
8397 unset grepbin
8398 unset cutbin
8399 need_binary "grep"
8400 need_binary "cut"
8401 for variable in `set | ${grepbin} "bin=" | ${cutbin} -d= -f1`
8402 do
8403 value=`eval echo \\${${variable}} 2> /dev/null`
8404 if [ "a${value}" != "a" ] && [ -x "${value}" ]; then
8405 eval "unset ${variable}"
8406 debug "Unset variable %s for security reasons.\n" "${variable}"
8407 fi
8408 done
8409 unset variable; unset value
8410 return 0
8411 }
8412
8413 # Removes \, ", ', ` from variables' contents
8414 secure_variables() {
8415 need_binary "sed"
8416 need_binary "tr"
8417 for variable in DISPLAY XAUTHORITY USERNAME HOME USER DESKTOP
8418 do
8419 debug "Sanitizing %s: %s\n" "${variable}" "`eval echo \"\\${${variable}}\"`"
8420 value=`eval "echo \"\\${${variable}}\"" 2> /dev/null | ${trbin} "\\\\" " " 2> /dev/null | ${trbin} "\"" " " | ${trbin} "'" " " | ${trbin} "\\\`" " "`
8421 debug "Sanitized value: %s\n" "${value}"
8422 eval "${variable}=\"""${value}""\""
8423 eval "${variable}=\"`eval echo \"\\${${variable}}\"`\""
8424 eval "export ${variable}"
8425 debug "Sanitized %s: %s\n" "${variable}" "`eval echo \"\\${${variable}}\"`"
8426 done
8427 unset value; unset variable
8428 return 0
8429 }
8430
8431 secure_capabilities() {
8432 debug "Will check shell capabilities.\n"
8433 set +o monitor > /dev/null 2> /dev/null
8434 set +m > /dev/null 2> /dev/null
8435 funcname=`set | grep "^FUNCNAME="`
8436 if [ "a${funcname}" = "a" ]; then
8437 debug "Shell does not provide FUNCNAME environment variable.\n"
8438 debug "USB Safety will be disabled.\n"
8439 export NOFUNCNAME="1"
8440 unset YESFUNCNAME=""
8441 else
8442 debug "Shell provides FUNCNAME environment variable.\n"
8443 unset NOFUNCNAME
8444 export YESFUNCNAME="1"
8445 fi
8446 unset funcname
8447 return 0
8448 }
8449
8450 # Makes sure no danger exists when run as root
8451 secure_environment() {
8452 secure_capabilities
8453 ! we_are_root_already && return 0
8454 secure_path
8455 secure_variables
8456 return 0
8457 }
8458
8459 # Preparation or death
8460 startup() {
8461 # try to set shell as helpful as possible with background jobs
8462 secure_environment
8463 addexittrap cleanscreen
8464 me=$1; [ "$#" -gt "0" ] && shift
8465 # Draftly set allargs. Will better do it during parse_arguments
8466 allargs="$@"; export allargs
8467 no_action_command "$@" && stop_with 0
8468 verbose "Starting up"
8469 parse_arguments "$@"
8470 debug_header "$@"
8471 resolv_binaries "${me}"; unset me
8472 check_udevd "$@"
8473 find_user
8474 config_load
8475 find_display
8476 find_gui
8477 translate_load
8478 check_root_deps
8479 modeswitch_load
8480 guruplug_probe
8481 debug "Finished starting up.\n"
8482 }
8483
8484 # Main program
8485 sakis3g_main() {
8486 # Initialization
8487 startup "$@"
8488 # Get action
8489 action_command "$@" && stop_with ${actionresult}
8490 default_actor
8491 ret=$?
8492 stop_with ${ret}
8493 }
8494
8495 # Execute main method
8496 sakis3g_main $0 "$@"
8497
8498 # In case all actors performed well
8499 debug "Reached end of program.\n"
8500 stop_with 0
8501
0 #
1 # Sakis3G All-in-one script
2 # Copyright (c) 2009, 2010 Sakis Dimopoulos (sakis3g @domain sakis3g.org)
3 # Under GNU GPL v2.
4 #
5 # URL: http://www.sakis3g.org/
6 # License: http://www.gnu.org/licenses/gpl.txt
7 #
8 # ATTENTION: DO NOT EDIT THIS FILE DIRECTLY, OR YOU RISK TO RENDER IT
9 # UNUSABLE. IF YOU WANT TO EDIT Sakis3G SCRIPT, ISSUE:
10 # $ /usr/bin/sakis3g disassemble /tmp
11 # $ cd /tmp/sakis3g-0.2.0/
12 # $ vi src/sakis3g
13 # $ ./compile
14 # $ cp /tmp/sakis3g-0.2.0/build/sakis3gz /usr/bin/.
15 #
16 # See embedded help:
17 # $ sakis3gz help
18 # or embedded man page:
19 # $ sakis3gz man
20 # Additional information at:
21 # http://wiki.sakis3g.org/
22 #
23
24 handler_get_file() {
25 [ ! -x "${MEGZ}" ] && return 1
26 bn=`basename "$1"`; [ "a${bn}" = "a" ] && return 1
27 dd "if=${MEGZ}" "bs=${BLOCKSIZE}" "skip=${PACKAGE_OFFSET}" of="/tmp/sakis3gz.$$.tar.${extension}" >/dev/null 2>&1
28 [ ! -f "/tmp/sakis3gz.$$.tar.${extension}" ] && return 1
29 if [ ! -s "/tmp/sakis3gz.$$.tar.${extension}" ]; then
30 rm -f "/tmp/sakis3gz.$$.tar.${extension}"; return 1
31 fi
32 tar xf "/tmp/sakis3gz.$$.tar.${extension}" "$1" -O | dd "of=/tmp/sakis3gz.$$.${bn}" >/dev/null 2>&1
33 rm -f "/tmp/sakis3gz.$$.tar.${extension}"
34 [ ! -f "/tmp/sakis3gz.$$.${bn}" ] && return 1
35 if [ ! -s "/tmp/sakis3gz.$$.${bn}" ]; then
36 rm -f "/tmp/sakis3gz.$$.${bn}"; return 1
37 fi
38 export EXTRACTED="/tmp/sakis3gz.$$.${bn}"
39 return 0
40 }
41
42 handler_disassemble() {
43 [ ! -x "${MEGZ}" ] && return 1
44 if [ "a${stripped}" != "a" ]; then
45 echo "This version cannot be disassembled."
46 return 0
47 fi
48 if [ "a$1" = "a" ]; then
49 echo "Usage: ${MEGZ} disassemble <destination>" >> /dev/stderr
50 return 0
51 fi
52 if [ ! -d "$1" ]; then
53 echo "Destination directory \"$1\" was not found." >> /dev/stderr
54 return 0
55 fi
56 dd "if=${MEGZ}" "bs=${BLOCKSIZE}" "skip=${PACKAGE_OFFSET}" of="/tmp/sakis3gz.$$.tar.${extension}" >/dev/null 2>&1
57 [ ! -f "/tmp/sakis3gz.$$.tar.${extension}" ] && return 1
58 if [ ! -s "/tmp/sakis3gz.$$.tar.${extension}" ]; then
59 rm -f "/tmp/sakis3gz.$$.tar.${extension}"; return 1
60 fi
61 mkdir "$1/sakis3g-${MYVERSION}"
62 if [ ! -d "$1/sakis3g-${MYVERSION}" ]; then
63 rm -f "/tmp/sakis3gz.$$.tar.${extension}"; return 1
64 fi
65 oldtar=`tar --version 2> /dev/null | grep "GNU tar" | sed -e "s/^\(.*\) \([0-9.][0-9.]*\)$/\2/g" | sed -e "s/\.//g" | cut -b1-2`
66 if [ "a${oldtar}" != "a" ] && [ "${oldtar}" -lt "12" ]; then
67 tar -C "$1/sakis3g-${MYVERSION}" -x -v -f "/tmp/sakis3gz.$$.tar.${extension}"
68 mv "$1/sakis3g-${MYVERSION}/sakis3g/"* "$1/sakis3g-${MYVERSION}/."
69 else
70 tar --transform "s/^sakis3g\///g" -C "$1/sakis3g-${MYVERSION}" -x -v -f "/tmp/sakis3gz.$$.tar.${extension}"
71 fi
72 rm -f "/tmp/sakis3gz.$$.tar.${extension}"
73 rmdir "$1/sakis3g-${MYVERSION}/sakis3g"
74 return 0
75 }
76
77 handler_cat() {
78 ! handler_get_file "$1" && return 1
79 [ ! -f "${EXTRACTED}" ] && return 1
80 cat "${EXTRACTED}"; rm -f "${EXTRACTED}"; unset EXTRACTED
81 return 0
82 }
83
84 handler_exec() {
85 ! handler_get_file "$1" && return 1
86 [ ! -f "${EXTRACTED}" ] && return 1
87 chmod +x "${EXTRACTED}"
88 export PROVIDER="${MEGZ}"
89 [ "$#" -gt "0" ] && shift
90 if [ ! "`which ldd 2>/dev/null`" ]; then
91 "${EXTRACTED}" "$@"
92 ret=$?
93 else
94 akis3g=`echo "${EXTRACTED}" | grep "sakis3g$"`
95 if [ "a${akis3g}" = "a" ]; then
96 ldd "${EXTRACTED}" >/dev/null 2>&1
97 ret=$?
98 unset akis3g
99 if [ "${ret}" -eq "0" ]; then
100 "${EXTRACTED}" "$@"
101 ret=$?
102 else
103 echo "Binary not available for this platform. Please recompile." > /dev/stderr
104 ret=95
105 fi
106 else
107 unset akis3g
108 "${EXTRACTED}" "$@"
109 ret=$?
110 fi
111 fi
112 rm -f "${EXTRACTED}"; unset EXTRACTED
113 return ${ret}
114 }
115
116 if [ "a$1" = "als" ]; then
117 echo "${PACKAGE_CONTENTS}"
118 exit 0
119 fi
120
121 for dep in dd tar ${decompressor} grep head basename chmod readlink
122 do
123 [ ! "`which ${dep} 2>/dev/null`" ] && echo "${dep} not found in path." > /dev/stderr && exit 1
124 done
125
126 export MEGZ="$0"
127
128 file="$1";
129 [ "a`basename "$0"`" = "ausb_modeswitch" ] && file="usb_modeswitch"
130 [ "a${file}" = "a" ] && file="sakis3g/src/sakis3g"
131 [ "a${file}" = "adisassemble" ] && unset file && handler_disassemble "$2" && exit $?
132 if [ "a${file}" = "agetfile" ]; then
133 unset file
134 [ "a$2" = "a" ] && exit 99
135 filexists=`echo "${PACKAGE_CONTENTS}" | grep -e "${2}$" | head -1`
136 [ "a${filexists}" != "a" ] && handler_cat "${filexists}" && unset filexists && exit 0
137 unset filexists
138 exit 99
139 fi
140 filexists=`echo "${PACKAGE_EXECUTABLES}" | grep -e "${file}$" | head -1`
141 if [ "a${filexists}" != "a" ]; then
142 unset file
143 [ "a`basename ${MEGZ}`" != "ausb_modeswitch" ] && [ "$#" -gt "0" ] && shift; handler_exec "${filexists}" "$@"
144 exit $?
145 else
146 unset filexists
147 filexists=`echo "${PACKAGE_CONTENTS}" | grep -e "${file}$" | head -1`
148 unset file
149 if [ "a`basename ${MEGZ}`" = "ausb_modeswitch" -a "a${filexists}" = "a" ]; then
150 MEGZ=`readlink -f "${MEGZ}"`
151 export MEGZ
152 handler_exec "sakis3g/src/sakis3g" usb_modeswitch "$@"
153 exit $?
154 elif [ "a${filexists}" != "a" ]; then
155 handler_cat "${filexists}"
156 exit $?
157 else
158 handler_exec "sakis3g/src/sakis3g" "$@"
159 exit $?
160 fi
161 fi