From 493b968a5f23c1bd10d6a8e6c429a46f5649e711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 28 Nov 2016 15:04:55 +0100 Subject: [PATCH] Auto-launch ZSH shell for some IP addresses. --- manifests/init.pp | 2 ++ manifests/params.pp | 3 +++ templates/preferences/profile.erb | 15 ++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 251b60c..bd5dbfb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -40,6 +40,8 @@ class root ( $profile_content = $root::params::profile_content, $bashrc_path = $root::params::bashrc_path, $bashrc_content = $root::params::bashrc_content, + $bashrc_content = $root::params::bashrc_content, + $ip_zsh = $root::params::ip_zsh, ) inherits root::params { include '::root::config' diff --git a/manifests/params.pp b/manifests/params.pp index 813b9c1..972a68b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,4 +8,7 @@ class root::params { $bashrc_path = '/root/.bashrc' $bashrc_content = 'root/preferences/bashrc.erb' + # For those IP, auto-launch ZSH as default shell + $ip_zsh = '127.0.0.1' + } # Private class: root::params diff --git a/templates/preferences/profile.erb b/templates/preferences/profile.erb index f577492..ab36ec3 100644 --- a/templates/preferences/profile.erb +++ b/templates/preferences/profile.erb @@ -1,16 +1,17 @@ # ~/.profile: executed by Bourne-compatible login shells. if [ "$BASH" ]; then - if [ -f ~/.bashrc ]; then - . ~/.bashrc - fi + if [ -f ~/.bashrc ]; then + . ~/.bashrc + fi fi -ZSH_IP="(129.20.79.141|129.20.79.142)" +# For those IP, auto-launch ZSH as default shell +IP_ZSH="<%= scope.lookupvar('root::ip_zsh') %>" -if [ "$(echo "${SSH_CLIENT}" | grep -E "${ZSH_IP}")" ]; then - printf '%b' "Launch ZSH\n" - exec zsh + +if [ "$(echo "${SSH_CLIENT}" | grep -E "${IP_ZSH}")" ]; then + exec zsh fi