use vars qw(%count %netsplit %netsplitservers %flood %dcc %orig
%nuh %talkWho %seen %floodwarn %param %dbh %ircPort %userList
%jointime %topic %joinverb %moduleAge %last %time %mask %file
+ %forked %pid %fork
);
# Signals.
$firsttime = 1;
### CHANGE TO STATIC.
-$bot_version = "blootbot 1.0.0 (20000725) -- $^O";
-$noreply = "NOREPLY";
+$bot_version = "blootbot cvs (20001212) -- $^O";
+$noreply = "NOREPLY";
##########
### misc commands.
} elsif ($bot_pid == $$) { # parent.
&status("parent caught SIG$sig (pid $$).") if (defined $sig);
+ &status("--- Start of quit.");
+
my $type;
&closeDCC();
&closePID();
&dumpallvars() if (&IsParam("dumpvarsAtExit"));
&closeLog();
&closeSQLDebug() if (&IsParam("SQLDebug"));
+ &status("--- QUIT.");
} else { # child.
&status("child caught SIG$sig (pid $$).");
}
&WARN("PERL: $_");
}
- $SIG{__WARN__} = 'doWarn';
+ $SIG{__WARN__} = 'doWarn'; # ???
}
# Usage: &IsParam($param);
sub setup {
&showProc(" (\&openLog before)");
&openLog(); # write, append.
+ &status("--- Started logging.");
- foreach ("debian","Temp") {
+ foreach ("debian") {
my $dir = "$bot_base_dir/$_/";
next if ( -d $dir);
&status("Making dir $_");
&loadLang($bot_misc_dir. "/blootbot.lang");
&loadIRCServers($bot_misc_dir. "/ircII.servers");
&loadUsers($bot_misc_dir. "/blootbot.users");
+ if (&IsParam("WIP")) {
+ require "src/UserFile.pl";
+ &NEWloadUsers($bot_misc_dir."/blootbot.users_NEW");
+ &closePID();
+ &closeLog();
+ exit 0;
+ }
$shm = &openSHM();
&openSQLDebug() if (&IsParam("SQLDebug"));
&status("Setup: ". &countKeys("factoids") ." factoids.");
+ $param{tempDir} =~ s#\~/#$ENV{HOME}/#;
+
&status("Initial memory usage: $memusage kB");
}
sub setupConfig {
$param{'VERBOSITY'} = 1;
&loadConfig($bot_misc_dir."/blootbot.config");
+ if (&IsParam("WIP")) {
+ require "src/Config.pl";
+ &NEWloadConfig();
+ }
- foreach ("ircNick", "ircUser", "ircName", "DBType") {
+ foreach ("ircNick", "ircUser", "ircName", "DBType", "tempDir") {
next if &IsParam($_);
&ERROR("Parameter $_ has not been defined.");
exit 1;
}
+ if ($param{tempDir} =~ s#\~/#$ENV{HOME}/#) {
+ &status("Fixing up tempDir.");
+ }
+
+ if ($param{tempDir} =~ /~/) {
+ &ERROR("parameter tempDir still contains tilde.");
+ exit 1;
+ }
+
+ if (! -d $param{tempDir}) {
+ &status("making $param{tempDir}...");
+ system("mkdir $param{tempDir}");
+ }
+
# static scalar variables.
$file{utm} = "$bot_base_dir/$param{'ircUser'}.uptime";
$file{PID} = "$bot_base_dir/$param{'ircUser'}.pid";
sub shutdown {
# reverse order of &setup().
+ &DEBUG("shutdown called.");
+
&closeDB();
&closeSHM($shm); # aswell. TODO: use this in &doExit?
&closeLog();
sub restart {
my ($sig) = @_;
+ &DEBUG(" forked => ".scalar(keys %forked) );
+ &DEBUG(" fork => ".scalar(keys %fork) );
+ &DEBUG(" pid => ".scalar(keys %pid) );
+
if ($$ == $bot_pid) {
- &status("$sig called.");
+ &status("--- $sig called.");
### crappy bug in Net::IRC?
if (!$conn->connected and time - $msgtime > 900) {
&reloadAllModules() if (&IsParam("DEBUG"));
&setup();
- &status("End of $sig.");
+ &status("--- End of $sig.");
} else {
&status("$sig called; ignoring restart.");
}