-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscp_test.sh
executable file
·79 lines (65 loc) · 1.27 KB
/
scp_test.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
#!/bin/bash
# copies MySQL tests to remote box
# prints usage information
usage ()
{
echo "$VERSION"
echo "
scp_test copies MySQL test files from t directory on local box to remote MySQL machine
Usage: `basename $0` [-v] [-d dirname] [-r user@host:path] [test ...]
Options:
-d directory, which contains test files
-r path to test directory on remote server, default: [email protected]:~/machine/src/tests/t
-v print version
-h print this help
"
}
# error exit
error()
{
printf "$@" >&2
exit $E_CDERROR
}
# creates defaults values
initialize()
{
TESTDIR=$HOME/src/tests
MOVETO='[email protected]:~/machine/src/tests/t'
TESTS_TO_MOVE=""
OLD_PWD=`pwd`
VERSION="scp_test v0.4 (Feb 23 2017)"
}
# parses arguments/sets values to defaults
parse()
{
while getopts "vhd:r:" Option
do
case $Option in
v) echo "$VERSION"; shift;;
h) usage; exit 0;;
d) TESTDIR="$OPTARG"; shift;;
r) MOVETO="$OPTARG"; shift;;
*) usage; exit 0;;
esac
done
shift $((OPTIND-1))
TESTS_TO_MOVE="$@"
}
# copies test to source directories
copy()
{
if [[ "xx" = x"$TESTS_TO_MOVE"x ]]
then
scp "$TESTDIR"/t/* "$MOVETO"
else
for test in $TESTS_TO_MOVE
do
scp "$TESTDIR/t/$test".{test,opt,init,sql,cfg,cnf} "$MOVETO"
done
fi
}
E_CDERROR=65
initialize
parse $@
copy
exit 0