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`
30 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
32 if [ -z $MAX_CLIENT_T ] ; then
38 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
39 `rm -rf .config.cache`
42 if [ -e ".config.cache" -a -z "$CLEAN" ] ; then
46 if [ "$1" = "-update" -o "$2" = "-update" ] ; then
47 # They wanna update their Makefile.. good for 'em
48 # Make sure .config.cache exists
49 if [ ! -e ".config.cache" ] ; then
50 echo "You have not run ./configure before. Please do this before trying to run the update script."
53 # Right, load the cache values
60 FLAGS="-fPIC -frtti $OPTIMISATI"
65 FLAGS="-fPIC -frtti $OPTIMISATI"
71 for module in src/modules/*.cpp ; do
72 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
73 MODULES="$MODULES $mod"
76 # Write the new makefile.
77 for file in Makefile; do
78 echo -e "\033[0mWriting \033[1;32m$file\033[0m"
81 s%@MAKEPROG@%$MAKEPROG%g
84 s%@CONFIG_DIR@%$CONFIG_DIR%g
85 s%@MODULE_DIR@%$MODULE_DIR%g
86 s%@BINARY_DIR@%$BINARY_DIR%g
87 s%@MODULES@%$MODULES%g
88 " .${file}.inc >> $file
90 echo -e "\033[0mWriting \033[1;32msrc/modules/Makefile\033[0m"
91 rm -f src/modules/Makefile
93 # Generate the Header..
95 echo "# (C) ChatSpike development team" >> src/modules/Makefile
96 echo "# Makefile by <Craig@ChatSpike.net>" >> src/modules/Makefile
97 echo "# Many Thanks to Andrew Church <achurch@achurch.org>" >> src/modules/Makefile
98 echo "# for assisting with making this work right." >> src/modules/Makefile
99 echo "#" >> src/modules/Makefile
100 echo "# Automatically Generated by ./configure to add a module" >> src/modules/Makefile
101 echo "# please run ./configure --update" >> src/modules/Makefile
102 echo "" >> src/modules/Makefile
103 echo "all: \$(MODULES)" >> src/modules/Makefile
104 echo "" >> src/modules/Makefile
107 for module in src/modules/*.cpp ; do
108 flags=`grep '$CompileFlags: ' $module | sed 's/\/\* $CompileFlags://' | sed 's/\*\///'`
109 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
110 mod2=`echo $module | sed 's/src\/modules\///'`
111 echo "$mod: $mod2 ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h" >> src/modules/Makefile
112 echo " \$(CC) -I../../include \$(FLAGS) -shared$flags -o $mod $mod2" >> src/modules/Makefile
113 echo " @cp $mod \$(MODPATH)/" >> src/modules/Makefile
114 echo "" >> src/modules/Makefile
123 if [ -z $MAX_CLIENT ] ; then
124 MAX_CLIENT=$MAX_CLIENT_T
130 if [ "`eval echo -e -n 'a'`" = "-n a" ] ; then
136 exists () { # because some shells don't have test -e
137 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
144 echo "#include <string.h>">.test.cpp
145 echo "#include <stdio.h>">>.test.cpp
146 echo "int main() { char a[10]; char b[10]; strlcpy(a,b,10); printf(\"%d\\n\",9); }" >>.test.cpp
147 g++ -o .test .test.cpp 2>&1
148 if [ -e ".test" ] ; then
151 rm -f .test.cpp .test
154 echo -e "'\033[1;33m####\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::'\033[1;33m####\033[0m:'\033[1;33m########\033[0m:::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::"
155 echo -e ". \033[1;33m##\033[0m:: \033[1;33m###\033[0m:: \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:. \033[1;33m##\033[0m:: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:"
156 echo -e ": \033[1;33m##\033[0m:: \033[1;33m####\033[0m: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:"
157 echo -e ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m \033[1;33m##\033[0m \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::: \033[1;33m##\033[0m:: \033[1;33m########\033[0m:: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:"
158 echo -e ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m. \033[1;33m####\033[0m::..... \033[1;33m##\033[0m: \033[1;33m##\033[0m.....:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m.. \033[1;33m##\033[0m::: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:"
159 echo -e ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m:. \033[1;33m###\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m::::::::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:: \033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:"
160 echo -e "'\033[1;33m####\033[0m: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m##\033[0m::::::::'\033[1;33m####\033[0m: \033[1;33m##\033[0m:::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::"
161 echo -e "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
163 echo "Welcome to the InspIRCd Configuration program!"
165 echo "*** If you are unsure of any of these values, leave it blank for ***"
166 echo "*** standard settings that will work, and your server will run ***"
167 echo "*** using them. If you are running this server as part of a ***"
168 echo "*** larger network, you must consult with your network admins ***"
169 echo "*** for the proper values to use, or server links will be unstable! ***"
171 echo -e "Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter"
172 echo -e "a new value. Please note: You will \033[1mHAVE\033[0m to read the docs"
173 echo -e "dir, otherwise you won't have a config file!"
175 echo -e "Your operating system is: \033[1;32m$OSNAME\033[0m (`uname -mnr`), fdmax: $MAX_CLIENT_T"
178 #############################################################################
182 echo "In what directory are the configuration files?"
183 while [ $ok -eq 0 ] ; do
184 echo -e $n "[\033[1;32m$CONFIG_DIR\033[0m] -> $c"
185 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
186 if [ ! "$INPUT" ] ; then
190 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
191 echo 'Please use a pathname without the characters: '\'' " \'
192 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
193 if exists "$INPUT" ; then
194 echo "$INPUT exists, but is not a directory!"
196 echo "$INPUT does not exist. Create it?"
197 echo -e $n "[\033[1;32my\033[0m] $c"
199 if [ "$YN" != "n" ] ; then
200 if mkdir -p "$INPUT" ; then
213 ##############################################################################
217 echo "In What directory are the modules to be compiled to?"
218 while [ $ok -eq 0 ] ; do
219 echo -e $n "[\033[1;32m$MODULE_DIR\033[0m] -> $c"
220 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
221 if [ ! "$INPUT" ] ; then
225 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
226 echo 'Please use a pathname without the characters: '\'' " \'
227 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
228 if exists "$INPUT" ; then
229 echo "$INPUT exists, but is not a directory!"
231 echo "$INPUT does not exist. Create it?"
232 echo -e $n "[\033[1;32my\033[0m] $c"
234 if [ "$YN" != "n" ] ; then
235 if mkdir -p "$INPUT" ; then
248 ##############################################################################
252 echo "In what directory is the IRCd binary to be placed?"
253 while [ $ok -eq 0 ] ; do
254 echo -e $n "[\033[1;32m$BINARY_DIR\033[0m] -> $c"
255 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
256 if [ ! "$INPUT" ] ; then
260 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
261 echo 'Please use a pathname without the characters: '\'' " \'
262 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
263 if exists "$INPUT" ; then
264 echo "$INPUT exists, but is not a directory!"
266 echo "$INPUT does not exist. Create it?"
267 echo -e $n "[\033[1;32my\033[0m] $c"
269 if [ "$YN" != "n" ] ; then
270 if mkdir -p "$INPUT" ; then
282 ###############################################################################
283 # Craigs Version 3 With slightly less Cheeze :p
286 echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT_T\033[0m)?"
287 while [ "$cheeze" -eq "0" ] ; do
288 echo -e $n "[\033[1;32m$MAX_CLIENT\033[0m] -> $c"
291 if [ -z "$cc" ] ; then
297 if [ "$cc" -gt "$MAX_CLIENT_T" -a -z "$SCAN_FAILED" ] ; then
298 echo -e "WARNING: Our scans have indicated that you are attempting"
299 echo -e "to use more sockets than there are avaliable. Are you sure"
300 echo -e "you wish to do this? It may cause the IRCd to malfunction [y/n]"
301 echo -e $n "[\033[1;32mn\033[0m] -> $c"
303 if [ "$YN" = "y" ] ; then
308 echo -e "Please enter the correct value (\033[1;32m1-$MAX_CLIENT_T\033[0m)"
318 echo "You must enter a number in this field. Please try again."
325 ###############################################################################
328 echo -e "What is the Maximum length of nicknames?"
329 while [ "$cheeze" -eq "0" ] ; do
330 echo -e $n "[\033[1;32m$NICK_LENGT\033[0m] -> $c"
340 echo "You Must Enter a Number in this field. Please Try Again."
350 ###############################################################################
353 echo -e "What is the Maximum length of channel names?"
354 while [ "$cheeze" -eq "0" ] ; do
355 echo -e $n "[\033[1;32m$MAX_CHANNE\033[0m] -> $c"
365 echo "You Must Enter a Number in this field. Please Try Again."
375 ###############################################################################
378 echo -e "What is the Maximum number of mode changes in one line?"
379 while [ "$cheeze" -eq "0" ] ; do
380 echo -e $n "[\033[1;32m$MAXI_MODES\033[0m] -> $c"
390 echo "You Must Enter a Number in this field. Please Try Again."
400 ###############################################################################
404 echo -e "Enter the Level Of Binary optimisation. This is a number between 0 and 3 (inclusive)"
405 echo -e "The InspIRCd Team will _NOT_ support any bug reports above 0."
406 echo -e "Also note, the IRCd behaviour will be different depending on this value."
407 echo -e "Please read the documentation for more information."
409 echo -e "The Higher the number, the more optimised your binary will be. This value will default to 0"
410 echo -e "If you either a) Dont enter a number, or b) Enter a value outside the range."
411 echo -e $n "[\033[1;32m$OPTIMITEMP\033[0m] -> $c"
413 if [ -z "$cc" ] ; then
436 ###############################################################################
439 echo -e "\033[1;32mPre-build configuration is complete!\033[0m"
441 echo -e "\033[0mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
442 echo -e "\033[0mModule path:\033[1;32m\t\t\t$MODULE_DIR"
443 echo -e "\033[0mMax connections:\033[1;32m\t\t$MAX_CLIENT"
444 echo -e "\033[0mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
445 echo -e "\033[0mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
446 echo -e "\033[0mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
447 echo -e "\033[0mMax mode length:\033[1;32m\t\t$MAXI_MODES"
448 echo -e "\033[0mGCC Version Found:\033[1;32m\t\t$GCCVER.$GCC34"
449 echo -e "\033[0mOptimatizaton Flag:\033[1;32m\t\t$OPTIMISATI"
452 echo "Writing cache file for future ./configures ..."
455 if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
460 if [ -e ".config.cache" ] ; then
463 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> .config.cache
464 echo "MODULE_DIR=\"$MODULE_DIR\"" >> .config.cache
465 echo "BINARY_DIR=\"$BINARY_DIR\"" >> .config.cache
466 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> .config.cache
467 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> .config.cache
468 echo "NICK_LENGT=\"$NICK_LENGT\"" >> .config.cache
469 echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache
470 echo "OPTIMITEMP=\"$OPTIMITEMP\"" >> .config.cache
471 echo "OPTIMISATI=\"$OPTIMISATI\"" >> .config.cache
472 echo "GCC34=\"$GCC34\"" >> .config.cache
473 echo "HAS_STRLCPY=\"$HAS_STRLCPY\"" >> .config.cache
474 echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
476 echo -e "Writing \033[1;32minspircd_config.h"
478 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
479 echo "" >>include/inspircd_config.h
480 if [ "$GCCVER" -eq "3" ] ; then
481 echo "#define GCC3" >>include/inspircd_config.h
482 if [ "$GCC34" -gt "3" ] ; then
483 echo "#define GCC34" >>include/inspircd_config.h
486 if [ "$HAS_STRLCPY" -eq "1" ] ; then
487 echo "#define HAS_STRLCPY" >>include/inspircd_config.h
489 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
490 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
491 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
492 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
493 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
494 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
495 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
496 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
497 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
498 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
499 echo "#define OPTIMISATION $OPTIMITEMP" >>include/inspircd_config.h
500 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
501 echo "#define MAXBUF 514">>include/inspircd_config.h
502 touch include/inspircd_config.h
507 FLAGS="-fPIC -frtti $OPTIMISATI"
512 FLAGS="-fPIC -frtti $OPTIMISATI"
518 for module in src/modules/*.cpp ; do
519 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
520 MODULES="$MODULES $mod"
523 for file in Makefile inspircd; do
524 echo -e "\033[0mWriting \033[1;32m$file\033[0m"
527 s%@MAKEPROG@%$MAKEPROG%g
530 s%@CONFIG_DIR@%$CONFIG_DIR%g
531 s%@MODULE_DIR@%$MODULE_DIR%g
532 s%@BINARY_DIR@%$BINARY_DIR%g
533 s%@MODULES@%$MODULES%g
534 " .${file}.inc >> $file
538 echo -e "\033[0mWriting \033[1;32msrc/modules/Makefile\033[0m"
539 rm -f src/modules/Makefile
541 # Generate the Header..
543 echo "# (C) ChatSpike development team" >> src/modules/Makefile
544 echo "# Makefile by <Craig@ChatSpike.net>" >> src/modules/Makefile
545 echo "# Many Thanks to Andrew Church <achurch@achurch.org>" >> src/modules/Makefile
546 echo "# for assisting with making this work right." >> src/modules/Makefile
547 echo "#" >> src/modules/Makefile
548 echo "# Automatically Generated by ./configure to add a module" >> src/modules/Makefile
549 echo "# please run ./configure --update" >> src/modules/Makefile
550 echo "" >> src/modules/Makefile
551 echo "all: \$(MODULES)" >> src/modules/Makefile
552 echo "" >> src/modules/Makefile
554 for module in src/modules/*.cpp ; do
555 flags=`grep '$CompileFlags: ' $module | sed 's/\/\* $CompileFlags://' | sed 's/\*\///'`
556 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
557 mod2=`echo $module | sed 's/src\/modules\///'`
558 echo "$mod: $mod2 ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h" >> src/modules/Makefile
559 echo " \$(CC) -I../../include \$(FLAGS) -shared$flags -o $mod $mod2" >> src/modules/Makefile
560 echo " @cp $mod \$(MODPATH)/" >> src/modules/Makefile
561 echo "" >> src/modules/Makefile
568 echo "Do you want to compile the IRCd binaries?"
569 echo -e $n "[\033[1;32my\033[0m] $c"
571 if [ "$YN" != "n" ] ; then
573 echo -e "\033[1;32mCompiling...\033[0m"
581 echo -e "To build your server with these settings, please type '\033[1;32m$MAKEPROG\033[0m' now."
586 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***"