summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-pppoe.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-02 21:40:17 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-02 21:40:19 +0200
commit6a0c6783d8b26b5c36c742b28d14397b676a5d43 (patch)
tree7044ad3267963d3254ea78f6ef39eb6a87b513da /src/conf_mode/interfaces-pppoe.py
parent75fbbf8e6035247d5a677d74275e7c0a27b2964d (diff)
downloadvyos-1x-6a0c6783d8b26b5c36c742b28d14397b676a5d43.tar.gz
vyos-1x-6a0c6783d8b26b5c36c742b28d14397b676a5d43.zip
pppoe: migrate alias and vrf script from pre-up to up
As the pre-up script is only run once when the interface is brought up but not when the interface maybe only comes up 20 seconds later due to the remote site some actions can not be performed as placing the interface e.g. into a VRF instance.
Diffstat (limited to 'src/conf_mode/interfaces-pppoe.py')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index aa3cebc42..ec7ba3c0d 100755
--- a/src/conf_mode/interfaces-pppoe.py
+++ b/src/conf_mode/interfaces-pppoe.py
@@ -304,51 +304,39 @@ def verify(pppoe):
def generate(pppoe):
config_file_pppoe = f"/etc/ppp/peers/{pppoe['intf']}"
- ip_pre_up_script_file = f"/etc/ppp/ip-pre-up.d/9999-vyos-vrf-{pppoe['intf']}"
+ ip_up_script_file = f"/etc/ppp/ip-up.d/9990-vyos-vrf-{pppoe['intf']}"
ipv6_if_up_script_file = f"/etc/ppp/ipv6-up.d/50-vyos-{pppoe['intf']}-autoconf"
+ config_files = [config_file_pppoe, ip_up_script_file, ipv6_if_up_script_file]
+
+ # Ensure directories for config files exist - otherwise create them on demand
+ for file in config_files:
+ dirname = os.path.dirname(file)
+ if not os.path.isdir(dirname):
+ os.mkdir(dirname)
+
# Always hang-up PPPoE connection prior generating new configuration file
cmd = f"systemctl stop ppp@{pppoe['intf']}.service"
subprocess_cmd(cmd)
if pppoe['deleted']:
# Delete PPP configuration files
- if os.path.exists(config_file_pppoe):
- os.unlink(config_file_pppoe)
-
- if os.path.exists(ipv6_if_up_script_file):
- os.unlink(ipv6_if_up_script_file)
-
- if os.path.exists(ip_pre_up_script_file):
- os.unlink(ip_pre_up_script_file)
+ for file in config_files:
+ if os.path.exists(file):
+ os.unlink(file)
else:
- # PPP peers directory
- dirname = os.path.dirname(config_file_pppoe)
- if not os.path.isdir(dirname):
- os.mkdir(dirname)
-
# Create PPP configuration files
tmpl = Template(config_pppoe_tmpl)
config_text = tmpl.render(pppoe)
with open(config_file_pppoe, 'w') as f:
f.write(config_text)
- # PPP ip-pre-up.d scripting directory
- dirname = os.path.dirname(ip_pre_up_script_file)
- if not os.path.isdir(dirname):
- os.mkdir(dirname)
-
- tmpl = Template(config_pppoe_ip_pre_up_tmpl)
+ tmpl = Template(config_pppoe_ip_up_tmpl)
config_text = tmpl.render(pppoe)
- with open(ip_pre_up_script_file, 'w') as f:
+ with open(ip_up_script_file, 'w') as f:
f.write(config_text)
- # PPP ipv6-up.d scripting directory
- dirname = os.path.dirname(ipv6_if_up_script_file)
- if not os.path.isdir(dirname):
- os.mkdir(dirname)
-
tmpl = Template(config_pppoe_ipv6_up_tmpl)
config_text = tmpl.render(pppoe)
with open(ipv6_if_up_script_file, 'w') as f: