-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bw: show generic information and unit status on login
- Loading branch information
Showing
10 changed files
with
129 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,7 @@ | |
10 | ||
10 | ||
10 | ||
% for line in description: | ||
${line} | ||
% endfor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
[[ -n "$DEBUG" ]] && set -x | ||
|
||
echo "systemd unit status:" | ||
|
||
% for idx, unitname in enumerate(sorted(units)): | ||
status="$(systemctl is-active "${unitname}")" | ||
if [[ "$?" -eq 0 ]] | ||
then | ||
tput setaf 2 | ||
else | ||
tput setaf 1 | ||
fi | ||
echo -n " ${unitname.ljust(30)}" | ||
tput sgr0 | ||
% if idx % 2: | ||
echo "" | ||
% endif | ||
% endfor | ||
|
||
% if not idx % 2: | ||
echo "" | ||
% endif | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,78 @@ | ||
from inspect import cleandoc | ||
from uuid import UUID | ||
from bundlewrap.utils.text import bold, italic, yellow | ||
|
||
from bundlewrap.utils.text import italic | ||
description = [] | ||
event = node.metadata.get('event/slug', None) | ||
if event: | ||
description.append('Event: {} ({})'.format( | ||
node.metadata.get('event/name', '?'), | ||
node.metadata.get('event/slug'), | ||
)) | ||
description.append('Room: {}'.format(node.metadata.get('event/room_name', '?'))) | ||
|
||
files = { | ||
'/etc/hosts': { | ||
'content_type': 'mako', | ||
}, | ||
'/etc/htoprc.global': { | ||
'source': 'htoprc', | ||
}, | ||
'/etc/motd': {}, | ||
'/etc/modules': { | ||
'content': '\n'.join(node.metadata.get('modules', set())) + '\n', | ||
}, | ||
if node.has_bundle('voctocore'): | ||
description.append('') | ||
description.append(bold('voctocore source config')) | ||
for name, opts in node.metadata.get('voctocore/sources', {}).items(): | ||
if opts.get('kind', 'decklink') == 'decklink': | ||
description.append(' {} kind=decklink - input {} @ {}'.format( | ||
name, | ||
opts['devicenumber'], | ||
opts['mode'] | ||
)) | ||
else: | ||
description.append(' {} kind={}'.format( | ||
name, | ||
yellow(opts['kind']), | ||
)) | ||
|
||
if node.has_bundle('samba'): | ||
description.append('') | ||
description.append(bold('samba shares:')) | ||
for name, opts in node.metadata.get('samba/shares', {}).items(): | ||
description.append(' {} as //{}/{}{}'.format( | ||
opts['path'], | ||
node.hostname, | ||
name, | ||
' (writable)' if opts.get('writable', True) else '', | ||
)) | ||
|
||
desc = node.metadata.get('description', []) | ||
if desc: | ||
description.append('') | ||
for line in desc: | ||
description.append('# {}'.format(italic(line))) | ||
|
||
files['/etc/hosts'] = { | ||
'content_type': 'mako', | ||
} | ||
|
||
description = [] | ||
files['/etc/htoprc.global'] = { | ||
'source': 'htoprc', | ||
} | ||
|
||
# TODO add some more information to this file, for example voc2mix | ||
# config or such | ||
files['/etc/motd'] = { | ||
'content_type': 'mako', | ||
'context': { | ||
'description': description, | ||
}, | ||
} | ||
|
||
for line in node.metadata.get('description', []): | ||
description.append('# {}'.format(italic(line))) | ||
files['/etc/modules'] = { | ||
'content': '\n'.join(node.metadata.get('modules', set())) + '\n', | ||
} | ||
|
||
if description: | ||
files['/etc/node.description'] = { | ||
'content': '\n'.join(description) + '\n', | ||
unit_status_on_login = node.metadata.get('unit-status-on-login', set()) | ||
if unit_status_on_login: | ||
files['/usr/local/bin/unit-status-on-login'] = { | ||
'mode': '0755', | ||
'content_type': 'mako', | ||
'context': { | ||
'units': unit_status_on_login, | ||
}, | ||
} | ||
else: | ||
files['/etc/node.description'] = { | ||
files['/usr/local/bin/unit-status-on-login'] = { | ||
'delete': True, | ||
} | ||
|
||
files['/etc/node.description'] = {'delete': True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ | |
'max_ttl': 3600, | ||
'cache_size': '512M', | ||
}, | ||
'unit-status-on-login': { | ||
'unbound', | ||
'knot', | ||
}, | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters