diff --git a/system/library/games/cs2/action.php b/system/library/games/cs2/action.php index d5c8e98..94be6e6 100644 --- a/system/library/games/cs2/action.php +++ b/system/library/games/cs2/action.php @@ -40,13 +40,25 @@ class action extends actions $proc_stat[0] = $ssh->get('cat /proc/stat'); } + // Проверка наличия steamclient.so + $checkLinkCommand = 'ls ' . $tarif['install'] . $server['uid'] . '/.steam/sdk64/steamclient.so'; + $checkLinkOutput = $ssh->get($checkLinkCommand); + + if (strpos($checkLinkOutput, 'steamclient.so') === false) { + // Символическая ссылка отсутствует, создаем ее + $createLinkCommand ='mkdir -p ' . $tarif['install'] . $server['uid'] . '/.steam/sdk64/' . ';' + . 'ln -s /path/cmd/linux64/steamclient.so ' . $tarif['install'] . $server['uid'] . '/.steam/sdk64/' . ';' + . 'chmod +x ' . $tarif['install'] . $server['uid'] . '/game/bin/linuxsteamrt64/cs2'; + $ssh->get($createLinkCommand); + } + // Проверка наличия стартовой карты - $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\''); + $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/game/csgo/maps/ && du -ah | grep -e "\.vpk$" | awk \'{print $2}\''); include_once(LIB . 'games/games.php'); - if (games::map($server['map_start'], $ssh->get())) - return array('e' => sys::updtext(sys::text('servers', 'nomap'), array('map' => $server['map_start'] . '.bsp'))); + if (games::map2($server['map_start'], $ssh->get())) + return array('e' => sys::updtext(sys::text('servers', 'nomap'), array('map' => $server['map_start'] . '.vpk'))); // Если система автораспределения продолжить парсинг загрузки процессора if (isset($proc_stat)) { @@ -92,7 +104,7 @@ class action extends actions $mod = !$server['pingboost'] ? $mods[2] : $mods[$server['pingboost']]; // Параметры запуска - $bash = './srcds_run -debug -game csgo -norestart -condebug console.log -usercon -tickrate ' . $server['tickrate'] . ' ' . $mod . ' +servercfgfile server.cfg ' . $map . ' -maxplayers_override ' . $server['slots_start'] . ' +ip ' . $ip . ' +net_public_adr ' . $ip . ' +port ' . $port . ' -sv_lan 0 ' . $vac . ' ' . $bots . ' ' . $tv; + $bash = './game/bin/linuxsteamrt64/cs2 -dedicated -condebug console.log -usercon -ip ' . $ip . ' -port ' . $port . ' -maxplayers ' . $server['slots_start'] . ' -tickrate ' . $server['tickrate'] . ' ' . $map . ' ' . $vac . ' ' . $bots; // Временный файл $temp = sys::temp($bash); @@ -103,10 +115,10 @@ class action extends actions // Строка запуска $ssh->set('cd ' . $tarif['install'] . $server['uid'] . ';' // переход в директорию игрового сервера . 'rm *.pid;' // Удаление *.pid файлов - . 'sudo -u server' . $server['uid'] . ' mkdir -p csgo/oldstart;' // Создание папки логов - . 'cat csgo/console.log >> csgo/oldstart/' . date('d.m.Y_H:i:s', $server['time_start']) . '.log; rm csgo/console.log; rm csgo/oldstart/01.01.1970_03:00:00.log;' // Перемещение лога предыдущего запуска + . 'sudo -u server' . $server['uid'] . ' mkdir -p game/csgo/oldstart;' // Создание папки логов + . 'cat game/csgo/console.log >> game/csgo/oldstart/' . date('d.m.Y_H:i:s', $server['time_start']) . '.log; rm game/csgo/console.log; rm game/csgo/oldstart/01.01.1970_03:00:00.log;' // Перемещение лога предыдущего запуска . 'chown server' . $server['uid'] . ':1000 start.sh;' // Обновление владельца файла start.sh - . 'sudo -u server' . $server['uid'] . ' screen -dmS s_' . $server['uid'] . ' ' . $taskset . ' sh -c "./start.sh"'); // Запуск игровго сервера + . 'sudo -u server' . $server['uid'] . ' screen -dmS s_' . $server['uid'] . ' sh -c "./start.sh"'); // Запуск игровго сервера $core = !isset($core) ? 0 : $core + 1; @@ -150,13 +162,13 @@ class action extends actions return array('e' => sys::text('error', 'ssh')); // Массив карт игрового сервера (папка "maps") - $aMaps = explode("\n", $ssh->get('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\'')); + $aMaps = explode("\n", $ssh->get('cd ' . $tarif['install'] . $server['uid'] . '/game/csgo/maps/ && du -ah | grep -e "\.vpk$" | awk \'{print $2}\'')); // Удаление пустого элемента unset($aMaps[count($aMaps) - 1]); - // Удаление ".bsp" - $aMaps = str_ireplace(array('./', '.bsp'), '', $aMaps); + // Удаление ".vpk" + $aMaps = str_ireplace(array('./', '.vpk'), '', $aMaps); // Если выбрана карта if ($map) { @@ -164,7 +176,7 @@ class action extends actions // Проверка наличия выбранной карты if (games::map($map, $aMaps)) - return array('e' => sys::updtext(sys::text('servers', 'change'), array('map' => $map . '.bsp'))); + return array('e' => sys::updtext(sys::text('servers', 'change'), array('map' => $map . '.vpk'))); // Отправка команды changelevel $ssh->set('sudo -u server' . $server['uid'] . ' screen -p 0 -S s_' . $server['uid'] . ' -X eval ' . "'stuff \"changelevel " . sys::cmd($map) . "\"\015'"); @@ -267,7 +279,7 @@ class action extends actions } $ssh->set('cd ' . $cfg['steamcmd'] . ' && ' . $taskset . ' screen -dmS u_' . $server['uid'] . ' sh -c "' - . './steamcmd.sh +login anonymous +force_install_dir "' . $install . '" +app_update 740 +quit;' + . './steamcmd.sh +login anonymous +force_install_dir "' . $install . '" +app_update 730 +quit;' . 'cd ' . $install . ';' . 'chown -R server' . $server['uid'] . ':servers .;' . 'find . -type d -exec chmod 700 {} \;;' diff --git a/system/library/games/cs2/rcon.php b/system/library/games/cs2/rcon.php index 59f48c3..4c4be29 100644 --- a/system/library/games/cs2/rcon.php +++ b/system/library/games/cs2/rcon.php @@ -88,7 +88,7 @@ class rcon $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1'); $tarif = $sql->get(); - $ssh->set('cat ' . $tarif['install'] . '/' . $server['uid'] . '/csgo/cfg/server.cfg | grep rcon_password'); + $ssh->set('cat ' . $tarif['install'] . '/' . $server['uid'] . '/game/csgo/cfg/server.cfg | grep rcon_password'); $get = explode(' ', str_replace('"', '', trim($ssh->get()))); $rcon = trim(end($get)); diff --git a/system/library/games/games.php b/system/library/games/games.php index 1447f7c..59c0914 100644 --- a/system/library/games/games.php +++ b/system/library/games/games.php @@ -627,6 +627,17 @@ class games return true; } + public static function map2($map, $aMaps) + { + if (!is_array($aMaps)) + $aMaps = explode("\n", str_ireplace(array('./', '.vpk'), '', $aMaps)); + + if (in_array($map, $aMaps)) + return false; + + return true; + } + public static function mapsql($arr = array()) { $sql = 'AND ('; diff --git a/system/sections/servers/cs2/console.php b/system/sections/servers/cs2/console.php index 6a2daed..89e5253 100644 --- a/system/sections/servers/cs2/console.php +++ b/system/sections/servers/cs2/console.php @@ -30,7 +30,7 @@ if ($go) { sys::out(sys::text('error', 'ssh')); } - $dir = $tarif['install'] . $server['uid'] . '/csgo/'; + $dir = $tarif['install'] . $server['uid'] . '/game/csgo/'; $filecmd = $dir . 'console.log'; diff --git a/system/sections/servers/cs2/maps.php b/system/sections/servers/cs2/maps.php index 8b5aa77..c4ccde1 100644 --- a/system/sections/servers/cs2/maps.php +++ b/system/sections/servers/cs2/maps.php @@ -37,11 +37,11 @@ if (isset($url['subsection']) and in_array($url['subsection'], $aSub)) { $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1'); $tarif = $sql->get(); - $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\''); + $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/game/csgo/maps/ && du -ah | grep -e "\.vpk$" | awk \'{print $2}\''); $maps = $ssh->get(); - $aMaps = explode("\n", str_ireplace('.bsp', '', $maps)); + $aMaps = explode("\n", str_ireplace('.vpk', '', $maps)); // Сортировка карт sort($aMaps); diff --git a/system/sections/servers/cs2/maps/delete.php b/system/sections/servers/cs2/maps/delete.php index be0613e..4d86f82 100644 --- a/system/sections/servers/cs2/maps/delete.php +++ b/system/sections/servers/cs2/maps/delete.php @@ -19,14 +19,14 @@ if (!$ssh->auth($unit['passwd'], $unit['address'])) $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1'); $tarif = $sql->get(); -$dir = $tarif['install'] . $server['uid'] . '/csgo/'; +$dir = $tarif['install'] . $server['uid'] . '/game/csgo/'; // Генерация списка карт -$ssh->set('cd ' . $dir . 'maps/ && ls | grep -iE "\.bsp$"'); +$ssh->set('cd ' . $dir . 'maps/ && ls | grep -iE "\.vpk$"'); $maps = $ssh->get(); -$aMaps = explode("\n", str_ireplace('.bsp', '', $maps)); +$aMaps = explode("\n", str_ireplace('.vpk', '', $maps)); // Массив переданных карт $in_aMaps = isset($_POST['maps']) ? $_POST['maps'] : array(); diff --git a/system/sections/servers/cs2/maps/install.php b/system/sections/servers/cs2/maps/install.php index e0c651f..cac0e68 100644 --- a/system/sections/servers/cs2/maps/install.php +++ b/system/sections/servers/cs2/maps/install.php @@ -20,7 +20,7 @@ if (!$ssh->auth($unit['passwd'], $unit['address'])) $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1'); $tarif = $sql->get(); -$dir = $tarif['install'] . $server['uid'] . '/csgo/'; +$dir = $tarif['install'] . $server['uid'] . '/game/csgo/'; // Проверить наличие свободного места $ssh->set('cd ' . $dir . ' && du -ms'); diff --git a/system/sections/servers/cs2/maps/listing.php b/system/sections/servers/cs2/maps/listing.php index 7b5e124..055456a 100644 --- a/system/sections/servers/cs2/maps/listing.php +++ b/system/sections/servers/cs2/maps/listing.php @@ -21,15 +21,15 @@ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . ' $tarif = $sql->get(); // Директория сервера -$dir = $tarif['install'] . $server['uid'] . '/csgo/'; +$dir = $tarif['install'] . $server['uid'] . '/game/csgo/'; // Генерация списка if ($go and isset($url['gen'])) { - $ssh->set('cd ' . $dir . 'maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\''); + $ssh->set('cd ' . $dir . 'maps/ && du -ah | grep -e "\.vpk$" | awk \'{print $2}\''); $maps = $ssh->get(); - $aMaps = explode("\n", str_ireplace(array('./', '.bsp'), '', $maps)); + $aMaps = explode("\n", str_ireplace(array('./', '.vpk'), '', $maps)); sort($aMaps); reset($aMaps); diff --git a/system/sections/servers/cs2/maps/search.php b/system/sections/servers/cs2/maps/search.php index 5ede4b5..6533e1e 100644 --- a/system/sections/servers/cs2/maps/search.php +++ b/system/sections/servers/cs2/maps/search.php @@ -2,7 +2,7 @@ if (!DEFINED('EGP')) exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404')); -$text = isset($_POST['text']) ? str_ireplace('.bsp', '', $_POST['text']) : ''; +$text = isset($_POST['text']) ? str_ireplace('.vpk', '', $_POST['text']) : ''; $mkey = md5($text . $id); diff --git a/system/sections/servers/cs2/settings/admins.php b/system/sections/servers/cs2/settings/admins.php index 6759274..e0993b3 100644 --- a/system/sections/servers/cs2/settings/admins.php +++ b/system/sections/servers/cs2/settings/admins.php @@ -65,11 +65,11 @@ if ($go) { $temp = sys::temp($usini); - $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/configs/admins_simple.ini', 0644); + $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/game/csgo/addons/sourcemod/configs/admins_simple.ini', 0644); unlink($temp); - $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/configs/admins_simple.ini'); + $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/game/csgo/addons/sourcemod/configs/admins_simple.ini'); $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \" sm_reloadadmins\"\015'"); diff --git a/system/sections/servers/cs2/settings/bans.php b/system/sections/servers/cs2/settings/bans.php index bc162fd..2ffdd42 100644 --- a/system/sections/servers/cs2/settings/bans.php +++ b/system/sections/servers/cs2/settings/bans.php @@ -16,7 +16,7 @@ if (!$ssh->auth($unit['passwd'], $unit['address'])) sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings'); // Путь к файлам (banned_user.cfg / banned_ip.cfg) -$folder = $tarif['install'] . $server['uid'] . '/csgo'; +$folder = $tarif['install'] . $server['uid'] . '/game/csgo'; // Если бан/разбан/проверка if ($go) { diff --git a/system/sections/servers/cs2/settings/logs.php b/system/sections/servers/cs2/settings/logs.php index 513db79..1935247 100644 --- a/system/sections/servers/cs2/settings/logs.php +++ b/system/sections/servers/cs2/settings/logs.php @@ -16,7 +16,7 @@ if (!$ssh->auth($unit['passwd'], $unit['address'])) sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings'); // Путь к логам -$folder = $tarif['install'] . $server['uid'] . '/csgo/logs'; +$folder = $tarif['install'] . $server['uid'] . '/game/csgo/logs'; // Если выбран лог if (isset($url['log'])) { diff --git a/system/sections/servers/cs2/settings/server.php b/system/sections/servers/cs2/settings/server.php index e6a9df3..30b467f 100644 --- a/system/sections/servers/cs2/settings/server.php +++ b/system/sections/servers/cs2/settings/server.php @@ -38,9 +38,9 @@ if ($go) { // Временый файл $temp = sys::temp($config . $config_end); - $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg', 0644); + $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg', 0644); - $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg'); + $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg'); unlink($temp); @@ -48,7 +48,7 @@ if ($go) { } // Чтение файла - server.cfg -$file = $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg'; +$file = $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg'; $ssh->set('echo "" >> ' . $file . ' && cat ' . $file . ' | grep -ve "^#\|^[[:space:]]*$"'); diff --git a/system/sections/servers/cs2/settings/smlogs.php b/system/sections/servers/cs2/settings/smlogs.php index 3576bf0..cc4c8ef 100644 --- a/system/sections/servers/cs2/settings/smlogs.php +++ b/system/sections/servers/cs2/settings/smlogs.php @@ -16,7 +16,7 @@ if (!$ssh->auth($unit['passwd'], $unit['address'])) sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings'); // Путь к логам -$folder = $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/logs'; +$folder = $tarif['install'] . $server['uid'] . '/game/csgo/addons/sourcemod/logs'; // Если выбран лог if (isset($url['log'])) { diff --git a/system/sections/servers/cs2/settings/start.php b/system/sections/servers/cs2/settings/start.php index 75d9419..4cfb45e 100644 --- a/system/sections/servers/cs2/settings/start.php +++ b/system/sections/servers/cs2/settings/start.php @@ -17,7 +17,7 @@ include(LIB . 'games/' . $server['game'] . '/tarif.php'); // Вывод списка карт if (isset($url['maps'])) - games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/csgo/maps', $server['map_start'], false); + games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/game/csgo/maps', $server['map_start'], false); // Сохранение if ($go and $url['save']) { @@ -28,7 +28,7 @@ if ($go and $url['save']) { $map = isset($url['value']) ? trim($url['value']) : sys::outjs(array('s' => 'ok'), $nmch); if ($map != $server['map_start']) - games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/csgo/maps', $map, true, $nmch); + games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/game/csgo/maps', $map, true, $nmch); $mcache->delete('server_settings_' . $id); sys::outjs(array('s' => 'ok'), $nmch); @@ -86,17 +86,17 @@ if ($go and $url['save']) { // Временый файл $temp = sys::temp($fastdl); - $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg', 0644); + $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/game/csgo/cfg/fastdl.cfg', 0644); - $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg;' - . 'ln -s ' . $tarif['install'] . $server['uid'] . '/csgo /var/nginx/fast_' . $server['uid'] . ';' - . 'sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg;' - . 'echo "exec fastdl.cfg" >> ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg'); + $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/fastdl.cfg;' + . 'ln -s ' . $tarif['install'] . $server['uid'] . '/game/csgo /var/nginx/fast_' . $server['uid'] . ';' + . 'sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg;' + . 'echo "exec fastdl.cfg" >> ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg'); unlink($temp); } else - $ssh->set('sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg;' - . 'rm ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg; rm /var/nginx/fast_' . $server['uid']); + $ssh->set('sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/server.cfg;' + . 'rm ' . $tarif['install'] . $server['uid'] . '/game/csgo/cfg/fastdl.cfg; rm /var/nginx/fast_' . $server['uid']); $sql->query('UPDATE `servers` set `fastdl`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');