vn-ansible/roles/config-base-debian-os/files/mymotd.sh

26 lines
1.4 KiB
Bash
Raw Normal View History

2023-10-30 14:38:20 +00:00
#!/bin/bash
GREEN="\033[0;32m"
RED='\033[0;31m'
RESET="\033[0m"
LAST_LOGIN_USER=$(lastlog | tail -n 1 | awk '{print $1}')
LAST_LOGIN_TIME_HOUR=$(lastlog | tail -n 1 | awk '{print $4" "$5" "$6" "$7}')
LAST_LOGIN_IP_FROM_USER=$(lastlog | tail -n 1 | awk '{print $3}')
UPTIME_SYSTEM=$(uptime -p | tr -d ',')
NUMBER_USERS_CONNECTED=$(uptime | awk '{print $6}' | tr -d ",")
LIST_USERS_CONNECTED=$(w | tail -n +2)
echo -e "****************************************************************************"
echo -e "${GREEN} _${RESET}"
echo -e "${GREEN} | |${RESET}"
echo -e "${GREEN} _ _ ____ ____ _ | |____ ____| |_ _ _ ____ ____${RESET}"
echo -e "${GREEN}| | | / _ )/ ___) || | _ \ / _ | _) | | |/ ___) _ |${RESET}"
echo -e "${GREEN} \ V ( (/ /| | ( (_| | | | ( ( | | |_| |_| | | ( ( | |${RESET}"
echo -e "${GREEN} \_/ \____)_| \____|_| |_|\_||_|\___)____|_| \_||_|${RESET}"
echo -e ""
echo -e "${RED}Host:${RESET}\n$HOSTNAME"
echo -e "${RED}Last Login:${RESET}\nUser -> $LAST_LOGIN_USER\nTime -> $LAST_LOGIN_TIME_HOUR\nIP -> $LAST_LOGIN_IP_FROM_USER"
echo -e "${RED}Uptime system:${RESET}\n$UPTIME_SYSTEM"
echo -e "${RED}Number of Users connected to the system:${RESET}\n$NUMBER_USERS_CONNECTED"
echo -e "${RED}Users connected to the system:${RESET}\n$LIST_USERS_CONNECTED"
echo -e ""
echo -e "****************************************************************************"