summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py47
-rwxr-xr-xsrc/op_mode/connect_disconnect.py18
2 files changed, 33 insertions, 32 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index 95136ecfa..f58095f13 100755
--- a/src/conf_mode/interfaces-pppoe.py
+++ b/src/conf_mode/interfaces-pppoe.py
@@ -205,30 +205,29 @@ def generate(pppoe):
if os.path.exists(file):
os.unlink(file)
- else:
- # generated script must be executable
-
- # Create PPP configuration files
- render(config_pppoe, 'pppoe/peer.tmpl',
- pppoe, trim_blocks=True, permission=0o755)
- # Create script for ip-pre-up.d
- render(script_pppoe_pre_up, 'pppoe/ip-pre-up.script.tmpl',
- pppoe, trim_blocks=True, permission=0o755)
- # Create script for ip-up.d
- render(script_pppoe_ip_up, 'pppoe/ip-up.script.tmpl',
- pppoe, trim_blocks=True, permission=0o755)
- # Create script for ip-down.d
- render(script_pppoe_ip_down, 'pppoe/ip-down.script.tmpl',
- pppoe, trim_blocks=True, permission=0o755)
- # Create script for ipv6-up.d
- render(script_pppoe_ipv6_up, 'pppoe/ipv6-up.script.tmpl',
- pppoe, trim_blocks=True, permission=0o755)
-
- if len(pppoe['dhcpv6_pd']) > 0:
- # ipv6.tmpl relies on ifname - this should be made consitent in the
- # future better then double key-ing the same value
- pppoe['ifname'] = intf
- render(config_wide_dhcp6c, 'dhcp-client/ipv6.tmpl', pppoe, trim_blocks=True)
+ return None
+
+ # Create PPP configuration files
+ render(config_pppoe, 'pppoe/peer.tmpl',
+ pppoe, trim_blocks=True, permission=0o755)
+ # Create script for ip-pre-up.d
+ render(script_pppoe_pre_up, 'pppoe/ip-pre-up.script.tmpl',
+ pppoe, trim_blocks=True, permission=0o755)
+ # Create script for ip-up.d
+ render(script_pppoe_ip_up, 'pppoe/ip-up.script.tmpl',
+ pppoe, trim_blocks=True, permission=0o755)
+ # Create script for ip-down.d
+ render(script_pppoe_ip_down, 'pppoe/ip-down.script.tmpl',
+ pppoe, trim_blocks=True, permission=0o755)
+ # Create script for ipv6-up.d
+ render(script_pppoe_ipv6_up, 'pppoe/ipv6-up.script.tmpl',
+ pppoe, trim_blocks=True, permission=0o755)
+
+ if len(pppoe['dhcpv6_pd']) > 0:
+ # ipv6.tmpl relies on ifname - this should be made consitent in the
+ # future better then double key-ing the same value
+ pppoe['ifname'] = intf
+ render(config_wide_dhcp6c, 'dhcp-client/ipv6.tmpl', pppoe, trim_blocks=True)
return None
diff --git a/src/op_mode/connect_disconnect.py b/src/op_mode/connect_disconnect.py
index fa865f840..a773aa28e 100755
--- a/src/op_mode/connect_disconnect.py
+++ b/src/op_mode/connect_disconnect.py
@@ -24,8 +24,8 @@ from time import strftime, localtime, time
from vyos.util import call
def check_interface(interface):
- if not os.path.isfile('/etc/ppp/peers/{}'.format(interface)):
- print('Interface {}: invalid!'.format(interface))
+ if not os.path.isfile(f'/etc/ppp/peers/{interface}'):
+ print(f'Interface {interface}: invalid!')
exit(1)
def check_ppp_running(interface):
@@ -46,12 +46,13 @@ def connect(interface):
check_interface(interface)
# Check if interface is already dialed
- if os.path.isdir('/sys/class/net/{}'.format(interface)):
- print('Interface {}: already connected!'.format(interface))
+ if os.path.isdir(f'/sys/class/net/{interface}'):
+ print(f'Interface {interface}: already connected!')
elif check_ppp_running(interface):
- print('Interface {}: connection is beeing established!'.format(interface))
+ print(f'Interface {interface}: connection is beeing established!')
else:
- print('Interface {}: connecting...'.format(interface))
+ print(f'Interface {interface}: connecting...')
+ call(f'systemctl restart ppp@{interface}.service')
def disconnect(interface):
"""
@@ -61,9 +62,10 @@ def disconnect(interface):
# Check if interface is already down
if not check_ppp_running(interface):
- print('Interface {}: connection is already down'.format(interface))
+ print(f'Interface {interface}: connection is already down')
else:
- print('Interface {}: disconnecting...'.format(interface))
+ print(f'Interface {interface}: disconnecting...')
+ call(f'systemctl stop ppp@{interface}.service')
def main():
parser = argparse.ArgumentParser()