-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
executable file
·53 lines (45 loc) · 977 Bytes
/
upgrade.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
#!/bin/bash
function print_usage() {
echo "A tool to upload changed files to FTP server."
echo "$0 SERVER USER PASSWORD WORKING_DIR FILE_LIST REMOTE_DIR"
echo "SERVER: FTP server"
echo "USER: FTP user name"
echo "PASSWORD: FTP password"
echo "WORKING_DIR: The directory contains the files in FILE_LIST_FILE"
echo "FILE_LIST: a file contains the changed file list generated by a tool, e.g. git diff"
echo "REMOTE_DIR: the target remote directory"
}
if [ $# != 6 ]
then
print_usage
exit 1
fi
SERVER=$1
USER=$2
PASSWORD=$3
WORKING_DIR=$4
FILE_LIST=$5
REMOTE_DIR=$6
while read file
do
if [ -e "$file" ]
then
cmd="send"
else
cmd="delete"
fi
echo "$cmd $file"
ftp -n >~/tmp/upgrade.sh.log 2>&1 <<!
open "$SERVER"
user "$USER" "$PASSWORD"
binary
prompt
cd "$REMOTE_DIR"
lcd "$WORKING_DIR"
passive
"$cmd" "$file"
close
bye
!
done < "$FILE_LIST"
echo "done"