def installMongo(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading zip file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.zip"), UPLOAD_ROOT+"/mongodb.zip") print("uploading md5 file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.md5"), UPLOAD_ROOT+"/mongodb.md5") print("checking md5 ...") cmd = "cd %s; md5sum -c %s" %(UPLOAD_ROOT, "./mongodb.md5") shell(id, cmd) print("creating mongodb folder ...") cmd = "mkdir %s/mongodb; mkdir %s/mongodb/bin; mkdir %s/mongodb/data; mkdir %s/mongodb/log; touch %s/mongodb/log/mongodb.log" %(UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT) shell(id, cmd) print("unziping file ...") cmd = "cd %s; unzip -o -d ./mongodb/bin %s" %(UPLOAD_ROOT, "./mongodb.zip") shell(id, cmd) startMongo(id) ssh.sftpClose(conn)
def installMongo(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading zip file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.zip"), UPLOAD_ROOT + "/mongodb.zip") print("uploading md5 file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.md5"), UPLOAD_ROOT + "/mongodb.md5") print("checking md5 ...") cmd = "cd %s; md5sum -c %s" % (UPLOAD_ROOT, "./mongodb.md5") shell(id, cmd) print("creating mongodb folder ...") cmd = "mkdir %s/mongodb; mkdir %s/mongodb/bin; mkdir %s/mongodb/data; mkdir %s/mongodb/log; touch %s/mongodb/log/mongodb.log" % ( UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT) shell(id, cmd) print("unziping file ...") cmd = "cd %s; unzip -o -d ./mongodb/bin %s" % (UPLOAD_ROOT, "./mongodb.zip") shell(id, cmd) startMongo(id) ssh.sftpClose(conn)
def updateSconf(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading sconf file ...") ssh.upload(conn, os.path.abspath(CONFIG_PATH %(id)), UPLOAD_PATH %(id) + "server/sconf.lua") ssh.sftpClose(conn)
def updateSconf(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading sconf file ...") ssh.upload(conn, os.path.abspath(CONFIG_PATH % (id)), UPLOAD_PATH % (id) + "server/sconf.lua") ssh.sftpClose(conn)
def initMongo(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading mongo init file ...") ssh.upload(conn, os.path.abspath(MONGO_INIT_FILE), UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE)) cmd = "cd %s/mongodb/bin; ./mongo odin_gamedb_%d '%s'" %(UPLOAD_ROOT, id, UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE)) shell(id, cmd) ssh.sftpClose(conn)
def updateServers(id, pack): if pack == "": publish(id, "odin*.tar.gz", UPLOAD_PATH %(id)) else: publish(id, pack, UPLOAD_PATH %(id)) ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading sconf file ...") ssh.upload(conn, os.path.abspath(CONFIG_PATH %(id)), UPLOAD_PATH %(id) + "server/sconf.lua") ssh.sftpClose(conn)
def initMongo(id): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading mongo init file ...") ssh.upload(conn, os.path.abspath(MONGO_INIT_FILE), UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE)) cmd = "cd %s/mongodb/bin; ./mongo odin_gamedb_%d '%s'" % ( UPLOAD_ROOT, id, UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE)) shell(id, cmd) ssh.sftpClose(conn)
def updateServers(id, pack): if pack == "": publish(id, "odin*.tar.gz", UPLOAD_PATH % (id)) else: publish(id, pack, UPLOAD_PATH % (id)) ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) print("uploading sconf file ...") ssh.upload(conn, os.path.abspath(CONFIG_PATH % (id)), UPLOAD_PATH % (id) + "server/sconf.lua") ssh.sftpClose(conn)
def publish(id, format, upPath): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) cmd = "cd %s; ls -lt %s | awk '{print $9}' | sed -n '1p;'" %(PACK_PATH, format) (status, packFile) = commands.getstatusoutput(cmd) packMd5 = packFile + ".md5" print("uploading zip file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + packFile), upPath + packFile) print("uploading md5 file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + packMd5), upPath + packMd5) print("checking md5 ...") cmd = "cd %s; md5sum -c %s" %(upPath, upPath + packMd5) shell(id, cmd) print("unziping file ...") cmd = "cd %s; tar -zxvf %s" %(upPath, upPath + packFile) shell(id, cmd) ssh.sftpClose(conn)
def publish(id, format, upPath): ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE)) conn = ssh.sftpConnect(ip, port, usr, psd) cmd = "cd %s; ls -lt %s | awk '{print $9}' | sed -n '1p;'" % (PACK_PATH, format) (status, packFile) = commands.getstatusoutput(cmd) packMd5 = packFile + ".md5" print("uploading zip file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + packFile), upPath + packFile) print("uploading md5 file ...") ssh.upload(conn, os.path.abspath(PACK_PATH + packMd5), upPath + packMd5) print("checking md5 ...") cmd = "cd %s; md5sum -c %s" % (upPath, upPath + packMd5) shell(id, cmd) print("unziping file ...") cmd = "cd %s; tar -zxvf %s" % (upPath, upPath + packFile) shell(id, cmd) ssh.sftpClose(conn)