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`
18 MODULE_DIR=$ME/modules
20 INSTALL=`which install`
23 MAX_CLIENT_T=`ulimit -n`
28 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
30 if [ -z $MAX_CLIENT_T ] ; then
36 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
37 `rm -rf .config.cache`
40 if [ -e ".config.cache" -a -z "$CLEAN" ] ; then
44 if [ "$1" = "-update" -o "$2" = "-update" ] ; then
45 # They wanna update their Makefile.. good for 'em
46 # Make sure .config.cache exists
47 if [ ! -e ".config.cache" ] ; then
48 echo "You have not run ./configure before. Please do this before trying to run the update script."
51 # Right, load the cache values
58 FLAGS="-fPIC -frtti $OPTIMISATI"
63 FLAGS="-fPIC -frtti $OPTIMISATI"
69 for module in src/modules/*.cpp ; do
70 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
71 MODULES="$MODULES $mod"
74 # Write the new makefile.
81 if [ -z $MAX_CLIENT ] ; then
82 MAX_CLIENT=$MAX_CLIENT_T
88 if [ "`eval echo -e -n 'a'`" = "-n a" ] ; then
94 exists () { # because some shells don't have test -e
95 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
103 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::"
104 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:"
105 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:"
106 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:"
107 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:"
108 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:"
109 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::"
110 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
112 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
114 echo "*** If you are unsure of any of these values, leave it blank for ***"
115 echo "*** standard settings that will work, and your server will run ***"
116 echo "*** using them. If you are running this server as part of a ***"
117 echo "*** larger network, you must consult with your network admins ***"
118 echo "*** for the proper values to use, or server links will be unstable! ***"
120 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
121 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
122 echo -e "dir, otherwise you won't have a config file!"
124 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT_T"
127 #############################################################################
131 echo "In what directory are the configuration files?"
132 while [ $ok -eq 0 ] ; do
133 echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
134 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
135 if [ ! "$INPUT" ] ; then
139 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
140 echo 'Please use a pathname without the characters: '\'' " \'
141 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
142 if exists "$INPUT" ; then
143 echo "$INPUT exists, but is not a directory!"
145 echo "$INPUT does not exist. Create it?"
146 echo -e $n "[\033[1;32my\033[0;37m] $c"
148 if [ "$YN" != "n" ] ; then
149 if mkdir -p "$INPUT" ; then
162 ##############################################################################
166 echo "In What directory are the modules to be compiled to?"
167 while [ $ok -eq 0 ] ; do
168 echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
169 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
170 if [ ! "$INPUT" ] ; then
174 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
175 echo 'Please use a pathname without the characters: '\'' " \'
176 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
177 if exists "$INPUT" ; then
178 echo "$INPUT exists, but is not a directory!"
180 echo "$INPUT does not exist. Create it?"
181 echo -e $n "[\033[1;32my\033[0;37m] $c"
183 if [ "$YN" != "n" ] ; then
184 if mkdir -p "$INPUT" ; then
197 ##############################################################################
201 echo "In what directory is the IRCd binary to be placed?"
202 while [ $ok -eq 0 ] ; do
203 echo -e $n "[\033[1;32m$BINARY_DIR\033[0;37m] -> $c"
204 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
205 if [ ! "$INPUT" ] ; then
209 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
210 echo 'Please use a pathname without the characters: '\'' " \'
211 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
212 if exists "$INPUT" ; then
213 echo "$INPUT exists, but is not a directory!"
215 echo "$INPUT does not exist. Create it?"
216 echo -e $n "[\033[1;32my\033[0;37m] $c"
218 if [ "$YN" != "n" ] ; then
219 if mkdir -p "$INPUT" ; then
231 ###############################################################################
232 # Craigs Version 3 With slightly less Cheeze :p
235 echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)?"
236 while [ "$cheeze" -eq "0" ] ; do
237 echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
240 if [ -z "$cc" ] ; then
246 if [ "$cc" -gt "$MAX_CLIENT_T" -a -z "$SCAN_FAILED" ] ; then
247 echo -e "WARNING: Our scans have indicated that you are attempting"
248 echo -e "to use more sockets than there are avaliable. Are you sure"
249 echo -e "you wish to do this? It may cause the IRCd to malfunction [y/n]"
250 echo -e $n "[\033[1;32mn\033[0;37m] -> $c"
252 if [ "$YN" = "y" ] ; then
257 echo -e "Please enter the correct value (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)"
267 echo "You must enter a number in this field. Please try again."
274 ###############################################################################
277 echo -e "What is the Maximum length of nicknames?"
278 while [ "$cheeze" -eq "0" ] ; do
279 echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
289 echo "You Must Enter a Number in this field. Please Try Again."
299 ###############################################################################
302 echo -e "What is the Maximum length of channel names?"
303 while [ "$cheeze" -eq "0" ] ; do
304 echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
314 echo "You Must Enter a Number in this field. Please Try Again."
324 ###############################################################################
327 echo -e "What is the Maximum number of mode changes in one line?"
328 while [ "$cheeze" -eq "0" ] ; do
329 echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
339 echo "You Must Enter a Number in this field. Please Try Again."
349 ###############################################################################
353 echo -e "Enter the Level Of Binary optimisation. This is a number between 0 and 3 (inclusive)"
354 echo -e "The InspIRCd Team will _NOT_ support any bug reports above 0."
355 echo -e "Also note, the IRCd behaviour will be different depending on this value."
356 echo -e "Please read the documentation for more information."
358 echo -e "The Higher the number, the more optimised your binary will be. This value will default to 0"
359 echo -e "If you either a) Dont enter a number, or b) Enter a value outside the range."
360 echo -e $n "[\033[1;32m$OPTIMITEMP\033[0;37m] -> $c"
362 if [ -z "$cc" ] ; then
385 ###############################################################################
388 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
390 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
391 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
392 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
393 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
394 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
395 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
396 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
397 echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER"
398 echo -e "\033[0;37mOptimation Flag:\033[1;32m\t\t$OPTIMISATI"
401 echo "Writing cache file for future ./configures ..."
403 if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
408 if [ -e ".config.cache" ] ; then
411 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> .config.cache
412 echo "MODULE_DIR=\"$MODULE_DIR\"" >> .config.cache
413 echo "BINARY_DIR=\"$BINARY_DIR\"" >> .config.cache
414 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> .config.cache
415 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> .config.cache
416 echo "NICK_LENGT=\"$NICK_LENGT\"" >> .config.cache
417 echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache
418 echo "OPTIMITEMP=\"$OPTIMITEMP\"" >> .config.cache
419 echo "OPTIMISATI=\"$OPTIMISATI\"" >> .config.cache
420 echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
422 echo "Writing include/inspircd_config.h ..."
424 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
425 echo "" >>include/inspircd_config.h
426 if [ "$GCCVER" -eq "3" ] ; then
427 echo "#define GCC3" >>include/inspircd_config.h
429 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
430 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
431 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
432 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
433 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
434 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
435 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
436 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
437 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
438 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
439 echo "#define OPTIMISATION $OPTIMITEMP" >>include/inspircd_config.h
440 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
441 echo "#define MAXBUF 514">>include/inspircd_config.h
442 touch include/inspircd_config.h
444 echo "Preparing Variables for the Makefile"
449 FLAGS="-fPIC -frtti $OPTIMISATI"
454 FLAGS="-fPIC -frtti $OPTIMISATI"
460 for module in src/modules/*.cpp ; do
461 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
462 MODULES="$MODULES $mod"
465 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
473 echo "Do you want to compile the IRCd binaries?"
474 echo -e $n "[\033[1;32my\033[0;37m] $c"
476 if [ "$YN" != "n" ] ; then
478 echo -e "\033[1;32mCompiling...\033[0;37m"
489 echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
491 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
497 echo "Do you want to run the config file maker?"
498 echo -e $n "[\033[1;32my\033[0;37m] $c"
500 if [ "$YN" != "n" ] ; then
504 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"