-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscpg
executable file
·59 lines (51 loc) · 1.12 KB
/
scpg
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
#!/bin/bash
typeset -a allowedsubdirs
allowedsubdirs=(assistir audiobooks filmes ebooks mp3 dropbear mnt . external externalm)
function elementExists
{
if [ -z "$1" ]
then
return 1
fi
for i in "${allowedsubdirs[@]}"
do
if [[ "$i" == "$1" ]]
then
return 0
fi
done
return 1
}
typeset -a source # list of elements
if [ $# -lt 2 ]
then
echo "*** Usage: $0 <source files> <galaxy tab directory>" >&2
exit 2
fi
while [ $# -gt 1 ]
do
file="$1"; shift;
if [ ! -r "$file" ]
then
echo "*** File/directory '$file' is not readable or does not exist." >&2
exit 1
fi
source+=("$file")
done
destination="$1"
if elementExists "$destination"
then
if [[ "$destination" == "external" ]]
then
destination=/mnt/sdcard/external_sd
elif [[ "$destination" == "externalm" ]]
then
destination=/mnt/sdcard/external_sd/musicas
else
destination="/sdcard/home/$destination"
fi
/bin/tar --transform='s,^.*/,,' -cvf - "${source[@]}" | ssh [email protected] "tar -x -v -f - -C $destination"
else
echo "*** Destination is not one of the valid ones: (${allowedsubdirs[@]})" >&2
exit 3
fi