2 # InspIRCd Configuration Script
4 # Copyright 2003 The ChatSpike Development Team
5 # <brain@chatspike.net>
6 # <Craig@chatspike.net>
10 ########################################
12 echo "Configuring default values..."
15 GCCVER=`gcc -dumpversion | cut -c 1`
17 MODULE_DIR=$ME/modules
19 MAX_CLIENT_T=`ulimit -n`
24 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
26 if [ -z $MAX_CLIENT_T ] ; then
32 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
33 `rm -rf .config.cache`
36 if [ -e ".config.cache" -a -z "$CLEAN" ] ; then
40 if [ "$1" = "-update" -o "$2" = "-update" ] ; then
41 # They wanna update their Makefile.. good for 'em
42 # Make sure .config.cache exists
43 if [ ! -e ".config.cache" ] ; then
44 echo "You have not run ./configure before. Please do this before trying to run the update script."
47 # Right, load the cache values
54 FLAGS="-fPIC -frtti -O3"
59 FLAGS="-fPIC -frtti -O3"
65 for module in src/modules/*.cpp ; do
66 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
67 MODULES="$MODULES $mod"
70 # Write the new makefile.
77 if [ -z $MAX_CLIENT ] ; then
78 MAX_CLIENT=$MAX_CLIENT_T
84 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
90 exists () { # because some shells don't have test -e
91 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
99 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::"
100 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:"
101 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:"
102 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:"
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::::::: \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:"
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::"
106 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
108 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
110 echo "*** If you are unsure of any of these values, leave it blank for ***"
111 echo "*** standard settings that will work, and your server will run ***"
112 echo "*** using them. If you are running this server as part of a ***"
113 echo "*** larger network, you must consult with your network admins ***"
114 echo "*** for the proper values to use, or server links will be unstable! ***"
116 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
117 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
118 echo -e "dir, otherwise you won't have a config file!"
120 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT_T"
123 #############################################################################
127 echo "In what directory are the configuration files?"
128 while [ $ok -eq 0 ] ; do
129 echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
130 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
131 if [ ! "$INPUT" ] ; then
135 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
136 echo 'Please use a pathname without the characters: '\'' " \'
137 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
138 if exists "$INPUT" ; then
139 echo "$INPUT exists, but is not a directory!"
141 echo "$INPUT does not exist. Create it?"
142 echo -e $n "[\033[1;32my\033[0;37m] $c"
144 if [ "$YN" != "n" ] ; then
145 if mkdir -p "$INPUT" ; then
158 ##############################################################################
162 echo "In What directory are the modules to be compiled to?"
163 while [ $ok -eq 0 ] ; do
164 echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
165 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
166 if [ ! "$INPUT" ] ; then
170 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
171 echo 'Please use a pathname without the characters: '\'' " \'
172 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
173 if exists "$INPUT" ; then
174 echo "$INPUT exists, but is not a directory!"
176 echo "$INPUT does not exist. Create it?"
177 echo -e $n "[\033[1;32my\033[0;37m] $c"
179 if [ "$YN" != "n" ] ; then
180 if mkdir -p "$INPUT" ; then
193 ##############################################################################
197 echo "In what directory is the IRCd binary to be placed?"
198 while [ $ok -eq 0 ] ; do
199 echo -e $n "[\033[1;32m$BINARY_DIR\033[0;37m] -> $c"
200 if read INPUT ; then : ; else echo "" ; exit 1 ; fi
201 if [ ! "$INPUT" ] ; then
205 if echo "$INPUT" | grep -q \[\'\"\\\] ; then
206 echo 'Please use a pathname without the characters: '\'' " \'
207 elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
208 if exists "$INPUT" ; then
209 echo "$INPUT exists, but is not a directory!"
211 echo "$INPUT does not exist. Create it?"
212 echo -e $n "[\033[1;32my\033[0;37m] $c"
214 if [ "$YN" != "n" ] ; then
215 if mkdir -p "$INPUT" ; then
227 ###############################################################################
228 # Craigs Version 3 With slightly less Cheeze :p
231 echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)?"
232 while [ "$cheeze" -eq "0" ] ; do
233 echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
236 if [ -z "$cc" ] ; then
242 if [ "$cc" -gt "$MAX_CLIENT_T" -a -z "$SCAN_FAILED" ] ; then
243 echo -e "WARNING: Our scans have indicated that you are attempting"
244 echo -e "to use more sockets than there are avaliable. Are you sure"
245 echo -e "you wish to do this? It may cause the IRCd to malfunction [y/n]"
246 echo -e $n "[\033[1;32mn\033[0;37m] -> $c"
248 if [ "$YN" = "y" ] ; then
253 echo -e "Please enter the correct value (\033[1;32m1-$MAX_CLIENT_T\033[0;37m)"
263 echo "You must enter a number in this field. Please try again."
270 ###############################################################################
273 echo -e "What is the Maximum length of nicknames?"
274 while [ "$cheeze" -eq "0" ] ; do
275 echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
285 echo "You Must Enter a Number in this field. Please Try Again."
295 ###############################################################################
298 echo -e "What is the Maximum length of channel names?"
299 while [ "$cheeze" -eq "0" ] ; do
300 echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
310 echo "You Must Enter a Number in this field. Please Try Again."
320 ###############################################################################
323 echo -e "What is the Maximum number of mode changes in one line?"
324 while [ "$cheeze" -eq "0" ] ; do
325 echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
335 echo "You Must Enter a Number in this field. Please Try Again."
345 ###############################################################################
348 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
350 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
351 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
352 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
353 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
354 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
355 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
356 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
357 echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER"
360 echo "Writing cache file for future ./configures ..."
361 if [ -e ".config.cache" ] ; then
364 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> .config.cache
365 echo "MODULE_DIR=\"$MODULE_DIR\"" >> .config.cache
366 echo "BINARY_DIR=\"$BINARY_DIR\"" >> .config.cache
367 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> .config.cache
368 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> .config.cache
369 echo "NICK_LENGT=\"$NICK_LENGT\"" >> .config.cache
370 echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache
374 echo "Writing include/inspircd_config.h ..."
376 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
377 echo "" >>include/inspircd_config.h
378 if [ "$GCCVER" -eq "3" ] ; then
379 echo "#define GCC3" >>include/inspircd_config.h
381 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
382 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
383 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
384 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
385 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
386 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
387 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
388 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
389 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
390 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
391 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
392 echo "#define MAXBUF 514">>include/inspircd_config.h
393 touch include/inspircd_config.h
395 echo "Preparing Variables for the Makefile"
397 if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
405 FLAGS="-fPIC -frtti -O3"
410 FLAGS="-fPIC -frtti -O3"
416 for module in src/modules/*.cpp ; do
417 mod=`echo $module | sed 's/.cpp/.so/' | sed 's/src\/modules\///'`
418 MODULES="$MODULES $mod"
421 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
429 echo "Do you want to compile the IRCd binaries?"
430 echo -e $n "[\033[1;32my\033[0;37m] $c"
432 if [ "$YN" != "n" ] ; then
434 echo -e "\033[1;32mCompiling...\033[0;37m"
445 echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
447 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
453 echo "Do you want to run the config file maker?"
454 echo -e $n "[\033[1;32my\033[0;37m] $c"
456 if [ "$YN" != "n" ] ; then
460 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"