Created
December 12, 2013 21:45
-
-
Save fridtjof/7936130 to your computer and use it in GitHub Desktop.
TTYPlay login script
This file contains hidden or 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
#!/bin/bash | |
#notify users per mail and write (now wrapped through notifydelay script by Kilobyte) | |
notify() { | |
USER_TO_NOTIFY=$1 | |
MESSAGE="$USER logged in!" | |
notifydelay $USER_TO_NOTIFY $MESSAGE | |
echo "$MESSAGE" | mail $USER_TO_NOTIFY | |
} | |
#notifydelay by kilobyte, feature gets triggered if user runs a program with a specific command | |
notifydelay() { | |
USER_TO_NOTIFY=$1 | |
TEXT=$2 | |
if [ -f /tmp/$USER_TO_NOTIFY/.notify-delay ] | |
then | |
echo "$2\n" >> /tmp/$USER_TO_NOTIFY/.notify-delay | |
else | |
echo "$TEXT" | write $USER_TO_NOTIFY | |
fi | |
} | |
#logfile | |
TDATE=$(date +%F_%T) | |
LFILE=/var/log/session/$USER-$TDATE | |
#group a user has to be in to get notified | |
NOTIFIED=ande | |
#gets all the users that should be notified | |
NUSERS=`users | sed -e 'y/ /\n/' | while read name; do groups $name; done | grep $NOTIFIED | awk -F: '{print $1}'` | |
#notify those ppl of logins | |
echo $NUSERS | while read name; do notify $name; done | |
#cat motd, like a real login shell | |
cat /etc/motd | |
#start recording | |
ttyrec $LFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment