-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;37mGCC Version Found:\033[1;32m\t\t$GCCVER"
-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
-if [ "$GCCVER" -eq "3" ] ; then
-echo "#define GCC3" >>include/inspircd_config.h
-fi
-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 ""
+if ($var eq "1") {
+ $config{OPTIMITEMP} = 1;
+ $config{OPTIMISATI} = "-O";
+} elsif ($var eq "2") {
+ $config{OPTIMITEMP} = 2;
+ $config{OPTIMISATI} = "-O2";
+} elsif ($var eq "3") {
+ $config{OPTIMITEMP} = 3;
+ $config{OPTIMISATI} = "-O3";
+} else {
+ $config{OPTIMITEMP} = 0;
+ $config{OPTIMISATI} = "-g";
+}
+
+print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
+print "\033[0mConfig path:\033[1;32m\t\t\t$config{CONFIG_DIR}\n";
+print "\033[0mModule path:\033[1;32m\t\t\t$config{MODULE_DIR}\n";
+print "\033[0mMax connections:\033[1;32m\t\t$config{MAX_CLIENT}\n";
+print "\033[0mMax User Channels\033[1;32m\t\t$config{MAX_CHANNE}\n";
+print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\n";
+print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\n";
+print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\n";
+print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.$config{GCC34}\n";
+print "\033[0mOptimatizaton Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n\n";
+
+makecache();
+writefiles();
+
+print "\n\n";
+print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
+print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
+
+################################################################################
+# HELPER FUNCTIONS #
+################################################################################
+sub getcache {
+ # Retrieves the .config.cache file, and loads values into the main config hash.
+ open(CACHE, ".config.cache") or return undef;
+ while (<CACHE>) {
+ chomp;
+
+ # Ignore Blank lines, and comments..
+ next if /^\s*$/;
+ next if /^\s*#/;
+
+ my ($key, $value) = split("=", $_);
+ $value =~ /^\"(.*)\"$/;
+ # Do something with data here!
+ $config{$key} = $1;
+ }
+ close(CONFIG);
+ return "true";
+}
+
+sub makecache {
+ # Dump the contents of %config
+ print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
+ open(FILEHANDLE, ">.config.cache");
+ foreach $key (keys %config)
+ {
+ print FILEHANDLE "$key=\"$config{$key}\"\n";
+ }
+ close(FILEHANDLE);
+}
+
+sub dir_check {
+ my ($desc, $hash_key) = @_;
+ my $complete = 0;
+ while (!$complete) {
+ print "In what directory $desc?\n";
+ print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
+ chomp($var = <STDIN>);
+ if ($var eq "") { $var = $config{$hash_key}; }
+ if ($var =~ /^\~\/(.+)$/) {
+ # Convert it to a full path..
+ $var = resolve_directory($ENV{HOME} . "/" . $1);
+ }
+ if (substr($var,0,1) ne "/")
+ {
+ # Assume relative Path was given.. fill in the rest.
+ $var = $this . "/$var";
+ }
+ $var = resolve_directory($var);
+ if (! -e $var) {
+ print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
+ chomp($tmp = <STDIN>);
+ if (($tmp eq "") || ($tmp =~ /^y/i)) {
+ # Attempt to Create the Dir..
+ $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
+ if ($chk != 0) {
+ print "Unable to create directory. ($var)\n\n";
+ # Restart Loop..
+ next;
+ }
+ } else {
+ # They said they don't want to create, and we can't install there.
+ print "\n\n";
+ next;
+ }
+ } else {
+ if (!is_dir($var)) {
+ # Target exists, but is not a directory.
+ print "File $var exists, but is not a directory.\n\n";
+ next;
+ }
+ }
+ # Either Dir Exists, or was created fine.
+ $config{$hash_key} = $var;
+ $complete = 1;
+ print "\n";
+ }
+}
+
+sub getosflags {
+ if ($config{OSNAME} eq "FreeBSD") {
+ $config{LDLIBS} = "-Ldl";
+ $config{FLAGS} = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
+ $config{MAKEPROG} = "gmake";
+ } else {
+ $config{LDLIBS} = "-ldl";
+ $config{FLAGS} = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
+ $config{MAKEPROG} = "make";
+ }
+}