3 # infobot -- copyright kevin lenzo (c) 1997-infinity
4 # no warrantee expressed or implied. terms as the
5 # license for X11R6 when needed.
8 use vars qw($infobot_base_dir $infobot_src_dir $infobot_misc_dir
9 $infobot_pid $memusage %param
13 # set this to the absolute path if you need it; especially
14 # if . is not in your path
16 $infobot_base_dir = '.';
17 $infobot_src_dir = "$infobot_base_dir/src";
18 $infobot_misc_dir = "$infobot_base_dir/files";
21 require "$infobot_src_dir/logger.pl";
22 require "$infobot_src_dir/core.pl";
23 require "$infobot_src_dir/interface.pl";
24 require "$infobot_src_dir/modules.pl";
26 # load the configuration (params) file.
29 &showProc(); # to get the first value.
30 &status("Initial memory usage: $memusage kB");
33 &loadFactoidsModules();
36 &status("Memory usage after loading modules: $memusage kB");
39 # prevent duplicate processes of the same bot
42 # initialize everything
43 &startup(); # first time initialization.
46 if (!&IsParam("Interface") or $param{'Interface'} =~ /IRC/) {
47 # launch the irc event loop
53 exit 0; # just so you don't look farther down in this file :)
55 # --- support routines
58 # add arguments, basically '-h' and '--help', heh.
64 my $file = $file{PID};
67 open(PIDFILE,$file) or die "error: cannot open $file.";
68 my $thispid = <PIDFILE> || "NULL\n";
72 if ($thispid =~ /^\D$/) {
73 &staus("warning: pidfile is invalid; wiping out.");
75 if ( -d "/proc/$thispid/") {
76 &ERROR("bot is already running from this directory.");
77 &ERROR("if this is incorrect, erase '*.pid'.");
78 &ERROR("verify with 'ps -axu | grep $thispid'.");
81 &status("warning: stale $file found; wiping.");
86 open(PIDFILE,">$file") or die "error: cannot write to $file.";
87 print PIDFILE "$pid\n";