1 | #!/bin/sh |
---|
2 | |
---|
3 | # |
---|
4 | # A simple startup script |
---|
5 | # |
---|
6 | SCRIPT=$(readlink -f $0) |
---|
7 | cd `dirname $SCRIPT` |
---|
8 | |
---|
9 | # Run this program |
---|
10 | PROGRAM="java -cp bin/:\ |
---|
11 | lib/commons-collections-3.2.1.jar:\ |
---|
12 | lib/org.restlet.jar:\ |
---|
13 | lib/antlr-2.7.7.jar:\ |
---|
14 | lib/stringtemplate.jar:\ |
---|
15 | lib/postgresql-8.3-604.jdbc4.jar:\ |
---|
16 | lib/gt-referencing-2.5.2.jar:\ |
---|
17 | lib/geoapi-2.2-M1.jar:\ |
---|
18 | lib/gt-metadata-2.5.2.jar:\ |
---|
19 | lib/gt-epsg-extension-2.5.2.jar:\ |
---|
20 | lib/gt-epsg-wkt-2.5.2.jar:\ |
---|
21 | lib/jsr-275-1.0-beta-2.jar:\ |
---|
22 | lib/vecmath-1.3.1.jar:\ |
---|
23 | lib/acme.jar:\ |
---|
24 | lib/flexjson.jar:\ |
---|
25 | lib/json.jar:\ |
---|
26 | lib/jdom.jar:\ |
---|
27 | lib/jts-1.10.jar:\ |
---|
28 | lib/xerces.jar:\ |
---|
29 | lib/gt-api-2.5.2.jar:\ |
---|
30 | lib/\ |
---|
31 | WRS ./data/configuration.xml" |
---|
32 | |
---|
33 | # In case "identifier" parameter is not set |
---|
34 | if [ $2 ] |
---|
35 | then |
---|
36 | pidfile="logs/restlet-$2-2.0.pid" |
---|
37 | else |
---|
38 | pidfile="logs/restlet-wrs-2.0.pid" |
---|
39 | fi |
---|
40 | |
---|
41 | # What should the service do? |
---|
42 | case $1 in |
---|
43 | start) |
---|
44 | |
---|
45 | echo " |
---|
46 | Service starting ..." |
---|
47 | |
---|
48 | if [ -e "$pidfile" ] |
---|
49 | then |
---|
50 | |
---|
51 | echo "Service is already running!" |
---|
52 | echo "Do nothing ... |
---|
53 | [$pidfile] |
---|
54 | |
---|
55 | " |
---|
56 | else |
---|
57 | $PROGRAM & |
---|
58 | PID=$! |
---|
59 | echo $PID > "$pidfile" |
---|
60 | |
---|
61 | echo "Service started! |
---|
62 | [$pidfile|$PID] |
---|
63 | |
---|
64 | " |
---|
65 | fi |
---|
66 | ;; |
---|
67 | |
---|
68 | restart) |
---|
69 | |
---|
70 | echo " |
---|
71 | Service restarting ..." |
---|
72 | |
---|
73 | if [ -e "$pidfile" ] |
---|
74 | then |
---|
75 | pid2kill=`cat $pidfile` |
---|
76 | kill -9 $pid2kill |
---|
77 | rm $pidfile |
---|
78 | |
---|
79 | echo "Service stopped!" |
---|
80 | |
---|
81 | else |
---|
82 | |
---|
83 | echo "No running service found ... starting a new one!" |
---|
84 | |
---|
85 | fi |
---|
86 | |
---|
87 | $PROGRAM & |
---|
88 | PID=$! |
---|
89 | echo $PID > "$pidfile" |
---|
90 | |
---|
91 | echo "Service started! |
---|
92 | [$pidfile|$PID] |
---|
93 | |
---|
94 | " |
---|
95 | ;; |
---|
96 | |
---|
97 | stop) |
---|
98 | if [ -e "$pidfile" ] |
---|
99 | then |
---|
100 | pid2kill=`cat $pidfile` |
---|
101 | kill -9 $pid2kill |
---|
102 | rm $pidfile |
---|
103 | |
---|
104 | echo " |
---|
105 | Service stopped! |
---|
106 | [$pid2kill] |
---|
107 | |
---|
108 | " |
---|
109 | else |
---|
110 | echo " |
---|
111 | No service found! |
---|
112 | |
---|
113 | " |
---|
114 | fi |
---|
115 | ;; |
---|
116 | |
---|
117 | |
---|
118 | list) |
---|
119 | # get current processes |
---|
120 | echo " |
---|
121 | Currently active WRS process(es): |
---|
122 | " |
---|
123 | |
---|
124 | ps afx | grep restlet |
---|
125 | |
---|
126 | echo " |
---|
127 | |
---|
128 | " |
---|
129 | ;; |
---|
130 | |
---|
131 | debug) |
---|
132 | # run the program as is |
---|
133 | echo " |
---|
134 | Service starting in DEBUG mode ... |
---|
135 | Type CTRL-C to stop the service. |
---|
136 | |
---|
137 | " |
---|
138 | $PROGRAM |
---|
139 | ;; |
---|
140 | |
---|
141 | help) |
---|
142 | echo " |
---|
143 | This is the Webrouting Service startup script |
---|
144 | |
---|
145 | Usage: |
---|
146 | ./wrs-2.0.sh {start|stop|restart|debug|list|help} [identifier] |
---|
147 | |
---|
148 | Commands: |
---|
149 | start Start the service |
---|
150 | stop Stop the service |
---|
151 | restart Stop and immediately start the service again |
---|
152 | debug Run the service in debug mode |
---|
153 | This will print log messages to the terminal window. |
---|
154 | list List currently active process(es) |
---|
155 | help Show the startup help |
---|
156 | |
---|
157 | Optional: |
---|
158 | identifier Run the service as a distinct process. |
---|
159 | |
---|
160 | " |
---|
161 | ;; |
---|
162 | |
---|
163 | *) |
---|
164 | echo " |
---|
165 | Usage: ./wrs-2.0.sh {start|stop|restart|debug|help} |
---|
166 | |
---|
167 | " |
---|
168 | ;; |
---|
169 | esac |
---|