forked from denora/denora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config
executable file
·518 lines (466 loc) · 11 KB
/
Config
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
#!/bin/sh
#
# Configuration script for Stats.
#
# Denora (c) 2004-2013 Denora Team
# Contact us at [email protected]
#
# This program is free but copyrighted software; see the file COPYING for
# details.
#
# Based on the original code of Anope by Anope Team.
# Based on the original code of Thales by Lucas.
#
#
#
###########################################################################
###########################################################################
# Functions
###########################################################################
echo2 () {
$ECHO2 "$*$ECHO2SUF" # these are defined later
}
Show_Banner () {
if [ -f .BANNER ] ; then
. ./version.in
clear
cat .BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH $VERSION_EXTRA/" | sed "s/CURSHORTVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH/" | more
fi
echo ""
echo "Beginning Stats configuration."
echo ""
}
Run_Config () {
WITH_BIN=""
WITH_DATA=""
WITH_RUN=""
WITH_PERM=""
WITH_MYSQL=""
WITH_MYSQL_BT=""
WITH_MEMORYDEBUG=""
WITH_ENCRYPT=""
WITH_THREADING=""
if [ "$BINDEST" != "" ] ; then
WITH_BIN=" --with-bindir=$BINDEST"
WITH_DATA=" --with-datadir=$DATDEST"
fi
if [ "$DATDEST" != "" ] ; then
WITH_DATA=" --with-datadir=$DATDEST"
fi
if [ "$RUNGROUP" != "" ] ; then
WITH_RUN=" --with-rungroup=$RUNGROUP"
fi
if [ "$UMASK" != "" ] ; then
WITH_PERM=" --with-permissions=$UMASK"
fi
if [ "$MYSQL" = "no" ] ; then
WITH_MYSQL=" --without-mysql"
fi
if [ "$MYSQL_BT" = "yes" ]; then
if [ "$MYSQL" = "no" ] ; then
echo "MySQL Backtrace disabled as denora will be compiled without mysql support"
else
WITH_MYSQL_BT=" --enable-mysqlbt"
fi
fi
if [ "$DMEMORY" = "yes" ] ; then
WITH_MEMORYDEBUG=" --enable-mtrace"
fi
if [ "$ENCRYPT" = "yes" ] ; then
WITH_ENCRYPT=" --enable-crypt"
fi
if [ "$THREAD" = "yes" ] ; then
WITH_THREADING=" --enable-threading"
fi
echo "./configure $WITH_BIN $WITH_DATA $WITH_RUN $WITH_PERM $WITH_MYSQL $WITH_MEMORYDEBUG $WITH_ENCRYPT $WITH_THREADING $WITH_MYSQL_BT"
./configure $WITH_BIN $WITH_DATA $WITH_RUN $WITH_PERM $WITH_MYSQL $WITH_MEMORYDEBUG $WITH_ENCRYPT $WITH_THREADING $WITH_MYSQL_BT
if [ "$REGSCRIPT" = "yes" ] ; then
src/bin/register
fi
}
exists () { # because some shells don't have test -e
if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
return 0
else
return 1
fi
}
Load_Cache () {
if [ -f config.cache -a -r config.cache -a ! "$NOCACHE" ] ; then
echo "Using defaults from config.cache. To ignore, rm config.cache"
. ./config.cache
CAN_QUICK="yes"
if [ "$BINDEST" = "" ] ; then
BINDEST=$HOME/stats
fi
if [ "$DATDEST" = "" ] ; then
DATDEST=$HOME/stats
fi
if [ "$MYSQL" = "" ] ; then
MYSQL="yes"
fi
if [ "$SQLITE" = "" ] ; then
SQLITE="yes"
fi
if [ "$MYSQL_BT" = "" ] ; then
MYSQL_BT="no"
fi
if [ "$DMEMORY" = "" ] ; then
DMEMORY="no"
fi
if [ "$REGSCRIPT" = "" ] ; then
REGSCRIPT="no"
fi
if [ "$ENCRYPT" = "" ] ; then
ENCRYPT="no"
fi
if [ "$THREAD" = "" ] ; then
THREAD="no"
fi
else
CAN_QUICK="no"
fi
}
###########################################################################
# Init values
###########################################################################
BINDEST=$HOME/stats
DATDEST=$HOME/stats
RUNGROUP=
UMASK=
DMEMORY="no"
ENCRYPT="yes"
NOCACHE=""
SHOW_INTRO="yes"
CAN_QUICK="no"
REGSCRIPT="no"
MYSQL="yes"
MYSQL_BT="no"
THREAD="no"
SQLITE="yes"
###########################################################################
# Check out the options
###########################################################################
while [ $# -ge 1 ] ; do
if [ $1 = "--help" ] ; then
echo "Config utility for Denora"
echo "-----------------------------"
echo "Syntax: ./Config [options]"
echo "-nocache Ignore settings saved in config.cache"
echo "-nointro Skip intro (release notes, etc)"
echo "-quick Skip questions, go straight to configure"
exit 0
elif [ $1 = "-nocache" ] ; then
NOCACHE="1"
elif [ $1 = "-nointro" ] ; then
SHOW_INTRO="no"
elif [ $1 = "-quick" -o $1 = "-q" ] ; then
Load_Cache
if [ $CAN_QUICK = "yes" ] ; then
Run_Config
else
echo "Can't find cache file, aborting..."
fi
exit 0
fi
shift 1
done
###########################################################################
# Load the cache
###########################################################################
if [ ! "$NOCACHE" ] ; then
Load_Cache
fi
###########################################################################
# Show the banner
###########################################################################
if [ $SHOW_INTRO = "yes" ] ; then
Show_Banner
else
echo ""
fi
###########################################################################
# Ask the user anything we need to know ahead of time.
###########################################################################
export ok INPUT
####
if [ "`id -u`" = "0" ] ; then
echo "ERROR: You can NOT run Config as root, nor run Denora as root"
echo ""
exit 0
fi
# need this file for configure
touch install-sh
ok=0
echo "Note: press Return for the default, or enter a new value."
echo "In what directory do you want the binaries to be installed?"
while [ $ok -lt 1 ] ; do
echo "[$BINDEST] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$BINDEST
fi
if [ ! -d "$INPUT" ] ; then
if exists "$INPUT" ; then
echo "$INPUT exists, but is not a directory!"
else
echo "$INPUT does not exist. Create it?"
echo "[y] "
read YN
if [ "$YN" != "n" ] ; then
if mkdir -p $INPUT ; then
ok=1
fi
fi
fi
elif exists "$INPUT/include/denora.h" ; then
echo "You cannot use the stats source directory as a target directory."
else
ok=1
fi
done
BINDEST=$INPUT
DATDEST=$INPUT
echo ""
####
ok=0
echo "Where do you want the data files to be installed?"
while [ $ok -lt 1 ] ; do
echo "[$DATDEST] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$DATDEST
fi
if [ ! -d "$INPUT" ] ; then
if exists "$INPUT" ; then
echo "$INPUT exists, but is not a directory!"
else
echo "$INPUT does not exist. Create it?"
echo "[y] "
read YN
if [ "$YN" != "n" ] ; then
if mkdir -p $INPUT ; then
ok=1
fi
fi
fi
elif exists "$INPUT/include/denora.h" ; then
echo "You cannot use the stats source directory as a target directory."
else
ok=1
fi
done
DATDEST=$INPUT
echo ""
####
OLD_RUNGROUP="$RUNGROUP"
if [ "$RUNGROUP" ] ; then
echo "Which group should all Stats data files be owned by? (If Stats"
echo "should not force files to be owned by a particular group, type "\"none\"
echo "(without the quotes) and press Return.)"
else
echo "Which group should all Stats data files be owned by? (If Stats"
echo "should not force files to be owned by a particular group, just press"
echo "Return.)"
fi
echo "[$RUNGROUP] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ "$INPUT" ] ; then
lcfile=`echo $INPUT | tr A-Z a-z`
if [ "$INPUT" = "none" ] ; then
RUNGROUP=""
elif [ $lcfile = "root" ] ; then
RUNGROUP=""
echo "Can not use root group to run denora"
exit 0;
else
RUNGROUP="$INPUT"
fi
fi
echo ""
####
if [ ! "$UMASK" -o "$RUNGROUP" != "$OLD_RUNGROUP" ] ; then
if [ "$RUNGROUP" ] ; then
UMASK=007
else
UMASK=077
fi
fi
ok=0
echo "What should the default umask for data files be (in octal)?"
echo "(077 = only accessible by owner; 007 = accessible by owner and group)"
while [ $ok -lt 1 ] ; do
echo "[$UMASK] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$UMASK
fi
if [ "$INPUT" = "000" ] ; then
echo "Invalid UMASK please enter a valid Umask";
elif [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then
echo "$UMASK is not a valid octal number!"
else
if [ "`echo $INPUT | cut -c1`" != "0" ] ; then
INPUT=0$INPUT
fi
ok=1
fi
done
UMASK=$INPUT
echo ""
####
ok=0
DEF=yes
echo "Allow Denora to automatically check for mysql client development libraries?"
echo "unless you get errors with make, there is no need to change this setting."
echo "WARNING: You NEED the mysql client devel libraries installed on your system"
echo " in order to compile Denora with SQL support."
echo " On Debian/Ubuntu systems for example, you need to install the"
echo " libmysqlclient15-dev package or similar."
while [ $ok -lt 1 ] ; do
echo "[$MYSQL] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$MYSQL
fi
case $INPUT in
n*|N*)
MYSQL="no"
ok=1
;;
y*|Y*)
MYSQL="yes"
ok=1
;;
*)
echo "Please enter 'yes' or 'no'."
;;
esac
done
echo ""
####
if [ "$MYSQL" = "yes" ]; then
ok=0
DEF=no
echo "Do you want to backtrace mysql queries?"
echo "WARNING: This will make your logs grow hugely."
while [ $ok -lt 1 ] ; do
echo "[$MYSQL_BT] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$MYSQL_BT
fi
case $INPUT in
n*|N*)
MYSQL_BT="no"
ok=1
;;
y*|Y*)
MYSQL_BT="yes"
ok=1
;;
*)
echo "Please enter 'yes' or 'no'."
;;
esac
done
echo ""
fi
####
ok=0
DEF=no
echo "Would you like to register your network with Denora?"
echo "Doing this will allow us to better focus our project"
while [ $ok -lt 1 ] ; do
echo "[$REGSCRIPT] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$REGSCRIPT
fi
case $INPUT in
n*|N*)
REGSCRIPT="no"
ok=1
;;
y*|Y*)
REGSCRIPT="yes"
ok=1
;;
*)
echo "Please enter 'yes' or 'no'."
;;
esac
done
echo ""
####
ok=0
DEF=Yes
echo "Allow Denora to attempt to build a crypt library so that admin passwords can be encrypted in the config and db files"
while [ $ok -lt 1 ] ; do
echo "[$ENCRYPT] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$ENCRYPT
fi
case $INPUT in
n*|N*)
ENCRYPT="no"
ok=1
;;
y*|Y*)
ENCRYPT="yes"
ok=1
;;
*)
echo "Please enter 'yes' or 'no'."
;;
esac
done
echo ""
####
ok=0
DEF=no
echo "Allow Denora to attempt to build a threading library so that the code can be multithreaded for speed"
while [ $ok -lt 1 ] ; do
echo "[$THREAD] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$THREAD
fi
case $INPUT in
n*|N*)
THREAD="no"
ok=1
;;
y*|Y*)
THREAD="yes"
ok=1
;;
*)
echo "Please enter 'yes' or 'no'."
;;
esac
done
echo ""
################################################################################
# Store values
################################################################################
echo "Saving configuration results in config.cache... "
cat <<EOT >config.cache
BINDEST="$BINDEST"
DATDEST="$DATDEST"
RUNGROUP="$RUNGROUP"
UMASK=$UMASK
MYSQL="$MYSQL"
MYSQL_BT="$MYSQL_BT"
REGSCRIPT="$REGSCRIPT"
DMEMORY="$DMEMORY"
ENCRYPT="$ENCRYPT"
THREAD="$THREAD"
EOT
echo "done."
###########################################################################
# Let's call the configure script
###########################################################################
Run_Config
# EOF