Last active
January 3, 2025 21:35
-
-
Save maximishchenko/664e8829190e69731d97ab189fc93f76 to your computer and use it in GitHub Desktop.
Bash Motd Generator 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 | |
| #FILE="/home/user/scripts/motd" | |
| FILE="/etc/motd" | |
| INSTDATE=$(date +%F) | |
| HOSTNAME=$(hostname) | |
| OSRELASE=$(cat /etc/*release | head -1) | |
| #OSDETECT="i-have-to-define" | |
| #IPADDRES=$(ifconfig eth0 | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -1) | |
| ETHERADD=$(ifconfig |grep -e ^[a-z] |grep -v lo | awk '{ printf $1 FS}') | |
| INTERFACE=$(hostname -I) | |
| # if [ -w $FILE ] | |
| # then | |
| # if [[ -n `egrep -o '[0-9]+++-[0-9]++-[0-9]++' $FILE` ]] | |
| # then | |
| # IDATE=$(egrep -o '[0-9]+++-[0-9]++-[0-9]++' $FILE) | |
| # echo "$FILE was in past $IDATE altered" | |
| # echo "Will be saved as .rpmsave" | |
| # FILE=$FILE.rpmsave | |
| # fi | |
| # else | |
| # logger -p local0.warn -t ME "`id -un` is not allowed to edit $FILE" | |
| # echo "File is not Writeable. You are Not allowed to chance Motd" | |
| # echo "Will be saved as .rpmsave" | |
| # FILE=$FILE.rpmsave | |
| # fi | |
| cat << End-of-Message > $FILE | |
| `echo -en "\033[1;31m"` | |
| * * * * * * * * * * * * *: W A R N I N G :* * * * * * * * * * * * * * | |
| *THIS SYSTEM IS RESTRICTED TO AUTHORIZED USERS FOR AUTHORIZED USE ONLY* | |
| * UNAUTHORIZED ACCESS IS STRICTLY PROHIBITED AND MAY BE PUNISHED * | |
| * * * * * * * * * * * * *: W A R N I N G :* * * * * * * * * * * * * * | |
| * $INSTDATE * | |
| End-of-Message | |
| printf " * %-16s%-42s*\n" "Hostname:" "$HOSTNAME" >>$FILE | |
| printf " * %-16s%-42s*\n" "OS:" "$OSRELASE" >>$FILE | |
| #printf " * %-16s%-42s*\n" "HW:" "$OSDETECT" >>$FILE | |
| #printf " * %-16s%-42s*\n" "IP:" "$INTERFACE" >>$FILE | |
| #printf " * %-16s%-42s*\n" "IP:" "$IPADDRES" >>$FILE | |
| for i in $ETHERADD | |
| do | |
| IP=$(ifconfig $i | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -1) | |
| printf " * %-16s%-42s*\n" "IP $i" "$INTERFACE" >>$FILE | |
| done | |
| cat << End-of-Message >> $FILE | |
| * * | |
| * Contact: Alliance Company Group * | |
| * 347 km "Caucasus" Road * | |
| * Russia * | |
| * Administrator: it@alians-kmv.ru * | |
| * * | |
| * Status: Productive * | |
| *********************************************************************** | |
| `echo -en "\033[0m"` | |
| End-of-Message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment