Exemplo n.º 1
0
def valveMapRemove(path, mapName, game='css'):

    mapList = path + '/maplist.txt'
    mapCycle = path + '/mapcycle.txt'
    try:
        # Удалить карту из конфигов
        if game not in ['cs16', 'cs16-old']:
            if (removeParamFromConfig(mapList, mapName) == True):
                xmlLog('Карта успешно удалена из maplist.txt')
            else:
                xmlLog('Возникла ошибка при удалении карты из maplist.txt', 'error')

        if (removeParamFromConfig(mapCycle, mapName) == True):
            xmlLog('Карта успешно удалена из mapcycle.txt')
        else:
            xmlLog('Возникла ошибка при удалении карты из mapcycle.txt', 'error')

        return True

    except OSError, e:
        xmlLog("Не удалось удалить карту из-за ошибки: " + e, 'error')
        return False
Exemplo n.º 2
0
Lesser General Public License for more details.
***********************************************
'''


from optparse import OptionParser
from commonLib import readAndSetParamFromConfig, xmlLog

parser = OptionParser()
parser.add_option("-i", "--param",  action="store", type="string", dest="param")
parser.add_option("-v", "--value",  action="store", type="string", dest="value")
parser.add_option("-d", "--desc",   action="store", type="string", dest="description")
parser.add_option("-c", "--config", action="store", type="string", dest="config_name")
parser.add_option("-p", "--path",   action="store", type="string", dest="config_path")
parser.add_option("-a", "--action", action="store", type="string", dest="action")
parser.add_option("-w", "--delim",  action="store", type="string", dest="delim")

(options, args) = parser.parse_args(args=None, values=None)
param = options.param.strip("'")
value = options.value.strip("'")
desc = options.description.strip("'")
config = options.config_name.strip("'")
path = options.config_path.strip("'")
action = options.action.strip("'")
delim = options.delim

try:
    readAndSetParamFromConfig(param, value, desc, config, path, action, delim)
except Exception, e:
    xmlLog(e, 'error')
            pw = pwd.getpwnam(userName)
            userUid = pw.pw_uid

            # Запуск скрипта проверки от имени пользователя
            try:
                retcode = Popen(
                    "sudo -u " + userName +
                    ' ./read_write_param.py -i "%s" -v "%s" -d "%s" -c "%s" -p "%s" -a %s -w %s'
                    % (param, value, desc, config, configPath, action, delim),
                    shell=True,
                    stdin=PIPE,
                    stdout=PIPE,
                    stderr=PIPE)
                (out, err) = retcode.communicate()
                print out
                print xmlLog(err, 'error')
                if err < 0:
                    print "<error>При попытке чтения/записи конфига возникла ошибка: ", err, '</error>'
                elif err == 0 or err == "":
                    print "<log>Операция завершена.</log>"

            except OSError, e:
                print "<error>При попытке чтения/записи конфига возникла ошибка: ", e, '</error>'

        else:
            print '<error>Не указан путь конфига.</error>'
    else:
        print '<error>Игровой сервер привязан к другому физическому.</error>'

print '</response>'
Exemplo n.º 4
0
        if (removeParamFromConfig(mapCycle, mapName) == True):
            xmlLog('Карта успешно удалена из mapcycle.txt')
        else:
            xmlLog('Возникла ошибка при удалении карты из mapcycle.txt', 'error')

        return True

    except OSError, e:
        xmlLog("Не удалось удалить карту из-за ошибки: " + e, 'error')
        return False


#

xmlLog(datetime.now().strftime("%A, %d. %B %Y %H:%M:%S%p"))
parser = OptionParser()

parser.add_option("-a", "--action",      action="store", type="string", dest="action")
parser.add_option("-s", "--serverpath",  action="store", type="string", dest="serverPath")
parser.add_option("-m", "--mappath",     action="store", type="string", dest="mapPath")
parser.add_option("-n", "--name",        action="store", type="string", dest="mapName")
parser.add_option("-i", "--installpath", action="store", type="string", dest="installPath")
parser.add_option("-t", "--template",    action="store", type="string", dest="gameTemplate")

(options, args) = parser.parse_args(args=None, values=None)

action = options.action
mapPath = re.sub('(\.{1,2}/)', '', options.mapPath)
serverPath = re.sub('(\.{1,2}/)', '', options.serverPath)
mapName = options.mapName
Exemplo n.º 5
0
def valveMapInsert(path, mapName, game='css'):

    mapList = path + '/maplist.txt'
    mapCycle = path + '/mapcycle.txt'

    if game in ['cs16', 'cs16-old']:
        serverCfg = path + '/server.cfg'
    else:
        serverCfg = path + '/cfg/server.cfg'

    try:
        # Добавить карты в конфиги
        if game not in ['cs16', 'cs16-old']:
            if (addInfoToConfig(mapList, mapName) == True):
                xmlLog('Карта успешно добавлена в maplist.txt')
            else:
                xmlLog('Возникла ошибка при добавлении карты в maplist.txt', 'error')

        if (addInfoToConfig(mapCycle, mapName) == True):
            xmlLog('Карта успешно добавлена в mapcycle.txt')
        else:
            xmlLog('Возникла ошибка при добавлении карты в mapcycle.txt', 'error')

        if (addInfoToConfig(serverCfg, 'sv_downloadurl "http://fdl1.teamserver.ru/fastdl/%s/"' % game) == True):
            xmlLog('FastDL успешно прописан в server.cfg')
        else:
            xmlLog('Возникла ошибка при добавлении FastDL в server.cfg', 'error')

        return True

    except OSError, e:
        xmlLog("Не удалось установить карту из-за ошибки: " + e, 'error')
        return False
                     mapID)

if int(commonCursor.rowcount) == 1:

    # Теперь данные о карте
    map = commonCursor.fetchone()

    serverCursor.execute(
        """SELECT * FROM servers where payedTill > NOW() AND initialised = 1 AND id = %s
                        ORDER BY `servers`.`created`  DESC LIMIT 1""",
        serverID)

    numrows = int(serverCursor.rowcount)

    if numrows > 0:
        xmlLog("Данные о сервере получены")

        server = serverCursor.fetchone()

        # Проверяем привязку игрового сервера к нашему физическому
        rootServer = defineRootServer(commonCursor, serverID)

        if rootServer['id'] == thisServerId:
            xmlLog("Сервер привязан на этот физический сервер. Продолжаю.")

            # Определяем пользователя
            user = defineUser(commonCursor, serverID)

            userName = "******" % user['id']
            homeDir = "/home/%s" % userName
            serversPath = homeDir + "/servers"
commonCursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)

commonCursor.execute("""SELECT `id`, `name` FROM `maps` WHERE `id` = %s""", mapID)

if int(commonCursor.rowcount) == 1:

    # Теперь данные о карте
    map = commonCursor.fetchone()

    serverCursor.execute("""SELECT * FROM servers where payedTill > NOW() AND initialised = 1 AND id = %s
                        ORDER BY `servers`.`created`  DESC LIMIT 1""", serverID)

    numrows = int(serverCursor.rowcount)

    if numrows > 0:
        xmlLog("Данные о сервере получены")

        server = serverCursor.fetchone()

        # Проверяем привязку игрового сервера к нашему физическому
        rootServer = defineRootServer(commonCursor, serverID)

        if rootServer['id'] == thisServerId:
            xmlLog("Сервер привязан на этот физический сервер. Продолжаю.")

            # Определяем пользователя
            user = defineUser(commonCursor, serverID)

            userName = "******" % user['id']
            homeDir = "/home/%s" % userName
            serversPath = homeDir + "/servers"
Exemplo n.º 8
0
                  action="store",
                  type="string",
                  dest="config")

(options, args) = parser.parse_args(args=None, values=None)
admStr = options.admStr
admType = options.admType
mod = options.mod
config = options.config
'''

 Для ManiAdmin использовать функцию addAdminToMani (config, admin, adminType)
 Для SourceMod и Amxmodx использовать addInfoToConfig

'''
xmlLog('Попытка добавить админа в %s' % mod)

if mod == 'sourcemod':

    if admType == 'steam':
        text = '"%s" "99:z"' % admStr
    elif admType == 'ip':
        text = '"!%s" "99:z"' % admStr
    elif admType == 'userPass':
        text = '%s "99:z"' % admStr

    # Для безопасности надо проверить наличие имени конфига в пути
    if re.search('admins_simple.ini', config):
        print '<log>'
        addInfoToConfig(config, text)
        print '/<log>'
    adminStr = server["adminStr"].value

# Получить данные сервера из базы
db = MySQLdb.connect(host=mysqlHost, user=mysqlUser, passwd=mysqlPass, db=mysqlDb)

# Create cursor with row names as array arguments
serverCursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
commonCursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)

serverCursor.execute("""SELECT * FROM servers where payedTill > NOW() AND initialised = 1 AND id = %s
                    ORDER BY `servers`.`created`  DESC LIMIT 1""", serverID)

numrows = int(serverCursor.rowcount)

if numrows > 0:
    xmlLog("Данные о сервере получены")

    server = serverCursor.fetchone()

    # Проверяем привязку игрового сервера к нашему физическому
    rootServer = defineRootServer(commonCursor, serverID)

    if rootServer['id'] == thisServerId:
        xmlLog("Сервер привязан на этот физический сервер. Продолжаю.")

        # Определяем пользователя
        user = defineUser(commonCursor, serverID)

        userName = "******" % user['id']
        userEmail = user['email']
        homeDir = "/home/%s" % userName
            pw = pwd.getpwnam(userName)
            userUid = pw.pw_uid

            # Запуск скрипта проверки от имени пользователя
            try:
                retcode = Popen("sudo -u " + userName
                                + ' ./read_write_param.py -i "%s" -v "%s" -d "%s" -c "%s" -p "%s" -a %s -w %s'
                                % (param, value, desc, config, configPath, action, delim),
                                shell=True,
                                stdin=PIPE,
                                stdout=PIPE,
                                stderr=PIPE)
                (out, err) = retcode.communicate()
                print out
                print xmlLog(err, 'error')
                if err < 0:
                    print "<error>При попытке чтения/записи конфига возникла ошибка: ", err, '</error>'
                elif err == 0 or err == "":
                    print "<log>Операция завершена.</log>"

            except OSError, e:
                print "<error>При попытке чтения/записи конфига возникла ошибка: ", e, '</error>'

        else:
            print '<error>Не указан путь конфига.</error>'
    else:
        print '<error>Игровой сервер привязан к другому физическому.</error>'

print '</response>'