-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
56 lines (49 loc) · 778 Bytes
/
deploy.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
#!/bin/sh
HOST=""
KEY=""
USER_NAME=""
SOURCE="./"
DESTINATION="./"
while getopts "h:k:u:s:d:" opt
do
case $opt in
h) arg_h=$OPTARG
HOST=$arg_h
;;
k) arg_k=$OPTARG
KEY=$arg_k
;;
u) arg_u=$OPTARG
USER_NAME=$arg_u
;;
s) arg_s=$OPTARG
SOURCE=$arg_s
;;
d) arg_d=$OPTARG
DESTINATION=$arg_d
;;
*)
echo "Wrong parameter."
exit 255
;;
esac
done
if [ "${HOST}" = "" ]; then
echo "Please input host using -h option."
exit 1
fi
if [ "${USER_NAME}" = "" ]; then
echo "Please input user name using -u option."
exit 2
fi
if [ "${KEY}" = "" ]; then
echo "Please input key using -k option."
exit 3
fi
echo "Start upload"
sftp -oIdentityFile="$KEY" "$USER"@"$HOST" << EOF
lcd "${SOURCE}"
cd "${DESTINATION}"
put -r *
bye
EOF