Added: python tools for server commands

Install Rocketchat script
feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent 406072f3e1
commit 5bddc6eaa7
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -0,0 +1,143 @@
import logging
import socket
from nel_message import *
class CAdminServiceWeb(CCallbackClient):
def globalCmd(self, command):
msg = CMessage()
msg.setName("GCMD")
msg.serialString(command)
return self.sendMessage(msg)
def controlCmd(self, serviceAlias, command):
msg = CMessage()
msg.setName("CCMD")
msg.serialString(serviceAlias)
msg.serialString(command)
return self.sendMessage(msg)
def serviceCmd(self, serviceAlias, command):
msg = CMessage()
msg.setName("SCMD")
msg.serialString(serviceAlias)
msg.serialString(command)
return self.sendMessage(msg)
def getShardOrders(self):
msg = CMessage()
msg.setName("GSO")
ret = ""
ret = sendMessage(msg)
if not ret:
print("getShardOrders: Error in 'sendMessage'")
return False
retMsg = waitMessage()
if not retMsg:
print("getShardOrders: Error in 'waitMessage'")
return False
if not retMsg.MsgName == "R_GSO":
print("getShardOrders: Invalid response, awaited 'R_GSO', received: "+retMsg.MsgName)
return False
nbElem = 0
retMsg.serialUInt32(nbElem)
retValue = []
for i in range(nbElem):
retMsg.serialString(item)
retValue.append(item)
return retValue
def waitCallback(self):
message = self.waitMessage()
if not message:
return False
if message.MsgName == "CMDR":
self.commandResult_skel(message)
else:
return False
return True
def commandResult_skel(self, message):
serviceAlias = message.serialString()
result = message.serialString()
self.commandResult(serviceAlias, result)
def commandResult(self, serviceAlias, result):
global command_return_data
command_return_data = result
def queryShard(service_name, fullcmd, waitCallback=True, is_control=False):
global command_return_data
nel_result = ""
nel_status = not waitCallback
res = ""
p_result = None
adminService = CAdminServiceWeb()
if adminService.connect("yubo.ryzom.com", 46700, res):
command_return_data = ""
if isinstance(fullcmd, str):
if is_control:
adminService.controlCmd(service_name, fullcmd)
else:
adminService.serviceCmd(service_name, fullcmd)
service_command = fullcmd
if waitCallback and adminService.waitCallback():
nel_status = True
nel_result += command_return_data
else:
for service_command in fullcmd:
if is_control:
adminService.controlCmd(service_name, service_command)
else:
adminService.serviceCmd(service_name, service_command)
adminService.close()
return {"status": nel_status, "query": service_name+":"+fullcmd, "raw": nel_result.split("\n")[1:]}
def serveShard():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 15555))
adminService = CAdminServiceWeb()
res = ""
i = 1
if adminService.connect("yubo.ryzom.com", 46700, res):
print("Connected")
while True:
sock.listen(5)
client, address = sock.accept()
response = client.recv(255)
if response != "":
print(i, response)
i = i + 1
adminService.serviceCmd("egs", response)
if adminService.waitCallback():
pass
print("Close")
client.close()
sock.close()

@ -0,0 +1,60 @@
#!/bin/bash
VERSION="1.0.0-rc.0"
BUILD_PATH=~/builds
echo "INSTALLATION OF VERSION $VERSION !!!!"
echo "If you don't have install all requirements check at:"
echo "https://rocket.chat/docs/installation/manual-installation/ubuntu/"
echo "To install meteor : curl https://install.meteor.com/ | sh"
echo "Erasing old..."
rm -rf $BUILD_PATH/RocketChat/Rocket.Chat.old
mv Rocket.Chat Rocket.Chat.old
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
cd ~/builds/RocketChat/
if [[ ! -d "megacorp" ]]
echo "Missing megacorp. Cloning it.."
hg clone ssh://hg@bitbucket.org/ryzom/megacorp
fi
cd megacorp
hg pull
hg update -v
cd ..
git clone https://github.com/RocketChat/Rocket.Chat.git
cd Rocket.Chat
git checkout $VERSION
cp $BUILD_PATH/RocketChat/megacorp/ryzom-rocket-bridge/ packages/
echo -e "\nryzom-rocket-bridge" >> .meteor/packages
##cd packages/rocketchat-iframe-login
##sed -i -e $'s/console.log/check(result.token, String);\\\n\\\tconsole.log/g' iframe_server.js
##cd ../..
npm install --production
#npm audit fix // ???
rm -rf ../rc-bundle
meteor build ../rc-bundle --architecture os.linux.x86_64
meteor build ../rc-bundle --architecture os.linux.x86_64
cd ../rc-bundle
tar xvfz Rocket.Chat.tar.gz
cd ~
mv Rocket.Chat/ Rocket.Chat.old
cp -r src/rc-bundle/bundle/ Rocket.Chat/
cd ~/Rocket.Chat/programs/server
npm install
tools@chat:~/src$

@ -0,0 +1,170 @@
import logging
import socket
SockTimeOut=10
class CMemStream:
def __init__(self):
self.InputStream = False
self.Pos = 0
self.Buffer = b""
def setBuffer(self, Buffer):
self.InputStream = True
self.Buffer = Buffer
self.Pos = 0
def isReading(self):
return self.InputStream
def serialUInt8(self, val=b""):
if self.isReading():
val = ord(self.Buffer[self.Pos])
self.Pos += 1
return val
else:
self.Buffer += bytes([val & 0xFF])
self.Pos += 1
def serialUInt32(self, val=b""):
if self.isReading():
val = ord(self.Buffer[self.Pos])
self.Pos += 1
val += ord(self.Buffer[self.Pos])*256
self.Pos += 1
val += ord(self.Buffer[self.Pos])*256*256
self.Pos += 1
val += ord(self.Buffer[self.Pos])*256*256*256
self.Pos += 1
return val
else:
self.Buffer += bytes([val & 0xFF])
self.Buffer += bytes([(val>>8) & 0xFF])
self.Buffer += bytes([(val>>16) & 0xFF])
self.Buffer += bytes([(val>>24) & 0xFF])
self.Pos += 4
def serialString(self, val=b""):
if self.isReading():
size = self.serialUInt32()
val = self.Buffer[self.Pos:self.Pos+size]
self.Pos += len(val)
return val
else:
try:
#Convert to bytes if need
val = val.encode("utf-8")
except AttributeError:
pass
valLen = len(val)
self.serialUInt32(valLen)
self.Buffer += val
self.Pos += valLen
def serialEnum(self, val=""):
pass
class CMessage(CMemStream):
def __init__(self):
super().__init__()
def setName(self, name):
self.MsgName = name
class CCallbackClient():
ConSock = False
MsgNum = 0
def connect(self, addr, port, res):
global SockTimeOut
self.MsgNum = 0
self.ConSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.ConSock.connect((addr, port))#, $errno, $errstr, $SockTimeOut)
except socket.error:
print("Connection failed...")
return False
print("Connection enabled!")
return True
#TODO: set time out on the socket to 2 secondes
#stream_set_timeout(self.ConSock, $SockTimeOut)
def close(self):
if self.ConSock:
self.ConSock.close()
def sendMessage(self, message):
hd = CMemStream()
hd.serialUInt32(self.MsgNum) #number the packet
self.MsgNum += 1
messageType = 0
hd.serialUInt8(messageType)
hd.serialString(message.MsgName)
size = hd.Pos + message.Pos
Buffer = chr((size>>24)&0xFF)
Buffer += chr((size>>16)&0xFF)
Buffer += chr((size>>8)&0xFF)
Buffer += chr(size&0xFF)
Buffer = Buffer.encode("iso-8859-1")
Buffer += hd.Buffer
Buffer += message.Buffer
print(Buffer.decode("utf-8", errors="replace"))
sent = self.ConSock.send(Buffer)
if not sent:
raise RuntimeError("socket connection broken")
def waitMessage(self):
size = 0
val = self.ConSock.recv(1)
if val:
size = ord(val) << 24
else:
print("Error")
val = self.ConSock.recv(1)
if val:
size = ord(val) << 16
else:
print("Error")
val = self.ConSock.recv(1)
size += ord(val) << 8
val = self.ConSock.recv(1)
size += ord(val)
fake = self.ConSock.recv(5)
size -= 5 #remove the fake
Buffer = ""
while size > 0 and len(Buffer) != size:
Buffer += self.ConSock.recv(size - len(Buffer)).decode("utf-8", errors="replace")
msgin = CMemStream()
msgin.setBuffer(Buffer)
#decode msg name
name = ""
name = msgin.serialString(name)
logging.info("Message name = '%s'" % name)
message = CMessage()
message.setBuffer(msgin.Buffer[msgin.Pos:])
message.setName(name)
return message

@ -0,0 +1,11 @@
/////////////////////////////////
/////////////////////////////////
/// SHEETS PACKER CONFIG FILE ///
/////////////////////////////////
/////////////////////////////////
DataPath = { "$RYZOMDATADIR/common/data_leveldesign", "$RYZOMDATADIR/common/data_common", "$D" };
WorldSheet = "ryzom.world";
PrimitivesPath = "$RYZOMDATADIR/common/data_leveldesign/primitives";
OutputDataPath = "$D";
LigoPrimitiveClass = "world_editor_classes.xml";
DumpVisualSlotsIndex = 1;
Loading…
Cancel
Save