]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Added copyright notices
[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
56 cd ..
57
58 ME=`pwd`
59 PERL=`which perl`
60 CONFIG_DIR=$ME/conf
61 MODULE_DIR=$ME/modules
62 MAX_CLIENT=`fdscount/fdcounter`
63 NICK_LENGT=32
64 CHAN_LENGT=64
65 MAX_CHANNE=20
66 MAXI_MODES=20
67
68 rm -rf fdscount
69
70 if [ "$PERL" = "" ] ; then
71         echo "You require perl to run this program."
72         exit
73 fi
74
75
76 OSNAME=`(uname -s) 2>/dev/null`  || OSNAME="unknown"
77
78 c=""
79 n=""
80 if [ "`eval echo -n 'a'`" = "-n a" ] ; then
81         c="\c"
82 else
83         n="-n"
84 fi
85
86 exists () { # because some shells don't have test -e
87     if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
88         return 0
89     else
90         return 1
91     fi
92 }
93
94 clear
95 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::"
96 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:"
97 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:"
98 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:"
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::::::: \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:"
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::"
102 echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
103 echo ""
104 echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
105 echo ""
106 echo "*** If you are unsure of any of these values, leave it blank for    ***"
107 echo "*** standard settings that will work, and your server will run      ***"
108 echo "*** using them. If you are running this server as part of a         ***"
109 echo "*** larger network, you must consult with your network admins       ***"
110 echo "*** for the proper values to use, or server links will be unstable! ***"
111 echo -e "\033[0;37m"
112 echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
113 echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
114 echo -e "dir, otherwise you won't have a config file!"
115 echo ""
116 echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT"
117 echo ""
118
119 #############################################################################
120
121     ok=0
122     asked=1
123     echo "In what directory are the configuration files?"
124     while [ $ok -eq 0 ] ; do
125         echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
126         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
127         if [ ! "$INPUT" ] ; then
128             INPUT=$CONFIG_DIR
129             default=1
130         fi
131         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
132             echo 'Please use a pathname without the characters: '\'' " \'
133         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
134             if exists "$INPUT" ; then
135                 echo "$INPUT exists, but is not a directory!"
136             else
137                 echo "$INPUT does not exist.  Create it?"
138                 echo -e $n "[\033[1;32my\033[0;37m] $c"
139                 read YN
140                 if [ "$YN" != "n" ] ; then
141                     if mkdir -p "$INPUT" ; then
142                         ok=1
143                     fi
144                 fi
145             fi
146             else
147             ok=1
148         fi
149     done
150     CONFIG_DIR=$INPUT
151     echo ""
152
153
154 ##############################################################################
155
156     ok=0
157     asked=1
158     echo "In What directory are the modules to be compiled to?"
159     while [ $ok -eq 0 ] ; do
160         echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
161         if read INPUT ; then : ; else echo "" ; exit 1 ; fi
162         if [ ! "$INPUT" ] ; then
163             INPUT=$MODULE_DIR
164             default=1
165         fi
166         if echo "$INPUT" | grep -q \[\'\"\\\] ; then
167             echo 'Please use a pathname without the characters: '\'' " \'
168         elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
169             if exists "$INPUT" ; then
170                 echo "$INPUT exists, but is not a directory!"
171             else
172                 echo "$INPUT does not exist.  Create it?"
173                 echo -e $n "[\033[1;32my\033[0;37m] $c"
174                 read YN
175                 if [ "$YN" != "n" ] ; then
176                     if mkdir -p "$INPUT" ; then
177                         ok=1
178                     fi
179                 fi
180             fi
181             else
182             ok=1
183         fi
184     done
185     MODULE_DIR=$INPUT
186     echo ""
187
188
189 ###############################################################################
190
191   echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT\033[0;37m)?"
192   echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
193   read cc
194   if [ "$cc" ] ; then 
195         if [ "$cc" > "$MAX_CLIENT" ] ; then
196                 echo -e "Number entered was above the maximum allowed by your OS."
197                 echo -e "Max clients was set to the highest possible value, \033[1;32m$MAX_CLIENT\033[0;37m"
198         else
199                 MAX_CLIENT=$cc
200         fi
201   fi
202     echo ""
203
204 ###############################################################################
205
206   echo "What is the Maximum length of nicknames?"
207   echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
208   read cc
209   if [ "$cc" ] ; then
210      NICK_LENGT=$cc
211   fi
212     echo ""
213
214 ###############################################################################
215
216   echo "What is the Maximum length of channel names?"
217   echo -e $n "[\033[1;32m$CHAN_LENGT\033[0;37m] -> $c"
218   read cc
219   if [ "$cc" ] ; then
220      CHAN_LENGT=$cc
221   fi
222     echo ""
223
224 ###############################################################################
225
226   echo "What is the Maximum Number of channels a user may Join?"
227   echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
228   read cc
229   if [ "$cc" ] ; then
230      MAX_CHANNE_LENGT=$cc
231   fi
232     echo ""
233
234 ###############################################################################
235
236   echo "What is the Maximum number of mode changes in one line?"
237   echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
238   read cc
239   if [ "$cc" ] ; then
240      MAXI_MODES=$cc
241   fi
242     echo ""
243
244 ###############################################################################
245
246
247 echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
248 echo ""
249 echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
250 echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
251 echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
252 echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
253 echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
254 echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
255 echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
256 echo -e "\033[0;37m"
257 echo "Writing include/inspircd_config.h ..."
258
259
260 echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
261 echo "" >>include/inspircd_config.h
262 echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
263 echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
264 echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
265 echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
266 echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
267 echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
268 echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
269 echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
270 echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
271 echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
272 echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
273 echo "#define MAXBUF 514">>include/inspircd_config.h
274
275 touch include/inspircd_config.h
276
277 echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
278 echo ""
279
280 if exists "Makefile.$OSNAME" ; then
281         echo "Operating system supported."
282 else
283         echo "Your operating system, \"$OSNAME\", is not supported!"
284         exit
285 fi
286
287 echo ""
288
289 cp -f Makefile.$OSNAME Makefile
290 cp -f src/Makefile.$OSNAME src/Makefile
291 cp -f src/modules/Makefile.$OSNAME src/modules/Makefile
292
293 echo ""
294 echo "Do you want to compile the IRCd binaries?"
295 echo -e $n "[\033[1;32my\033[0;37m] $c"
296 read YN
297 if [ "$YN" != "n" ] ; then
298         echo ""
299         echo -e "\033[1;32mCompiling...\033[0;37m"
300         echo ""
301         cd $ME
302         make
303         echo ""
304         echo "Done!"
305         echo ""
306 else
307         echo ""
308         echo "Done!"
309         echo ""
310         echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
311         echo ""
312         echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
313         echo ""
314 fi
315
316
317 echo ""
318 echo "Do you want to run the config file maker?"
319 echo -e $n "[\033[1;32my\033[0;37m] $c"
320 read YN
321 if [ "$YN" != "n" ] ; then
322         sh makeconf
323 fi
324
325 echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
326 echo ""
327