- Introduction to UNIX Users and Groups
- The Users and Groups Module
- Creating a New User
- Editing an Existing User
- Deleting a User
- Creating a New Group
- Editing an Existing Group
- Deleting a Group
- Viewing Recent and Current Logins
- Reading Users' Email
- Creating Users from Batch Files
- Configuring the Users and Groups Module
- Before and After Commands
- Module Access Control
- Other Operating Systems
- Summary
4.13 Before and After Commands
As Section 4.12 "Configuring the Users and Groups Module" explains, you can specify shell commands to be run before and after any action is taken in the module. Because these commands are called for every addition, modification, or deletion of a user or group, they need some way of telling exactly what action is being performed. They can do this using environment variables that are set before the command is run. The available environment variables are shown in Table 4.3.
If you wanted to send out email when a user is created, for example, you could set the Command to run after making changes option to:
[ "$USERADMIN_ACTION" = "CREATE_USER" ] && echo "Added user $USERADMIN_USER ($USERADMIN_REAL)" | mail –s "Added new user" you@yourdomain.com