Skip to content

Commit

Permalink
Merge pull request #73 from ghostbsd/regex-patch1
Browse files Browse the repository at this point in the history
Fixed src/setup-nic.py notnics_regex
  • Loading branch information
vic-thacker authored Aug 9, 2021
2 parents 725ccb4 + 283a910 commit ba05534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/auto-switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import os
import re
from subprocess import Popen, PIPE

args = sys.argv
Expand Down Expand Up @@ -29,16 +30,18 @@
universal_newlines=True
)

nics = nics.stdout.read().replace(nic, '').strip()
notnics_regex = r"(enc|lo|fwe|fwip|tap|plip|pfsync|pflog|ipfw|tun|sl|faith|" \
r"ppp|bridge|wg)[0-9]+(\s*)|vm-[a-z]+(\s*)"

if not nics:
exit()
nics_lelfover = nics.stdout.read().replace(nic, '').strip()
nic_list = re.sub(notnics_regex, '', nics_lelfover).strip().split()

nic_list = nics.split()
if not nic_list:
exit()

for nics in nic_list:
for current_nic in nic_list:
output = Popen(
['ifconfig', nics],
['ifconfig', current_nic],
stdout=PIPE,
close_fds=True,
universal_newlines=True
Expand All @@ -47,7 +50,7 @@
if 'status: active' in nic_ifconfig or 'status: associated' in nic_ifconfig:
if 'inet ' in nic_ifconfig or 'inet6' in nic_ifconfig:
if openrc:
os.system(f'service dhcpcd.{nics} restart')
os.system(f'service dhcpcd.{current_nic} restart')
else:
os.system(f'service dhclient restart {nics}')
os.system(f'service dhclient restart {current_nic}')
break
2 changes: 1 addition & 1 deletion src/setup-nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
rcconflocal = "None"

notnics_regex = "(enc|lo|fwe|fwip|tap|plip|pfsync|pflog|ipfw|tun|sl|faith|" \
"ppp|bridge|ixautomation|vm-ixautomation|wg|wlan)[0-9]+"
"ppp|bridge|wg|wlan)[0-9]+|vm-[a-z]+"

# wifi_driver_regex is taken from devd.conf wifi-driver-regex
wifi_driver_regex = "(ath|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|" \
Expand Down

0 comments on commit ba05534

Please sign in to comment.