unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

Config (26519B)

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