-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·122 lines (114 loc) · 2.89 KB
/
install.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
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
#!/bin/sh
#Version=201904211015
# known clientMode:
# ro: get.sh list.sh
# wo: upload.sh delete.sh
# sr: sget.sh slist.sh
# sw: supload.sh sdelete.sh
# sro: get.sh list.sh sget.sh slist.sh
# swo: upload.sh delete.sh supload.sh slist.sh
# srw: get.sh list.sh upload.sh delete.sh sget.sh slist.sh supload.sh sdelete.sh
# so: sget.sh slist.sh supload.sh sdelete.sh
# default: get.sh list.sh upload.sh delete.sh
clientRepo="https://raw.githubusercontent.com/MSSputnik/s3scripts/master"
clientRFiles="get.sh list.sh"
clientWFiles="upload.sh delete.sh"
clientRSFiles="sget.sh slist.sh"
clientWSFiles="supload.sh sdelete.sh"
clientSFiles=
echo "Installscript for s3scripts"
clientType=$1
clientMode=$2
clientPath=$3
httpClient=$4
if [ -z "$clientType" ]; then
clientType=curl
fi
if [ -z "$clientMode" ]; then
clientMode=rw
fi
if [ -z "$clientPath" ]; then
clientPath=.
fi
if [ -z "$httpClient" ]; then
httpClient=curl
fi
echo Using:
echo clientType: $clientType
echo clientMode: $clientMode
echo clientPath: $clientPath
if [ $httpClient != "curl" -a $httpClient != "wget" ]; then
echo "ERROR: httpClient invalid http client specified. [curl|wget]"
exit 1
fi
if [ -e "$clientPath" ]; then
if [ ! -d "$clientPath" ]; then
echo "ERROR: clientPath $clientPath exists but is not a diretory."
exit 1
fi
else
echo "clientPath $clientPath does not exist. Creating..."
mkdir -p $clientPath
erg=$?
if [ $erg -gt 0 ]; then
echo "ERROR: Create clientPath $clientPath failed. Abort installation."
exit $erg
fi
fi
if ! echo "${clientPath}" | grep '/$'; then
clientPath=$clientPath/
fi
if [ $clientMode = "ro" ]; then
clientFiles="$clientRFiles"
fi
if [ $clientMode = "wo" ]; then
clientFiles="$clientWFiles"
fi
if [ $clientMode = "sr" ]; then
clientFiles="$clientRSFiles"
fi
if [ $clientMode = "sw" ]; then
clientFiles="$clientWSFiles"
fi
if [ $clientMode = "sro" ]; then
clientFiles="$clientRFiles $clientRSFiles"
fi
if [ $clientMode = "swo" ]; then
clientFiles="$clientWFiles $clientWSFiles"
fi
if [ $clientMode = "srw" ]; then
clientFiles="$clientRFiles $clientWFiles $clientRSFiles $clientWSFiles"
fi
if [ $clientMode = "so" ]; then
clientFiles="$clientRSFiles $clientWSFiles"
fi
if [ -z "$clientFiles" ]; then
clientFiles="$clientRFiles $clientWFiles"
fi
clientFiles="$clientFiles $clientSFiles"
echo "Files to download: $clientFiles"
erg=0
for f in $clientFiles; do
clientSource=$clientRepo/$clientType/$f
clientDest=$clientPath$f
if [ $httpClient = "wget" ]; then
echo "wget $clientSource $clientDest"
wget -O "$clientDest" $clientSource
erg=$(( $erg+$? ))
else
echo "curl $clientSource $clientDest"
curl -f -o "$clientDest" $clientSource
erg=$(( $erg+$? ))
fi
if [ -e $clientDest ]; then
chmod 755 $clientDest
fi
done
if [ $erg -gt 0 ]; then
echo
echo "ERROR: Not all files downloaded."
else
echo
echo "All scripts downloaded successfully."
fi
exit $erg