32 lines
		
	
	
	
		
			886 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			886 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| 
 | |
| from sys import argv
 | |
| from os.path import realpath, dirname
 | |
| from shlex import quote
 | |
| from bundlewrap.repo import Repository
 | |
| 
 | |
| repo = Repository(dirname(dirname(realpath(__file__))))
 | |
| 
 | |
| if len(argv) == 1:
 | |
|     for node in repo.nodes:
 | |
|         for name in node.metadata.get('left4dead2/servers', {}):
 | |
|             print(name)
 | |
|     exit(0)
 | |
| 
 | |
| server = argv[1]
 | |
| command = argv[2]
 | |
| 
 | |
| remote_code = """
 | |
| from rcon.source import Client
 | |
| 
 | |
| with Client('127.0.0.1', {port}, passwd='''{password}''') as client:
 | |
|     response = client.run('''{command}''')
 | |
| 
 | |
| print(response)
 | |
| """
 | |
| 
 | |
| for node in repo.nodes:
 | |
|     for name, conf in node.metadata.get('left4dead2/servers', {}).items():
 | |
|         if name == server:
 | |
|             response = node.run('python3 -c ' + quote(remote_code.format(port=conf['port'], password=conf['rcon_password'], command=command)))
 | |
|             print(response.stdout.decode())
 |