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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
$NetBSD: patch-bin_cppcms__run,v 1.1 2013/07/16 10:12:48 joerg Exp $
--- bin/cppcms_run.orig 2013-01-02 22:26:03.000000000 +0000
+++ bin/cppcms_run
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
############################################################################
#
@@ -8,8 +8,7 @@
#
############################################################################
-locate_server()
-{
+locate_server() {
NAME=$1
if [ "$WEB_SERVER" != "" ] ; then
return
@@ -29,7 +28,7 @@ locate_server()
return
fi
done
- if [ "$2" == "exit" ] ; then
+ if [ "$2" = "exit" ] ; then
echo "Failed to locate server $NAME, exitting"
echo "Try providing PATH valiable"
exit 1
@@ -39,7 +38,7 @@ locate_server()
lighttpd() {
locate_server lighttpd $1
-[ "$WEB_SERVER" == "" ] && return
+[ "$WEB_SERVER" = "" ] && return
CONFIG_FILE=$DIR/lighty.conf
@@ -47,7 +46,7 @@ case $API in
fastcgi) ;;
scgi) ;;
http) if [ "$SOCKET" != "" ]; then
- if [ "$1" == "exit" ]; then
+ if [ "$1" = "exit" ]; then
echo "http is supported over TCP/IP only" ; exit 1
else
WEB_SERVER=""
@@ -57,7 +56,7 @@ case $API in
;;
*)
- if [ "$1" == "exit" ]; then
+ if [ "$1" = "exit" ]; then
echo "Mod $API is not supported by lightppd" ; exit 1
else
WEB_SERVER=""
@@ -66,7 +65,7 @@ case $API in
;;
esac
-if [ "$API" == "http" ]; then
+if [ "$API" = "http" ]; then
LIGHTTPD_MODULE=proxy
else
LIGHTTPD_MODULE=$API
@@ -175,12 +174,12 @@ nginx()
locate_server nginx $1
-[ "$WEB_SERVER" == "" ] && return
+[ "$WEB_SERVER" = "" ] && return
case $API in
fastcgi) ;;
scgi) if [ "$HTTP_HEADERS" != "true" ] ; then
- if [ "$1" == "exit" ]; then
+ if [ "$1" = "exit" ]; then
echo "service.generate_http_headers is false, nginx SCGI module requires it to be set to true"
exit 1
else
@@ -190,7 +189,7 @@ case $API in
fi
;;
http) if [ "$SOCKET" != "" ]; then
- if [ "$1" == "exit" ]; then
+ if [ "$1" = "exit" ]; then
echo "http is supported over TCP/IP only" ; exit 1
else
WEB_SERVER=""
@@ -200,8 +199,8 @@ case $API in
;;
*)
- if [ "$1" == "exit" ]; then
- echo "Mod $API is not supported by lightppd" ; exit 1
+ if [ "$1" = "exit" ]; then
+ echo "Mod $API is not supported by nginx" ; exit 1
else
WEB_SERVER=""
return
@@ -289,7 +288,7 @@ http {
}
EOF
-if [ "$API" == "fastcgi" ]; then
+if [ "$API" = "fastcgi" ]; then
cat >>$CONFIG_FILE <<EOF
@@ -319,7 +318,7 @@ cat >>$CONFIG_FILE <<EOF
}
EOF
-elif [ "$API" == "scgi" ] ; then
+elif [ "$API" = "scgi" ] ; then
cat >>$CONFIG_FILE <<EOF
@@ -370,8 +369,7 @@ WEB_SERVER="$WEB_SERVER -c $CONFIG_FILE"
}
-apache()
-{
+apache() {
locate_server apache2
locate_server httpd2
@@ -379,8 +377,8 @@ locate_server apache
locate_server httpd $1
-[ "$WEB_SERVER" == "" ] && return
-if [ "$APACHE_MOD_DIR" == "" ] ; then
+[ "$WEB_SERVER" = "" ] && return
+if [ "$APACHE_MOD_DIR" = "" ] ; then
for p in /usr/lib/apache2/modules \
/usr/local/lib/apache2/modules \
/opt/lib/apache2/modules \
@@ -419,8 +417,8 @@ if [ "$APACHE_MOD_DIR" == "" ] ; then
done
fi
-if [ "$APACHE_MOD_DIR" == "" ] ; then
- if [ "$1" == "exit" ] ; then
+if [ "$APACHE_MOD_DIR" = "" ] ; then
+ if [ "$1" = "exit" ] ; then
echo "Can't find apache modules directory try specifing APACHE_MOD_DIR"
exit 1;
else
@@ -430,8 +428,8 @@ if [ "$APACHE_MOD_DIR" == "" ] ; then
fi
-if ! [ -f "$APACHE_MOD_DIR/mod_fastcgi.$APACHE_MOD_EXT" ] && [ "$API" == "fastcgi" ]; then
- if [ "$1" == "exit" ] ; then
+if ! [ -f "$APACHE_MOD_DIR/mod_fastcgi.$APACHE_MOD_EXT" ] && [ "$API" = "fastcgi" ]; then
+ if [ "$1" = "exit" ] ; then
echo "Can't find apache fastcgi modue"
exit 1
else
@@ -439,8 +437,8 @@ if ! [ -f "$APACHE_MOD_DIR/mod_fastcgi.$
fi
fi
-if ! [ -f "$APACHE_MOD_DIR/mod_scgi.$APACHE_MOD_EXT" ] && [ "$API" == "scgi" ]; then
- if [ "$1" == "exit" ] ; then
+if ! [ -f "$APACHE_MOD_DIR/mod_scgi.$APACHE_MOD_EXT" ] && [ "$API" = "scgi" ]; then
+ if [ "$1" = "exit" ] ; then
echo "Can't find apache scgi modue"
exit 1
else
@@ -448,8 +446,8 @@ if ! [ -f "$APACHE_MOD_DIR/mod_scgi.$APA
fi
fi
-if ! [ -f "$APACHE_MOD_DIR/mod_proxy_http.$APACHE_MOD_EXT" ] && [ "$API" == "http" ]; then
- if [ "$1" == "exit" ] ; then
+if ! [ -f "$APACHE_MOD_DIR/mod_proxy_http.$APACHE_MOD_EXT" ] && [ "$API" = "http" ]; then
+ if [ "$1" = "exit" ] ; then
echo "Can't find apache proxy_http modue"
exit 1
else
@@ -457,8 +455,8 @@ if ! [ -f "$APACHE_MOD_DIR/mod_proxy_htt
fi
fi
-if [ "$API" == "scgi" ] && [ "$SOCKET" != "" ]; then
- if [ "$1" == "exit" ] ; then
+if [ "$API" = "scgi" ] && [ "$SOCKET" != "" ]; then
+ if [ "$1" = "exit" ] ; then
echo "Apache2 supports scgi over tcp sockets only"
exit 1
else
@@ -514,7 +512,7 @@ cat >$DIR/apache.conf << EOF
LoadModule mime_module $APACHE_MOD_DIR/mod_mime.$APACHE_MOD_EXT
EOF
-if [ "$API" == "fastcgi" ];
+if [ "$API" = "fastcgi" ];
then
@@ -529,7 +527,7 @@ cat >>$DIR/apache.conf <<EOF
EOF
-elif [ "$API" == "scgi" ];
+elif [ "$API" = "scgi" ];
then
@@ -538,7 +536,7 @@ cat >>$DIR/apache.conf <<EOF
SCGIMount $SCRIPT $SERVICE_IP:$SERVICE_PORT
EOF
-elif [ "$API" == "http" ];
+elif [ "$API" = "http" ];
then
@@ -559,8 +557,7 @@ WEB_SERVER="$WEB_SERVER -f $DIR/apache.c
}
-find_param()
-{
+find_param() {
if [ -e ./cppcms_config_find_param ]; then
./cppcms_config_find_param $2 $1
else
@@ -568,8 +565,7 @@ find_param()
fi
}
-help()
-{
+help() {
echo "Usage cppcms_run [-e] [ -S server ] [-p port] [-h host] \\"
echo " [-r /document/root ] [-s /script ]"
echo " program -c config.txt [ additional parameters ]"
@@ -593,21 +589,21 @@ PORT=8080
ROOT=`pwd`
while ! [ -e "$1" ] ; do
- if [ "$1" == "-s" ] ; then
+ if [ "$1" = "-s" ] ; then
SCRIPT="$2"
shift
- elif [ "$1" == "-S" ] ; then
+ elif [ "$1" = "-S" ] ; then
TRY_SETUP="$2"
shift
- elif [ "$1" == "-h" ]; then
+ elif [ "$1" = "-h" ]; then
HOST="$2"
shift
- elif [ "$1" == "-p" ]; then
+ elif [ "$1" = "-p" ]; then
PORT="$2";
shift
- elif [ "$1" == "-e" ]; then
+ elif [ "$1" = "-e" ]; then
NO_APP=yes
- elif [ "$1" == "-r" ]; then
+ elif [ "$1" = "-r" ]; then
ROOT="$2"
shift
else
@@ -618,13 +614,13 @@ done
PROGRAM="$1"
-if [ "$2" != "-c" ] || [ "$3" == "" ] ; then
+if [ "$2" != "-c" ] || [ "$3" = "" ] ; then
help
fi
APP_CONFIG_FILE="$3"
-if [ "$SCRIPT" == "" ] ; then
+if [ "$SCRIPT" = "" ] ; then
SCRIPT="/$PROGRAM"
fi
@@ -636,17 +632,17 @@ SERVICE_PORT=`find_param $APP_CONFIG_FIL
API=`find_param $APP_CONFIG_FILE service.api`
HTTP_HEADERS=`find_param $APP_CONFIG_FILE service.generate_http_headers`
-if [ "$API" == "" ] ; then
+if [ "$API" = "" ] ; then
echo "Can't find service.api or service.socket in $APP_CONFIG_FILE"
echo "Aborting"
exit 1
fi
-if [ "$SERVICE_IP" == "" ]; then
+if [ "$SERVICE_IP" = "" ]; then
SERVICE_IP=127.0.0.1
fi
-if [ "$SOCKET" == "" ] && [ "$SERVICE_PORT" == "" ] ; then
+if [ "$SOCKET" = "" ] && [ "$SERVICE_PORT" = "" ] ; then
echo "Can't find service.socket or service.ip and service.port in $APP_CONFIG_FILE"
echo "Aborting"
exit 1
@@ -682,9 +678,9 @@ if [ "$TRY_SETUP" != "" ]; then
esac
else
lighttpd
- [ "$WEB_SERVER" == "" ] && nginx
- [ "$WEB_SERVER" == "" ] && apache
- if [ "$WEB_SERVER" == "" ]; then
+ [ "$WEB_SERVER" = "" ] && nginx
+ [ "$WEB_SERVER" = "" ] && apache
+ if [ "$WEB_SERVER" = "" ]; then
echo "Can't find sutiable web server (nginx/lighttpd/apache)"
echo "You may try to change PATH variable. In case of Apache2"
echo "You may want to define APACHE_MOD_DIR variable"
|