Скрипт запуска серверов hlds и srcds в Linux
Участник
Скрипт запуска серверов hlds и srcds в Linux
Автор LeXiKoN
Версия 0.98 от 02.05.2011
Цветовая индикация, что позволит вам легко понять информацию
Распределения серверов по ядрам ( подробнее ниже )
Подключение по команде к консоли сервера
Определение статуса работы сервера
Возможность компиляции плагинов в каталоге scripting AmxModX
Проверка версии скрипта
Предстартовая проверка на запущенный процесс hlds
Проверка работоспособности сервера ( необходимо добавить фунцию в crontab — читаем раздел «Установка» )
Ведение лога консоли сервера в файл cstrike/qconsole.log
Ведение лога проверки работоспособности сервера в файл checker.log
Очистка логов checker.log и qconsole.log при превышении размера в 10Мб. ( необходимо добавить фунцию в crontab — читаем раздел «Установка» )
Конфигурация происходит напрямую в самом файле с помощью блокнота
SERVER_NAME=»My Server» #Название сервера
screen_name=server #Название screen-сессии
path=»/home/hlds/server/» #Путь до ROOT-директории сервера
hlds_ip=0.0.0.0 #IP сервера
hlds_port=27015 #Порт сервера
hlds_gametype=cstrike #Тип игры
hlds_players=20 #Максимальное количество игроков на сервере
hlds_map=de_inferno #Имя первоначальной карты при запуске
hlds_pid=server.pid
screen_pid=$screen_name-screen.pid
hlds_options=»-pingboost 3 +exec server.cfg +log on» #Дополнительные параметры запуска
use_user=hlds #Имя юзера от которого запускается сервер
condebug=1
check_version=0
checker_command=»quakestat» #Команда пакета qStat отвечающего за проверку сервера
restarttime=10 #Время после которого сервер будет перезагружен ( выводится в чат на сервере )
#—————————————————-
# Номер ядра/процессора в линуксе
# 2х-ядерные: 0 — первое ядро, 1 — второе ядро
# 4x-ядерные: 0 — первое ядро . 3 — четвертое ядро
# По аналогии с другими многоядерными процессорами
use_core=0
#—————————————————-
Установленные пакеты: qstat, tail, screen, wget, crontab
Скачиваем txt файл для нужной системы
server_deb.txt — Для систем на дистрибутиве Debian
server_rh.txt — Для систем на дистрибутиве RedHat
Переименовываем в нужное вам имя без расширения
Копируем в /etc/init.d/
Устанавливаем пакет qstat, а также другие необходимые для работы пакеты, описанные в разделе «Требования»
Debian подобные дистрибы:
aptitude install qstat
Fedora/Mandriva/CentOS подобные дистрибы:
yum install qstat
Если данный пакет отсутствует в ваших дистрибутивах то скачиваем исходники и собираем!
Устанавливаем права
chmod +x /etc/init.d/hlds_runscript
Добавляем в автозагрузку:
Системы RedHat:
chkconfig —add [имя скрипта]
Системы Debian:
update-rc.d [имя скрипта] defaults
Добавляем проверку работы сервера по расписанию в Crontab (. Проверка будет
происходить каждые 30 минут . )
и вносим туда строку
0,30 * * * * /etc/init.d/[имя скрипта] checker
Добавляем проверку размеров логов по расписанию в Crontab (. Проверка будет происходить каждую неделю . )
и вносим туда строку
0 0 * * 0 /etc/init.d/[имя скрипта] logsize
Не забудьте
checker_command=»quakestat» #Команда пакета qStat отвечающего за проверку сервера
В Вашем дистрибутиве она может быть иной! Иначе не будет работать проверка сервера по расписанию
Для Debian Squeeze ВАЖНО! Если вы используете несколько скриптов для каждого сервера в отдельности то НЕОБХОДИМО поменять в заголовке файла параметр
# Provides:
для каждого сервера он должен быть разный, к примеру:
# Provides: server1
Debian/Ubuntu и прочие
RedHat/Fedora и прочие
Файлы во вложении от 27-11-11, более свежие версии смотрите на сайте автора
Источник
Создание HLDS-сервера на Linux ручками
Javekson
Javekson
- Для написании статьи был задействован виртуальный сервер VDS от хостинг-компании майарены на платформе Debian
- Если у Вас установлена x64-разрядная система, то перед прочтением статьи заранее установите необходимую «либу» для дальнейшей корректной работы сервера.
- Для систем: Ubuntu/Debian 64-Bit выполните команду в терминале: sudo apt-get install lib32gcc1
- Для систем: RedHat/CentOS выполните команду в терминале: yum install glibc libstdc++
- Для систем: RedHat/CentOS 64-Bit выполните команду в терминале: yum install glibc.i686 libstdc++.i686
- Вторым делом мы создадим дополнительную директории для выкачивание специальной утилиты SetamCMD, которая в свою очередь позволит загрузить нам свеженький HLDS-сервер.
Resolving steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net). 87.245.202.16, 87.245.202.57
Connecting to steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)|87.245.202.16|:443. connected.
HTTP request sent, awaiting response. 200 OK
Length: 3170982 (3.0M) [application/octet-stream]
Saving to: `steamcmd_linux.tar.gz’
2017-01-19 17:19:54 (2.17 MB/s) — `steamcmd_linux.tar.gz’ saved [3170982/3170982]
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
ILocalize::AddFile() failed to load file «public/steambootstrapper_english.txt».
[ 0%] Checking for available update.
[ 0%] Downloading update (0 of 10173 KB).
[ 0%] Downloading update (2235 of 10173 KB).
[ 21%] Downloading update (4012 of 10173 KB).
[ 39%] Downloading update (4465 of 10173 KB).
[ 43%] Downloading update (4984 of 10173 KB).
[ 48%] Downloading update (5346 of 10173 KB).
[ 52%] Downloading update (5665 of 10173 KB).
[ 55%] Downloading update (6107 of 10173 KB).
[ 60%] Downloading update (6693 of 10173 KB).
[ 65%] Downloading update (7528 of 10173 KB).
[ 74%] Downloading update (8267 of 10173 KB).
[ 81%] Downloading update (8609 of 10173 KB).
[ 84%] Downloading update (8992 of 10173 KB).
[ 88%] Downloading update (9582 of 10173 KB).
[ 94%] Downloading update (10173 of 10173 KB).
[100%] Downloading update (10173 of 10173 KB).
[100%] Download Complete.
[—-] Applying update.
[—-] Extracting package.
[—-] Extracting package.
[—-] Extracting package.
[—-] Installing update.
[—-] Installing update.
[—-] Installing update.
[—-] Cleaning up.
[—-] Update complete, launching.
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
[ 0%] Checking for available updates.
[—-] Downloading update (0 of 7058 KB).
[ 0%] Downloading update (2070 of 7058 KB).
[ 29%] Downloading update (3708 of 7058 KB).
[ 52%] Downloading update (4618 of 7058 KB).
[ 65%] Downloading update (5136 of 7058 KB).
[ 72%] Downloading update (5567 of 7058 KB).
[ 78%] Downloading update (6039 of 7058 KB).
[ 85%] Downloading update (6489 of 7058 KB).
[ 91%] Downloading update (6859 of 7058 KB).
[ 97%] Downloading update (7058 of 7058 KB).
[100%] Download complete.
[—-] Installing update.
[—-] Extracting package.
[—-] Extracting package.
[—-] Extracting package.
[—-] Installing update.
[—-] Installing update.
[—-] Installing update.
[—-] Cleaning up.
[—-] Update complete, launching Steamcmd.
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
[ 0%] Checking for available updates.
[—-] Verifying installation.
Steam Console Client (c) Valve Corporation
— type ‘quit’ to exit —
Loading Steam API. Created shared memory when not owner SteamController_Shared_mem
OK.
- Авторизуемся в ней от имени анонима.
- Укажем путь куда загрузим полноценный HLDS-сервер.
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x61) downloading, progress: 0.00 (0 / 63579018)
Update state (0x61) downloading, progress: 22.77 (14476949 / 63579018)
Update state (0x61) downloading, progress: 40.37 (25666967 / 63579018)
Update state (0x61) downloading, progress: 56.86 (36152727 / 63579018)
Update state (0x61) downloading, progress: 70.53 (44844614 / 63579018)
Update state (0x61) downloading, progress: 85.38 (54281798 / 63579018)
Update state (0x61) downloading, progress: 98.35 (62530442 / 63579018)
Error! App ’90’ state is 0x6 after update job.
- Видим ошибку, ничего страшного, такое бывает, повторим команду.
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x5) validating, progress: 0.00 (0 / 0)
Update state (0x11) preallocating, progress: 92.97 (686293130 / 738158916)
Update state (0x61) downloading, progress: 1.30 (9579281 / 738158916)
Update state (0x61) downloading, progress: 3.76 (27723531 / 738158916)
Update state (0x61) downloading, progress: 7.15 (52793185 / 738158916)
Update state (0x61) downloading, progress: 10.12 (74737807 / 738158916)
Update state (0x61) downloading, progress: 13.18 (97297331 / 738158916)
Update state (0x61) downloading, progress: 16.47 (121572650 / 738158916)
Update state (0x61) downloading, progress: 19.51 (144045027 / 738158916)
Update state (0x61) downloading, progress: 22.61 (166934604 / 738158916)
Update state (0x61) downloading, progress: 25.96 (191650977 / 738158916)
Update state (0x61) downloading, progress: 29.67 (219045714 / 738158916)
Update state (0x61) downloading, progress: 33.76 (249180936 / 738158916)
Update state (0x61) downloading, progress: 38.30 (282720713 / 738158916)
Update state (0x61) downloading, progress: 41.08 (303219453 / 738158916)
Update state (0x61) downloading, progress: 44.44 (328005853 / 738158916)
Update state (0x61) downloading, progress: 44.44 (328005853 / 738158916)
Update state (0x61) downloading, progress: 44.65 (329599753 / 738158916)
Update state (0x61) downloading, progress: 46.65 (344323522 / 738158916)
Update state (0x61) downloading, progress: 50.67 (374012566 / 738158916)
Update state (0x61) downloading, progress: 54.99 (405944218 / 738158916)
Update state (0x61) downloading, progress: 60.14 (443954326 / 738158916)
Update state (0x61) downloading, progress: 62.63 (462319046 / 738158916)
Update state (0x61) downloading, progress: 64.09 (473057757 / 738158916)
Update state (0x61) downloading, progress: 65.29 (481956283 / 738158916)
Update state (0x61) downloading, progress: 65.29 (481956283 / 738158916)
Update state (0x61) downloading, progress: 67.32 (496950092 / 738158916)
Update state (0x61) downloading, progress: 68.71 (507159569 / 738158916)
Update state (0x61) downloading, progress: 68.71 (507159569 / 738158916)
Update state (0x61) downloading, progress: 69.73 (514709103 / 738158916)
Update state (0x61) downloading, progress: 72.95 (538497442 / 738158916)
Update state (0x61) downloading, progress: 74.15 (547328303 / 738158916)
Update state (0x61) downloading, progress: 74.15 (547328303 / 738158916)
Update state (0x61) downloading, progress: 75.03 (553855982 / 738158916)
Update state (0x61) downloading, progress: 78.00 (575748716 / 738158916)
Update state (0x61) downloading, progress: 81.59 (602238620 / 738158916)
Update state (0x61) downloading, progress: 86.06 (635231427 / 738158916)
Update state (0x61) downloading, progress: 88.98 (656814322 / 738158916)
Update state (0x61) downloading, progress: 89.56 (661093560 / 738158916)
Update state (0x61) downloading, progress: 92.00 (679139990 / 738158916)
Update state (0x61) downloading, progress: 92.15 (680188566 / 738158916)
Update state (0x61) downloading, progress: 92.32 (681471853 / 738158916)
Update state (0x61) downloading, progress: 94.07 (694409850 / 738158916)
Update state (0x61) downloading, progress: 95.56 (705403074 / 738158916)
Update state (0x61) downloading, progress: 97.43 (719219649 / 738158916)
Update state (0x61) downloading, progress: 98.36 (726017316 / 738158916)
Update state (0x61) downloading, progress: 98.70 (728587665 / 738158916)
Update state (0x61) downloading, progress: 98.86 (729770905 / 738158916)
Success! App ’90’ fully installed.
- Сервер успешно загрузился, но на всякий случай повторим команду, что бы убедится наверняка, что все файлы загрузились.
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x5) validating, progress: 41.58 (121764961 / 292827978)
Update state (0x5) validating, progress: 99.47 (291270405 / 292827978)
Update state (0x5) validating, progress: 62.71 (462883261 / 738158916)
Update state (0x5) validating, progress: 87.37 (644913618 / 738158916)
Success! App ’90’ fully installed.
- Как видно, валидация прошла успешно, все файлы на месте.
- Выходим из программы
- Создадим заранее парочку директорий и скопируем одну из необходимых «сошек», чтобы в дальнейшем не было ошибок при запуске сервера.
- Попробуем запустить сервер от имени созданного пользователя HLDS.
Auto-restarting the server on crash
Console initialized.
Using breakpad crash handler
Setting breakpad minidump AppID = 10
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
Exe build: 13:12:29 Aug 29 2013 (6153)
STEAM Auth Server
Server IP address 37.230.210.128:27017
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
couldn’t exec listip.cfg
couldn’t exec banned.cfg
Connection to Steam servers successful.
VAC secure mode is activated.
Есть что сказать или остались вопросы?
Залогиньтесь, чтобы иметь возможность общаться
Всего 30 секунд нужно для регистрации через соц. сети
Источник
Создание HLDS-сервера на Linux
Javekson
- Для написании статьи был задействован виртуальный сервер VDS от хостинг-компании майарены на платформе Debian 7_x86
- Если у Вас установлена x64-разрядная система, то перед прочтением статьи заранее установите необходимую «либу» для дальнейшей корректной работы сервера.
- Первым делом мы создадим нового пользователя (для запуска HLDS ). По умолчанию при создание нового пользователя директория имеет следующий путь: /home/hlds. При добавлении нового пользователя нас запросят ввести пароль, повторить пароль, ввести дополнительные данные (необязательно) и подтвердить корректность информации.
# adduser hlds
Adding user `hlds’ .
Adding new group `hlds’ (1002) .
Adding new user `hlds’ (1002) with group `hlds’ .
Creating home directory `/home/hlds’ .
Copying files from `/etc/skel’ .
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for hlds
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
- Вторым делом мы создадим дополнительную директории для выкачивание специальной утилиты SetamCMD, которая в свою очередь позволит загрузить нам свеженький HLDS-сервер.
- Перейдем непосредственно к самой загрузке утилиты.
# cd /home/hlds/platform
[email protected]:/home/hlds/platform# wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
—2017-01-19 17:19:51— https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
Resolving steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net). 87.245.202.16, 87.245.202.57
Connecting to steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)|87.245.202.16|:443. connected.
HTTP request sent, awaiting response. 200 OK
Length: 3170982 (3.0M) [application/octet-stream]
Saving to: `steamcmd_linux.tar.gz’
2017-01-19 17:19:54 (2.17 MB/s) — `steamcmd_linux.tar.gz’ saved [3170982/3170982]
[email protected]:/home/hlds/platform# ./steamcmd.sh
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
ILocalize::AddFile() failed to load file «public/steambootstrapper_english.txt».
[ 0%] Checking for available update.
[ 0%] Downloading update (0 of 10173 KB).
[ 0%] Downloading update (2235 of 10173 KB).
[ 21%] Downloading update (4012 of 10173 KB).
[ 39%] Downloading update (4465 of 10173 KB).
[ 43%] Downloading update (4984 of 10173 KB).
[ 48%] Downloading update (5346 of 10173 KB).
[ 52%] Downloading update (5665 of 10173 KB).
[ 55%] Downloading update (6107 of 10173 KB).
[ 60%] Downloading update (6693 of 10173 KB).
[ 65%] Downloading update (7528 of 10173 KB).
[ 74%] Downloading update (8267 of 10173 KB).
[ 81%] Downloading update (8609 of 10173 KB).
[ 84%] Downloading update (8992 of 10173 KB).
[ 88%] Downloading update (9582 of 10173 KB).
[ 94%] Downloading update (10173 of 10173 KB).
[100%] Downloading update (10173 of 10173 KB).
[100%] Download Complete.
[—-] Applying update.
[—-] Extracting package.
[—-] Extracting package.
[—-] Extracting package.
[—-] Installing update.
[—-] Installing update.
[—-] Installing update.
[—-] Cleaning up.
[—-] Update complete, launching.
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
[ 0%] Checking for available updates.
[—-] Downloading update (0 of 7058 KB).
[ 0%] Downloading update (2070 of 7058 KB).
[ 29%] Downloading update (3708 of 7058 KB).
[ 52%] Downloading update (4618 of 7058 KB).
[ 65%] Downloading update (5136 of 7058 KB).
[ 72%] Downloading update (5567 of 7058 KB).
[ 78%] Downloading update (6039 of 7058 KB).
[ 85%] Downloading update (6489 of 7058 KB).
[ 91%] Downloading update (6859 of 7058 KB).
[ 97%] Downloading update (7058 of 7058 KB).
[100%] Download complete.
[—-] Installing update.
[—-] Extracting package.
[—-] Extracting package.
[—-] Extracting package.
[—-] Installing update.
[—-] Installing update.
[—-] Installing update.
[—-] Cleaning up.
[—-] Update complete, launching Steamcmd.
Redirecting stderr to ‘/root/Steam/logs/stderr.txt’
[ 0%] Checking for available updates.
[—-] Verifying installation.
Steam Console Client (c) Valve Corporation
— type ‘quit’ to exit —
Loading Steam API. Created shared memory when not owner SteamController_Shared_mem
OK.
- Авторизуемся в ней от имени анонима.
Connecting anonymously to Steam Public. Logged in OK
Waiting for license info.
- Укажем путь куда загрузим полноценный HLDS-сервер.
Steam>app_update 90 validate
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x61) downloading, progress: 0.00 (0 / 63579018)
Update state (0x61) downloading, progress: 22.77 (14476949 / 63579018)
Update state (0x61) downloading, progress: 40.37 (25666967 / 63579018)
Update state (0x61) downloading, progress: 56.86 (36152727 / 63579018)
Update state (0x61) downloading, progress: 70.53 (44844614 / 63579018)
Update state (0x61) downloading, progress: 85.38 (54281798 / 63579018)
Update state (0x61) downloading, progress: 98.35 (62530442 / 63579018)
Error! App ’90’ state is 0x6 after update job.
- Видим ошибку, ничего страшного, такое бывает, повторим команду.
Steam>app_update 90 validate
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x5) validating, progress: 0.00 (0 / 0)
Update state (0x11) preallocating, progress: 92.97 (686293130 / 738158916)
Update state (0x61) downloading, progress: 1.30 (9579281 / 738158916)
Update state (0x61) downloading, progress: 3.76 (27723531 / 738158916)
Update state (0x61) downloading, progress: 7.15 (52793185 / 738158916)
Update state (0x61) downloading, progress: 10.12 (74737807 / 738158916)
Update state (0x61) downloading, progress: 13.18 (97297331 / 738158916)
Update state (0x61) downloading, progress: 16.47 (121572650 / 738158916)
Update state (0x61) downloading, progress: 19.51 (144045027 / 738158916)
Update state (0x61) downloading, progress: 22.61 (166934604 / 738158916)
Update state (0x61) downloading, progress: 25.96 (191650977 / 738158916)
Update state (0x61) downloading, progress: 29.67 (219045714 / 738158916)
Update state (0x61) downloading, progress: 33.76 (249180936 / 738158916)
Update state (0x61) downloading, progress: 38.30 (282720713 / 738158916)
Update state (0x61) downloading, progress: 41.08 (303219453 / 738158916)
Update state (0x61) downloading, progress: 44.44 (328005853 / 738158916)
Update state (0x61) downloading, progress: 44.44 (328005853 / 738158916)
Update state (0x61) downloading, progress: 44.65 (329599753 / 738158916)
Update state (0x61) downloading, progress: 46.65 (344323522 / 738158916)
Update state (0x61) downloading, progress: 50.67 (374012566 / 738158916)
Update state (0x61) downloading, progress: 54.99 (405944218 / 738158916)
Update state (0x61) downloading, progress: 60.14 (443954326 / 738158916)
Update state (0x61) downloading, progress: 62.63 (462319046 / 738158916)
Update state (0x61) downloading, progress: 64.09 (473057757 / 738158916)
Update state (0x61) downloading, progress: 65.29 (481956283 / 738158916)
Update state (0x61) downloading, progress: 65.29 (481956283 / 738158916)
Update state (0x61) downloading, progress: 67.32 (496950092 / 738158916)
Update state (0x61) downloading, progress: 68.71 (507159569 / 738158916)
Update state (0x61) downloading, progress: 68.71 (507159569 / 738158916)
Update state (0x61) downloading, progress: 69.73 (514709103 / 738158916)
Update state (0x61) downloading, progress: 72.95 (538497442 / 738158916)
Update state (0x61) downloading, progress: 74.15 (547328303 / 738158916)
Update state (0x61) downloading, progress: 74.15 (547328303 / 738158916)
Update state (0x61) downloading, progress: 75.03 (553855982 / 738158916)
Update state (0x61) downloading, progress: 78.00 (575748716 / 738158916)
Update state (0x61) downloading, progress: 81.59 (602238620 / 738158916)
Update state (0x61) downloading, progress: 86.06 (635231427 / 738158916)
Update state (0x61) downloading, progress: 88.98 (656814322 / 738158916)
Update state (0x61) downloading, progress: 89.56 (661093560 / 738158916)
Update state (0x61) downloading, progress: 92.00 (679139990 / 738158916)
Update state (0x61) downloading, progress: 92.15 (680188566 / 738158916)
Update state (0x61) downloading, progress: 92.32 (681471853 / 738158916)
Update state (0x61) downloading, progress: 94.07 (694409850 / 738158916)
Update state (0x61) downloading, progress: 95.56 (705403074 / 738158916)
Update state (0x61) downloading, progress: 97.43 (719219649 / 738158916)
Update state (0x61) downloading, progress: 98.36 (726017316 / 738158916)
Update state (0x61) downloading, progress: 98.70 (728587665 / 738158916)
Update state (0x61) downloading, progress: 98.86 (729770905 / 738158916)
Success! App ’90’ fully installed.
- Сервер успешно загрузился, но на всякий случай повторим команду, что бы убедится наверняка, что все файлы загрузились.
Steam>app_update 90 validate
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x5) validating, progress: 41.58 (121764961 / 292827978)
Update state (0x5) validating, progress: 99.47 (291270405 / 292827978)
Update state (0x5) validating, progress: 62.71 (462883261 / 738158916)
Update state (0x5) validating, progress: 87.37 (644913618 / 738158916)
Success! App ’90’ fully installed.
Источник