-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
android-sdk-installer
executable file
·1238 lines (861 loc) · 24.6 KB
/
android-sdk-installer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash -e
#
# android-sdk-installer - Linux utility which automatically installs and
# configures Android SDK, Eclipse ADT Plugin, adds hardware support for
# devices and adds full MTP support.
#
# Copyright © 2012 Adnan Hodzic <adnan@foolcontrol.org>
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
ASI="Android SDK Installer"
ASI_VERSION="0.1.5"
DIV="\n----------------------------------------------------------------------------\n";
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Prevents most errors that come from interrupted installation of packages.
dpkg --configure -a
# Detect architecture, if x86_64 install its dependencies
ARCH="$(uname -m)"
DEPEND="wget unzip"
# Install some dependencies required.
if dpkg -s "wget" 2>/dev/null 1>/dev/null
then
if dpkg -s "unzip" 2>/dev/null 1>/dev/null
then
echo -e $DIV
echo -e "Dependencies $DEPEND to run this script are already installed.\nMoving on ..."
else
read -p "Dependencies $DEPEND to run this script are required.
Install?
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
echo -e "\nOkay, will now install $DEPEND\n"
apt-get install $DEPEND
;;
[Nn]* )
echo -e "\nPlease install $DEPEND manually"
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1;;
esac
fi
fi
PACKAGE="lib32ncurses5 lib32stdc++6"
# This whole step needs to be rewritten due to getting rid of ia32-libs by
# moving to Multiarch
#
# References:
# http://wiki.debian.org/Multiarch
if dpkg -s "lib32ncurses5" 2>/dev/null 1>/dev/null
then
if dpkg -s "lib32stdc++6" 2>/dev/null 1>/dev/null
then
echo -e $DIV
echo -e "Dependencies $PACKAGE to install the Android SDK are already installed.\nMoving on ..."
else
read -p "Dependencies $PACKAGE to install the Android SDK are required.
Install?
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
echo -e "\nOkay, will now install $PACKAGE\n"
apt-get install $PACKAGE
;;
[Nn]* )
echo -e "\nPlease install $PACKAGE manually"
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1;;
esac
fi
fi
# Check if OpenJDK Development Kit (JDK) dependency is satisfied
PACKAGE=openjdk-7-jdk
if dpkg -s "$PACKAGE" 2>/dev/null 1>/dev/null
then
echo -e $DIV
echo -e "OpenJDK Development Kit is installed.\nMoving on ..."
else
echo -e $DIV
read -p "OpenJDK Development Kit ($PACKAGE) is NOT installed.
Would you like to install it?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
apt-get install $PACKAGE
;;
[Nn]* )
echo -e "\nAndroid SDK can't run without $PACKAGE"
exit 1
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
# Pre-cleaning process
SDK_R="android-sdk_r20.0.1-linux.tgz"
SDK_15="android-15_r03.zip"
SDK_21="android-2.1_r03-linux.zip"
ADT_RM="ADT-20.0.1.zip"
ADT_RM_URL=http://dl.google.com/android/ADT-20.0.1.zip
if [ -f $SDK_R ]
then
echo -e $DIV
read -p "Installer found \"$SDK_R\" file which might defect rest of
the installation process, remove?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
rm -f $SDK_R 2>/dev/null
;;
[Nn]* )
chmod 666 $SDK_R
;;
[Ss]* )
chmod 666 $SDK_R
;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
if [ -f $SDK_15 ]
then
echo -e $DIV
read -p "Installer found \"$SDK_15\" file which might defect rest of
the installation process, remove?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
rm -f $SDK_15 2>/dev/null
;;
[Nn]* )
chmod 666 $SDK_15
;;
[Ss]* )
chmod 666 $SDK_15
;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
if [ -f $SDK_21 ]
then
echo -e $DIV
read -p "Installer found \"$SDK_21\" file which might defect rest of
the installation process, remove?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
rm -f $SDK_21 2>/dev/null
;;
[Nn]* )
chmod 666 $SDK_21
;;
[Ss]* )
chmod 666 $SDK_21
;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
if [ -f $ADT_RM ]
then
echo -e $DIV
read -p "Installer found \"$ADT_RM\" file which might defect rest of
the installation process, remove?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
rm -f $ADT_RM 2>/dev/null
;;
[Nn]* )
chmod 666 $ADT_RM
;;
[Ss]* )
chmod 666 $ADT_RM
;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
# Is there a /opt/android-sdk-linux directory?
DIRECTORY=/opt/android-sdk-linux
if [ -d "$DIRECTORY" ]
then
echo -e $DIV
read -p "Directory \"$DIRECTORY\" already exists.
Installer will ovewrite this directory with new installation data,
backup will be stored in \"$DIRECTORY.sdk.bak\"
Continue?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
# backup and/or remove existing /opt/android-sdk-linux directory
cp -R $DIRECTORY $DIRECTORY.sdk.bak
rm -Rf $DIRECTORY 2>/dev/null
;;
[Nn]* )
echo -e "\nCan't continue without access to \"$DIRECTORY\" directory"
exit 1
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
else
mkdir $DIRECTORY
chmod 755 -R $DIRECTORY
fi
echo -e $DIV
# Check if SDK/Tools directory is empty
#
# In future find the constant URL to the latest API revision
# Attempt to get one from Google:
# https://groups.google.com/forum/?fromgroups#!starred/android-developers/CywPfuWBKJ0
TOOL="/opt/android-sdk-linux/tools"
STARTER="Android SDK Starter Package"
LATEST_STARTER_URL=http://dl.google.com/android/android-sdk_r20.0.1-linux.tgz
LATEST_STARTER_PAK=$SDK_R
if [ -z "ls $TOOL" ]
then
echo -e "\n\nAndroid SDK Tools seem to be present, moving forward\n"
else
read -p "Install $STARTER?
Provides tools such as \"android\" (Android SDK and AVD Manager),
\"emulator\" (Android Emulator), \"ddms\" (Dalvik Debug Monitor), et cetera ...
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
echo -e "\nWill now download the $STARTER\n"
wget $LATEST_STARTER_URL
tar -xzvf $LATEST_STARTER_PAK -C /opt/
echo -e "\n$STARTER successfully installed"
;;
[Nn]* )
echo -e "\nInstallation aborted:
\nCan't continue without Android Tools!\n"
exit 1
;;
[Ss]* )
echo -e "\nReluctantly skipping over this step"
;;
* ) echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
echo -e $DIV
# Install latest Android API?
LATEST_REV="4.1, API 16, revision 1 (Jelly Bean)"
LATEST_REV_URL=http://dl.google.com/android/repository/android-16_r01.zip
LATEST_REV_PAK=android-16_r01.zip
read -p "Install latest Android $LATEST_REV?
(supports all the latest features)
[Y]es, [N]o, [S]kip : " response
case $response in
[Yy]* )
# Download latest Android SDK
echo -e "\nWill now download $LATEST_REV\n"
wget $LATEST_REV_URL
unzip $LATEST_REV_PAK -d /opt/android-sdk-linux/platforms
echo -e "\nSuccessfully installed Android API $LATEST_REV"
;;
[Nn]* )
echo -e "Android $LATEST_REV did NOT install\n"
;;
[Ss]* ) ;;
* ) echo "Wrong value: installaton aborted."
exit 1
;;
esac
echo -e $DIV
CLASSIC_REV="2.1, revision 03"
CLASSIC_REV_URL=http://dl.google.com/android/repository/android-2.1_r03-linux.zip
read -p "Install Android API $CLASSIC_REV? (supported by ~97% phones and tablets)
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
# Download Android 2.1 SDK
echo -e "\nWill now download $CLASSIC_REV\n"
wget $CLASSIC_REV_URL
# check if there's no "android-sdk-linux/platforms" do you have to make one?
unzip $SDK_21 -d /opt/android-sdk-linux/platforms
echo -e "\nSuccessfully installed Android API $CLASSIC_VERSION"
;;
[Nn]* )
echo -e "Android $CLASSIC_REV did NOT install\n"
;;
[Ss]* ) ;;
* ) echo "Wrong value: installaton aborted."
exit 1
;;
esac
echo -e $DIV
# Configure PATH environmental variable
PATHV=/etc/profile.d/android-sdk.sh
read -p "Configure PATH environmental variable?
Will allow you to run tools such as \"android\" (Android SDK and AVD Manager),
\"emulator\" (Android Emulator), \"ddms\" (Dalvik Debug Monitor) directly from
Terminal.
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
if [ -f $PATHV ]
then
echo -e $DIV
read -p "
An existing \"$PATHV\" file has been detected in \"/etc/profile.d/\"
Installer will overwrite this file, backup will be made and stored in
\"$PATHV.sdk.bak\"
Continue?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
# Backup and remove current android-sdk.sh file
cp -f $PATHV $PATHV.sdk.bak
rm -f $PATHV 2>/dev/null
;;
[Nn]* )
echo -e "\PATH environmental variable was NOT configured, Goodbye"
exit 1
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
else
touch $PATHV
chmod 644 $PATHV
fi
read -p "Do you have a different bashrc file? Type in the complete path or press enter to use the default /etc/bash.bashrc: " new_path
if [ "$new_path" == "" ]
then
new_path=/etc/bash.bashrc
fi
# create a backup of bash.bashrc
cp "$new_path" "${new_path}".bak
if [ -n "$(echo $PATH | grep /opt/android-sdk-linux/tools:/opt/android-sdk-linux/platforms:/opt/android-sdk-linux/platform-tools
)"]; then
echo '' >> "$new_path"
echo '# android-sdk-installer path setting' >> "$new_path"
echo 'export PATH=$PATH:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platforms:/opt/android-sdk-linux/platform-tools' >> "$new_path"
# apply PATH without user having to log out
export PATH=$PATH:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platforms:/opt/android-sdk-linux/platform-tools
echo -e "\nPATH successfully added and configured."
echo "If you need to restore your bashrc file that has been modified, you can do so with ${new_path}.bak"
else
echo "PATH is already configured."
fi
;;
[Nn]* )
echo -e "\nWon't continue without configuring PATH environmental variable"
exit 1
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
echo -e $DIV
# Eclipse and Android ADT plugin installation
#
# This part is completely broken, procedure that is done below worked on
# Eclipse <=3.3
# On latest Eclipse version Plugin needs to be made as seperate component
#
# Reference:
# http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/p2_director.html
read -p "Install ADT (Android Development Tools) Plugin for Eclipse IDE?
[Y]es, [N]o, [S]kip: " response
case $response in
[Yy]* )
PACKAGE=Eclipse
if dpkg -s "$PACKAGE" 2>/dev/null 1>/dev/null
then
echo -e "\n$PACKAGE is installed.\nWill now download Eclipse ADT Plugin\n"
wget $ADT_RM_URL
unzip $ADT_RM -d /tmp/
cp /tmp/features/*.jar /usr/share/eclipse/features/
cp /tmp/plugins/*.jar /usr/share/eclipse/plugins/
# see what to do with rest of the files web/ index.html & site.xml
else
read -p "
$PACKAGE IDE is NOT installed, would you like to install it?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
apt-get install eclipse
echo -e "\nOkay, will now download Eclipse ADT Plugin\n"
wget $ADT_RM_URL
unzip $ADT_RM -d /tmp/
cp /tmp/features/*.jar /usr/share/eclipse/features/
cp /tmp/plugins/*.jar /usr/share/eclipse/plugins/
# see what to do with rest of the files web/ index.html & site.xml
;;
[Nn]* )
echo -e "\nADT Plugin can't be installed without $PACKAGE IDE"
exit 1
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
esac
echo -e $DIV
# Adds Hardware Device support by adding udev rules
RULES=/etc/udev/rules.d/51-android.rules
read -p "Add hardware support for you Android devices?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
echo "Adding hardware support"
;;
[Nn]* )
echo "Hardware support was NOT added"
;;
[Ss]* ) ;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
# Check if the "rules" file already exists
if [ -f $RULES ];
then
echo -e $DIV
read -p "An existing \"51-android.rules\" file has been detected in \"/etc/udev/rules.d/\"
Installer will overwrite this file, backup will be made and stored in
\"$RULES.sdk.bak\"
Continue?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
# backup and remove current 51-android.rules file
cp -f $RULES $RULES.sdk.bak
rm -f $RULES 2>/dev/null
;;
[Nn]* ) echo -e "\nInstaller did NOT add hardware support, Goodbye"
exit 1
;;
[Ss]* ) ;;
* ) echo "Wrong value: installaton aborted."
exit 1
;;
esac
else
# create rules files and give it proper permissions
touch $RULES
chmod 644 $RULES
fi
# add new 51-android.rules file
# Consider removing "OWNER="plugdev" due to the fact that during the boot
# system (Debian Sid) reports it's an unknown user
echo -n '# udev rules which add hardware device support on Linux
#
# \"Using Hardware devices\"
# (http://developer.android.com/guide/developing/device.html)
#
# List last updated: May 9, 2012
# Acer
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0502\", MODE=\"0666\", OWNER=\"plugdev\"
# ASUS
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0b05\", MODE=\"0666\", OWNER=\"plugdev\"
# Dell
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"413c\", MODE=\"0666\", OWNER=\"plugdev\"
# Foxconn
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0489\", MODE=\"0666\", OWNER=\"plugdev\"
# Fujitsu
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"04c5\", MODE=\"0666\", OWNER=\"plugdev\"
# Fujitsu Toshiba
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"04c5\", MODE=\"0666\", OWNER=\"plugdev\"
# Garmin-Asus
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"091e\", MODE=\"0666\", OWNER=\"plugdev\"
# Google
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"18d1\", MODE=\"0666\", OWNER=\"plugdev\"
# Hisense
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"109b\", MODE=\"0666\", OWNER=\"plugdev\"
# HTC
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0bb4\", MODE=\"0666\", OWNER=\"plugdev\"
# Huawei
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"12d1\", MODE=\"0666\", OWNER=\"plugdev\"
# K-Touch
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"24e3\", MODE=\"0666\", OWNER=\"plugdev\"
# KT Tech
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"2116\", MODE=\"0666\", OWNER=\"plugdev\"
# Kyocera
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0482\", MODE=\"0666\", OWNER=\"plugdev\"
# Lenovo
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"17ef\", MODE=\"0666\", OWNER=\"plugdev\"
# LG
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1004\", MODE=\"0666\", OWNER=\"plugdev\"
# Motorola
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"22b8\", MODE=\"0666\", OWNER=\"plugdev\"
# NEC
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0409\", MODE=\"0666\", OWNER=\"plugdev\"
# Nook
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"2080\", MODE=\"0666\", OWNER=\"plugdev\"
# Nvidia
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0955\", MODE=\"0666\", OWNER=\"plugdev\"
# OTGV
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"2257\", MODE=\"0666\", OWNER=\"plugdev\"
# Pantech
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"10a9\", MODE=\"0666\", OWNER=\"plugdev\"
# Pegatron
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1d4d\", MODE=\"0666\", OWNER=\"plugdev\"
# Philips
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0471\", MODE=\"0666\", OWNER=\"plugdev\"
# PMC-Sierra
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"04da\", MODE=\"0666\", OWNER=\"plugdev\"
# Qualcomm
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"05c6\", MODE=\"0666\", OWNER=\"plugdev\"
# SK Telesys
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1f53\", MODE=\"0666\", OWNER=\"plugdev\"
# Samsung
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"04e8\", MODE=\"0666\", OWNER=\"plugdev\"
# Sharp
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"04dd\", MODE=\"0666\", OWNER=\"plugdev\"
# Sony
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"054c\", MODE=\"0666\", OWNER=\"plugdev\"
# Sony Ericsson
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0fce\", MODE=\"0666\", OWNER=\"plugdev\"
# Teleepoch
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"2340\", MODE=\"0666\", OWNER=\"plugdev\"
# Toshiba
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0930\", MODE=\"0666\", OWNER=\"plugdev\"
# ZTE
SUBSYSTEM==\"usb\", ATTR{idVendor}==\"19d2\", MODE=\"0666\", OWNER=\"plugdev\"
' > $RULES
# in future add "sed" in order to avoid repetitive code
# provide all groups, users and others with read permissions for this file
chmod a+r $RULES
echo -e "\nHardware device support successfully installed"
echo -e $DIV
# add MTP support
read -p "Add MTP support? (enables USB mass storage support on Android >= 4.0)
[Y]es, [N]o, [S]kip: " response
# Tell the user to disconnect his device
echo -e "\nPlease make sure your device is disconnected before proceeding!"
case $response in
[Yy]* )
PACKAGE=mtpfs
if [ dpkg -s "$PACKAGE" 2>/dev/null 1>/dev/null ]
then
echo -e "It seems you have all the needed packages installed"
else
read -p "
Packages seem to be missing, install required packages?
[Y]es, [N]o :" response
case $response in
[Yy]* )
apt-get install mtpfs mtp-tools libmtp9 libmtp-runtime libmtp-common
;;
[Nn]* )
echo "Did not install MTP support"
# exit 1
;;
* )
echo "Wrong value: installaton aborted."
exit 1
;;
esac
fi
esac
if [ ! -f $RULES ]
then
# temporary
# echo -e $DIV
read -p "
Missing hardware device support. Add now?
[Y]es, [N]o, [S]kip :" response
case $response in
[Yy]* )
# create rules file and give it proper permissions
touch $RULES
chmod 666 $RULES
# Consider removing "OWNER="plugdev" due to the fact that during the boot
# system (Debian Sid) reports it's an unknown user
echo '# udev rules which add hardware device support on Linux
#
# "Using Hardware devices"
# (http://developer.android.com/guide/developing/device.html)
#
# List last updated: May 9, 2012
# Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", OWNER="plugdev"
# ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", OWNER="plugdev"
# Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", OWNER="plugdev"
# Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", OWNER="plugdev"
# Fujitsu
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", OWNER="plugdev"
# Fujitsu Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", OWNER="plugdev"
# Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", OWNER="plugdev"
# Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", OWNER="plugdev"
# Hisense
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", OWNER="plugdev"
# HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", OWNER="plugdev"
# Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", OWNER="plugdev"
# K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", OWNER="plugdev"
# KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", OWNER="plugdev"
# Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", OWNER="plugdev"
# Lenovo
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", OWNER="plugdev"
# LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", OWNER="plugdev"
# Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", OWNER="plugdev"
# NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", OWNER="plugdev"
# Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", OWNER="plugdev"
# Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", OWNER="plugdev"
# OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", OWNER="plugdev"
# Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", OWNER="plugdev"
# Pegatron
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", OWNER="plugdev"
# Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", OWNER="plugdev"
# PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", OWNER="plugdev"
# Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", OWNER="plugdev"
# SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", OWNER="plugdev"
# Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", OWNER="plugdev"
# Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", OWNER="plugdev"
# Sony
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", OWNER="plugdev"
# Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", OWNER="plugdev"
# Teleepoch
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", OWNER="plugdev"
# Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", OWNER="plugdev"
# ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", OWNER="plugdev"
' > $RULES
# in future add "sed" in order to avoid repetitive code
# provide all groups, users and others with read permissions for this file
chmod a+r+x $RULES
# restart udev