summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-05 21:17:33 +0000
committerfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-05 21:17:33 +0000
commitc2dd34ae043d06781cd59bd56fbbdcd4d4df04b9 (patch)
treef7dc83d8ce326f6ee5135bca57494699b1f6b85e
parent5cce62f7d799f073ea6ca1793328c08c2df7c3ff (diff)
Added ./inspircd (start|stop|restart|rehash|status|cron|Cheese-Sandwich) (Happy luigiman?)
Made a slightly nicer method for .Makefile.inc Updated ./configure to reflect the above changes. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@983 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--.Makefile.inc94
-rw-r--r--.inspircd.inc135
-rwxr-xr-xconfigure35
3 files changed, 207 insertions, 57 deletions
diff --git a/.Makefile.inc b/.Makefile.inc
index 816a7e38b..e2739b242 100644
--- a/.Makefile.inc
+++ b/.Makefile.inc
@@ -1,50 +1,44 @@
-echo "# Insp Main Makefile" > Makefile
-echo "#" >> Makefile
-echo "# (C) ChatSpike development team" >> Makefile
-echo "#####" >> Makefile
-echo "# MAKEFILE DYNAMICLY GENERATED BY ./configure" >> Makefile
-echo "# DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING!" >> Makefile
-echo "#####" >> Makefile
-echo "# Original Makefile & ./configure by <Craig@ChatSpike.net>" >> Makefile
-echo "# Small modifications by <brain@ChatSpike.net>" >> Makefile
-echo "#" >>Makefile
-echo ""
-echo "CC = g++" >> Makefile
-echo "MAKE = $MAKEPROG" >> Makefile
-echo "PROGS = inspircd" >> Makefile
-echo "FLAGS = $FLAGS" >> Makefile
-echo "LDLIBS = $LDLIBS" >> Makefile
-echo "CONPATH = $CONFIG_DIR" >> Makefile
-echo "MODPATH = $MODULE_DIR" >> Makefile
-echo "BINPATH = $BINARY_DIR" >> Makefile
-echo "MODULES =$MODULES" >> Makefile
-echo "MAKEARGS = 'PROGS=\${PROGS}' 'FLAGS=\${FLAGS}' 'CC=\${CC}' 'LDLIBS=\${LDLIBS}' 'MODULES=\${MODULES}' 'MODPATH=\$(MODPATH)'" >> Makefile
-echo "" >> Makefile
-echo "all : ircd mods config bininst" >> Makefile
-echo "" >> Makefile
-echo "mods:" >> Makefile
-echo " \${MAKE} -C src/modules DIRNAME="src/modules" \$(MAKEARGS)" >> Makefile
-echo "" >> Makefile
-echo "ircd:" >> Makefile
-echo " \${MAKE} -C src DIRNAME="src" \$(MAKEARGS)" >> Makefile
-echo "" >> Makefile
-echo "bininst:" >> Makefile
-echo " @cp src/inspircd \$(BINPATH)" >> Makefile
-echo "" >> Makefile
-echo "config:" >> Makefile
-if [ "$COPY_CONF" -eq "1" ] ; then
-echo " @cp conf/inspire.motd \$(CONPATH)/inspire.motd.example" >> Makefile
-echo " @cp conf/inspire.quotes \$(CONPATH)/inspire.quotes.example" >> Makefile
-echo " @cp conf/inspire.rules \$(CONPATH)/inspire.rules.example" >> Makefile
-echo " @cp docs/*.example \$(CONPATH)" >> Makefile
-else
-echo " @echo \"*** Nothing to Be Done for make config\"" >> Makefile
-fi
-echo "clean:" >> Makefile
-echo " rm -rf src/*.o" >> Makefile
-echo " rm -rf src/modules/*.so" >> Makefile
-echo "" >> Makefile
-echo "modclean:" >> Makefile
-echo " rm -rf modules/*.so" >> Makefile
-echo "" >> Makefile
-echo "squeakyclean: modclean clean" >> Makefile
+# Inspircd Main Makefile
+#
+# (C) ChatSpike development team
+# DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING!
+#####
+# Original Makefile & ./configure by <Craig@ChatSpike.net>
+# Small modifications by <brain@ChatSpike.net>
+#
+
+CC = g++
+MAKE = @MAKEPROG@
+PROGS = inspircd
+FLAGS = @FLAGS@
+LDLIBS = @LDLIBS@
+CONPATH = @CONFIG_DIR@
+MODPATH = @MODULE_DIR@
+BINPATH = @BINARY_DIR@
+MODULES = @MODULES@
+MAKEARGS = 'PROGS=${PROGS}' 'FLAGS=${FLAGS}' 'CC=${CC}' 'LDLIBS=${LDLIBS}' 'MODULES=${MODULES}' 'MODPATH=$(MODPATH)'
+
+all : ircd mods config bininst
+
+mods:
+ ${MAKE} -C src/modules DIRNAME="src/modules" $(MAKEARGS)
+
+ircd:
+ ${MAKE} -C src DIRNAME="src" $(MAKEARGS)
+
+bininst:
+ @cp src/inspircd $(BINPATH)
+
+config:
+ @cp conf/inspire.motd $(CONPATH)/inspire.motd.example
+ @cp conf/inspire.quotes $(CONPATH)/inspire.quotes.example
+ @cp conf/inspire.rules $(CONPATH)/inspire.rules.example
+ @cp docs/*.example $(CONPATH)
+clean:
+ rm -rf src/*.o
+ rm -rf src/modules/*.so
+
+modclean:
+ rm -rf modules/*.so
+
+squeakyclean: modclean clean
diff --git a/.inspircd.inc b/.inspircd.inc
new file mode 100644
index 000000000..a3032f676
--- /dev/null
+++ b/.inspircd.inc
@@ -0,0 +1,135 @@
+#!/usr/bin/perl
+# +------------------------------------+
+# | Inspire Internet Relay Chat Daemon |
+# +------------------------------------+
+#
+# Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+# E-mail:
+# <brain@chatspike.net>
+# <Craig@chatspike.net>
+#
+# Written by Craig Edwards, Craig McLure, and others.
+# This program is free but copyrighted software; see
+# the file COPYING for details.
+#
+# I HATE PERL.. kthxbye
+# ---------------------------------------------------
+
+my $conffile = "@CONFIG_DIR@/inspircd.conf";
+my $binpath = "@BINARY_DIR@/inspircd";
+
+# Lets see what they want to do.. Set the variable (Cause i'm a lazy coder)
+my $arg = $ARGV[0];
+getpidfile();
+
+if ($arg eq "start") { start(); exit(); }
+if ($arg eq "stop") { stop(); exit(); }
+if ($arg eq "status") {
+ if (getstatus() == 1) {
+ my $pid = getprocessid();
+ print "InspIRCd is running (PID: $pid)\n";
+ exit();
+ } else {
+ print "InspIRCd is not running. (Or PID File not found)\n";
+ exit();
+ }
+}
+if ($arg eq "rehash") {
+ if (getstatus() == 1) {
+ my $pid = getprocessid();
+ system("kill -HUP $pid >/dev/null 2>&1");
+ print "InspIRCd rehashed.\n";
+ exit();
+ } else {
+ print "InspIRCd is not running. (Or PID File not found)\n";
+ exit();
+ }
+}
+
+if ($arg eq "cron") {
+ if (getstatus() == 0) { start(); exit(); }
+}
+
+if ($arg eq "restart") {
+ stop();
+ start();
+ # kthxbye();
+ exit();
+}
+
+if ($arg eq "Cheese-Sandwich") {
+ print "Creating Cheese Sandwich..\n";
+ print "Done.\n";
+ exit();
+}
+
+###
+# If we get here.. bad / no parameters.
+###
+print "Invalid Argument: $arg\n";
+print "Usage: inspircd (start|stop|restart|rehash|status|cron)\n";
+exit();
+
+###
+# Generic Helper Functions.
+###
+
+sub start {
+ # Check to see its not 'running' already.
+ if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
+ # If we are still alive here.. Try starting the IRCd..
+ system($binpath);
+ sleep 1;
+ if (getstatus() == 0) {
+ print "InspIRCd Seemingly not started, Log follows:\n";
+ system("tail ircd.log");
+ } else {
+ # We're good!
+ return 1;
+ }
+}
+
+sub stop {
+ if (getstatus() == 0) { print "InspIRCd is not running. (Or PID File not found)"; return 0; }
+ # Get to here, we have something to kill.
+ my $pid = getprocessid();
+ system("kill -TERM $pid >/dev/null 2>&1");
+ print "InspIRCd Stopped.\n";
+}
+
+
+sub getpidfile {
+ open INFILE, "< $conffile" or die "Couldn't open $conffile";
+ my(@lines) = <INFILE>;
+ close INFILE;
+ chomp(@lines);
+
+ foreach $i (@lines) {
+ $i =~ s/[^=]+=\s(.*)/\1/;
+ }
+
+ my $tmp = join("",@lines);
+ $tmp =~ /<pid file=\"(\S+)\">/i;
+
+ $pidfile = $1;
+}
+
+sub getstatus {
+ my $pid = getprocessid();
+ if ($pid == 0) { return 0; }
+ $status = system("kill -0 $pid >/dev/null 2>&1") / 256;
+ if ($status == 0) { return 1; }
+ else { return 0; }
+}
+
+
+sub getprocessid {
+ my $pid;
+ open PIDFILE, "< $pidfile" or die "Cannot open PID";
+ while($i = <PIDFILE>)
+ {
+ $pid = $i;
+ }
+ close PIDFILE;
+ return $pid;
+}
diff --git a/configure b/configure
index afc228539..92acbf6a4 100755
--- a/configure
+++ b/configure
@@ -73,7 +73,19 @@ if [ "$1" = "-update" -o "$2" = "-update" ] ; then
done
# Write the new makefile.
- . .Makefile.inc
+ for file in Makefile; do
+ echo -e "\033[0;37mWriting \033[1;32m$file\033[0;37m"
+ rm -f $file
+ sed -e "
+ s%@MAKEPROG@%$MAKEPROG%g
+ s%@FLAGS@%$FLAGS%g
+ s%@LDLIBS@%$LDLIBS%g
+ s%@CONFIG_DIR@%$CONFIG_DIR%g
+ s%@MODULE_DIR@%$MODULE_DIR%g
+ s%@BINARY_DIR@%$BINARY_DIR%g
+ s%@MODULES@%$MODULES%g
+ " .${file}.inc >> $file
+ done
echo "Complete."
exit 1;
fi
@@ -430,7 +442,7 @@ echo "GCC34=\"$GCC34\"" >> .config.cache
echo "HAS_STRLCPY=\"$HAS_STRLCPY\"" >> .config.cache
echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
-echo "Writing include/inspircd_config.h ..."
+echo -e "Writing \033[1;32minspircd_config.h"
echo "/* Auto generated by configure, do not modify! */" >include/inspircd_config.h
echo "" >>include/inspircd_config.h
@@ -458,8 +470,6 @@ 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 "Preparing Variables for the Makefile"
-
case "$OSNAME" in
FreeBSD)
LDLIBS="-Ldl"
@@ -479,10 +489,21 @@ for module in src/modules/*.cpp ; do
MODULES="$MODULES $mod"
done
-echo -e "Writing \033[1;37m$OSNAME\033[0;37m makefile"
-echo ""
+for file in Makefile inspircd; do
+ echo -e "\033[0;37mWriting \033[1;32m$file\033[0;37m"
+ rm -f $file
+ sed -e "
+ s%@MAKEPROG@%$MAKEPROG%g
+ s%@FLAGS@%$FLAGS%g
+ s%@LDLIBS@%$LDLIBS%g
+ s%@CONFIG_DIR@%$CONFIG_DIR%g
+ s%@MODULE_DIR@%$MODULE_DIR%g
+ s%@BINARY_DIR@%$BINARY_DIR%g
+ s%@MODULES@%$MODULES%g
+ " .${file}.inc >> $file
+done
-. .Makefile.inc
+`chmod 700 inspircd`
echo ""