|
|
| version 1.8, 2010/12/16 21:38:46 | version 1.11, 2010/12/20 20:51:39 |
|---|---|
| Line 44 my $port = $opts{'port'} || $c | Line 44 my $port = $opts{'port'} || $c |
| my $DISPLAY = $cfg{'display'} || ":0.0"; | my $DISPLAY = $cfg{'display'} || ":0.0"; |
| my $BBS_NAME = $cfg{'bbs_name'} || "Hell's Dominion BBS"; | my $BBS_NAME = $cfg{'bbs_name'} || "Hell's Dominion BBS"; |
| my $DBCONF = $cfg{'dosbox_cfg'} || "/tmp/dosbox-__NODE__.conf"; | my $DBCONF = $cfg{'dosbox_cfg'} || "/tmp/dosbox-__NODE__.conf"; |
| my $BBS_CMD = $cfg{'bbs_cmd'} || "DISPLAY=$DISPLAY /usr/bin/dosbox -conf "; | my $BBS_CMD = $cfg{'bbs_cmd'} || "DISPLAY=__DISPLAY__ /usr/bin/dosbox -conf "; |
| my $LOGGING = $cfg{'logging'} || 0; | my $LOGGING = $cfg{'logging'} || 0; |
| my $LOG = $cfg{'log_path'} || "/tmp/bbs.log"; | my $LOG = $cfg{'log_path'} || "/tmp/bbs.log"; |
| my $MAX_NODE = $cfg{'nodes'} || 1; | my $MAX_NODE = $cfg{'nodes'} || 1; |
| my $DOSBOXT = $cfg{'dosboxt'} || "dosbox.conf.template"; | my $DOSBOXT = $cfg{'dosboxt'} || "dosbox.conf.template"; |
| my $BASE_PORT = $cfg{'base_port'} || 7000; | my $BASE_PORT = $cfg{'base_port'} || 7000; |
| my $LOCK_PATH = $cfg{'lock_path'} || "/tmp"; | my $LOCK_PATH = $cfg{'lock_path'} || "/tmp"; |
| $BBS_CMD =~ s/__DISPLAY__/$DISPLAY/g; | |
| ## | ## |
| ## Check that we are 'root' | ## Check that we are 'root' |
| Line 180 sub startNetServer | Line 181 sub startNetServer |
| ## | ## |
| my $node = 0; | my $node = 0; |
| my $lock_file = ""; | my $lock_file = ""; |
| foreach (1 .. $MAX_NODE) | my $cnt = 0; |
| while ( ! $node && $cnt < $MAX_NODE ) | |
| { | { |
| next if ( -f $LOCK_PATH."/".$BBS_NAME."_node".$_.".lock" ); | $cnt++; |
| $lock_file = $LOCK_PATH . "/" . $BBS_NAME . | |
| "_node" . $cnt . ".lock"; | |
| print "Checking for node lock: $lock_file\n"; | |
| next if ( -f $lock_file ); | |
| ## | ## |
| ## Create node lock file | ## Create node lock file |
| ## | ## |
| $lock_file = $LOCK_PATH."/".$BBS_NAME."_node".$_.".lock"; | |
| open LOCK, ">$lock_file"; | open LOCK, ">$lock_file"; |
| close( LOCK ); | close( LOCK ); |
| $node = $BBS_NODE = $_; | $BBS_NODE = $node = $cnt; |
| print "Using node: $node\n"; | |
| } | } |
| ## | ## |
| Line 200 sub startNetServer | Line 206 sub startNetServer |
| my @dbt = <DBT>; | my @dbt = <DBT>; |
| close( DBT ); | close( DBT ); |
| my $bpn = $BASE_PORT + $BBS_NODE; | my $bpn = $BASE_PORT + $BBS_NODE - 1; |
| $DBCONF =~ s/__NODE__/$BBS_NODE/g; | $DBCONF =~ s/__NODE__/$BBS_NODE/g; |
| open( DBC, ">$DBCONF" ); | open( DBC, ">$DBCONF" ); |
| foreach( @dbt ) | foreach( @dbt ) |
| Line 232 sub startNetServer | Line 238 sub startNetServer |
| print "Welcome to $BBS_NAME!" . $EOL; | print "Welcome to $BBS_NAME!" . $EOL; |
| ## | ## |
| if ( ! $lock_file ) | if ( ! $node ) |
| { | { |
| print "No available nodes. Try again later.".$EOL; | print "No available nodes. Try again later.".$EOL; |
| exit; | exit; |
| Line 250 sub startNetServer | Line 256 sub startNetServer |
| my $cmd = $BBS_CMD . $DBCONF; | my $cmd = $BBS_CMD . $DBCONF; |
| system( $cmd ); | system( $cmd ); |
| print "Shutting down node $BBS_NODE\n"; | print "Shutting down node $BBS_NODE\n"; |
| ## | ## |
| ## Remove Lock | ## Remove Lock |
| ## | ## |
| unlink( $lock_file ); | unlink( $lock_file ); |
| unlink( $DBCONF ); | unlink( $DBCONF ); |
| close( $hostConnection ); | |
| close( $server ); | |
| kill( "TERM" => $bbsPID ); | |
| exit; | exit; |
| } | } |
| Line 299 sub startNetServer | Line 309 sub startNetServer |
| unlink( $DBCONF ); | unlink( $DBCONF ); |
| } | } |
| close( $hostConnection ); | close( $hostConnection ); |
| exit; | close( $server ); |
| # close( $server ); | exit; |
| } | } |
| ############################################################################### | ############################################################################### |
| Line 451 sub processExists | Line 461 sub processExists |
| } | } |
| ############################################################################### | ############################################################################### |
| ## | |
| ## %config_hash = &fetchConfig( ); | |
| ## | |
| ## This reads in a file in the format of "key = value" and stores them | |
| ## in to a hash of $hash{$key} = $value. Lines starting with '#' are | |
| ## considered comments and ignored. | |
| ## | |
| ############################################################################### | ############################################################################### |
| sub fetchConfig | sub fetchConfig |
| { | { |
| Line 478 sub fetchConfig | Line 495 sub fetchConfig |
| } | } |
| ############################################################################### | ############################################################################### |
| ## | |
| ## my $file = &fetchConfig( ); | |
| ## | |
| ## This function will look for 'telnetbbs.conf' or whatever was specified | |
| ## on the command line. It will search the @paths below for the default | |
| ## filename if none is specifed. | |
| ## | |
| ############################################################################### | ############################################################################### |
| sub findConfig | sub findConfig |
| { | { |