]> jfr.im git - irc/unrealircd/unrealircd.git/blob - Config
./Config: import settings from UnrealIRCd 6.1.5
[irc/unrealircd/unrealircd.git] / Config
1 #!/bin/sh
2 #
3 # Config script for UnrealIRCd
4 # (C) 2001-2021 The UnrealIRCd Team
5 #
6 # This configure script is free software; the UnrealIRCd Team gives
7 # unlimited permission to copy, distribute and modify as long as the
8 # copyright headers stay intact
9 #
10 #
11 # Rewritten completely to be an interface to autoconf by codemastr
12 # This was inspired by the config by Michael Graff (explorer@flame.org)
13 # but was written from scratch
14
15 # In order to be faster than the old Config, this assumes that all information
16 # in the cache file is valid and therefore doesn't check it, so if you messed with
17 # default values thats your problem :P
18
19 # some bits edited by baafie on March 17 2004, every change marked.
20
21 # Remove trailing slash in paths (if any)
22 FIX_PATHNAMES () {
23 BASEPATH="${BASEPATH%/}"
24 BINDIR="${BINDIR%/}"
25 DATADIR="${DATADIR%/}"
26 CONFDIR="${CONFDIR%/}"
27 MODULESDIR="${MODULESDIR%/}"
28 LOGDIR="${LOGDIR%/}"
29 CACHEDIR="${CACHEDIR%/}"
30 DOCDIR="${DOCDIR%/}"
31 TMPDIR="${TMPDIR%/}"
32 PRIVATELIBDIR="${PRIVATELIBDIR%/}"
33 SSLDIR="${SSLDIR%/}"
34 CURLDIR="${CURLDIR%/}"
35 }
36
37 # Create and run the ./configure command with the appropriate
38 # options based on the users settings.
39 RUN_CONFIGURE () {
40 ARG=" "
41
42 if [ -z "$BINDIR" -o -z "$DATADIR" -o -z "$CONFDIR" -o -z "$MODULESDIR" -o -z "$LOGDIR" -o -z "$CACHEDIR" -o -z "$DOCDIR" -o -z "$TMPDIR" -o -z "$PRIVATELIBDIR" ]; then
43 echo "Sorry './Config -quick' cannot be used because your 'config.settings'"
44 echo "file either does not exist or is from an old UnrealIRCd version"
45 echo "(older than UnrealIRCd 5.0.0)."
46 echo ""
47 echo "Please run './Config' without -quick and answer all questions."
48 echo ""
49 exit
50 fi
51
52
53 mkdir -p $TMPDIR
54 mkdir -p $PRIVATELIBDIR
55
56 # Do this even if we're not in advanced mode
57 if [ "$ADVANCED" = "1" ] ; then
58 if [ "$NOOPEROVERRIDE" = "1" ] ; then
59 ARG="$ARG--with-no-operoverride "
60 fi
61 if [ "$OPEROVERRIDEVERIFY" = "1" ] ; then
62 ARG="$ARG--with-operoverride-verify "
63 fi
64 fi
65 if test x"$SSLDIR" = "x" ; then
66 ARG="$ARG--enable-ssl "
67 else
68 ARG="$ARG--enable-ssl=$SSLDIR "
69 fi
70 # Ensure we install curl even if someone does ./Config -quick...
71 if [ "x$CURLDIR" = "x$UNREALCWD/extras/curl" ]; then
72 INSTALLCURL=1
73 else
74 # And that the path does not refer to eg an old unrealircd-1.2.3 either ;)
75 if echo "$CURLDIR"|egrep -qi extras.*curl; then
76 echo "WARNING: Potentially old cURL directory encountered ($CURLDIR)."
77 echo "I am changing the cURL directory to $UNREALCWD/extras/curl and forcing a rebuild of cURL."
78 CURLDIR="$UNREALCWD/extras/curl"
79 INSTALLCURL=1
80 fi
81 fi
82 if [ "$REMOTEINC" = "1" ] ; then
83 ARG="$ARG--enable-libcurl=$CURLDIR "
84 fi
85 if [ "$MAXCONNECTIONS_REQUEST" != "auto" ]; then
86 ARG="$ARG--with-maxconnections=$MAXCONNECTIONS_REQUEST "
87 fi
88
89 ARG="$ARG--with-bindir=$BINDIR "
90 ARG="$ARG--with-datadir=$DATADIR "
91 ARG="$ARG--with-pidfile=$DATADIR/unrealircd.pid "
92 ARG="$ARG--with-controlfile=$DATADIR/unrealircd.ctl "
93 ARG="$ARG--with-confdir=$CONFDIR "
94 ARG="$ARG--with-modulesdir=$MODULESDIR "
95 ARG="$ARG--with-logdir=$LOGDIR "
96 ARG="$ARG--with-cachedir=$CACHEDIR "
97 ARG="$ARG--with-docdir=$DOCDIR "
98 ARG="$ARG--with-tmpdir=$TMPDIR "
99 ARG="$ARG--with-privatelibdir=$PRIVATELIBDIR "
100 ARG="$ARG--with-scriptdir=$BASEPATH "
101 ARG="$ARG--with-nick-history=$NICKNAMEHISTORYLENGTH "
102 ARG="$ARG--with-permissions=$DEFPERM "
103 ARG="$ARG--enable-dynamic-linking "
104 if [ "$GEOIP" = "classic" ]; then
105 ARG="$ARG--enable-geoip-classic "
106 fi
107 if [ "$GEOIP" = "libmaxminddb" ]; then
108 ARG="$ARG--enable-libmaxminddb "
109 fi
110 if [ "$SANITIZER" = "asan" ]; then
111 ARG="$ARG--enable-asan "
112 fi
113 ARG="$ARG $EXTRAPARA "
114 CONF="./configure $ARG"
115 # remove possibly old instances of curl in ~/unrealircd/lib/
116 rm -f $PRIVATELIBDIR/*curl* 1>/dev/null 2>&1
117 if [ "x$INSTALLCURL" = "x1" ]; then
118 extras/curlinstall "$PRIVATELIBDIR" || exit 1
119 fi
120 # At least do SOME parallel compiling by default, IF:
121 # - the MAKE environment variable is not set
122 # - the MAKEFLAGS environment variable is not set
123 # - we are using GNU Make
124 if [ "x$MAKE" = "x" ]; then
125 if [ "x$MAKEFLAGS" = "x" ]; then
126 if make --version 2>&1|grep -q "GNU Make"; then
127 LOWMEM=0
128 if [ -f /proc/meminfo ]; then
129 FREEKB="`cat /proc/meminfo |grep MemAvailable|awk '{ print $2 }'`"
130 if [ "$FREEKB" != "" -a "$FREEKB" -lt 768000 ]; then
131 LOWMEM=1
132 fi
133 fi
134 if [ "$LOWMEM" = 0 ]; then
135 echo "Running with 4 concurrent build processes by default (make -j4)."
136 export MAKE='make -j4'
137 else
138 echo "System detected with less than 750MB available memory, not forcing parallel build."
139 fi
140 fi
141 fi
142 fi
143
144 echo $CONF
145 $CONF || exit 1
146 cd "$UNREALCWD"
147
148 if [ "$QUICK" != "1" ] ; then
149 if [ ! -f $CONFDIR/tls/server.cert.pem -a ! -f $CONFDIR/ssl/server.cert.pem ]; then
150 export OPENSSLPATH
151 if [ "$GENCERTIFICATE" = 1 ]; then
152 echo
153 echo "*******************************************************************************"
154 echo "Next you will be asked some questions in order to generate the TLS certificate."
155 echo "IMPORTANT: If you don't own a domain or don't know what to answer, then you can"
156 echo " simply press ENTER or use fictional names for each question!"
157 echo "*******************************************************************************"
158 echo "Press ENTER to continue"
159 read cc
160 $MAKE pem
161 echo "Certificate created successfully."
162 sleep 1
163 else
164 echo "Ok, not generating TLS certificate. Make sure that the certificate and key"
165 echo "are installed in conf/tls/server.cert.pem and conf/tls/server.key.pem prior to starting the IRCd."
166 fi
167 else
168 echo "TLS certificate already exists in configuration directory, no need to regenerate."
169 fi
170 fi
171
172 # Silently force a 'make clean' as otherwise part (or whole) of the
173 # compiled source could be using different settings than the user
174 # just requested when re-running ./Config.
175 $MAKE clean 1>/dev/null 2>&1
176 }
177
178 RUN_ADVANCED () {
179 TEST=""
180 while [ -z "$TEST" ] ; do
181 if [ "$NOOPEROVERRIDE" = "1" ] ; then
182 TEST="Yes"
183 else
184 TEST="No"
185 fi
186 echo ""
187 echo "Do you want to disable oper override?"
188 echo $n "[$TEST] -> $c"
189 read cc
190 if [ -z "$cc" ] ; then
191 cc=$TEST
192 fi
193 case "$cc" in
194 [Yy]*)
195 NOOPEROVERRIDE="1"
196 ;;
197 [Nn]*)
198 NOOPEROVERRIDE=""
199 ;;
200 *)
201 echo ""
202 echo "You must enter either Yes or No"
203 TEST=""
204 ;;
205 esac
206 done
207
208 TEST=""
209 while [ -z "$TEST" ] ; do
210 if [ "$OPEROVERRIDEVERIFY" = "1" ] ; then
211 TEST="Yes"
212 else
213 TEST="No"
214 fi
215 echo ""
216 echo "Do you want to require opers to /invite themselves into a +s or +p channel?"
217 echo $n "[$TEST] -> $c"
218 read cc
219 if [ -z "$cc" ] ; then
220 cc=$TEST
221 fi
222 case "$cc" in
223 [Yy]*)
224 OPEROVERRIDEVERIFY="1"
225 ;;
226 [Nn]*)
227 OPEROVERRIDEVERIFY=""
228 ;;
229 *)
230 echo ""
231 echo "You must enter either Yes or No"
232 TEST=""
233 ;;
234 esac
235 done
236
237 }
238 c=""
239 n=""
240 UNREALCWD="`pwd`"
241 BASEPATH="$HOME/unrealircd"
242 DEFPERM="0600"
243 SSLDIR=""
244 NICKNAMEHISTORYLENGTH="2000"
245 MAXCONNECTIONS_REQUEST="auto"
246 REMOTEINC=""
247 CURLDIR=""
248 NOOPEROVERRIDE=""
249 OPEROVERRIDEVERIFY=""
250 GENCERTIFICATE="1"
251 EXTRAPARA=""
252 SANITIZER=""
253 GEOIP="classic"
254 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
255 c="\c"
256 else
257 n="-n"
258 fi
259
260
261 #parse arguments
262 IMPORTEDSETTINGS=""
263 NOINTRO=""
264 QUICK=""
265 ADVANCED=""
266 while [ $# -ge 1 ] ; do
267 if [ $1 = "--help" ] ; then
268 echo "Config utility for UnrealIRCd"
269 echo "-----------------------------"
270 echo "Syntax: ./Config [options]"
271 echo "-nointro Skip intro (release notes, etc)"
272 echo "-quick Skip questions, go straight to configure"
273 echo "-advanced Include additional advanced questions"
274 exit 0
275 elif [ $1 = "-nointro" ] ; then
276 NOINTRO="1"
277 elif [ $1 = "-quick" -o $1 = "-q" ] ; then
278 QUICK="1"
279 echo "running quick config"
280 if [ -f "config.settings" ] ; then
281 . ./config.settings
282 fi
283 FIX_PATHNAMES
284 RUN_CONFIGURE
285 cd "$UNREALCWD"
286 exit 0
287 elif [ $1 = "-advanced" ] ; then
288 PREADVANCED="1"
289 fi
290 shift 1
291 done
292
293 if [ "$PREADVANCED" = "1" ] ; then
294 ADVANCED="1"
295 elif [ "$ADVANCED" = "1" ]; then
296 ADVANCED=""
297 fi
298
299 if [ "`id -u`" = "0" ]; then
300 echo "ERROR: You cannot build or run UnrealIRCd as root"
301 echo ""
302 echo "Please create a separate account for building and running UnrealIRCd."
303 echo "See https://www.unrealircd.org/docs/Do_not_run_as_root"
304 exit
305 fi
306
307 # Check for gmake early...
308 if [ "$MAKE" = "" ]; then
309 MAKE="make"
310 fi
311
312 if ! $MAKE --version 2>&1|grep -q "GNU Make"; then
313 # So $MAKE is not GNU make, but do we have gmake?
314 if gmake --version 2>&1|grep -q "GNU Make"; then
315 # Great, use that one!
316 MAKE="gmake"
317 else
318 # Both $MAKE and gmake are not GNU make, do we have a working $MAKE at all?
319 if $MAKE --version 1>/dev/null 2>&1; then
320 echo "Your system has 'make' but UnrealIRCd requires GNU Make ('gmake')"
321 echo "Please install 'gmake' (eg 'pkg install gmake' on BSD)."
322 exit 1
323 else
324 echo "Your system does not have the required tools installed to build UnrealIRCd."
325 echo "Please check https://www.unrealircd.org/docs/Installing_from_source"
326 echo "and install the required tools listed under 'Prerequisites'."
327 echo "After that, you can run ./Config again"
328 exit 1
329 fi
330 fi
331 fi
332
333
334 clear
335
336 if [ -f "doc/Config.header" -a -z "$NOINTRO" ] ; then
337 cat doc/Config.header
338 echo ""
339 echo $n "[Press Enter to continue]"
340 read cc
341 clear
342 fi
343
344 echo "We will now ask you a number of questions. You can just press ENTER to accept the defaults!"
345 echo ""
346
347 # This needs to be updated each release so auto-upgrading works for settings, modules, etc!!:
348 UNREALRELEASES="unrealircd-6.1.5 unrealircd-6.1.4 unrealircd-6.1.3 unrealircd-6.1.3-rc1 unrealircd-6.1.2.3 unrealircd-6.1.2.2 unrealircd-6.1.2.1 unrealircd-6.1.2 unrealircd-6.1.2-rc2 unrealircd-6.1.2-rc1 unrealircd-6.1.1.1 unrealircd-6.1.1 unrealircd-6.1.0 unrealircd-6.1.0-rc2 unrealircd-6.1.0-rc1 unrealircd-6.0.7 unrealircd-6.0.6 unrealircd-6.0.5 unrealircd-6.0.5-rc2 unrealircd-6.0.5-rc1 unrealircd-6.0.4.2 unrealircd-6.0.4.1 unrealircd-6.0.4 unrealircd-6.0.4-rc2 unrealircd-6.0.4-rc1 unrealircd-6.0.3 unrealircd-6.0.2 unrealircd-6.0.1.1 unrealircd-6.0.1 unrealircd-6.0.0 unrealircd-6.0.0-rc2 unrealircd-6.0.0-rc1 unrealircd-6.0.0-beta4 unrealircd-6.0.0-beta3 unrealircd-6.0.0-beta2 unrealircd-6.0.0-beta1 unrealircd-5.2.3 unrealircd-5.2.2 unrealircd-5.2.1.1 unrealircd-5.2.1 unrealircd-5.2.1-rc1 unrealircd-5.2.0.2 unrealircd-5.2.0.1 unrealircd-5.2.0 unrealircd-5.2.0-rc1 unrealircd-5.0.9.1 unrealircd-5.0.9"
349 if [ -f "config.settings" ]; then
350 . ./config.settings
351 else
352 # Try to load a previous config.settings
353 for x in $UNREALRELEASES
354 do
355 if [ -f ../$x/config.settings ]; then
356 IMPORTEDSETTINGS="../$x"
357 break
358 fi
359 done
360 echo "If you have previously installed UnrealIRCd on this shell then you can specify a"
361 echo "directory here so I can import the build settings and third party modules"
362 echo "to make your life a little easier."
363 if [ ! -z "$IMPORTEDSETTINGS" ]; then
364 echo "Found previous installation in: $IMPORTEDSETTINGS."
365 echo "You can enter a different path or type 'none' if you don't want to use it."
366 echo "Just press Enter to accept the default settings."
367 else
368 echo "If you install UnrealIRCd for the first time on this shell, then just hit Enter";
369 fi
370
371 TEST="$IMPORTEDSETTINGS"
372 echo $n "[$TEST] -> $c"
373 read cc
374 if [ -z "$cc" ]; then
375 IMPORTEDSETTINGS="$TEST"
376 else
377 IMPORTEDSETTINGS="$cc"
378 fi
379 if [ "$IMPORTEDSETTINGS" = "none" ]; then
380 IMPORTEDSETTINGS=""
381 fi
382 if [ "$IMPORTEDSETTINGS" != "" ]; then
383 if [ -d $IMPORTEDSETTINGS/conf ]; then
384 echo "ERROR: Directory $IMPORTEDSETTINGS is an INSTALLATION directory (eg /home/irc/unrealircd)."
385 echo "This question was about a SOURCE directory (eg /home/irc/unrealircd-5.0.0)."
386 exit
387 fi
388 if [ ! -f $IMPORTEDSETTINGS/config.settings ]; then
389 echo "Directory $IMPORTEDSETTINGS does not exist or does not contain a config.settings file"
390 exit
391 fi
392 COPYMODULES="1"
393 if grep -q TOPICNICKISNUH $IMPORTEDSETTINGS/config.settings; then
394 echo "Directory $IMPORTEDSETTINGS seems to be UnrealIRCd 4.x (or older)."
395 echo "I will copy the settings but not any 3rd party modules, as they are incompatible with 5.x."
396 COPYMODULES="0"
397 fi
398 # Actually load the settings
399 . $IMPORTEDSETTINGS/config.settings
400 if [ "$COPYMODULES" = "1" ]; then
401 # Copy over 3rd party modules (also deals with 0 file cases, hence the silly looking code)
402 for f in $IMPORTEDSETTINGS/src/modules/third/*.c
403 do
404 [ -e "$f" ] && cp $f src/modules/third/
405 done
406 fi
407 fi
408 fi
409 # If we just imported settings and the curl dir is set to
410 # something like /home/xxx/unrealircd-5.x.y/extras/curl/
411 # (what we call 'local-curl') then remove this setting as
412 # it would refer to the old UnrealIRCd installation.
413 if [ ! -z "$IMPORTEDSETTINGS" ]; then
414 if echo "$CURLDIR"|grep -qi unrealircd; then
415 CURLDIR=""
416 fi
417 fi
418
419 TEST="$BASEPATH"
420 echo ""
421 echo "In what directory do you want to install UnrealIRCd?"
422 echo "(Note: UnrealIRCd 6 will need to be installed somewhere."
423 echo " If this directory does not exist it will be created.)"
424 echo $n "[$TEST] -> $c"
425 read cc
426 if [ -z "$cc" ] ; then
427 BASEPATH=$TEST
428 else
429 BASEPATH=`eval echo $cc` # modified
430 fi
431 if [ "$BASEPATH" = "$UNREALCWD" ]; then
432 echo ""
433 echo "ERROR: The installation directory cannot be the same as the directory"
434 echo " containing the source code ($UNREALCWD)."
435 echo " HINT: Usually the directory containing the source is $HOME/unrealircd-5.x.y"
436 echo " and the installation directory you would need to enter is $HOME/unrealircd"
437 exit 1
438 fi
439
440 # TODO: For -advanced we could prompt the user.
441 BINDIR="$BASEPATH/bin"
442 DATADIR="$BASEPATH/data"
443 CONFDIR="$BASEPATH/conf"
444 MODULESDIR="$BASEPATH/modules"
445 LOGDIR="$BASEPATH/logs"
446 CACHEDIR="$BASEPATH/cache"
447 DOCDIR="$BASEPATH/doc"
448 TMPDIR="$BASEPATH/tmp"
449 PRIVATELIBDIR="$BASEPATH/lib"
450
451 TEST=""
452 while [ -z "$TEST" ] ; do
453 TEST="$DEFPERM"
454 echo ""
455 echo "What should the default permissions for your configuration files be? (Set this to 0 to disable)"
456 echo "It is strongly recommended that you use 0600 to prevent unwanted reading of the file"
457 echo $n "[$TEST] -> $c"
458 read cc
459 if [ -z "$cc" ] ; then
460 DEFPERM=$TEST
461 break
462 fi
463 case "$cc" in
464 [0-9]*)
465 DEFPERM="$cc"
466 ;;
467 *)
468 echo ""
469 echo "You must enter a number"
470 TEST=""
471 ;;
472 esac
473 done
474
475 echo ""
476 echo "If you want, you can manually enter the path to OpenSSL/LibreSSL here."
477 echo "In most cases you can leave this blank and it will be detected automatically."
478
479 if [ -z "$SSLDIR" ]; then
480 uname|grep -q Darwin
481 if [ "$?" = 0 ]; then
482 echo "Looks like you're on a Mac - El Capitan and higher require"
483 echo "a 3rd party OpenSSL installation. We recommend using homebrew"
484 echo "to install OpenSSL, but you may install it any other way as well."
485 echo "We are selecting the default homebrew OpenSSL path - but you can"
486 echo "change it to another path if you have installed OpenSSL another way"
487 SSLDIR="/usr/local/opt/openssl/"
488 fi
489 fi
490
491 TEST="$SSLDIR"
492 echo $n "[$TEST] -> $c"
493 read cc
494 if [ -z "$cc" ] ; then
495 SSLDIR="$TEST"
496 else
497 SSLDIR=`eval echo $cc` # modified
498 fi
499
500 if [ "$SSLDIR" != "" -a "$SSLDIR" != "/usr" ]; then
501 echo ""
502 echo "You answered previous question manually. Just note that if the library is not"
503 echo "in your default library path then UnrealIRCd may fail to start with an error"
504 echo "that it cannot find certain .so files (libraries). In that case you would have"
505 echo "to either set the LD_LIBARY_PATH environment variable, or you could update the"
506 echo "Makefile to link with -Wl,-rpath,$SSLDIR or similar."
507 echo ""
508 if [ "$SSLDIR" = "/usr/local" ]; then
509 echo "**** CAUTION ****"
510 echo "You have chosen to use OpenSSL from /usr/local. Just be aware that if you"
511 echo "use the LD_LIBRARY_PATH or -Wl,-rpath,$SSLDIR from above,"
512 echo "that you are diverting OTHER libraries to that path as well."
513 echo "It's not only loading OpenSSL from /usr/local but also potentially other"
514 echo "libraries like PCRE2, Jansson, or any of the other libraries that"
515 echo "UnrealIRCd uses (including dependencies about 40 libs in total!)"
516 echo "All that can result in weird issues and crashes!"
517 echo ""
518 fi
519 echo "Press enter to continue with the rest of the questions, or CTRL+C to abort."
520 read cc
521 fi
522
523 if [ ! -f $BASEPATH/conf/tls/server.cert.pem -a ! -f $BASEPATH/conf/ssl/server.cert.pem ]; then
524 TEST=""
525 while [ -z "$TEST" ] ; do
526 if [ "$GENCERTIFICATE" = "1" ] ; then
527 TEST="Yes"
528 else
529 TEST="No"
530 fi
531 echo ""
532 echo "UnrealIRCd requires a TLS certificate in order to work."
533 echo "Do you want to generate a self-signed TLS certificate for the IRCd?"
534 echo "Only answer No if you already have one."
535 echo $n "[$TEST] -> $c"
536 read cc
537 if [ -z "$cc" ] ; then
538 cc=$TEST
539 fi
540 case "$cc" in
541 [Yy]*)
542 GENCERTIFICATE="1"
543 ;;
544 [Nn]*)
545 GENCERTIFICATE=""
546 ;;
547 *)
548 echo ""
549 echo "You must enter either Yes or No"
550 TEST=""
551 ;;
552 esac
553 done
554 fi
555
556 TEST=""
557 while [ -z "$TEST" ] ; do
558 if [ "$REMOTEINC" = "1" ] ; then
559 TEST="Yes"
560 else
561 TEST="No"
562 fi
563 echo ""
564 echo "UnrealIRCd comes with support for 'remote includes', this allows things like:"
565 echo "include \"https://www.example.org/files/opers.conf\";"
566 echo "Do you want to compile with the libcurl library to enable additional protocols?"
567 echo "If you answer 'No' then only https:// links will work for remote includes."
568 echo "Answer 'Yes' if you need other protocols, such as plaintext http, ftp, tftp or smb."
569 echo "Most people answer 'No' here because they don't use remote includes or only need https."
570 echo $n "[$TEST] -> $c"
571 read cc
572 if [ -z "$cc" ] ; then
573 cc=$TEST
574 fi
575 case "$cc" in
576 [Yy]*)
577 REMOTEINC="1"
578 ;;
579 [Nn]*)
580 REMOTEINC=""
581 CURLDIR=""
582 ;;
583 *)
584 echo ""
585 echo "You must enter either Yes or No"
586 TEST=""
587 ;;
588 esac
589 done
590
591 if [ "$REMOTEINC" = "1" ] ; then
592 if [ ! -d "$CURLDIR" ]; then
593 # Reset any previous CURLDIR if it doesn't exist (anymore)
594 CURLDIR=""
595 fi
596
597 INSTALLCURL="0"
598 SUGGESTCURLDIR=""
599
600 if [ -d "/usr/local/include/curl" ]; then
601 SUGGESTCURLDIR="/usr/local"
602 fi
603 if [ -d "/usr/include/curl" ]; then
604 SUGGESTCURLDIR="/usr"
605 fi
606 # This one also works for /usr/include/x86_64-linux-gnu and friends:
607 if [ -f "/usr/bin/curl-config" ]; then
608 SUGGESTCURLDIR="/usr"
609 fi
610
611 GOTASYNC=0
612 if [ "x$SUGGESTCURLDIR" != "x" ]; then
613 # Check if it's of any use: a curl without async dns (cares) hangs the entire ircd..
614 # normally this is done in ./configure but now we're forced to do it also here..
615 if "$SUGGESTCURLDIR"/bin/curl-config --features | grep -q -e AsynchDNS; then
616 GOTASYNC="1"
617 fi
618 if [ "$GOTASYNC" != "1" ]; then
619 SUGGESTCURLDIRBAD="$CURLDIR"
620 SUGGESTCURLDIR=""
621 fi
622 fi
623
624 if [ "x$CURLDIR" = "x$HOME/curl" ]; then
625 if [ "x$SUGGESTCURLDIR" != "x" ]; then
626 # I guess some people will complain about this, but if system wide cURL is available
627 # and many people have old defaults then this is much preferred:
628 echo ""
629 echo "WARNING: Your previous (potentially old) setting is to use cURL from $HOME/curl."
630 echo "However, your operating system also provides a working cURL."
631 echo "I am therefore changing the setting to: $SUGGESTCURLDIR"
632 CURLDIR="$SUGGESTCURLDIR"
633 else
634 echo ""
635 echo "WARNING: We no longer use $HOME/curl nowadays."
636 echo "Use the automatic download and install feature below."
637 CURLDIR=""
638 fi
639 fi
640
641 if [ "x$CURLDIR" = "x" ]; then
642 CURLDIR="$SUGGESTCURLDIR"
643 # NOTE: CURLDIR may still be empty after this
644
645 # System curl has no asyncdns, so install our own.
646 if [ "$GOTASYNC" != "1" ]; then
647 CURLDIR=""
648 fi
649
650 # Need to output it here, as the HOME check from above may cause this to be no longer relevant.
651 if [ "x$CURLDIR" = "x" -a "x$SUGGESTCURLDIRBAD" != "x" ]; then
652 echo "Curl library was found in $SUGGESTCURLDIRBAD, but it does not support Asynchronous DNS (not compiled with c-ares)"
653 echo "so it's of no use to us as it would stall the IRCd on REHASH."
654 fi
655 fi
656
657 # Final check
658 if [ "x$CURLDIR" != "x" ]; then
659 "$CURLDIR/bin/curl-config" --features 2>/dev/null | grep -q -e AsynchDNS
660 if [ "$?" != 0 ]; then
661 echo "Curl from $CURLDIR seems unusable ($CURLDIR/bin/curl-config does not exist)"
662 CURLDIR=""
663 fi
664 fi
665
666 if [ "x$CURLDIR" = "x" ]; then
667 # Still empty?
668 TEST=""
669 while [ -z "$TEST" ] ; do
670 TEST="Yes"
671 echo ""
672 echo "Do you want me to automatically download and install curl for you?"
673 echo $n "[$TEST] -> $c"
674 read cc
675 if [ -z "$cc" ] ; then
676 cc=$TEST
677 fi
678 case "$cc" in
679 [Yy]*)
680 INSTALLCURL="1"
681 CURLDIR="$UNREALCWD/extras/curl"
682 ;;
683 [Nn]*)
684 INSTALLCURL="0"
685 ;;
686 *)
687 echo ""
688 echo "You must enter either Yes or No"
689 TEST=""
690 ;;
691 esac
692 done
693 fi
694
695 if [ "$INSTALLCURL" != "1" ]; then
696 TEST=""
697 while [ -z "$TEST" ] ; do
698 TEST="$CURLDIR"
699 echo ""
700 echo "Specify the directory you installed libcurl to"
701 echo $n "[$TEST] -> $c"
702 read cc
703 if [ -z "$cc" ] ; then
704 cc=$TEST
705 else
706 TEST=$cc
707 CURLDIR=`eval echo $cc` # modified
708 fi
709 done
710 if [ "x$CURLDIR" != "x" ]; then
711 "$CURLDIR/bin/curl-config" --libs 1>/dev/null 2>&1
712 if [ "$?" != 0 ]; then
713 echo "Curl from $CURLDIR seems unusable ($CURLDIR/bin/curl-config does not exist)"
714 CURLDIR=""
715 fi
716 fi
717 fi
718 fi
719
720
721 TEST=""
722 while [ -z "$TEST" ] ; do
723 TEST="$NICKNAMEHISTORYLENGTH"
724 echo ""
725 echo "How far back do you want to keep the nickname history?"
726 echo $n "[$TEST] -> $c"
727 read cc
728 if [ -z "$cc" ] ; then
729 NICKNAMEHISTORYLENGTH=$TEST
730 break
731 fi
732 case "$cc" in
733 [1-9]*)
734 NICKNAMEHISTORYLENGTH="$cc"
735 ;;
736 *)
737 echo ""
738 echo "You must enter a number"
739 TEST=""
740 ;;
741 esac
742 done
743
744 TEST=""
745 while [ -z "$TEST" ] ; do
746 TEST="$GEOIP"
747 echo ""
748 echo "GeoIP is a feature that allows converting an IP address to a location (country)"
749 echo "Possible build options:"
750 echo " classic: This is the DEFAULT geoip engine. It should work on all systems"
751 echo " and receives automatic updates."
752 echo "libmaxminddb: This uses the libmaxminddb library. If you want to use this, then"
753 echo " you need to install the libmaxminddb library on your system first"
754 echo " none: Don't build with any geoip library (geoip-csv is still built)"
755 echo "Choose one of: classic, libmaxminddb, none"
756 echo $n "[$TEST] -> $c"
757 read cc
758 if [ -z "$cc" ] ; then
759 GEOIP=$TEST
760 break
761 fi
762 case "$cc" in
763 classic)
764 GEOIP="$cc"
765 ;;
766 libmaxminddb)
767 GEOIP="$cc"
768 ;;
769 none)
770 GEOIP="$cc"
771 ;;
772 *)
773 echo ""
774 echo "Invalid choice: $cc"
775 TEST=""
776 ;;
777 esac
778 done
779
780 echo ""
781 TEST=""
782 while [ -z "$TEST" ] ; do
783 TEST="$MAXCONNECTIONS_REQUEST"
784 echo ""
785 echo "What is the maximum number of sockets (and file descriptors) that"
786 echo "UnrealIRCd may use?"
787 echo "It is recommended to leave this at the default setting 'auto',"
788 echo "which at present results in a limit of up to 16384, depending on"
789 echo "the system. When you boot UnrealIRCd later you will always see"
790 echo "the effective limit."
791 echo $n "[$TEST] -> $c"
792 read cc
793 if [ -z "$cc" ] ; then
794 MAXCONNECTIONS_REQUEST=$TEST
795 break
796 fi
797 case "$cc" in
798 auto)
799 MAXCONNECTIONS_REQUEST="$cc"
800 ;;
801 [1-9][0-9][0-9]*)
802 MAXCONNECTIONS_REQUEST="$cc"
803 ;;
804 *)
805 echo ""
806 echo "You must to enter a number greater than or equal to 100."
807 echo "Or enter 'auto' to leave it at automatic, which is recommended."
808 TEST=""
809 ;;
810 esac
811 done
812 if [ -n "$ADVANCED" ] ; then
813 RUN_ADVANCED
814 fi
815
816 TEST=""
817 while [ -z "$TEST" ] ; do
818 if [ "$SANITIZER" = "asan" ] ; then
819 TEST="Yes"
820 else
821 TEST="No"
822 fi
823 echo ""
824 echo "Are you running UnrealIRCd as a test, debugging a problem or developing a module?"
825 echo "Then it is possible to run with AddressSanitizer enabled. This will make it"
826 echo "catch bugs such as out-of-bounds and other memory corruption issues, which can"
827 echo "be really helpful in some cases. The downside is that it will consume a lot"
828 echo "more memory and run slower too. So, only answer 'Yes' if you are OK with this."
829 echo "Also, on some systems (notably FreeBSD), when you enable AddressSanitizer,"
830 echo "UnrealIRCd may fail to start. So when in doubt, answer 'No'."
831 echo "Do you want to enable AddressSanitizer?"
832 echo $n "[$TEST] -> $c"
833 read cc
834 if [ -z "$cc" ] ; then
835 cc=$TEST
836 fi
837 case "$cc" in
838 [Yy]*)
839 SANITIZER="asan"
840 ;;
841 [Nn]*)
842 SANITIZER=""
843 ;;
844 *)
845 echo ""
846 echo "You must enter either Yes or No"
847 TEST=""
848 ;;
849 esac
850 done
851
852 TEST="$EXTRAPARA"
853 echo ""
854 echo "Would you like to pass any custom parameters to configure?"
855 echo "Most people don't need this and can just press ENTER."
856 echo "Otherwise, see \`./configure --help' and write them here:"
857 echo $n "[$TEST] -> $c"
858 read EXTRAPARA
859 if [ -z "$EXTRAPARA" ]; then
860 EXTRAPARA="$TEST"
861 fi
862
863 FIX_PATHNAMES
864
865 rm -f config.settings
866 cat > config.settings << __EOF__
867 #
868 # These are the settings saved from running './Config'.
869 # Note that it is not recommended to edit config.settings by hand!
870 # Chances are you misunderstand what a variable does or what the
871 # supported values are. You better just re-run the ./Config script
872 # and answer appropriately there, to get a correct config.settings
873 # file.
874 #
875 BASEPATH="$BASEPATH"
876 BINDIR="$BINDIR"
877 DATADIR="$DATADIR"
878 CONFDIR="$CONFDIR"
879 MODULESDIR="$MODULESDIR"
880 LOGDIR="$LOGDIR"
881 CACHEDIR="$CACHEDIR"
882 DOCDIR="$DOCDIR"
883 TMPDIR="$TMPDIR"
884 PRIVATELIBDIR="$PRIVATELIBDIR"
885 MAXCONNECTIONS_REQUEST="$MAXCONNECTIONS_REQUEST"
886 NICKNAMEHISTORYLENGTH="$NICKNAMEHISTORYLENGTH"
887 GEOIP="$GEOIP"
888 DEFPERM="$DEFPERM"
889 SSLDIR="$SSLDIR"
890 REMOTEINC="$REMOTEINC"
891 CURLDIR="$CURLDIR"
892 NOOPEROVERRIDE="$NOOPEROVERRIDE"
893 OPEROVERRIDEVERIFY="$OPEROVERRIDEVERIFY"
894 GENCERTIFICATE="$GENCERTIFICATE"
895 SANITIZER="$SANITIZER"
896 EXTRAPARA="$EXTRAPARA"
897 ADVANCED="$ADVANCED"
898 __EOF__
899 RUN_CONFIGURE
900 cd "$UNREALCWD"
901 cat << __EOF__
902
903 _______________________________________________________________________
904 | |
905 | UnrealIRCd Compile-Time Config |
906 |_______________________________________________________________________|
907 |_______________________________________________________________________|
908 | |
909 | - The UnrealIRCd Team - |
910 | |
911 | Bram Matthys (Syzop) - syzop@unrealircd.org |
912 | Krzysztof Beresztant (k4be) - k4be@unrealircd.org |
913 | Gottem - gottem@unrealircd.org |
914 | i - i@unrealircd.org |
915 |_______________________________________________________________________|
916 |_______________________________________________________________________|
917 | |
918 | Now all you have to do is type '$MAKE' and let it compile. When that's |
919 | done, you will receive other instructions on what to do next. |
920 |_______________________________________________________________________|
921 __EOF__
922