summaryrefslogtreecommitdiff
path: root/configure
blob: aad323d85e094b4a7680caa6e200d129e363edf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#!/bin/sh
# InspIRCd Configuration Script
#
# Copyright 2003 The ChatSpike Development Team
# <brain@chatspike.net>
# <Craig@chatspike.net>
#
# $Id$
#
# Some shell code based on the configure script of IRC Services.
# IRC Services is copyright (c) 1996-2002 Andrew Church. 
# E-mail: <achurch@achurch.org>
#
#
########################################

# echo -e "\033[1;37mtest\033[0;37m"

echo "Configuring default values..."
mkdir fdscount
echo "#include <sys/types.h>" >> fdscount/fdcounter.c
echo "#include <sys/socket.h>" >> fdscount/fdcounter.c
echo "main()" >> fdscount/fdcounter.c
echo "{" >> fdscount/fdcounter.c
echo "        int  i;" >> fdscount/fdcounter.c
echo "        int  s;" >> fdscount/fdcounter.c
echo "" >> fdscount/fdcounter.c
echo "        for (i = 1; i <= 10000; i++)" >> fdscount/fdcounter.c
echo "        {" >> fdscount/fdcounter.c
echo "                s = socket(AF_INET, SOCK_STREAM, 0);" >> fdscount/fdcounter.c
echo "                if (s < 0)" >> fdscount/fdcounter.c
echo "                {" >> fdscount/fdcounter.c
echo "                        printf(\"%i\", i + 2);" >> fdscount/fdcounter.c
echo "                  exit(-1);" >> fdscount/fdcounter.c
echo "                }" >> fdscount/fdcounter.c
echo "        }" >> fdscount/fdcounter.c
echo "}" >> fdscount/fdcounter.c

echo "PROGS     = fdcounter" >> fdscount/Makefile
echo "OBJS = fdcounter.o" >> fdscount/Makefile
echo "" >> fdscount/Makefile
echo "CC = gcc" >> fdscount/Makefile
echo "CXXFLAGS = -fPIC -frtti -O" >> fdscount/Makefile
echo "" >> fdscount/Makefile
echo "all : \$(PROGS)" >> fdscount/Makefile
echo "" >> fdscount/Makefile
echo "\$(PROGS): \$(OBJS)" >> fdscount/Makefile
echo "	\$(CXX) -rdynamic \$^ -o \$@" >> fdscount/Makefile
echo "" >> fdscount/Makefile
echo ".PHONY: clean" >> fdscount/Makefile
echo "clean:" >> fdscount/Makefile
echo "	rm -f *.o core" >> fdscount/Makefile

cd fdscount
make >> /dev/null
cd ..

ME=`pwd`
CONFIG_DIR=$ME/conf
MODULE_DIR=$ME/modules
MAX_CLIENT=`fdscount/fdcounter`
NICK_LENGT=32
CHAN_LENGT=64
MAX_CHANNE=20
MAXI_MODES=20

rm -rf fdscount

if [ -z $MAX_CLIENT ] ; then
	MAX_CLIENT=1024
        SCAN_FAILED=1
fi

if [ "$1" = "-clean" -o "$2" = "-clean" ] ; then
  `rm -rf config.cache`
fi

if [ -e "config.cache" -a -z "$CLEAN" ] ; then
    . config.cache 
fi

OSNAME=`(uname -s) 2>/dev/null` || OSNAME="unknown"


c=""
n=""
if [ "`eval echo -n 'a'`" = "-n a" ] ; then
        c="\c"
else
        n="-n"
fi

exists () { # because some shells don't have test -e
    if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
	return 0
    else
	return 1
    fi
}

clear
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::"
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:"
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:"
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:"
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:"
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:"
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::"
echo -e "\033[0;37m\033[0;37m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::"
echo ""
echo -e "\033[1;37mWelcome to the InspIRCd Configuration program!"
echo ""
echo "*** If you are unsure of any of these values, leave it blank for    ***"
echo "*** standard settings that will work, and your server will run      ***"
echo "*** using them. If you are running this server as part of a         ***"
echo "*** larger network, you must consult with your network admins       ***"
echo "*** for the proper values to use, or server links will be unstable! ***"
echo -e "\033[0;37m"
echo -e "Press \033[1;37m<RETURN>\033[0;37m to accept the default for any option, or enter"
echo -e "a new value. Please note: You will \033[1;37mHAVE\033[0;37m to read the docs"
echo -e "dir, otherwise you won't have a config file!"
echo ""
echo -e "Your operating system is: \033[1;37m$OSNAME\033[0;37m (`uname -mnr`), fdmax: $MAX_CLIENT"
echo ""

#############################################################################

    ok=0
    asked=1
    echo "In what directory are the configuration files?"
    while [ $ok -eq 0 ] ; do
	echo -e $n "[\033[1;32m$CONFIG_DIR\033[0;37m] -> $c"
	if read INPUT ; then : ; else echo "" ; exit 1 ; fi
	if [ ! "$INPUT" ] ; then
	    INPUT=$CONFIG_DIR
	    default=1
	fi
	if echo "$INPUT" | grep -q \[\'\"\\\] ; then
	    echo 'Please use a pathname without the characters: '\'' " \'
	elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
	    if exists "$INPUT" ; then
		echo "$INPUT exists, but is not a directory!"
	    else
		echo "$INPUT does not exist.  Create it?"
		echo -e $n "[\033[1;32my\033[0;37m] $c"
		read YN
		if [ "$YN" != "n" ] ; then
		    if mkdir -p "$INPUT" ; then
			ok=1
		    fi
		fi
	    fi
	    else
            ok=1
	fi
    done
    CONFIG_DIR=$INPUT
    echo ""


##############################################################################

    ok=0
    asked=1
    echo "In What directory are the modules to be compiled to?"
    while [ $ok -eq 0 ] ; do
        echo -e $n "[\033[1;32m$MODULE_DIR\033[0;37m] -> $c"
        if read INPUT ; then : ; else echo "" ; exit 1 ; fi
        if [ ! "$INPUT" ] ; then
            INPUT=$MODULE_DIR
            default=1
        fi
        if echo "$INPUT" | grep -q \[\'\"\\\] ; then
            echo 'Please use a pathname without the characters: '\'' " \'
        elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
            if exists "$INPUT" ; then
                echo "$INPUT exists, but is not a directory!"
            else
                echo "$INPUT does not exist.  Create it?"
                echo -e $n "[\033[1;32my\033[0;37m] $c"
                read YN
                if [ "$YN" != "n" ] ; then
                    if mkdir -p "$INPUT" ; then
                        ok=1
                    fi
                fi
            fi
            else
            ok=1
        fi
    done
    MODULE_DIR=$INPUT
    echo ""


###############################################################################
# Craigs Version 2 With Extra Cheeze :p

  cheeze=0
  echo -e "Maximum number of clients at any one time (\033[1;32m1-$MAX_CLIENT\033[0;37m)?"
  while [ "$cheeze" -eq "0" ] ; do
	echo -e $n "[\033[1;32m$MAX_CLIENT\033[0;37m] -> $c"
	read cc
	if [ "$cc" ] ; then
		case "$cc" in
			[0-9]*)
			if [ "$cc" > "$MAX_CLIENT" ] ; then
				ASK=1
			else
				MAX_CLIENT=$cc
			fi
			cheeze=1
			;;
			*)
			echo ""
			echo "You Must Enter a Number in this field. Please Try Again."
			cheeze=0
			;;
		esac
	else
		cheeze=1
	fi
	if [ "$cheeze" -eq "1" ] ; then
		if [ -z "$SCAN_FAILED" ] ; then
			if [ "$ASK" -eq "1" ] ; then
				echo "WARNING: Our scans have indicated that you are"
				echo "         Attempting to use more sockets than"
				echo "         there are avaliable, do you wish to"
				echo "         do this? [y/n]"
				echo -e $n "[\033[1;32mn\033[0;37m] $c"
				read YN
				if [ "$YN" == "y" ] ; then
					MAX_CLIENT=$cc
				else
                                        cheeze=0
                                        echo ""
                                        echo "Please Enter the Correct number of sockets:"
				fi
			fi
		fi
	fi
  done
  echo ""

###############################################################################

  cheeze=0
  echo -e "What is the Maximum length of nicknames?"
  while [ "$cheeze" -eq "0" ] ; do
        echo -e $n "[\033[1;32m$NICK_LENGT\033[0;37m] -> $c"
        read cc
        if [ "$cc" ] ; then
                case "$cc" in
                        [0-9]*)
                        NICK_LENGT=$cc
                        cheeze=1
                        ;;
                        *)
                        echo ""
                        echo "You Must Enter a Number in this field. Please Try Again."
                        cheeze=0
                        ;;
                esac
        else
                cheeze=1
        fi
  done
  echo ""

###############################################################################

  cheeze=0
  echo -e "What is the Maximum length of channel names?"
  while [ "$cheeze" -eq "0" ] ; do
        echo -e $n "[\033[1;32m$MAX_CHANNE\033[0;37m] -> $c"
        read cc
        if [ "$cc" ] ; then
                case "$cc" in
                        [0-9]*)
                        MAX_CHANNE=$cc
                        cheeze=1
                        ;;
                        *)
                        echo ""
                        echo "You Must Enter a Number in this field. Please Try Again."
                        cheeze=0
                        ;;
                esac
        else
                cheeze=1
        fi
  done
  echo ""

###############################################################################

  cheeze=0
  echo -e "What is the Maximum number of mode changes in one line?"
  while [ "$cheeze" -eq "0" ] ; do
        echo -e $n "[\033[1;32m$MAXI_MODES\033[0;37m] -> $c"
        read cc
        if [ "$cc" ] ; then
                case "$cc" in
                        [0-9]*)
                        MAXI_MODES=$cc
                        cheeze=1
                        ;;
                        *)
                        echo ""
                        echo "You Must Enter a Number in this field. Please Try Again."
                        cheeze=0
                        ;;
                esac
        else
                cheeze=1
        fi
  done
  echo ""

###############################################################################


echo -e "\033[1;32mPre-build configuration is complete!\033[0;37m"
echo ""
echo -e "\033[0;37mConfig path:\033[1;32m\t\t\t$CONFIG_DIR"
echo -e "\033[0;37mModule path:\033[1;32m\t\t\t$MODULE_DIR"
echo -e "\033[0;37mMax connections:\033[1;32m\t\t$MAX_CLIENT"
echo -e "\033[0;37mMax User Channels\033[1;32m\t\t$MAX_CHANNE"
echo -e "\033[0;37mMax nickname length:\033[1;32m\t\t$NICK_LENGT"
echo -e "\033[0;37mMax channel length:\033[1;32m\t\t$CHAN_LENGT"
echo -e "\033[0;37mMax mode length:\033[1;32m\t\t$MAXI_MODES"
echo -e "\033[0;37m"

echo "Writing cache file for future ./configures ..."
if [ -e "config.cache" ] ; then
	rm config.cache
fi
echo "CONFIG_DIR=\"$CONFIG_DIR\"" >> config.cache
echo "MODULE_DIR=\"$MODULE_DIR\"" >> config.cache
echo "MAX_CLIENT=\"$MAX_CLIENT\"" >> config.cache
echo "MAX_CHANNE=\"$MAX_CHANNE\"" >> config.cache
echo "NICK_LENGT=\"$NICK_LENGT\"" >> config.cache
echo "MAXI_MODES=\"$MAXI_MODES\"" >> config.cache 



echo "Writing include/inspircd_config.h ..."

echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
echo "" >>include/inspircd_config.h
echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
echo "#define MOD_PATH \"$MODULE_DIR\"" >>include/inspircd_config.h
echo "#define VERSION \"`sh ./src/version.sh`\"" >>include/inspircd_config.h
echo "#define MAXCLIENTS $MAX_CLIENT" >>include/inspircd_config.h
echo "#define NICKMAX $NICK_LENGT" >>include/inspircd_config.h
echo "#define CHANMAX $CHAN_LENGT" >>include/inspircd_config.h
echo "#define MAXCHANS $MAX_CHANNE" >>include/inspircd_config.h
echo "#define MAXMODES $MAXI_MODES" >>include/inspircd_config.h
echo "#define SYSTEM \"`uname -n -s -r`\"" >>include/inspircd_config.h
echo "#define MAXBUF 514">>include/inspircd_config.h

touch include/inspircd_config.h

echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
echo ""

if exists "Makefile.$OSNAME" ; then
	echo "Operating system supported."
else
	echo "Your operating system, \"$OSNAME\", is not supported!"
	exit
fi

echo ""

cp -f Makefile.$OSNAME Makefile
cp -f src/Makefile.$OSNAME src/Makefile
cp -f src/modules/Makefile.$OSNAME src/modules/Makefile

echo ""
echo "Do you want to compile the IRCd binaries?"
echo -e $n "[\033[1;32my\033[0;37m] $c"
read YN
if [ "$YN" != "n" ] ; then
	echo ""
	echo -e "\033[1;32mCompiling...\033[0;37m"
	echo ""
	cd $ME
	make
	echo ""
        echo "Done!"
        echo ""
else
	echo ""
	echo "Done!"
	echo ""
	echo -e "To build your server with these settings, please type '\033[1;32mmake\033[0;37m' now."
	echo ""
	echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
	echo ""
fi


echo ""
echo "Do you want to run the config file maker?"
echo -e $n "[\033[1;32my\033[0;37m] $c"
read YN
if [ "$YN" != "n" ] ; then
	sh makeconf
fi

echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
echo ""