Added changelog and pre/post up scripts

parent 6b223506
= Sat 31 Jul 2021 11:57:57 SAST =
- Added support for preup and postup external scripts
...@@ -9,7 +9,6 @@ Or you can bulling me to do it. Good luck with that. ...@@ -9,7 +9,6 @@ Or you can bulling me to do it. Good luck with that.
- "polite" mode, with less rudeness in the messages ( if enough or reasonable requests to do it will arrive ) - "polite" mode, with less rudeness in the messages ( if enough or reasonable requests to do it will arrive )
- better managing of key-mgmnt modes - better managing of key-mgmnt modes
- support ad-hoc connections - support ad-hoc connections
- preup, postup custom external script
- checking the outcome of the connection. - checking the outcome of the connection.
- better config parser/format. - better config parser/format.
- better command line arguments parsing. - better command line arguments parsing.
......
...@@ -168,6 +168,8 @@ def read_netconf(net): ...@@ -168,6 +168,8 @@ def read_netconf(net):
'ip': '192.168.42.42', 'ip': '192.168.42.42',
'nmask': '255.255.255.0', 'nmask': '255.255.255.0',
'gw': '192.168.42.1', 'gw': '192.168.42.1',
'preup': False,
'postup': False,
'saved': False 'saved': False
} }
if os.path.isfile(p): if os.path.isfile(p):
...@@ -180,6 +182,9 @@ def read_netconf(net): ...@@ -180,6 +182,9 @@ def read_netconf(net):
v=v.replace("\n", "") v=v.replace("\n", "")
if k in ['auto', 'dhcp']: if k in ['auto', 'dhcp']:
v=checkYN(v) v=checkYN(v)
if k in ['preup', 'postup']:
if not os.path.isfile(v):
v=False
if k=='gw': if k=='gw':
if not validateIP(v): if not validateIP(v):
v=checkYN(v) v=checkYN(v)
...@@ -208,6 +213,9 @@ def write_netconf(net, nconf): ...@@ -208,6 +213,9 @@ def write_netconf(net, nconf):
if nconf[k]: if nconf[k]:
v='y' v='y'
f.write(k+':'+v+'\n') f.write(k+':'+v+'\n')
elif k in ['preup', 'postup']:
if not v:
f.write(k+':n\n')
else: else:
f.write(k+':'+str(nconf[k])+'\n') f.write(k+':'+str(nconf[k])+'\n')
f.close() f.close()
...@@ -457,6 +465,8 @@ while not EXIT: ...@@ -457,6 +465,8 @@ while not EXIT:
elif SM=="connect": elif SM=="connect":
done=False done=False
if selected: if selected:
if selected['conf']['preup']:
sh('export WLAN="'+interface+'" && export WNAME="'+selected['Name']+'" && '+selected['conf']['preup']+' preup')
cfile='/tmp/wpa.'+interface+'.conf' cfile='/tmp/wpa.'+interface+'.conf'
create_wpacfile(cfile, selected) create_wpacfile(cfile, selected)
start_wpa(interface, cfile) start_wpa(interface, cfile)
...@@ -472,7 +482,8 @@ while not EXIT: ...@@ -472,7 +482,8 @@ while not EXIT:
print_error("FUCK, Are you asking me to connect but you didn't select successfully any network???") print_error("FUCK, Are you asking me to connect but you didn't select successfully any network???")
if done: if done:
# TODO launch here a post-connect external script? if selected['conf']['postup']:
sh('export WLAN="'+interface+'" && export WNAME="'+selected['Name']+'" && '+selected['conf']['postup']+' postup')
print(colors.BCYAN+"\n Are we fucking connected? Up to you to check, do something for fuck sake! \n"+colors.ENDC) print(colors.BCYAN+"\n Are we fucking connected? Up to you to check, do something for fuck sake! \n"+colors.ENDC)
if boot: if boot:
if done: if done:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment