2 # InspIRCd Configuration Script
4 # Copyright 2003 The ChatSpike Development Team
5 # <brain@chatspike.net>
6 # <Craig@chatspike.net>
11 ########################################
13 echo "Configuring default values..."
16 GCCVER=`gcc -dumpversion | cut -c 1`
17 GCC34=`gcc -dumpversion | cut -c 3`
19 MODULE_DIR=$ME/modules
21 INSTALL=`which install`
24 MAX_CLIENT_T=`ulimit -n`
29 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
31 if [ -z $MAX_CLIENT_T ] ; then
37 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
38 `rm -rf .config.cache`
41 if [ -e ".config.cache" -a -z "$CLEAN" ] ; then
45 if [ "$1" = "-update" -o "$2" = "-update" ] ; then
46 # They wanna update their Makefile.. good for 'em
47 # Make sure .config.cache exists
48 if [ ! -e ".config.cache" ] ; then
49 echo "You have not run ./configure before. Please do this before trying to run the update script."
52 # Right, load the cache values
59 FLAGS="-fPIC -frtti $OPTIMISATI"
64 FLAGS="-fPIC -frtti $OPTIMISATI"
70 for module in src/modules/*.cpp ; do
71 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
72 MODULES="$MODULES $mod"
75 # Write the new makefile.
82 if [ -z $MAX_CLIENT ] ; then
83 MAX_CLIENT=$MAX_CLIENT_T
89 if [ "`eval echo -e -n 'a'`" = "-n a" ] ; then
95 exists () { # because some shells don't have test -e
96 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
103 echo "#include <string.h>">.test.cpp
104 echo "#include <stdio.h>">>.test.cpp
105 echo "int main() { char a[10]; char b[10]; strlcpy(a,b,10); printf(\"%d\\n\",999); }" >>.test.cpp
106 g++ -o .test .test.cpp
107 HAS_STRLCPY=`./.test`
108 rm -f .test.cpp .test
111 echo -e "'\033[1;33m####\033[0;37m:'\033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::'\033[1;33m####\033[0;37m:'\033[1;33m########\033[0;37m:::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::"
112 echo -e ". \033[1;33m##\033[0;37m:: \033[1;33m###\033[0;37m:: \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:. \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:"
113 echo -e ": \033[1;33m##\033[0;37m:: \033[1;33m####\033[0;37m: \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m:::..:: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m:::..:: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m:"
114 echo -e ": \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m \033[1;33m##\033[0;37m \033[1;33m##\033[0;37m:. \033[1;33m######\033[0;37m:: \033[1;33m########\033[0;37m::: \033[1;33m##\033[0;37m:: \033[1;33m########\033[0;37m:: \033[1;33m##\033[0;37m::::::: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m:"
115 echo -e ": \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m. \033[1;33m####\033[0;37m::..... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.....:::: \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m.. \033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m::::::: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m:"
116 echo -e ": \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m:. \033[1;33m###\033[0;37m:'\033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m::::::::: \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m::. \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m:::: \033[1;33m##\033[0;37m:"
117 echo -e "'\033[1;33m####\033[0;37m: \033[1;33m##\033[0;37m::. \033[1;33m##\033[0;37m:. \033[1;33m######\033[0;37m:: \033[1;33m##\033[0;37m::::::::'\033[1;33m####\033[0;37m: \033[1;33m##\033[0;37m:::. \033[1;33m##\033[0;37m:. \033[1;33m######\033[0;37m:: \033[1;33m########\033[0;37m::"
118 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
120 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
122 echo "*** If you are unsure of any of these values, leave it blank for ***"
123 echo "*** standard settings that will work, and your server will run ***"
124 echo "*** using them. If you are running this server as part of a ***"
125 echo "*** larger network, you must consult with your network admins ***"
126 echo "*** for the proper values to use, or server links will be unstable! ***"
128 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
129 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
130 echo -e "dir, otherwise you won't have a config file!"
132 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT_T"
135 #############################################################################
139 echo "In what directory are the configuration files?"
140 while [ $ok -eq 0 ] ; do
141 echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
142 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
143 if [ ! "$INPUT" ] ; then
147 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
148 echo 'Please use a pathname without the characters: '\'' " \'
149 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
150 if exists "$INPUT" ; then
151 echo "$INPUT exists, but is not a directory!"
153 echo "$INPUT does not exist. Create it?"
154 echo -e $n "[\033[1;32my\033[0;37m] $c"
156 if [ "$YN" != "n" ] ; then
157 if mkdir -p "$INPUT" ; then
170 ##############################################################################
174 echo "In What directory are the modules to be compiled to?"
175 while [ $ok -eq 0 ] ; do
176 echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
177 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
178 if [ ! "$INPUT" ] ; then
182 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
183 echo 'Please use a pathname without the characters: '\'' " \'
184 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
185 if exists "$INPUT" ; then
186 echo "$INPUT exists, but is not a directory!"
188 echo "$INPUT does not exist. Create it?"
189 echo -e $n "[\033[1;32my\033[0;37m] $c"
191 if [ "$YN" != "n" ] ; then
192 if mkdir -p "$INPUT" ; then
205 ##############################################################################
209 echo "In what directory is the IRCd binary to be placed?"
210 while [ $ok -eq 0 ] ; do
211 echo -e $n "[\033[1;32m$BINARY_DIR\033[0;37m] -> $c"
212 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
213 if [ ! "$INPUT" ] ; then
217 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
218 echo 'Please use a pathname without the characters: '\'' " \'
219 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
220 if exists "$INPUT" ; then
221 echo "$INPUT exists, but is not a directory!"
223 echo "$INPUT does not exist. Create it?"
224 echo -e $n "[\033[1;32my\033[0;37m] $c"
226 if [ "$YN" != "n" ] ; then
227 if mkdir -p "$INPUT" ; then
239 ###############################################################################
240 # Craigs Version 3 With slightly less Cheeze :p
243 echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)?"
244 while [ "$cheeze" -eq "0" ] ; do
245 echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
248 if [ -z "$cc" ] ; then
254 if [ "$cc" -gt "$MAX_CLIENT_T" -a -z "$SCAN_FAILED" ] ; then
255 echo -e "WARNING: Our scans have indicated that you are attempting"
256 echo -e "to use more sockets than there are avaliable. Are you sure"
257 echo -e "you wish to do this? It may cause the IRCd to malfunction [y/n]"
258 echo -e $n "[\033[1;32mn\033[0;37m] -> $c"
260 if [ "$YN" = "y" ] ; then
265 echo -e "Please enter the correct value (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)"
275 echo "You must enter a number in this field. Please try again."
282 ###############################################################################
285 echo -e "What is the Maximum length of nicknames?"
286 while [ "$cheeze" -eq "0" ] ; do
287 echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
297 echo "You Must Enter a Number in this field. Please Try Again."
307 ###############################################################################
310 echo -e "What is the Maximum length of channel names?"
311 while [ "$cheeze" -eq "0" ] ; do
312 echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
322 echo "You Must Enter a Number in this field. Please Try Again."
332 ###############################################################################
335 echo -e "What is the Maximum number of mode changes in one line?"
336 while [ "$cheeze" -eq "0" ] ; do
337 echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
347 echo "You Must Enter a Number in this field. Please Try Again."
357 ###############################################################################
361 echo -e "Enter the Level Of Binary optimisation. This is a number between 0 and 3 (inclusive)"
362 echo -e "The InspIRCd Team will _NOT_ support any bug reports above 0."
363 echo -e "Also note, the IRCd behaviour will be different depending on this value."
364 echo -e "Please read the documentation for more information."
366 echo -e "The Higher the number, the more optimised your binary will be. This value will default to 0"
367 echo -e "If you either a) Dont enter a number, or b) Enter a value outside the range."
368 echo -e $n "[\033[1;32m$OPTIMITEMP\033[0;37m] -> $c"
370 if [ -z "$cc" ] ; then
393 ###############################################################################
396 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
398 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
399 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
400 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
401 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
402 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
403 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
404 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
405 echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER.$GCC34"
406 echo -e "\033[0;37mOptimatizaton Flag:\033[1;32m\t\t$OPTIMISATI"
409 echo "Writing cache file for future ./configures ..."
411 if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
416 if [ -e ".config.cache" ] ; then
419 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> .config.cache
420 echo "MODULE_DIR=\"$MODULE_DIR\"" >> .config.cache
421 echo "BINARY_DIR=\"$BINARY_DIR\"" >> .config.cache
422 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> .config.cache
423 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> .config.cache
424 echo "NICK_LENGT=\"$NICK_LENGT\"" >> .config.cache
425 echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache
426 echo "OPTIMITEMP=\"$OPTIMITEMP\"" >> .config.cache
427 echo "OPTIMISATI=\"$OPTIMISATI\"" >> .config.cache
428 echo "GCC34=\"$GCC34\"" >> .config.cache
429 echo "HAS_STRLCPY=\"$HAS_STRLCPY\"" >> .config.cache
430 echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
432 echo "Writing include/inspircd_config.h ..."
434 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
435 echo "" >>include/inspircd_config.h
436 if [ "$GCCVER" -eq "3" ] ; then
437 echo "#define GCC3" >>include/inspircd_config.h
438 if [ "$GCC34" -gt "3" ] ; then
439 echo "#define GCC34" >>include/inspircd_config.h
442 if [ "$HAS_STRLCPY" -eq "999" ] ; then
443 echo "#define HAS_STRLCPY" >>include/inspircd_config.h
445 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
446 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
447 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
448 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
449 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
450 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
451 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
452 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
453 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
454 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
455 echo "#define OPTIMISATION $OPTIMITEMP" >>include/inspircd_config.h
456 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
457 echo "#define MAXBUF 514">>include/inspircd_config.h
458 touch include/inspircd_config.h
460 echo "Preparing Variables for the Makefile"
465 FLAGS="-fPIC -frtti $OPTIMISATI"
470 FLAGS="-fPIC -frtti $OPTIMISATI"
476 for module in src/modules/*.cpp ; do
477 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
478 MODULES="$MODULES $mod"
481 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
489 echo "Do you want to compile the IRCd binaries?"
490 echo -e $n "[\033[1;32my\033[0;37m] $c"
492 if [ "$YN" != "n" ] ; then
494 echo -e "\033[1;32mCompiling...\033[0;37m"
505 echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
507 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
513 echo "Do you want to run the config file maker?"
514 echo -e $n "[\033[1;32my\033[0;37m] $c"
516 if [ "$YN" != "n" ] ; then
520 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"