Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
fwdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2df3a3d6
authored
Jul 25, 2015
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and apply systemd detector function
parent
1176a7a8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
fw.py
+3
-3
utils.py
+15
-0
No files found.
fw.py
View file @
2df3a3d6
...
...
@@ -5,7 +5,7 @@ import json
import
logging
from
utils
import
(
ns_exec
,
sudo
,
ADDRESSES
,
get_network_type
,
dhcp_no_free_re
,
dhcp_ack_re
)
dhcp_no_free_re
,
dhcp_ack_re
,
is_there_systemd
)
DHCP_LOGFILE
=
getenv
(
'DHCP_LOGFILE'
,
'/var/log/syslog'
)
VLAN_CONF
=
getenv
(
'VLAN_CONF'
,
'vlan.conf'
)
...
...
@@ -77,8 +77,8 @@ def reload_firewall_vlan(data, save_config=True):
def
reload_dhcp
(
data
):
with
open
(
'/etc/dhcp/dhcpd.conf.generated'
,
'w'
)
as
f
:
f
.
write
(
"
\n
"
.
join
(
data
)
+
"
\n
"
)
import
platform
if
platform
.
dist
()[
0
]
==
"centos"
:
if
is_there_systemd
()
:
sudo
((
'/bin/systemctl'
,
'restart'
,
'dhcpd'
))
else
:
sudo
((
'/etc/init.d/isc-dhcp-server'
,
'restart'
))
...
...
utils.py
View file @
2df3a3d6
import
os
from
os
import
getenv
import
subprocess
as
sp
import
logging
...
...
@@ -60,3 +61,17 @@ def ns_exec(args, stdin=None):
else
:
return
sudo
((
'/sbin/ip'
,
'netns'
,
'exec'
,
NETNS
)
+
args
,
stdin
)
def
is_there_systemd
():
devnull
=
open
(
os
.
devnull
,
"w"
)
try
:
sp
.
call
([
"/bin/systemctl"
,
"--version"
],
stdout
=
devnull
,
stderr
=
devnull
)
except
OSError
:
devnull
.
close
()
return
False
devnull
.
close
()
return
True
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