]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Fixed one or 2 small bugs.. :p
[user/henk/code/inspircd.git] / configure
1 #!/bin/sh
2 # InspIRCd Configuration Script
3 #
4 # Copyright 2003 The ChatSpike Development Team
5 # <brain@chatspike.net>
6 # <Craig@chatspike.net>
7 #
8 # $Id$
9 #
10 # Some shell code based on the configure script of IRC Services.
11 # IRC Services is copyright (c) 1996-2002 Andrew Church. 
12 # E-mail: <achurch@achurch.org>
13 #
14 #
15 ########################################
16
17 # echo -e "\033[1;37mtest\033[0;37m"
18
19 echo "Configuring default values..."
20 mkdir fdscount
21 echo "#include <sys/types.h>" >> fdscount/fdcounter.c
22 echo "#include <sys/socket.h>" >> fdscount/fdcounter.c
23 echo "main()" >> fdscount/fdcounter.c
24 echo "{" >> fdscount/fdcounter.c
25 echo "        int  i;" >> fdscount/fdcounter.c
26 echo "        int  s;" >> fdscount/fdcounter.c
27 echo "" >> fdscount/fdcounter.c
28 echo "        for (i = 1; i <= 10000; i++)" >> fdscount/fdcounter.c
29 echo "        {" >> fdscount/fdcounter.c
30 echo "                s = socket(AF_INET, SOCK_STREAM, 0);" >> fdscount/fdcounter.c
31 echo "                if (s < 0)" >> fdscount/fdcounter.c
32 echo "                {" >> fdscount/fdcounter.c
33 echo "                        printf(\"%i\", i + 2);" >> fdscount/fdcounter.c
34 echo "                  exit(-1);" >> fdscount/fdcounter.c
35 echo "                }" >> fdscount/fdcounter.c
36 echo "        }" >> fdscount/fdcounter.c
37 echo "}" >> fdscount/fdcounter.c
38
39 echo "PROGS     = fdcounter" >> fdscount/Makefile
40 echo "OBJS = fdcounter.o" >> fdscount/Makefile
41 echo "" >> fdscount/Makefile
42 echo "CC = gcc" >> fdscount/Makefile
43 echo "CXXFLAGS = -fPIC -frtti -O" >> fdscount/Makefile
44 echo "" >> fdscount/Makefile
45 echo "all : \$(PROGS)" >> fdscount/Makefile
46 echo "" >> fdscount/Makefile
47 echo "\$(PROGS): \$(OBJS)" >> fdscount/Makefile
48 echo "  \$(CXX) -rdynamic \$^ -o \$@" >> fdscount/Makefile
49 echo "" >> fdscount/Makefile
50 echo ".PHONY: clean" >> fdscount/Makefile
51 echo "clean:" >> fdscount/Makefile
52 echo "  rm -f *.o core" >> fdscount/Makefile
53
54 cd fdscount
55 make >> /dev/null
56 cd ..
57
58 ME=`pwd`
59 CONFIG_DIR=$ME/conf
60 MODULE_DIR=$ME/modules
61 MAX_CLIENT=`fdscount/fdcounter`
62 NICK_LENGT=32
63 CHAN_LENGT=64
64 MAX_CHANNE=20
65 MAXI_MODES=20
66
67 rm -rf fdscount
68
69 if [ -z $MAX_CLIENT ] ; then
70         MAX_CLIENT=1024
71         SCAN_FAILED=1
72 fi
73
74 if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
75   `rm -rf config.cache`
76 fi
77
78 if [ -e "config.cache" -a -z "$CLEAN" ] ; then
79     . config.cache 
80 fi
81
82 OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"
83
84
85 c=""
86 n=""
87 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
88         c="\c"
89 else
90         n="-n"
91 fi
92
93 exists () { # because some shells don't have test -e
94     if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
95         return 0
96     else
97         return 1
98     fi
99 }
100
101 clear
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::"
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... \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:"
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:"
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: \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::"
109 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
110 echo ""
111 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
112 echo ""
113 echo "*** If you are unsure of any of these values, leave it blank for    ***"
114 echo "*** standard settings that will work, and your server will run      ***"
115 echo "*** using them. If you are running this server as part of a         ***"
116 echo "*** larger network, you must consult with your network admins       ***"
117 echo "*** for the proper values to use, or server links will be unstable! ***"
118 echo -e "\033[0;37m"
119 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
120 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
121 echo -e "dir, otherwise you won't have a config file!"
122 echo ""
123 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT"
124 echo ""
125
126 #############################################################################
127
128     ok=0
129     asked=1
130     echo "In what directory are the configuration files?"
131     while [ $ok -eq 0 ] ; do
132         echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
133         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
134         if [ ! "$INPUT" ] ; then
135             INPUT=$CONFIG_DIR
136             default=1
137         fi
138         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
139             echo 'Please use a pathname without the characters: '\'' " \'
140         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
141             if exists "$INPUT" ; then
142                 echo "$INPUT exists, but is not a directory!"
143             else
144                 echo "$INPUT does not exist.  Create it?"
145                 echo -e $n "[\033[1;32my\033[0;37m] $c"
146                 read YN
147                 if [ "$YN" != "n" ] ; then
148                     if mkdir -p "$INPUT" ; then
149                         ok=1
150                     fi
151                 fi
152             fi
153             else
154             ok=1
155         fi
156     done
157     CONFIG_DIR=$INPUT
158     echo ""
159
160
161 ##############################################################################
162
163     ok=0
164     asked=1
165     echo "In What directory are the modules to be compiled to?"
166     while [ $ok -eq 0 ] ; do
167         echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
168         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
169         if [ ! "$INPUT" ] ; then
170             INPUT=$MODULE_DIR
171             default=1
172         fi
173         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
174             echo 'Please use a pathname without the characters: '\'' " \'
175         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
176             if exists "$INPUT" ; then
177                 echo "$INPUT exists, but is not a directory!"
178             else
179                 echo "$INPUT does not exist.  Create it?"
180                 echo -e $n "[\033[1;32my\033[0;37m] $c"
181                 read YN
182                 if [ "$YN" != "n" ] ; then
183                     if mkdir -p "$INPUT" ; then
184                         ok=1
185                     fi
186                 fi
187             fi
188             else
189             ok=1
190         fi
191     done
192     MODULE_DIR=$INPUT
193     echo ""
194
195
196 ###############################################################################
197 # Craigs Version 2 With Extra Cheeze :p
198
199   cheeze=0
200   echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT\033[0;37m)?"
201   while [ "$cheeze" -eq "0" ] ; do
202         echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
203         read cc
204         if [ "$cc" ] ; then
205                 case "$cc" in
206                         [0-9]*)
207                         if [ "$cc" > "$MAX_CLIENT" ] ; then
208                                 ASK=1
209                         else
210                                 MAX_CLIENT=$cc
211                         fi
212                         cheeze=1
213                         ;;
214                         *)
215                         echo ""
216                         echo "You Must Enter a Number in this field. Please Try Again."
217                         cheeze=0
218                         ;;
219                 esac
220         else
221                 cheeze=1
222         fi
223         if [ "$cheeze" -eq "1" ] ; then
224                 if [ -z "$SCAN_FAILED" ] ; then
225                         if [ "$ASK" -eq "1" ] ; then
226                                 echo "WARNING: Our scans have indicated that you are"
227                                 echo "         Attempting to use more sockets than"
228                                 echo "         there are avaliable, do you wish to"
229                                 echo "         do this? [y/n]"
230                                 echo -e $n "[\033[1;32mn\033[0;37m] $c"
231                                 read YN
232                                 if [ "$YN" == "y" ] ; then
233                                         MAX_CLIENT=$cc
234                                 else
235                                         cheeze=0
236                                         echo ""
237                                         echo "Please Enter the Correct number of sockets:"
238                                 fi
239                         fi
240                 fi
241         fi
242   done
243   echo ""
244
245 ###############################################################################
246
247   cheeze=0
248   echo -e "What is the Maximum length of nicknames?"
249   while [ "$cheeze" -eq "0" ] ; do
250         echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
251         read cc
252         if [ "$cc" ] ; then
253                 case "$cc" in
254                         [0-9]*)
255                         NICK_LENGT=$cc
256                         cheeze=1
257                         ;;
258                         *)
259                         echo ""
260                         echo "You Must Enter a Number in this field. Please Try Again."
261                         cheeze=0
262                         ;;
263                 esac
264         else
265                 cheeze=1
266         fi
267   done
268   echo ""
269
270 ###############################################################################
271
272   cheeze=0
273   echo -e "What is the Maximum length of channel names?"
274   while [ "$cheeze" -eq "0" ] ; do
275         echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
276         read cc
277         if [ "$cc" ] ; then
278                 case "$cc" in
279                         [0-9]*)
280                         MAX_CHANNE=$cc
281                         cheeze=1
282                         ;;
283                         *)
284                         echo ""
285                         echo "You Must Enter a Number in this field. Please Try Again."
286                         cheeze=0
287                         ;;
288                 esac
289         else
290                 cheeze=1
291         fi
292   done
293   echo ""
294
295 ###############################################################################
296
297   cheeze=0
298   echo -e "What is the Maximum number of mode changes in one line?"
299   while [ "$cheeze" -eq "0" ] ; do
300         echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
301         read cc
302         if [ "$cc" ] ; then
303                 case "$cc" in
304                         [0-9]*)
305                         MAXI_MODES=$cc
306                         cheeze=1
307                         ;;
308                         *)
309                         echo ""
310                         echo "You Must Enter a Number in this field. Please Try Again."
311                         cheeze=0
312                         ;;
313                 esac
314         else
315                 cheeze=1
316         fi
317   done
318   echo ""
319
320 ###############################################################################
321
322
323 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
324 echo ""
325 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
326 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
327 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
328 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
329 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
330 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
331 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
332 echo -e "\033[0;37m"
333
334 echo "Writing cache file for future ./configures ..."
335 if [ -e "config.cache" ] ; then
336         rm config.cache
337 fi
338 echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> config.cache
339 echo "MODULE_DIR=\"$MODULE_DIR\"" >> config.cache
340 echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> config.cache
341 echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> config.cache
342 echo "NICK_LENGT=\"$NICK_LENGT\"" >> config.cache
343 echo "MAXI_MODES=\"$MAXI_MODES\"" >> config.cache 
344
345
346
347 echo "Writing include/inspircd_config.h ..."
348
349 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
350 echo "" >>include/inspircd_config.h
351 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
352 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
353 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
354 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
355 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
356 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
357 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
358 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
359 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
360 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
361 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
362 echo "#define MAXBUF 514">>include/inspircd_config.h
363
364 touch include/inspircd_config.h
365
366 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
367 echo ""
368
369 if exists "Makefile.$OSNAME" ; then
370         echo "Operating system supported."
371 else
372         echo "Your operating system, \"$OSNAME\", is not supported!"
373         exit
374 fi
375
376 echo ""
377
378 cp -f Makefile.$OSNAME Makefile
379 cp -f src/Makefile.$OSNAME src/Makefile
380 cp -f src/modules/Makefile.$OSNAME src/modules/Makefile
381
382 echo ""
383 echo "Do you want to compile the IRCd binaries?"
384 echo -e $n "[\033[1;32my\033[0;37m] $c"
385 read YN
386 if [ "$YN" != "n" ] ; then
387         echo ""
388         echo -e "\033[1;32mCompiling...\033[0;37m"
389         echo ""
390         cd $ME
391         make
392         echo ""
393         echo "Done!"
394         echo ""
395 else
396         echo ""
397         echo "Done!"
398         echo ""
399         echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
400         echo ""
401         echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
402         echo ""
403 fi
404
405
406 echo ""
407 echo "Do you want to run the config file maker?"
408 echo -e $n "[\033[1;32my\033[0;37m] $c"
409 read YN
410 if [ "$YN" != "n" ] ; then
411         sh makeconf
412 fi
413
414 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
415 echo ""
416