diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-11-30 09:04:31 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-02-23 14:36:56 +0100 |
commit | f9120cd8b866cbcd6aaaa48f5fc8303f034cad50 (patch) | |
tree | faf92e8ef7875df8a2859e691471508c07068872 /src/conf_mode/interfaces-pppoe.py | |
parent | 858deb599c5fc207d979e9dadf423a17a9c3a2a7 (diff) | |
download | vyos-1x-f9120cd8b866cbcd6aaaa48f5fc8303f034cad50.tar.gz vyos-1x-f9120cd8b866cbcd6aaaa48f5fc8303f034cad50.zip |
pppoe: T1318: move process startup to apply()
Diffstat (limited to 'src/conf_mode/interfaces-pppoe.py')
-rwxr-xr-x | src/conf_mode/interfaces-pppoe.py | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index c7eca5056..16c59b39b 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -224,22 +224,6 @@ def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) config_file_ifup = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) - pid = 0 - pidfile = '/var/run/{}.pid'.format(pppoe['intf']) - if os.path.isfile(pidfile): - pid = 0 - with open(pidfile, 'r') as f: - pid = int(f.read()) - - # Always stop OpenVPN service. We can not send a SIGUSR1 for restart of the - # service as the configuration is not re-read. Stop daemon only if it's - # running - it could have died or killed by someone evil - print("pid: {}".format(pid)) - if pid_exists(pid): - cmd = 'start-stop-daemon --stop --quiet' - cmd += ' --pidfile ' + pidfile - subprocess_cmd(cmd) - if pppoe['deleted']: # Delete PPP configuration files if os.path.exists(config_file_pppoe): @@ -263,8 +247,26 @@ def generate(pppoe): os.chmod(config_file_ifup, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) + return None + +def apply(pppoe): + pid = 0 + pidfile = '/var/run/{}.pid'.format(pppoe['intf']) + if os.path.isfile(pidfile): + pid = 0 + with open(pidfile, 'r') as f: + pid = int(f.read()) + + # Always stop PPPoE dialer first + if pid_exists(pid): + cmd = 'start-stop-daemon --stop --quiet' + cmd += ' --pidfile ' + pidfile + subprocess_cmd(cmd) + if not pppoe['disable']: # No matching PPP process running - spawn a new one + # NOTE: PID file is only created after dial-in is complete. This is bad + # as you could have zombie dialers. cmd = 'start-stop-daemon --start --quiet' cmd += ' --pidfile ' + pidfile cmd += ' --background' @@ -278,11 +280,6 @@ def generate(pppoe): return None - -def apply(pppoe): - return None - - if __name__ == '__main__': try: c = get_config() |