-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcardproxy.sh
More file actions
146 lines (121 loc) · 2.52 KB
/
Copy pathcardproxy.sh
File metadata and controls
146 lines (121 loc) · 2.52 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
## uncomment this for large csp installations
#JVM_PARAMS="-Xmx512m -Dsun.net.inetaddr.ttl=0"
## otherwise use this
JVM_PARAMS="-Dsun.net.inetaddr.ttl=0"
## to enable running under other jvms besides sun:
#JVM_PARAMS="-Dcom.bowman.cardserv.allowanyjvm=true -Dnetworkaddress.cache.ttl=0"
case "`uname -s`" in
'CYGWIN'*)
SYSTEM="Cygwin"
;;
'Linux')
SYSTEM="Linux"
;;
'OSF1')
SYSTEM="Tru64"
;;
'SunOS')
SYSTEM="Solaris"
;;
*)
SYSTEM="Unknown"
;;
esac
PID_FILE=cardservproxy.pid
serverpid() {
if [ -f $PID_FILE ]; then
if [ "$SYSTEM" = "Cygwin" ]; then
PID=`cat $PID_FILE`
if [ "x"$PID != "x" ]; then
if [ -n "`ps | grep $PID`" ]; then
cat $PID_FILE
return
fi
fi
else
if [ "$SYSTEM" = "Solaris" ]; then
if [ -n "`cat $PID_FILE | xargs ps -p | tail +2`" ]; then
cat $PID_FILE
return
fi
else
if [ -n "`cat $PID_FILE | xargs ps | tail -n +2`" ]; then
cat $PID_FILE
return
fi
fi
fi
fi
echo -n 0
}
echoresult() {
echo -n " "
$MOVE_TO_COL
echo -n "[ "
echo -n $1
echo " ]"
shift
if [ "$#" != "0" ] ; then echo "$1" ; fi
}
case "$1" in
'start')
echo -n "Starting CardServProxy:"
if [ "`serverpid`" != "0" ]; then
echoresult FAILED "An instance of the server is already running"
exit 1
fi
java $JVM_PARAMS -jar lib/cardservproxy.jar > log/cardserv-sysout.log 2>&1 &
echo $! > $PID_FILE
sleep 3
ERR=`cat log/cardserv-sysout.log | grep '[Ee]rror\|[Ee]xception\|[Ff]ailed\|not found'`
if [ "$ERR" ]; then
echoresult FAILED
cat log/cardserv-sysout.log
OP=`serverpid`
if [ $OP != "0" ]; then
kill $OP
fi
rm $PID_FILE
exit
else
echoresult OK
fi
;;
'stop')
echo -n "Killing Proxy:"
OP=`serverpid`
if [ $OP != "0" ]; then
rm $PID_FILE
kill $OP
echoresult OK
else
echoresult FAILED "Cannot determine pid"
fi
;;
'dump')
echo -n "Sending SIGQUIT:"
OP=`serverpid`
if [ $OP != "0" ]; then
kill -3 $OP
echoresult OK
else
echoresult FAILED "Cannot determine pid"
fi
;;
'status')
OP=`serverpid`
if [ $OP = "0" ]; then
echo "Proxy is stopped"
exit 1
else
echo "Proxy (pid $OP) is running..."
exit 0
fi
;;
*)
echo "Usage: $0 {start|stop|status|dump}"
exit 1
;;
esac
exit $?