Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eterban
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eterban
Commits
27975bf5
Commit
27975bf5
authored
Jul 26, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway: avoid restarting switcher on config errors
parent
82460dc5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
eterban.service
gateway/etc/systemd/system/eterban.service
+1
-0
eterban_switcher.py
gateway/usr/share/eterban/eterban_switcher.py
+3
-3
static-checks.sh
tests/static-checks.sh
+11
-0
No files found.
gateway/etc/systemd/system/eterban.service
View file @
27975bf5
...
...
@@ -4,6 +4,7 @@ After=syslog.target network.target
[Service]
Restart=always
RestartPreventExitStatus=78
ExecStart=/usr/bin/python3 /usr/share/eterban/eterban_switcher.py
[Install]
...
...
gateway/usr/share/eterban/eterban_switcher.py
View file @
27975bf5
...
...
@@ -45,7 +45,7 @@ def parse_config (path_to_config, path_to_log):
info
+=
' '
+
'Problem in config file ('
+
path_to_config
+
'). Check him!'
with
open
(
path_to_log
,
"a"
)
as
log_file
:
log_file
.
write
(
info
)
sys
.
exit
(
1
)
sys
.
exit
(
78
)
config
=
configparser
.
ConfigParser
()
config
.
read
(
path_to_config
)
...
...
@@ -96,14 +96,14 @@ def parse_config (path_to_config, path_to_log):
info
+=
" Problem in config file ("
+
path_to_config
+
"): "
+
str
(
error
)
+
"
\n
"
with
open
(
path_to_log
,
"a"
)
as
log_file
:
log_file
.
write
(
info
)
sys
.
exit
(
1
)
sys
.
exit
(
78
)
if
redis_server
==
"redis_server"
or
ban_server
==
"ban_server"
or
not
wan_ifaces
:
info
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
info
+=
' '
+
'Problem in config file ('
+
path_to_config
+
'). Check him!'
with
open
(
path_to_log
,
"a"
)
as
log_file
:
log_file
.
write
(
info
)
sys
.
exit
(
1
)
sys
.
exit
(
78
)
else
:
return
(
redis_server
,
ban_server
,
ban_server_ipv6
,
wan_ifaces
,
internal_interface
,
maxelem
,
whitelist_file
)
...
...
tests/static-checks.sh
View file @
27975bf5
...
...
@@ -19,3 +19,14 @@ if python3 -c 'from pathlib import Path; p = Path("prod-server/usr/share/eterban
echo
'ban.py without configuration must fail'
>
&2
exit
1
fi
if
(
cd
gateway/usr/share/eterban
&&
python3
-c
'from pathlib import Path; p = Path("eterban_switcher.py"); code = p.read_text().replace("/etc/eterban/settings.ini", "/dev/null").replace("/var/log/eterban/eterban.log", "/tmp/eterban-switcher-static-check.log"); exec(compile(code, str(p), "exec"))'
)
>
/dev/null 2>&1
;
then
echo
'switcher without configuration must fail'
>
&2
exit
1
else
status
=
$?
fi
if
[
"
$status
"
-ne
78
]
;
then
echo
"switcher without configuration returned
$status
, expected 78"
>
&2
exit
1
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment