-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmount-nexus
executable file
·87 lines (82 loc) · 2.1 KB
/
mount-nexus
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
#!/bin/bash
set -euf -o pipefail
out () { printf %s\\n "$*" ; }
##
# How to mount a Nexus 5 phone on Linux.
#
# Enable Developer Options on the Nexus:
#
#
# * Settings > About Phone
# * Tap seven times on "Build Number".
#
# Enable USB debugging:
#
# * Settings > Developer options > Debuggins
# * Tap "USB debugging"
#
# Install necessary MTP modules to your computer:
#
# sudo apt-get install mtp-tools mtpfs
#
# Configure 51-android.rules:
#
# sudo gedit /etc/udev/rules.d/51-android.rules
#
# Paste the following at the end of the file;
# if the file does not exist then just paste:
#
# # LG - Nexus 4 phone
# SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"
#
# # LG - Nexus 5 phone
# SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"
#
# # Samsung - Nexus 7 & 10
# SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
#
# Make the file executable:
#
# sudo chmod +x /etc/udev/rules.d/51-android.rules
#
# Restart udev:
#
# sudo service udev restart
#
# Contact: Joel Parker Henderson ([email protected])
# License: GPL
# Updated: 2015-01-25
##
if [ `lsusb |grep Google |wc -l` == 0 ]; then
out "Please plug in the device"
exit 1
fi
if [ `dpkg -l mtpfs |wc -l` == "0" ]; then
out "Installing MTP: Media Transfer Protocol"
sudo apt-get update && sudo apt-get install mtpfs
fi
rules_file=/etc/udev/rules.d/60-android.rules
if [ ! -f $rules_file ]; then
vp=`lsusb|grep Google|cut -d " " -f 6`
vendor=`out $vp | cut -d ':' -f 1`
product=`out $vp | cut -d ':' -f 2`
rule="SUBSYSTEM==\"usb\", ATTR{idVendor}==\"$vendor\", ATTR{idProduct}==\"$product\", MODE=\"0600\", GROUP=\"plugdev\" OWNER=\"$USER\""
out "Creating $rules_file"
out "For user $USER"
out "---"
out $rule
out "---"
sudo bash -c "out $rule > $rules_file"
sudo chmod +x $rules_file
sudo service udev restart
fi
mount_point=/media/nexus
if [ ! -d $mount_point ]; then
sudo mkdir $mount_point
sudo chmod 775 $mount_point
fi
sudo mtpfs -o allow_other $mount_point
out "Mounting $mount_point"
out "This may take a minute..."
out "To change to this directory:"
out " cd $mount_point"