bundles/users: also deploy shell config
This commit is contained in:
parent
6656a0864f
commit
841b49cd18
3 changed files with 63 additions and 0 deletions
26
bundles/users/files/bashrc
Normal file
26
bundles/users/files/bashrc
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
[ -z "$PS1" ] && return
|
||||||
|
|
||||||
|
__node_name="${node.name}"
|
||||||
|
|
||||||
|
<%text>
|
||||||
|
if [[ "$(id -u)" -eq 0 ]]
|
||||||
|
then
|
||||||
|
export PS1='\[\e[1;34m\][\[\e[1;32m\]'"$__node_name"'\[\e[1;34m\]][\[\e[1;32m\]\u\[\e[1;34m\]@\[\e[1;32m\]\w\[\e[1;34m\]] $PRODWARNING> \[\e[0m\]'
|
||||||
|
else
|
||||||
|
export PS1='\[\e[1;0m\]['"$__node_name"'][\u@\w]\[\e[1;34m\] $PRODWARNING\[\e[1;0m\]> '
|
||||||
|
fi
|
||||||
|
case $TERM in
|
||||||
|
xterm*|rxvt*)
|
||||||
|
export PROMPT_COMMAND='echo -ne "\a\e]0;'"$__node_name"':${PWD/$HOME/~}\a"'
|
||||||
|
;;
|
||||||
|
screen*)
|
||||||
|
export PROMPT_COMMAND='echo -ne "\a\ek'"$__node_name"':${PWD/$HOME/~}\e\\"'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
unset PROMPT_COMMAND
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
uptime
|
||||||
|
last | grep 'still logged in'
|
||||||
|
</%text>
|
23
bundles/users/files/config.fish
Normal file
23
bundles/users/files/config.fish
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
function fish_greeting
|
||||||
|
uptime
|
||||||
|
last | grep 'still logged in'
|
||||||
|
end
|
||||||
|
|
||||||
|
function fish_prompt
|
||||||
|
set -l last_status $status
|
||||||
|
|
||||||
|
echo -n "$USER@${node.name}:"
|
||||||
|
|
||||||
|
set_color $fish_color_cwd
|
||||||
|
echo -n (pwd)
|
||||||
|
set_color normal
|
||||||
|
|
||||||
|
if not test $last_status -eq 0
|
||||||
|
set_color $fish_color_error
|
||||||
|
echo -n " [$status]"
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
|
|
||||||
|
echo -n '➤ '
|
||||||
|
set_color normal
|
||||||
|
end
|
|
@ -14,6 +14,11 @@ users['root'] = {
|
||||||
'password': repo.vault.human_password_for('root on {}'.format(node.name)),
|
'password': repo.vault.human_password_for('root on {}'.format(node.name)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files['/etc/bash.bashrc'] = {
|
||||||
|
'source': 'bashrc',
|
||||||
|
'content_type': 'mako',
|
||||||
|
}
|
||||||
|
|
||||||
for username, attrs in node.metadata['users'].items():
|
for username, attrs in node.metadata['users'].items():
|
||||||
home = attrs.get('home', '/home/{}'.format(username))
|
home = attrs.get('home', '/home/{}'.format(username))
|
||||||
|
|
||||||
|
@ -46,3 +51,12 @@ for username, attrs in node.metadata['users'].items():
|
||||||
else:
|
else:
|
||||||
files[home + '/.ssh/authorized_keys'] = {'delete': True}
|
files[home + '/.ssh/authorized_keys'] = {'delete': True}
|
||||||
|
|
||||||
|
files[home + '/.config/fish/config.fish'] = {
|
||||||
|
'content_type': 'mako',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for user, config in users.items():
|
||||||
|
files[config['home'] + '/.bashrc'] = {
|
||||||
|
'delete': True,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue