-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBP.sh
executable file
·62 lines (54 loc) · 1.33 KB
/
MBP.sh
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
#!/bin/bash
#mnt_dir=$(mtp-detect | grep -A 1 Found | grep -v Found | cut -d ':' -f1)
CON_DEV=$(jmtpfs -l | grep Device | wc -l)
source ./lib
clear
#########################LISTING###################################
for i in $(seq 1 $CON_DEV)
do
echo "$i.$(jmtpfs -l | cut -d "," -f6 | sed '1,2d' | sed -n "${i}p")"
done
echo -e "\\nTotal Devices Connected With MTP : $CON_DEV\\n"
#########################MOUNTING###################################
read -p "Select Device : " in
DEV_NAME=$(jmtpfs -l | cut -d "," -f6 | sed '1,2d' | sed -n "${in}p" | tr -d '[:space:]')
if [[ -d ~/$DEV_NAME ]]
then
if grep ~/$DEV_NAME /etc/mtab > /dev/null
then
echo Already Mounted.... Starting Backup
rsync_copy "$DEV_NAME" "$1"
fi
echo Directory $DEV_NAME Exist! Remove it?
read choice
case $choice in
y|Y|yes|YES)
rm -rf ~/$DEV_NAME
;;
n|N|no|NO)
echo OKAY BYYY
exit 0
;;
*)
echo Invalid Choice
;;
esac
fi
mkdir ~/$DEV_NAME
if [[ $? -eq 0 ]]
then
echo ~/$DEV_NAME Created
else
exit 0
fi
echo Mounting $DEV_NAME
BUS=$(jmtpfs -l | cut -d "," -f1 | sed '1,2d' | sed -n "${in}p")
DEV=$(jmtpfs -l | cut -d "," -f2 | sed '1,2d' | sed -n "${in}p" | tr -d '[:space:]')
if $(jmtpfs -device=${BUS},${DEV} ~/$DEV_NAME)
then
echo Mounting Successfull
else
echo Failed
fi
echo Starting Backup
rsync_copy "$DEV_NAME" "$1"