Commit 2dc157bc authored by Ruzal Gimazov's avatar Ruzal Gimazov

Update hostname in ban.py

parent 9de2a89d
......@@ -83,7 +83,7 @@ cp -a prod-server/usr/share/%name/* %buildroot%_datadir/%name/
%files web
%webserver_htdocsdir/%name/
%buildroot/etc/nginx/sites-enabled.d/
/etc/nginx/sites-enabled.d/
%files fail2ban
%config(noreplace) /etc/%name/settings.ini
......
......@@ -6,7 +6,7 @@ import sys
import configparser
import os
import signal
import socket
......@@ -17,7 +17,7 @@ def createConfig(path_to_config, path_to_log):
config = configparser.ConfigParser()
config.add_section("Settings")
config.set("Settings", "redis_server", "10.20.30.101")
config.set("Settings", "hostname", "")
config.set("Settings", "hostname", socket.gethostname())
with open(path_to_config, "w") as config_file:
config.write(config_file)
......
......@@ -3,6 +3,7 @@ import redis
import sys
import configparser
import os
import socket
def createConfig(path_to_config):
"""
......@@ -11,7 +12,7 @@ def createConfig(path_to_config):
config = configparser.ConfigParser()
config.add_section("Settings")
config.set("Settings", "redis_server", "10.20.30.101")
config.set("Settings", "hostname", "UNKNOWN")
config.set("Settings", "hostname", socket.gethostname())
with open(path_to_config, "w") as config_file:
config.write(config_file)
......@@ -27,7 +28,7 @@ def get_ip_redis_server (path_to_config):
# Читаем некоторые значения из конфиг. файла.
redis_server = config.get("Settings", "redis_server", fallback = "No such things as redis_server")
hostname = config.get("Settings", "hostname", fallback = "No such things as hostname")
hostname = config.get("Settings", "hostname", fallback = socket.gethostname())
if redis_server == "No such things as redis_server":
config.set("Settings", "redis_server", "10.20.30.101")
with open(path_to_config, "a") as config_file:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment