source: tags/0.9.0/cardproxy.sh

Last change on this file was 27, checked in by merek, 14 years ago
  • Dont use -Xmx512m as default in init scripts, as this couÃld break small installations
  • Add LSB information to ubuntu/debian init scripts
File size: 2.4 KB
Line 
1#!/bin/bash
2
3## uncomment this for large csp installations
4#JVM_PRAMS="-Xmx512m -Dsun.net.inetaddr.ttl=0"
5## otherwise use this
6JVM_PARAMS="-Dsun.net.inetaddr.ttl=0"
7
8case "`uname -s`" in
9
10 'CYGWIN'*)
11 SYSTEM="Cygwin"
12 ;;
13
14 'Linux')
15 SYSTEM="Linux"
16 ;;
17
18 'OSF1')
19 SYSTEM="Tru64"
20 ;;
21
22 'SunOS')
23 SYSTEM="Solaris"
24 ;;
25
26 *)
27 SYSTEM="Unknown"
28 ;;
29
30esac
31
32PID_FILE=cardservproxy.pid
33
34serverpid() {
35 if [ -f $PID_FILE ]; then
36 if [ "$SYSTEM" = "Cygwin" ]; then
37 PID=`cat $PID_FILE`
38 if [ "x"$PID != "x" ]; then
39 if [ -n "`ps | grep $PID`" ]; then
40 cat $PID_FILE
41 return
42 fi
43 fi
44 else
45 if [ "$SYSTEM" = "Solaris" ]; then
46 if [ -n "`cat $PID_FILE | xargs ps -p | tail +2`" ]; then
47 cat $PID_FILE
48 return
49 fi
50 else
51 if [ -n "`cat $PID_FILE | xargs ps | tail -n +2`" ]; then
52 cat $PID_FILE
53 return
54 fi
55 fi
56 fi
57 fi
58 echo -n 0
59}
60
61echoresult() {
62 echo -n " "
63 $MOVE_TO_COL
64 echo -n "[ "
65 echo -n $1
66 echo " ]"
67 shift
68 if [ "$#" != "0" ] ; then echo "$1" ; fi
69}
70
71case "$1" in
72
73 'start')
74 echo -n "Starting CardServProxy:"
75 if [ "`serverpid`" != "0" ]; then
76 echoresult FAILED "An instance of the server is already running"
77 exit 1
78 fi
79 java $JVM_PARAMS -jar lib/cardservproxy.jar > log/cardserv-sysout.log 2>&1 &
80 echo $! > $PID_FILE
81 sleep 3
82 ERR=`cat log/cardserv-sysout.log | grep '[Ee]rror\|[Ee]xception\|[Ff]ailed\|not found'`
83 if [ "$ERR" ]; then
84 echoresult FAILED
85 cat log/cardserv-sysout.log
86 OP=`serverpid`
87 if [ $OP != "0" ]; then
88 kill $OP
89 fi
90 rm $PID_FILE
91 exit
92 else
93 echoresult OK
94 fi
95 ;;
96
97 'stop')
98 echo -n "Killing Proxy:"
99 OP=`serverpid`
100 if [ $OP != "0" ]; then
101 rm $PID_FILE
102 kill $OP
103 echoresult OK
104 else
105 echoresult FAILED "Cannot determine pid"
106 fi
107 ;;
108
109 'dump')
110 echo -n "Sending SIGQUIT:"
111 OP=`serverpid`
112 if [ $OP != "0" ]; then
113 kill -3 $OP
114 echoresult OK
115 else
116 echoresult FAILED "Cannot determine pid"
117 fi
118 ;;
119
120 'status')
121 OP=`serverpid`
122 if [ $OP = "0" ]; then
123 echo "Proxy is stopped"
124 exit 1
125 else
126 echo "Proxy (pid $OP) is running..."
127 exit 0
128 fi
129 ;;
130
131 *)
132 echo "Usage: $0 {start|stop|status|dump}"
133 exit 1
134 ;;
135
136esac
137
138exit $?
139
140
141
142
Note: See TracBrowser for help on using the repository browser.