scripts/update-motd.d/02-user

40 lines
1.1 KiB
Bash
Executable File

#! /usr/bin/env sh
## Useless cause the motd scripts are run by root user
#############################################################################
#
# Usage:
#
#############################################################################
#### Colors definition
BLACK='\033[30;40m'
RED='\033[0;31m'
REDB='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[34;40m'
MAGENTA='\033[0;35m'
CYAN='\033[36;40m'
WHITE='\033[0;37m'
WHITEB='\033[1;37m'
RESET='\033[0m'
#++++++++++++++++++++: User Data :++++++++++++++++++++++
USERNAME=$(whoami)
USER_SESSION=$(who | grep $USER | wc -l)
PROC_COUNT=$(ps -Afl | wc -l)
PROC_COUNT=$(expr $PROC_COUNT - 5)
# The "ulimit" from sh don't support the -u option
PROC_LIMIT=$(ulimit)
printf '%b' "${RESET}${MAGENTA}++++++++++++++++++++: ${WHITE}User Data${MAGENTA} :++++++++++++++++++++++${RESET}
${MAGENTA}+ ${WHITE}Username\t${MAGENTA}= ${GREEN}${USERNAME}
${MAGENTA}+ ${WHITE}Sessions\t${MAGENTA}= ${GREEN}${USER_SESSION}
${MAGENTA}+ ${WHITE}Processes\t${MAGENTA}= ${GREEN}$PROC_COUNT of ${PROC_LIMIT} MAX${RESET}"
printf '%b' "${RESET}\n"