SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

scriptbashenvironment

Script: Bash: Environment Script For Production and Acceptance

This is a script I use to warn users for the environment they work on. We have a lot of different environments and I like to take every opportunity to warn them about the environment, especially production. This is based on the hostname. I also use it to show a few specific thing, for example, where their system mails gets forwarded to. Below the script you'll find a section on how to set the script into action.

#!/bin/bash
########################################################################################################################
# Author : Sjoerd Hooft
# Date Initial Version: 22 March 2011
# Comments: sjoerd_getshifting.com
#
# Description:
# This is the script to warn about the environment where users login to.
#
# Recommendations:
# The script is designed for a 120 column terminal.
#
# Changes:
# Please comment on your changes to the script (your name and email address, line number, description):
########################################################################################################################

# Script Variables
BOLD=`tput bold`
BOLDOFF=`tput sgr0`
ENV=`hostname -s | awk -F- '{ print $2 }'`
MAIL=`cat $HOME/.forward`

if [ $ENV == prd ]; then
   echo
   echo "You have logged on to the ${BOLD}PRODUCTION ENVIRONMENT${BOLDOFF}. Be careful."
   echo "You have logged on to the ${BOLD}PRODUCTION ENVIRONMENT${BOLDOFF}. Be very careful."
   echo
   echo "Your local mail is being forwarded to $MAIL"
   echo "If this is wrong please change it in $HOME/.forward"
else
   echo "You have logged on to the Acceptance environment"
fi
exit

Script Usage

To set the script into action add these lines to the /etc/profile file:

# Run the IT environment script
/opt/getshifting/scripts/environment.sh
You could leave a comment if you were logged in.
scriptbashenvironment.txt · Last modified: 2021/09/24 00:25 (external edit)