summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-21 19:06:03 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-21 19:06:03 +0200
commit49defb01143eb032b143ecee8ee0e7d007d6b0f2 (patch)
tree48e85be31ee648db1f0e4d5b0b266c73eba04660 /src/op_mode
parent39c53aadbf9ee63efd802de52755341b11ea77d1 (diff)
downloadvyos-1x-49defb01143eb032b143ecee8ee0e7d007d6b0f2.tar.gz
vyos-1x-49defb01143eb032b143ecee8ee0e7d007d6b0f2.zip
pppoe: T2380: dis-/connect should use proper systemd calls
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/connect_disconnect.py18
1 files changed, 10 insertions, 8 deletions
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()