From 757bf1d6c0294464261f8cff043e0c43198e0451 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 6 Feb 2014 15:34:21 -0500 Subject: [PATCH] Send email on user login --- files/profile | 36 ++++++++++++++++++++++++++++++++++++ manifests/site.pp | 7 +++++++ 2 files changed, 43 insertions(+) create mode 100644 files/profile diff --git a/files/profile b/files/profile new file mode 100644 index 0000000..bf9c2b6 --- /dev/null +++ b/files/profile @@ -0,0 +1,36 @@ +# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) +# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). + +if [ "$PS1" ]; then + if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then + # The file bash.bashrc already sets the default PS1. + # PS1='\h:\w\$ ' + if [ -f /etc/bash.bashrc ]; then + . /etc/bash.bashrc + fi + else + if [ "`id -u`" -eq 0 ]; then + PS1='# ' + else + PS1='$ ' + fi + fi +fi + +# The default umask is now handled by pam_umask. +# See pam_umask(8) and /etc/login.defs. + +if [ -d /etc/profile.d ]; then + for i in /etc/profile.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done + unset i +fi + +# Send an email when someone logs in +if [ -n "$SSH_CLIENT" ]; then + remote=$(echo $SSH_CLIENT | awk '{ print $1 }') + echo | mail -s "SSH Login From ${USER}@${remote}" atomaka@gmail.com +fi diff --git a/manifests/site.pp b/manifests/site.pp index af2f9f9..5b3439d 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -40,6 +40,7 @@ user { 'jeff': # PACKAGES package { 'mosh': } package { 'zsh': } +package { 'mailutils': } # CLASSES include augeas @@ -106,3 +107,9 @@ file { '/home/jeff/web': target => '/var/www/tc362.atomaka.com', require => [ User['jeff'], File['/var/www/tc362.atomaka.com'] ], } + +file { '/etc/profile': + ensure => present, + content => file('/tmp/puppet/files/profile'), + require => Package['mailutils'], +}