mirror of
https://github.com/towalink/wgfrontend.git
synced 2025-04-19 08:55:11 +00:00
Call command on config changes
This commit is contained in:
parent
78d219bb43
commit
ebcecf8394
@ -7,6 +7,7 @@ import jinja2
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from . import pwdtools
|
from . import pwdtools
|
||||||
from . import wgcfg
|
from . import wgcfg
|
||||||
@ -18,7 +19,7 @@ class WebApp():
|
|||||||
"""Instance initialization"""
|
"""Instance initialization"""
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
self.jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')))
|
self.jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')))
|
||||||
self.wg = wgcfg.WGCfg(self.cfg.wg_configfile, self.cfg.libdir)
|
self.wg = wgcfg.WGCfg(self.cfg.wg_configfile, self.cfg.libdir, self.on_change_func)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self, action=None, id=None, description=None):
|
def index(self, action=None, id=None, description=None):
|
||||||
@ -89,6 +90,12 @@ class WebApp():
|
|||||||
raise cherrypy.HTTPRedirect('/', 302)
|
raise cherrypy.HTTPRedirect('/', 302)
|
||||||
return '"{0}" has been logged out'.format(username)
|
return '"{0}" has been logged out'.format(username)
|
||||||
|
|
||||||
|
def on_change_func(self):
|
||||||
|
"""React on config changes"""
|
||||||
|
on_change_command = self.cfg.on_change_command
|
||||||
|
if (on_change_command is not None) and (len(on_change_command) > 0):
|
||||||
|
subprocess.call(on_change_command, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def run_webapp(cfg):
|
def run_webapp(cfg):
|
||||||
"""Runs the CherryPy web application with the provided configuration data"""
|
"""Runs the CherryPy web application with the provided configuration data"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user