Loading script problem.

Post here if you need help setting up your server, etc.
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Loading script problem.

Post by Moofie »

I am trying to load a script into my server. I just took a random php script I found to try and figure this out with. I made this sh file:

Code: Select all

#!/bin/sh
tron="./.cache/0install.net/implementations/styct/usr/local/bin/armagetronad-styct-dedicated"
var="/home/mark/.armagetronad-styct-dedicated/var/"
log="${var}console_log.txt"
userconfigdir="/home/mark/.armagetronad-styct-dedicated/config/settings_custom.cfg"
parser="/home/mark/.armagetronad-styct-dedicated/var/deathpulse.php"
ladderlog="${var}ladderlog.txt"
 
tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log
and I have everything in the right spots. Then when i try to run, it says:

Code: Select all

error while loading shared libraries: libZThread-2.3.so.2: cannot open shared object file: No such file or directory
If i do a search for libZThread-2.3.so.2, I have it, under a different directory under implementations, so that could be the problem?
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Loading script problem.

Post by AI-team »

did you compile z-thread with

Code: Select all

--prefix=/usr/
?

(for a detailed instruction on how to install z-thread check the wiki)
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: Loading script problem.

Post by Jip »

When configuring before you compile armagetron you can tell it where you got z-thread installed:

Code: Select all

  --with-zthread-prefix=PFX   Prefix where ZTHREAD is installed (optional)
  --with-zthread-exec-prefix=PFX Exec prefix where ZTHREAD is installed (optional)
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

I used 0install, so I didn't compile everything, but I can try it
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

Update, I did the install/configure of ZThreads, but I did not install libtools (do not have root at the moment, am able to get it if I need to though). It gave the same error.
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: Loading script problem.

Post by Jip »

Moofie wrote:Update, I did the install/configure of ZThreads, but I did not install libtools (do not have root at the moment, am able to get it if I need to though). It gave the same error.
Reinstall Z-Threads with --prefix=/usr/ (like AI-Team suggested) and it would work I think.
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Loading script problem.

Post by AI-team »

Moofie wrote:Update, I did the install/configure of ZThreads, but I did not install libtools (do not have root at the moment, am able to get it if I need to though). It gave the same error.
I don't think you need libtools (atleast I don't remember I ever did :P)
After installing Z-Thread with

Code: Select all

--prefix=/usr/
and you need to re-compile tron with

Code: Select all

--with-zthread-prefix=/usr/
as Jip already said


edit: seems like ed had the same problem as you and managed to fix it
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

Hooray, it worked. But the script didn't, maybe it was just not a good one. I'll have to try another. Thanks for the help
User avatar
Z-Man
God & Project Admin
Posts: 11587
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Loading script problem.

Post by Z-Man »

Ah, with 0install, you shouldn't call the implementations directly. Always use 0launch or 0alias, only then will it auto-resolve its dependencies.

Edit, as for the script: try the console/config command SPAWN_SCRIPT. It starts scripts the way you want: with stdin coming from ladderlog and the output fed into arma's input. For you:
SPAWN_SCRIPT deathpulse.php
and deathpulse.php needs to be moved from the var/ subfolder to the scripts/ subfolder of your user data directory.

Also, in your launch code, you may have a look at your userconfigdir; it's a config file, not a directory. You should probably just drop both the --userconfigdir and --vardir arguments, the vardir you set is the default anyway.
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

Hm, alright. I'll check it out. What you said (and everyone else) only made half sense, but I made it this far learning, I can make it more :P

EDIT: I put it in my everytime.cfg file, as I think you can't enter it though console. In the logs is says

Code: Select all

Launching external command '/home/mark//.armagetronad-styct-dedicated/scripts/deathpulse.php
Nothing launches, but it tries. It has 2 // ^, I that may be the problem but I didn't set any. I putting the full path in the command as well and it gave this

Code: Select all

[0] ERROR: User given path "scripts//home/mark/.armagetronad-styct-dedicated/scripts/deathpulse.php" contains a hidden component.
[0] External command '/home/mark/.armagetronad-styct-dedicated/scripts/deathpulse.php' not found anywhere in <datapath>/scripts/
User avatar
Z-Man
God & Project Admin
Posts: 11587
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Loading script problem.

Post by Z-Man »

Moofie wrote:EDIT: I put it in my everytime.cfg file, as I think you can't enter it though console. In the logs is says

Code: Select all

Launching external command '/home/mark//.armagetronad-styct-dedicated/scripts/deathpulse.php
Nothing launches, but it tries. It has 2 // ^,
That would be the correct way, the double / doesn't matter. Absolute paths are forbidden for security reasons, all commands can also be triggered by remote admins and you don't want anyone to be able to just run arbitrary scripts on your server.

Maybe the issue is with the php script itself, can you post it? Also, is it possible to launch the script from the shell by entering /home/mark//.armagetronad-styct-dedicated/scripts/deathpulse.php? I dimly remember that not being possible for php, you'll need to write a regular shell script wrapper then.
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

Yeah, I just used this example script from http://crazy-tronners.com/wiki/index.ph ... g_a_Server

Code: Select all

#!/usr/bin/php
<?php
while (1)  {
    $line = rtrim(fgets(STDIN, 1024));
    // watch the game time to update settings based on time
    if (preg_match("/^GAME_TIME/", $line)){
        $keywords = preg_split("/ /", $line);
        $game_time=$keywords[1];
        if ( $game_time == 0 ){
            for ( $i=0; $i<=500; $i+=50 )
                for ( $j=0; $j<=500; $j+=50 )
                    print("spawn_zone death $i $j 1 0\n");
        } else if ( $game_time % 14 == 0 ){
            for ( $i=0; $i<=500; $i+=100 ){
                for ( $j=0; $j<=500; $j+=100 ){
                    print("spawn_zone death $i $j " . $game_time/2 . " -" . $game_time/5 . "\n");
                    usleep(20000);
                }
            }
        } else if ( $game_time % 7 == 0 ) {
            for ( $i=50; $i<=450; $i+=100 ){
                for ( $j=50; $j<=450; $j+=100 ){
                    print("spawn_zone death $i $j " . $game_time/2 . " -" . $game_time/5 . "\n");
                    usleep(20000);
                }
            }
        }
    }
}
?>
Oh, and here is the thing where I said I didn't think you can use spawn_script:

Code: Select all

[0] Remote admin command by Moofie@forums: spawn_script deathpulse.php
[0] Launching scripts from RINCLUDE or maps is not possible for security reasons. Work around it by delegating the actual script launch to a local configuration file.
User avatar
Z-Man
God & Project Admin
Posts: 11587
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Loading script problem.

Post by Z-Man »

Works for me; the thing you may be missing is that this script reacts to GAME_TIME messages which are not written by default. You need to add

Code: Select all

LADDERLOG_GAME_TIME_INTERVAL 1
(or 2 or 7 or 14) to your configuration.
Moofie wrote:Oh, and here is the thing where I said I didn't think you can use spawn_script:

Code: Select all

[0] Remote admin command by Moofie@forums: spawn_script deathpulse.php
[0] Launching scripts from RINCLUDE or maps is not possible for security reasons. Work around it by delegating the actual script launch to a local configuration file.
That just means what it says: No remote triggered start of scripts. We always want two layers of security between us and remote exploit hacks because every layer alone can have flaws. Here, while we do check that the command that is launched really is just the script and not the script plus some payload, those checks may be faulty or get broken by future OSes or be already broken on Unix variants we don't usually test. Or consider the fact that you can pass parameters to scripts: scripts run with full rights of the server, what if a script has a vulnerability parsing its arguments?
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Loading script problem.

Post by Moofie »

Oh, it worked! Sweet, thanks for the help.
User avatar
Z-Man
God & Project Admin
Posts: 11587
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Loading script problem.

Post by Z-Man »

Oh, one thing to note: if you start your scripts that way, they need to terminate when they receive EOF or errors on input. The little test script doesn't do that and doesn't terminate and, worse, eats up as much CPU time as it can get.
Post Reply