Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    Default Synergy server (hl2 mod)

    Hello all. I have been stabbing and trying to get this to work for over a months now and I just hit a wall.

    I just will not start. I have there for been running the server via ssh with screen but this isn't doable. (the server has restarted quite often recently)

    Now for your info this is just a single install, so I didn't bother with making a cpgs package.(I tried but failed too). All file are downloaded Manually via the steam updater or uploaded via ftp.

    I have hacked together a synergy.pm based on the one from tf2.
    This is it:
    Code:
    package cPGS::synergy;
    
    use strict;
    use IPC::Open2;
    use cPGS::Shared;
    
    our $VERSION="1.0";
    
    my $short = 'synergy';
    my $long = 'Synergy: Real HL2 Multi-Player';
    
    sub new {
            my $class = shift;
            return bless {}, $class;
    }
    
    sub register_self {
            return(1,__PACKAGE__,$short,$VERSION,$long);
    }
    
    sub showsimpleconfig {
    	my($self,$s,$srvargs_hashref,$home,$servdir,$user,$game,$srvn,$portdata,$ipdata,$ports_list,$ips_list) = @_;
    	my %srvargs = %{$srvargs_hashref};
    	my $map_list;
    
    	open(CONF,'<'."$home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/server.cfg") or print $s "Could not open config file ($home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/server.cfg) : $!\n";
    	while(<CONF>) {
    		s/(\r|\n|\")//g;
    		next if /^\/\//;
    		if(/^(.*?)\s+(.*)/) {
    			$srvargs{$1}=$2;
    			$srvargs{$1} =~ s/(\s+)?\/\/.*$//;
    		} else {
    			next;
    		}
    	}
    	close(CONF);
    
    	opendir(DIRS,"$home/.gameservers/$servdir\_$srvn/orangebox/synergy/maps/");
    	my @maps= readdir(DIRS);
    	closedir(DIRS);
    	foreach (@maps) { if(($_ =~ /(.*)\.bsp$/i) and ($1 ne $srvargs{'defmap'}) and ($1 ne 'credits')) { $map_list .= "<option value=\"$1\">$1\n"; } }
    
    	return(\%srvargs,$map_list,$ports_list,$ips_list);
    }
    
    sub configsave {
    	my($self,$s,$form_hashref,$home,$servdir,$user,$game,$srvn,$maxc) = @_;
    	my %form = %{$form_hashref};
    	my $chg_cnt = 0;
    	my $cfg_file = delete $form{'cfg_file'};
    
    	if( $cfg_file eq 'advconfig') {
    		my @realform = split(/\n/,$form{'conf'});
    		if(open(CONF,'>',"$home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/server.cfg")) {
    			foreach my $line(@realform) {
    				$line =~ s/(\r|\n)//g;
    				print CONF "$line\n";
    			}
    			close(CONF);
    			return("Config file saved.");
    		} else {
    			print $s "ERROR: Can not open config file: $!\n";
    		}
    	}
    	return("Unknown config, can not save.");
    }
    
    sub formsave {
    	my($self,$s,$form_hashref,$home,$servdir,$user,$game,$srvn,$maxc) = @_;
    	my %form = %{$form_hashref};
    	my $chg_cnt = 0;
    
    	open(CONF,'<',"$home/.gameservers/$servdir\_$srvn/.launchrc");
    	my @existconf=(<CONF>);
    	close(CONF);
    
    	open(CONFRE,'>',"$home/.gameservers/$servdir\_$srvn/.launchrc");
    	foreach my $line(@existconf) {
    		$line =~ s/(\n|\r)//g;
    		next if $line =~ /^\/\//;
    		if($line =~ /^(.*?)\s+(.*)/) {
    			my $var = $1;
    			my $val = $2;
    			if(defined($form{$var})) {
    				print CONFRE "$var $form{$var}\n";
    				if($val ne $form{$var}) { 
    					$chg_cnt++;
    					print $s "<tr><td>$var</td><td>$val</td><td>$form{$var}</td></tr>\n";
    				}
    				delete($form{$var});
    			} else {
    				print CONFRE "$line\n";
    			}
    		}
    	}
    	close(CONFRE);
    
    	open(CONF,'<',"$home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/server.cfg");
    	my @existconf=(<CONF>);
    	close(CONF);
    
    	open(CONFRE,'>',"$home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/server.cfg");
    
    	foreach my $line(@existconf) {
    		$line =~ s/(\n|\r)//g;
    		$line =~ s/\"//g;
    		if($line =~ /^\/\//) {
    			print CONFRE "$line\n";
    		} elsif($line =~ /^(.*?)\s+(.*)/) {
    			my $var = $1;
    			my $val = $2;
    			if(defined($form{$var})) {
    				print CONFRE "$var \"". $form{$var} ."\"\n";
    				if($val ne $form{$var}) { 
    					$chg_cnt++;
    					print $s "<tr><td>$var</td><td>$val</td><td>$form{$var}</td></tr>\n";
    				}
    				delete($form{$var});
    			} else {
    				print CONFRE "$line\n";
    			}
    		}
    	}
    	foreach my $new (keys %form) {
    		if($form{$new}) {
    			print CONFRE "$new \"". $form{$new} . "\"\n";
    			print $s "<tr><td>$new</td><td>&nbsp;</td><td>$form{$new}</td></tr>\n";
    			$chg_cnt++;
    		}
    	}
    	close(CONFRE);
    
    	return($chg_cnt);
    }
    
    sub showconfig {
    	my($self,$s,$query,$home,$servdir,$user,$game,$srvn) = @_;
    	if( $query eq 'servercfg' ) {
    		my $sercfg='server.cfg';
    		open(synergyCONF,'<',"$home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/" . $sercfg) or print $s "ERROR: Could not open server config file \" $home/.gameservers/$servdir\_$srvn/orangebox/synergy/cfg/$sercfg \": $!\n";
    		my @confi=(<synergyCONF>);
    		close(synergyCONF);
    		foreach my $line(@confi) {
    			print $s "OK: $line";
    		}
    	}
    }
    
    sub get_servdir {
    	return('synergy');
    }
    
    
    sub isinstalledql {
    	my($self,$s,$user,$game,$srvn,$home,$servdir) = @_;
    	if(-x "$home/.gameservers/$servdir\_$srvn/orangebox/srcds_run") { return 0; }
    	else { return 1; }
    }
    
    # gather game specific data to send to startserver code in cpgsd
    sub loadlaunchrc {
    	my($self,$user,$game,$srvn,$home)= @_;
    	my(%launchrc);
    	my $gd = &get_servdir;
    	open(my $launch_fh,'<',"$home/.gameservers/$gd\_$srvn/.launchrc") or main::msglog("Could not open config file ($home/.gameservers/$gd\_$srvn/.launchrc) : $!");
    	my @srvargs = (<$launch_fh>);
    	close($launch_fh);
    	foreach my $args(@srvargs) {
    		$args =~ s/(\r|\n)//g;
    		if($args =~ /^net_port(=|\s+)(.*)/i) { $launchrc{'port'}=$2; }
    		elsif($args =~ /^net_ip(=|\s+)(.*)/i) { $launchrc{'ip'}=$2; }
    		elsif($args =~ /^defmap(=|\s+)(.*)/i) { $launchrc{'defmap'}=$2; }
    		elsif($args =~ /^autoupdate(=|\s+)(.*)/i) { $launchrc{'autoupdate'}=$2; }
    		elsif($args =~ /^maxplayers(=|\s+)(.*)/i) { $launchrc{'maxplayers'}=$2; }
    	}
    
    	my $srcbin = 'srcds_i486';
    	$launchrc{'game_exec_bin'} = "$home/.gameservers/$gd\_$srvn/orangebox/$srcbin";
    	$launchrc{'chdir'} = "$home/.gameservers/$gd\_$srvn/orangebox/";
    	if($launchrc{'autoupdate'} == 1) { main::steamupdate($user,$game,$srvn,$short,$long,'synergy'); }
    	$launchrc{'ld_library_path'} = 'bin:synergy/bin:.';
    	$launchrc{'fullname'} = $long;
    	$launchrc{'cpgs-divider'} = ' ';
    	return(\%launchrc);
    }
    
    
    sub set_default_configs {
    	my($self,$s,$user,$game,$srvn,$dir,$maxc,$lowport,$defip) = @_;
    	my $pcnt = my @ports = split(/\_/,$lowport);
    	if($pcnt > 1) {
    		$lowport = shift(@ports);
    	}
    	my $err;
    
    	# not needed and overrides server.cfg
    	unlink("$dir/orangebox/synergy/cfg/config_arena.cfg") if -f "$dir/orangebox/synergy/cfg/config_arena.cfg";
    
    	if(open(DEF,'<','/var/cpanel/cpgs/games/synergy/custom_default_server.cfg') || open(DEF,'<','/var/cpanel/cpgs/games/synergy/default_server.cfg')) {
    		if(open(DEFC,'>',"$dir/orangebox/synergy/cfg/server.cfg")) {
    			while(<DEF>) {
    				print DEFC $_;
    			}
    			close(DEFC);
    		} else {
    			$err .= "Could not write to $dir/orangebox/synergy/cfg/server.cfg : $!\n";
    			main::msglog("Could not write to $dir/orangebox/synergy/cfg/server.cfg : $!");
    		} 
    		close(DEF);
    	} else {
    		$err .= "Could not open default config file: $! \n";
    		main::msglog("Could not open default config file: $!");
    	}
    
    	if(open(LAUNCHRC,'>',"$dir/.launchrc")) {
    		print LAUNCHRC "net_ip $defip\n";
    		print LAUNCHRC "defmap syn_oldcanals\n";
    		print LAUNCHRC "net_port $lowport\n";
    		print LAUNCHRC "autoupdate 0\n";
    		print LAUNCHRC "maxplayers $maxc\n";
    		close(LAUNCHRC);
    	} else {
    		$err .= "Could not open $dir/.launchrc : $! \n";
    		main::msglog("Could not open $dir/.launchrc : $!");
    	}
    
    	return($err);
    }
    
    sub getserverip {
    	my($self,$s,$user,$game,$srvn,$home,$servdir) = @_;
    	open(ARGSF,"<$home/.gameservers/$servdir\_$srvn/.launchrc") or print $s "Could not open config file ($home/.gameservers/$servdir\_$srvn/.launchrc) : $! <br>\n";
    	my @srvargs = (<ARGSF>);
    	close(ARGSF);
    	foreach my $args(@srvargs) {
    		$args =~ s/(\r|\n)//g;
    		if($args =~ /net_ip\s+(.*)/i) { return($1); }
    	}
    	return(1);
    }
    
    sub getStats {
    	my($self,$user,$game,$srvn,$ipval,$pubip,$verbose,@targets) = @_;
    	my($sip,$players,$map,$gtype,$sname,@reply,$target,%seen,$matched,%retteam,$pname,$time,$score);
    	my($pkg,$calling_file,$calling_line)=caller;
    
    	foreach $target(@targets) {
    		if($target =~ /(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3})\:(\d+)\s+\((.*)\)/) {
    			my $ip=$1;
    			my $port=$2;
    			if($ip eq '0.0.0.0') { $ip=$pubip; }
    			$target = "$ip\:$port";
    		}
    		if($seen{$target} eq $target) { next; }
    		$seen{$target}=$target;
    		# print "user = $user <br> game = $game <br> srvn = $srvn <br> pubip = $pubip <br> verbose = $verbose <br> targets = @targets <br><br>\n";
    		@reply="";
    		if($verbose == 0) {
    			my @arg = ("-a2s",$target,"-nh","-timeout",$cPGS::Shared::to);
    			my $pid = open2(\*READ,\*WRITE,$cPGS::Shared::qstatpath,@arg); close(WRITE); while(<READ>) { push(@reply,$_); } close(READ);
    			foreach my $ln(@reply) {
    				if($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+\d+\s+\/\s+\d+\s+(\w+)\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched=1;
    				} elsif($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+\d+\s+\/\s+\d+\s+(\w+)\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched=1;
    				}
    			}
    			if($matched == 1) {
    				last;
    			}
    		} else {
    			my @arg = ("-a2s",$target,"-P","-nh","-timeout",$cPGS::Shared::to);
    			my @reply="";
    			my $pid = open2(\*READ,\*WRITE,$cPGS::Shared::qstatpath,@arg); close(WRITE); while(<READ>) { push(@reply,$_); } close(READ);
    			foreach my $ln(@reply) {  
    				if($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+\d+\s+\/\s+\d+\s+(\w+)\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched=1;
    				} elsif($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+\d+\s+\/\s+\d+\s+(\w+)\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched=1;
    				}
    				elsif($ln =~ /^\s+(\d+)\s+frags\s+(\-\d+s|\d+s|.+?s)\s+(.+$)/) {
    #                                elsif($ln =~ /^\s+(\d+)\s+frags\s+(\d+[\d\s\w]{2,10}s)\s+(.+$)/) {
    					$score=$1;
    					$time=$2;
    					$pname=$3;
    					$pname = $pkg->filter($pname);
    					$retteam{$pname}{'score'}=$score;
    					$retteam{$pname}{'time'}=$time;
    					$retteam{$pname}{'pname'}=$pname;
    				}
    			}
    			if($matched == 1) {
    				last;
    			}
    		}
    	}
          return($matched,$sip,$players,$map,$gtype,$sname,undef,%retteam);	
    }
    
    sub showPlayerStats {
    	my($self,$game,$retteam)=@_;
    	print "<table border=0 cellpadding=0 cellspacing=0 width=100\%><tr><th>Player Name</th><th>Score</th><th>Time Played</th></tr>";
    	foreach my $key(keys %{$retteam}) { print "<tr><td>$$retteam{$key}{'pname'}</td><td>$$retteam{$key}{'score'}</td><td>$$retteam{$key}{'time'}</td></tr>\n"; }
    	print "</div></table></div>\n";
    }
    
    sub showWHMopts {
    	my ($self,$user,$game,$srvn) = @_;
    	my ($pkg,$calling_file,$calling_line)=caller;
    	if((! $user) or (! $game) or ($srvn !~ m/^\d+$/)) {
    		print "Missing user($user) , game($game) or srvn($srvn) <br>\n";
    		return(0);
    	}
    	my ($tickrate) = main::sendssl("127.0.0.1 gettickrate $user $game $srvn");
    	$tickrate =~ s/(\r|\n)//g;
    	if ( $tickrate =~ /not connect/i ) { $tickrate = '' . $user . $game . $srvn; }
    	print "<tr><td>Tickrate</td><td>";
    	print "<input type=text name=\"$user\_$game\_$srvn\_tickrate\" value=\"$tickrate\" size=30></td></tr>";
    }
    
    1;
    Now I do not see what is wrong here. I changed all the paths and update the other files.
    The error + cmd line:
    Code:
    [Tue Jul 20 19:35:56 2010] Launching server with the following commandline:
    # /home/*/.gameservers/synergy_0/orangebox/srcds_i486 -dir /home/*/.gameservers/synergy_0/orangebox -game synergy -maxplayers 10 -ip * -port 27016 +exec server.cfg +map syn_oldcanals -tickrate 100
    
    Failed to open bin/dedicated_i486.so (bin/dedicated_i486.so: cannot open shared object file: No such file or directory)
    This error indicates the start server command is executted from the wrong directory however I told it to go to this dir:
    Code:
    /home/*/.gameservers/synergy_0/orangebox
    in the synergy.pm

    If anyone see what I did wrong I would be very grate full. Thank in advanced.

  2. #2
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    That all looks right to me, what do you have in /var/cpanel/cpgs/games/synergy/startup_options ? If you want, put in a ticket for me and I'll be glad to take a look. I was able to start the server using the same command line after checking out synergy from steam and moving the hl2 directory to the orangebox directory.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    Default

    My synergy server starts fine if I do it Manually ( have been running it like this for a while now). However it does not start via cpanel. It keep complain about the error from the op. This is solved by cd to the orangebox folder of the game server and launching it from there.

    From what i read in tf2.pm this is also needed for tf2, this is why I remade the synergy.pm based on the tf2 one. I thought this line would make it work:
    Code:
    $launchrc{'chdir'} = "$home/.gameservers/$gd\_$srvn/orangebox/";
    If not then what does it do?
    Btw it would be handy if there was a wiki or info page on these pm files, For the beginner this would very handy.

    Anyway this is the startup_options
    Code:
    game_exec_bin|||$home/.gameservers/synergy_$srvn/orangebox/srcds_i486|||0
    -dir|||$basedirorangebox|||1
    -game|||synergy|||2
    -maxplayers|||$maxplayers|||3
    -ip|||$ip|||4
    -port|||$port|||5
    +map|||$map|||7
    +exec|||server.cfg|||6
    I hope this helps.

  4. #4
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    The $launchrc{'chdir'} should be forcing it into the orangebox directory as you inferred. That is used right before the server forks as the user to launch the game, so it should be going to the right place:

    Code:
    	my $chdir = $launch_ref->{'chdir'} || $basedir;
    	chdir($chdir);
    I assume you are running the game via ssh as the user and not root, and that all the files are owned by the user ?
    Feel free to put in a ticket for me to strace cPGSD and see if I can find out why it's not getting to the right directory or if something else is up. From what I can see of what you pasted it looks like it should be working.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    Default

    Quote Originally Posted by darren View Post
    The $launchrc{'chdir'} should be forcing it into the orangebox directory as you inferred. That is used right before the server forks as the user to launch the game, so it should be going to the right place:

    Code:
    	my $chdir = $launch_ref->{'chdir'} || $basedir;
    	chdir($chdir);
    I assume you are running the game via ssh as the user and not root, and that all the files are owned by the user ?
    Feel free to put in a ticket for me to strace cPGSD and see if I can find out why it's not getting to the right directory or if something else is up. From what I can see of what you pasted it looks like it should be working.
    You are correct on all your assumptions.
    At least where on the page.
    I will talk to the owner of the server if can give you access.
    Could it be because you installed a non-official version of cpgs. version 0.7.3, from before it was released.
    If I get the go a head, what do you need apart from the obvious user/pass?

    PS, do I need to do anything with that code?

  6. #6
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    A forced "self reinstall" in WHM->Manage Gameservers might help if they are still running a 0.7.3 pre-release, although it should have updated them. I don't think that would affect this however as that code didn't really change much from the pre-release to the actual release.
    All I need is the root pass for the server and anything else needed for SSH login (IP, wheel user/pass if required, etc.)
    The code I pasted was just to show where the chdir came from, if it's set in the launchrc, it should be used, otherwise it will use the base directory. I can add some debugging code around this to verify that the correct directory is being used for the chdir when I take a look at it.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

Similar Threads & Tags
Similar threads

  1. Hl2:dm
    By ShadowSeeker in forum cPGS Discussions
    Replies: 12
    Last Post: 11-03-2010, 01:51 PM
  2. DOD:S or HL2
    By Cyber-Surfer in forum cPGS Discussions
    Replies: 6
    Last Post: 06-03-2010, 02:18 PM
  3. HL2 Mod - Age of Chivalry
    By mtaylor500 in forum cPGS Discussions
    Replies: 2
    Last Post: 02-12-2010, 02:25 PM
  4. HL2 Tickrate
    By rh4u123 in forum cPGS Discussions
    Replies: 4
    Last Post: 08-26-2008, 01:28 AM
  5. HL2 Issue
    By csutton in forum cPGS Discussions
    Replies: 16
    Last Post: 05-12-2008, 10:18 AM
Tags for this Thread
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube