add 'current' alias

showing installed state
This commit is contained in:
2023-08-08 11:11:13 +02:00
parent b19d1368c2
commit fdef0b69cf
3 changed files with 23 additions and 2 deletions

View File

@ -183,7 +183,7 @@ def write_when_new(filename, content, ignore_reduction=False):
print('>>>') print('>>>')
print('\n'.join(old[-bottom_lines:-1])) print('\n'.join(old[-bottom_lines:-1]))
print("===") print("===")
return True return content
def create_if(name, cfg, mac, dhcp_server_cfg): def create_if(name, cfg, mac, dhcp_server_cfg):
@ -447,7 +447,13 @@ def handle_config():
if action == 'restart': if action == 'restart':
unix_cmd('systemctl restart %s' % service) unix_cmd('systemctl restart %s' % service)
unix_cmd('systemctl enable %s' % service) unix_cmd('systemctl enable %s' % service)
return True result = [f'config file:\n {cfgfile}']
for section in parser.sections():
result.append(section)
for key, value in parser.items(section):
result.append(f' {key} = {value}')
result.append('')
return '\n'.join(result)
doit = False doit = False
@ -465,5 +471,7 @@ elif show.dirty and more_info == 'NONE':
if answer.lower().startswith('y'): if answer.lower().startswith('y'):
handle_config() handle_config()
walk(Do()) walk(Do())
with open('/root/aputools/current', 'w') as f:
f.write(result)
else: else:
print('nothing to do') print('nothing to do')

View File

@ -0,0 +1,11 @@
[NETWORK]
; please refer to README.md for help
enp1s0=192.168.127.254
enp2s0=192.168.12.2
enp3s0=192.168.13.3
enp4s0=wan,192.168.1.0/24
[ROUTER]
; please refer to README.md for help
3001=192.168.127.254:3001
8080=192.168.127.254:80

View File

@ -6,4 +6,6 @@ function service_status () {
echo ${name} $(systemctl is-active ${name}) $(systemctl is-enabled ${name}); \ echo ${name} $(systemctl is-active ${name}) $(systemctl is-enabled ${name}); \
done | column -t | grep --color=always '\(disabled\|inactive\|$\)' done | column -t | grep --color=always '\(disabled\|inactive\|$\)'
} }
alias current='cat /root/aputools/current'
service_status router frappy service_status router frappy
echo "> current # show currently installed state"