Rewrite all motd scripts
This commit is contained in:
		
							parent
							
								
									4ec1eb8e53
								
							
						
					
					
						commit
						f8127cc686
					
				| 
						 | 
					@ -0,0 +1,49 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					# Vars definition [[[
 | 
				
			||||||
 | 
					HOSTNAME=$(hostname)
 | 
				
			||||||
 | 
					NET_ADDR=$(hostname -I)
 | 
				
			||||||
 | 
					KERNEL_VER=$(uname -r)
 | 
				
			||||||
 | 
					UPTIME=$(uptime | sed 's/.*up ([^,]*), .*/1/')
 | 
				
			||||||
 | 
					CORE_NUMBER=$(grep -c "model name" /proc/cpuinfo)
 | 
				
			||||||
 | 
					CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo | awk -F: '{print $2}')
 | 
				
			||||||
 | 
					MEM_FREE=$(grep MemFree /proc/meminfo | awk '{print $2}')
 | 
				
			||||||
 | 
					MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2}')
 | 
				
			||||||
 | 
					SWAP_FREE=$(grep SwapFree /proc/meminfo | awk '{print $2}')
 | 
				
			||||||
 | 
					SWAP_TOTAL=$(grep SwapTotal /proc/meminfo | awk '{print $2}')
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#+++++++++++++++++++: System Data :+++++++++++++++++++
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
 | 
					printf "${BLACKB}%33s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					printf '%b' " ${CYAN}System Data${RESET} "
 | 
				
			||||||
 | 
					printf "${BLACKB}%34s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Hostname\\t\\t${BLACKB}= ${GREEN}${HOSTNAME}
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Addresses\\t\\t${BLACKB}= ${GREEN}${NET_ADDR}
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Kernel\\t\\t${BLACKB}= ${GREEN}${KERNEL_VER}
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Uptime\\t\\t${BLACKB}=${GREEN}${UPTIME}
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} CPU\\t\\t\\t${BLACKB}= ${GREEN}${CORE_NUMBER}x${CPU_MODEL}
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Memory\\t\\t${BLACKB}= ${GREEN}${MEM_FREE}(free)/${MEM_TOTAL}(total) kB
 | 
				
			||||||
 | 
					${BLACKB}+${WHITE} Swap\\t\\t\\t${BLACKB}= ${GREEN}${SWAP_FREE}(free)/${SWAP_TOTAL}(total) kB
 | 
				
			||||||
 | 
					"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
| 
						 | 
					@ -1,48 +0,0 @@
 | 
				
			||||||
#! /usr/bin/env sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#############################################################################
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 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'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#+++++++++++++++++++: System Data :+++++++++++++++++++
 | 
					 | 
				
			||||||
HOSTNAME=$(hostname)
 | 
					 | 
				
			||||||
NET_ADDR=$(hostname -I)
 | 
					 | 
				
			||||||
KERNEL_VER=$(uname -r)
 | 
					 | 
				
			||||||
UPTIME=$(uptime | sed 's/.*up ([^,]*), .*/1/')
 | 
					 | 
				
			||||||
CORE_NUMBER=$(grep "model name" /proc/cpuinfo | wc -l)
 | 
					 | 
				
			||||||
CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo | awk -F: '{print $2}')
 | 
					 | 
				
			||||||
MEM_FREE=$(grep MemFree /proc/meminfo | awk '{print $2}')
 | 
					 | 
				
			||||||
MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2}')
 | 
					 | 
				
			||||||
SWAP_FREE=$(grep SwapFree /proc/meminfo | awk '{print $2}')
 | 
					 | 
				
			||||||
SWAP_TOTAL=$(grep SwapTotal /proc/meminfo | awk '{print $2}')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${RESET}${MAGENTA}+++++++++++++++++++: ${WHITE}System Data${MAGENTA} :+++++++++++++++++++++${RESET}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Hostname\t${MAGENTA}= ${GREEN}${HOSTNAME}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Addresses\t${MAGENTA}= ${GREEN}${NET_ADDR}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Kernel\t${MAGENTA}= ${GREEN}${KERNEL_VER}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Uptime\t${MAGENTA}=${GREEN}${UPTIME}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}CPU\t\t${MAGENTA}= ${GREEN}${CORE_NUMBER}x${CPU_MODEL}
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Memory\t${MAGENTA}= ${GREEN}${MEM_FREE}(free)/${MEM_TOTAL}(total) kB
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Swap\t\t${MAGENTA}= ${GREEN}${SWAP_FREE}(free)/${SWAP_TOTAL}(total) kB"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${RESET}\n"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
#! /usr/bin/env sh
 | 
					#! /usr/bin/env sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Useless cause the motd scripts are run by root user
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#############################################################################
 | 
					#############################################################################
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Usage:
 | 
					# Usage:
 | 
				
			||||||
| 
						 | 
					@ -1,68 +0,0 @@
 | 
				
			||||||
#! /usr/bin/env sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#############################################################################
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 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'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Return the number of occurrence a pattern is present in a file
 | 
					 | 
				
			||||||
# and a color (red:>0, green:=0)
 | 
					 | 
				
			||||||
get_pattern_count() {
 | 
					 | 
				
			||||||
  local GREP_PAT="${1}"
 | 
					 | 
				
			||||||
  local FILE="${2}"
 | 
					 | 
				
			||||||
  local EXP_VAL="${3}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # Count the pattern in the file
 | 
					 | 
				
			||||||
  NUM=$(grep -E "${GREP_PAT}" "${FILE}" | wc -l)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # If $EXP_VAL exist ++ the $NUM and $EXP_VAL are equal
 | 
					 | 
				
			||||||
  if [ "${EXP_VAL}" ] && [ "${NUM}" = "${EXP_VAL}" ]; then
 | 
					 | 
				
			||||||
    MSG="${GREEN}${NUM}"
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    MSG="${REDB}${NUM}"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  printf '%b' "${MSG}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#++++++++++++: Authentication Information :+++++++++++++
 | 
					 | 
				
			||||||
# Get only one "auth.log" file path, the most recent
 | 
					 | 
				
			||||||
# Simpliest way to get it?
 | 
					 | 
				
			||||||
AUTH_LOG_FILE=$(find /var/log -iname 'auth.log' -type f -printf '%TY-%Tm-%Td_%TT %p\n' | sort -r | tail -n1 | cut -d' ' -f2)
 | 
					 | 
				
			||||||
SSH_USER_LOGIN=$(grep 'session opened' "${AUTH_LOG_FILE}" | awk '/sshd/' | awk "/${USERNAME}/" | wc -l)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${MAGENTA}++++++++++++: ${WHITE}Authentication Information${MAGENTA} :+++++++++++++${RESET}"
 | 
					 | 
				
			||||||
## Count the number of session for all standard's user (with a home/)
 | 
					 | 
				
			||||||
#for SSH_USER in `ls -1 /home/`; do
 | 
					 | 
				
			||||||
#echo -e "${MAGENTA}+    ${WHITE}SSH login ${MAGENTA}= ${GREEN}`grep 'session opened' "${AUTH_LOG_FILE}" | awk '/sshd/' | awk "/${SSH_USER}/" | wc -l` times this week ("${SSH_USER}")"
 | 
					 | 
				
			||||||
##echo -e "${MAGENTA}+    ${WHITE}SSH login ${MAGENTA}= ${GREEN}`grep 'session opened' "${AUTH_LOG_FILE}".1 | awk '/login/' | awk "/${SSH_USER}/" | wc -l` times this week ("${SSH_USER}")"
 | 
					 | 
				
			||||||
#done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Count the number of failed ssh authentication
 | 
					 | 
				
			||||||
SSH_FAIL_LOGIN=$(get_pattern_count 'sshd.*Failed' "${AUTH_LOG_FILE}" '0')
 | 
					 | 
				
			||||||
printf '%b' "\n${MAGENTA}+ ${WHITE}SSH fail\t${MAGENTA}= ${SSH_FAIL_LOGIN} fail(s) this week"
 | 
					 | 
				
			||||||
# Count the number of failed sudo authentication
 | 
					 | 
				
			||||||
SUDO_FAIL=$(get_pattern_count 'sudo.*authentication failure' "${AUTH_LOG_FILE}" '0')
 | 
					 | 
				
			||||||
SUDO_3_FAIL=$(get_pattern_count 'sudo.*3 incorrect password' "${AUTH_LOG_FILE}" '0')
 | 
					 | 
				
			||||||
printf '%b' "\n${MAGENTA}+ ${WHITE}Sudo fail\t${MAGENTA}= ${GREEN}${SUDO_FAIL} fail(s) this week
 | 
					 | 
				
			||||||
${MAGENTA}+ ${WHITE}Sudo 3 fails\t${MAGENTA}= ${GREEN}${SUDO_3_FAIL} fail(s) this week"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${RESET}\n"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,55 +0,0 @@
 | 
				
			||||||
#! /usr/bin/env sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#############################################################################
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 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'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${MAGENTA}++++++++++++++++++++: ${WHITE}Disk Usage${RESET} ${MAGENTA}:+++++++++++++++++++++${RESET}"
 | 
					 | 
				
			||||||
# Root partition
 | 
					 | 
				
			||||||
# Replace by rootfs in few kernel version
 | 
					 | 
				
			||||||
DISK_USAGE=$(df | grep -m1 "/$" | awk '{print $5}')
 | 
					 | 
				
			||||||
printf '%b' "\n${MAGENTA}+ ${WHITEB}/${RESET}\t[ ${DISK_USAGE} ] "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Other partition
 | 
					 | 
				
			||||||
for PART in /boot /home /opt /tmp /usr /var /var/lib/vz; do
 | 
					 | 
				
			||||||
  # "/...$" : $ to grep only the mount point and not sub-directories (/var: OK; /mnt/temp: nOK)
 | 
					 | 
				
			||||||
  if (df | grep "${PART}$" > /dev/null); then
 | 
					 | 
				
			||||||
    DISK_USAGE=$(df | grep "${PART}$" | awk '{print $5}')
 | 
					 | 
				
			||||||
    printf '%b' "\n${MAGENTA}+ ${WHITEB}${PART}${RESET}\t[ ${DISK_USAGE} ] "
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF ZFS
 | 
					 | 
				
			||||||
if [ $(command -v zpool) ]; then
 | 
					 | 
				
			||||||
  printf '%b' "\n${MAGENTA}+++++++++++++++++++ ${WHITEB}ZFS${RESET} ${WHITE}Partitions${RESET} ${MAGENTA}:++++++++++++++++++${RESET}"
 | 
					 | 
				
			||||||
  NUMBER_PART=$(df -T | grep zfs | wc -l)
 | 
					 | 
				
			||||||
  LINE=1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  while [ "${LINE}" -le "${NUMBER_PART}" ]; do
 | 
					 | 
				
			||||||
    PART_NAME=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}')
 | 
					 | 
				
			||||||
    DISK_USAGE=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}')
 | 
					 | 
				
			||||||
    printf '%b' "\n${MAGENTA}+ ${WHITEB}${PART_NAME}${RESET} [ ${DISK_USAGE} ] "
 | 
					 | 
				
			||||||
    LINE=$((LINE+1))
 | 
					 | 
				
			||||||
    # Bash ONLY:  (( LINE++ ))
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI ZFS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${RESET}\n"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,66 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					# Function definition [[[
 | 
				
			||||||
 | 
					## count_pattern()
 | 
				
			||||||
 | 
					### Return the number of occurrence of a pattern in a file with a color
 | 
				
			||||||
 | 
					###   (=expected_value : green ; otherwise : red).
 | 
				
			||||||
 | 
					count_pattern() {
 | 
				
			||||||
 | 
						## Get the args
 | 
				
			||||||
 | 
						PATTERN="${1}"
 | 
				
			||||||
 | 
						FILE="${2}"
 | 
				
			||||||
 | 
						EXPECTED_VALUE="${3}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						## Count the pattern in the file
 | 
				
			||||||
 | 
						NUM=$(grep -cE "${PATTERN}" "${FILE}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						## If $EXPECTED_VALUE exist AND $NUM equal $EXPECTED_VALUE
 | 
				
			||||||
 | 
						if [ "${EXPECTED_VALUE}" ] && [ "${NUM}" = "${EXPECTED_VALUE}" ]; then
 | 
				
			||||||
 | 
							MSG="${GREEN}${NUM}"
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							MSG="${RED}${NUM}"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						printf '%b' "${MSG}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					# Vars definition [[[
 | 
				
			||||||
 | 
					## Get the most recent "auth.log" file.
 | 
				
			||||||
 | 
					##	Simpliest way to get it ?
 | 
				
			||||||
 | 
					AUTH_LOG_FILE=$(find /var/log -type f -iname 'auth.log' -printf "%T@ %p\\n" | sort -n | cut -d' ' -f 2- | tail -n 1)
 | 
				
			||||||
 | 
					## Number of failed SSH authentication
 | 
				
			||||||
 | 
					SSH_FAIL_LOGIN=$(count_pattern 'sshd.*Failed' "${AUTH_LOG_FILE}" '0')
 | 
				
			||||||
 | 
					## Number of failed sudo authentication
 | 
				
			||||||
 | 
					SUDO_FAIL=$(count_pattern 'sudo.*authentication failure' "${AUTH_LOG_FILE}" '0')
 | 
				
			||||||
 | 
					SUDO_3_FAIL=$(count_pattern 'sudo.*3 incorrect password' "${AUTH_LOG_FILE}" '0')
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#+++++++++++++++++++: Auth Info :+++++++++++++++++++
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
 | 
					printf "${BLACKB}%33s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					printf '%b'  " ${CYAN}Auth Info${RESET}   "
 | 
				
			||||||
 | 
					printf "${BLACKB}%34s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "
 | 
				
			||||||
 | 
					${BLACKB}+ ${WHITE}SSH fail\\t\\t${BLACKB}= ${SSH_FAIL_LOGIN} fail(s) this week
 | 
				
			||||||
 | 
					${BLACKB}+ ${WHITE}Sudo fail\\t\\t${BLACKB}= ${GREEN}${SUDO_FAIL} fail(s) this week
 | 
				
			||||||
 | 
					${BLACKB}+ ${WHITE}Sudo 3 fails\\t\\t${BLACKB}= ${GREEN}${SUDO_3_FAIL} fail(s) this week
 | 
				
			||||||
 | 
					"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
| 
						 | 
					@ -1,227 +0,0 @@
 | 
				
			||||||
#! /usr/bin/env sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#############################################################################
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# 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'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Return the state of processes passed in parameters
 | 
					 | 
				
			||||||
# process_info $PROCESS_LIST_TO_MONITOR $MESSAGE
 | 
					 | 
				
			||||||
process_info() {
 | 
					 | 
				
			||||||
  local PROCESS_LIST="${1}"
 | 
					 | 
				
			||||||
  local MSG="${2}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for PROCESS in ${PROCESS_LIST}; do
 | 
					 | 
				
			||||||
    MSG="${MSG}${MAGENTA}+ "
 | 
					 | 
				
			||||||
    if (ps ax | grep -v grep | grep ${PROCESS} > /dev/null); then
 | 
					 | 
				
			||||||
      MSG="${MSG}${WHITEB}${PROCESS}${RESET} [ ${GREEN}RUNNING${RESET} ] "
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      MSG="${MSG}${WHITEB}${PROCESS}${RESET} [ ${REDB}NOT RUNNING${RESET} ] "
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  printf '%b' "${MSG}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Return the listening socket
 | 
					 | 
				
			||||||
# service_info $PORT_LIST_TO_MONITOR $MESSAGE
 | 
					 | 
				
			||||||
service_info() {
 | 
					 | 
				
			||||||
  local PORT_LIST="${1}"
 | 
					 | 
				
			||||||
  local MSG="${2}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for PORT in ${PORT_LIST}; do
 | 
					 | 
				
			||||||
    MSG="${MSG}${MAGENTA}+ "
 | 
					 | 
				
			||||||
    # If a port listen
 | 
					 | 
				
			||||||
    if (ss -lutn|grep -m1 ":${PORT}" > /dev/null); then
 | 
					 | 
				
			||||||
      # Example: "tcp/127.0.0.1:25"
 | 
					 | 
				
			||||||
      #MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} "
 | 
					 | 
				
			||||||
      MSG="${MSG}${GREEN}$(ss -lutn|grep ${PORT}|sort|head -n1|awk '{print $1"/"$5}')${RESET} "
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      # Example: "22: NOT LISTENING"
 | 
					 | 
				
			||||||
      MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} "
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  printf '%b' "${MSG}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${MAGENTA}+++++++++++++++++++: ${WHITE}Service Info${MAGENTA} :++++++++++++++++++++${RESET}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## IF POSTFIX
 | 
					 | 
				
			||||||
if [ $(command -v postfix) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "postfix" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "25" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
## FI POSTFIX
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF APACHE2
 | 
					 | 
				
			||||||
if [ $(command -v apache2) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "apache2" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "80 443" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI APACHE2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF NGINX
 | 
					 | 
				
			||||||
if [ $(command -v nginx) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "nginx" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "80 443" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI NGINX
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF MYSQLD
 | 
					 | 
				
			||||||
if [ $(command -v mysqld) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "mysqld" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "3306" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI MYSQLD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF SLAPD
 | 
					 | 
				
			||||||
if [ $(command -v slapd) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "slapd" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "389 636" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI SLAPD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF ZFS
 | 
					 | 
				
			||||||
if [ $(command -v zfs) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "zfs" '')
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI ZFS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF PUPPETMASTER
 | 
					 | 
				
			||||||
if [ $(command -v puppetmaster) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "puppetmaster" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "8140" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### IF PUPPETMASTER
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF NFS Server
 | 
					 | 
				
			||||||
if [ $(command -v nfsd) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "nfsd" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "111 2049" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI NFS Server
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF TFTPD
 | 
					 | 
				
			||||||
if [ $(command -v in.tftpd) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "in.tftpd" '')
 | 
					 | 
				
			||||||
  #MSG=$(service_info "69" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI TFTPD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF SQUID3
 | 
					 | 
				
			||||||
if [ $(command -v squid3) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "squid3" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "3128" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI SQUID3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF APT-CACHER-NG
 | 
					 | 
				
			||||||
if [ $(command -v apt-cacher-ng) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "apt-cacher-ng" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "3142" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI APT-CACHER-NG
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF SSHD
 | 
					 | 
				
			||||||
if [ $(command -v sshd) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "sshd" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "22" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI SSHD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF DHCPD
 | 
					 | 
				
			||||||
if [ $(command -v dhcpd) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "dhcpd" '')
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI DHCPD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF FAIL2BAN
 | 
					 | 
				
			||||||
if [ $(command -v fail2ban-server) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "fail2ban" '')
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI FAIL2BAN
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF ETHERPAD
 | 
					 | 
				
			||||||
if [ $(command -v etherpad) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "etherpad" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "9001" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI ETHERPAD
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF ETHERCALC
 | 
					 | 
				
			||||||
if [ $(command -v ethercalc) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "ethercalc" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "8000" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI ETHERCALC
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF GITLAB
 | 
					 | 
				
			||||||
if [ $(command -v gitlab-ctl) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "nginx" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "80 443" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
  MSG=$(process_info "gitlab" '')
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI GITLAB
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF XYMONSERVER
 | 
					 | 
				
			||||||
if [ $(command -v xymond) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "xymond" '')
 | 
					 | 
				
			||||||
  MSG=$(service_info "1984" "${MSG}")
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI XYMONSERVER
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### IF XYMONCLIENT
 | 
					 | 
				
			||||||
if [ $(command -v xymon) ]; then
 | 
					 | 
				
			||||||
  MSG=$(process_info "xymonlaunch" '')
 | 
					 | 
				
			||||||
  printf '%b' "\n${MSG}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
### FI XYMONCLIENT
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Service need a warning if running
 | 
					 | 
				
			||||||
YELLOW_SERVICE='tmux screen glances htop automysqlbackup vzdump puppet aptitude'
 | 
					 | 
				
			||||||
for SERVICE in ${YELLOW_SERVICE}; do
 | 
					 | 
				
			||||||
  if (ps ax | grep -v grep | grep ${SERVICE} > /dev/null); then
 | 
					 | 
				
			||||||
    printf '%b' "\n${MAGENTA}+ ${WHITEB}${SERVICE}${RESET} [ ${YELLOW}RUNNING${RESET} ]"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf '%b' "${RESET}\n"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#echo -e "${MAGENTA}+++++++++++++: ${RED}Maintenance Information${MAGENTA} :+++++++++++++++${RESET}
 | 
					 | 
				
			||||||
#${MAGENTA}+${RED}""
 | 
					 | 
				
			||||||
#echo -e "${MAGENTA}+++++++++++++++++++++++++++++++++++++++++++++++++++++++${RESET}"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,67 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					# Vars definition [[[
 | 
				
			||||||
 | 
					ROOT_PART_USAGE=$(df | grep -m1 "/$" | awk '{print $5}')
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#+++++++++++++++++++: Disk Usage :+++++++++++++++++++
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
 | 
					printf "${BLACKB}%33s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					printf '%b' " ${CYAN}Disk Usage${RESET}  "
 | 
				
			||||||
 | 
					printf "${BLACKB}%34s${RESET}\\n" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Root partition
 | 
				
			||||||
 | 
					## Replaced by rootfs in few kernel version
 | 
				
			||||||
 | 
					PRINTF_ROOT_NAME=$(printf '%-22s' "/")
 | 
				
			||||||
 | 
					printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_ROOT_NAME}${RESET}${BLACKB}= ${CYAN}${ROOT_PART_USAGE}${RESET}\\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Other partition
 | 
				
			||||||
 | 
					for PART_NAME in /boot /home /opt /srv /tmp /tmp /usr /var /var/lib/docker /var/lib/vz; do
 | 
				
			||||||
 | 
						## "/...$" : $ to grep only the mount point and not sub-directories (/var: OK; /mnt/temp: nOK)
 | 
				
			||||||
 | 
						if (df | grep "${PART_NAME}$" > /dev/null); then
 | 
				
			||||||
 | 
							PART_USAGE=$(df | grep "${PART_NAME}$" | awk '{print $5}')
 | 
				
			||||||
 | 
							PRINTF_PART_NAME=$(printf '%-22s' "${PART_NAME}")
 | 
				
			||||||
 | 
							printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET}${BLACKB}= ${CYAN}${PART_USAGE}${RESET}\\n"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## IF ZFS [[[
 | 
				
			||||||
 | 
					#+++++++++++++++++++: ZFS Usage :+++++++++++++++++++
 | 
				
			||||||
 | 
					if [ "$(command -v zpool)" ]; then
 | 
				
			||||||
 | 
						printf '%b' "${RESET}"
 | 
				
			||||||
 | 
						printf "${BLACKB}%32s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
						printf '%b' " ${CYAN}${BOLD}ZFS${RESET} ${CYAN}Partition${RESET} "
 | 
				
			||||||
 | 
						printf "${BLACKB}%33s${RESET}\\n" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						NUMBER_PART=$(df -T | grep -c zfs)
 | 
				
			||||||
 | 
						LINE=1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while [ "${LINE}" -le "${NUMBER_PART}" ]; do
 | 
				
			||||||
 | 
							DISK_USAGE=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}')
 | 
				
			||||||
 | 
							PART_NAME=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}')
 | 
				
			||||||
 | 
							PRINTF_PART_NAME=$(printf '%-23s' "${PART_NAME}")
 | 
				
			||||||
 | 
							printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET} ${CYAN}${DISK_USAGE}${RESET}\\n"
 | 
				
			||||||
 | 
							LINE=$((LINE+1))
 | 
				
			||||||
 | 
							# Bash ONLY:  (( LINE++ ))
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## FI ZFS ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,348 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					# Function definition [[[
 | 
				
			||||||
 | 
					## process_info() [[[
 | 
				
			||||||
 | 
					### Return the state of processes passed in parameters
 | 
				
			||||||
 | 
					###		process_info $PROCESS_LIST_TO_MONITOR $MESSAGE
 | 
				
			||||||
 | 
					process_info() {
 | 
				
			||||||
 | 
						PROCESS_LIST="${1}"
 | 
				
			||||||
 | 
						MSG="${2}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for PROCESS in ${PROCESS_LIST}; do
 | 
				
			||||||
 | 
							MSG="${MSG}${BLACKB}+ "
 | 
				
			||||||
 | 
							PRINTF_PROCESS=$(printf '%-22s' "${PROCESS}")
 | 
				
			||||||
 | 
							if (ps ax | grep -v grep | grep -E "${PROCESS}" > /dev/null); then
 | 
				
			||||||
 | 
								MSG="${MSG}${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${GREEN}RUNNING${RESET}"
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								MSG="${MSG}${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${REDB}NOT RUNNING${RESET}"
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						printf '%b' "${MSG}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## service_info() [[[
 | 
				
			||||||
 | 
					### Return the listening socket
 | 
				
			||||||
 | 
					###		service_info $PORT_LIST_TO_MONITOR $MESSAGE
 | 
				
			||||||
 | 
					service_info() {
 | 
				
			||||||
 | 
						PORT_LIST="${1}"
 | 
				
			||||||
 | 
						MSG="${2}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for PORT in ${PORT_LIST}; do
 | 
				
			||||||
 | 
							MSG="${MSG}\\t${BLACKB}+ "
 | 
				
			||||||
 | 
							# If a port listen
 | 
				
			||||||
 | 
							if (ss -lutn|grep -m1 -E ":${PORT}" > /dev/null); then
 | 
				
			||||||
 | 
								# Example: "tcp/127.0.0.1:25"
 | 
				
			||||||
 | 
								#MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} "
 | 
				
			||||||
 | 
								MSG="${MSG}${GREEN}$(ss -lutn|grep -E "${PORT}"|sort|head -n1|awk '{print $1"/"$5}')${RESET} "
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								# Example: "22: NOT LISTENING"
 | 
				
			||||||
 | 
								MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} "
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						printf '%b' "${MSG}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#+++++++++++++++++++: Service Info :+++++++++++++++++++
 | 
				
			||||||
 | 
					printf '%b' "${RESET}"
 | 
				
			||||||
 | 
					printf "${BLACKB}%33s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					printf '%b' " ${CYAN}Service Info${RESET} "
 | 
				
			||||||
 | 
					printf "${BLACKB}%33s${RESET}" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Monitore some service if availabe [[[
 | 
				
			||||||
 | 
					## WEB SERVER [[[
 | 
				
			||||||
 | 
					### IF APACHE2 [[[
 | 
				
			||||||
 | 
					if [ "$(command -v apache2)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "apache2" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "80 443" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF NGINX [[[
 | 
				
			||||||
 | 
					if [ "$(command -v nginx)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "nginx" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "80 443" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## WEB APPS [[[
 | 
				
			||||||
 | 
					### IF BACKUPPC [[[
 | 
				
			||||||
 | 
					if [ -d "/var/lib/backuppc" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "backuppc" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF ETHERPAD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v etherpad)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "etherpad" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "9001" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF ETHERCALC [[[
 | 
				
			||||||
 | 
					if [ "$(command -v ethercalc)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "ethercalc" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "8000" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF GOGS [[[
 | 
				
			||||||
 | 
					if [ "$(command -v gogs)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "gogs" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "3000" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF GITLAB [[[
 | 
				
			||||||
 | 
					if [ "$(command -v gitlab-ctl)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "nginx" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "80 443" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					  MSG=$(process_info "gitlab" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF Jenkins [[[
 | 
				
			||||||
 | 
					if [ -d "/var/lib/jenkins" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "java" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "8080" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF XYMONSERVER [[[
 | 
				
			||||||
 | 
					if [ "$(command -v xymond)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "xymond" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "1984" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## System [[[
 | 
				
			||||||
 | 
					### IF POSTFIX [[[
 | 
				
			||||||
 | 
					if [ "$(command -v postfix)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "postfix" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "25" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF SLAPD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v slapd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "slapd" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "389 636" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF SSHD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v sshd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "sshd" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "22" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF DHCPD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v dhcpd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "dhcpd" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF MYSQLD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v mysqld)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "mysqld" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "3306" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF ZFS [[[
 | 
				
			||||||
 | 
					if [ "$(command -v zfs)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "zed" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF PUPPETMASTER [[[
 | 
				
			||||||
 | 
					if [ "$(command -v puppetmaster)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "puppetmaster" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "8140" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## NFS [[[
 | 
				
			||||||
 | 
					### IF NFS Server [[[
 | 
				
			||||||
 | 
					if [ "$(command -v nfsd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "nfsd" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "111 2049" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF RPCBIND [[[
 | 
				
			||||||
 | 
					if [ "$(command -v rpcbind)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "rpcbind" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF RPC.IDMAPD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v rpc.idmapd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "rpc.idmapd" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF RPC.MOUNTD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v rpc.mountd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "rpc.mountd" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF TFTPD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v in.tftpd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "in.tftpd" '')
 | 
				
			||||||
 | 
					  #MSG=$(service_info "69" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF SQUID3 [[[
 | 
				
			||||||
 | 
					if [ "$(command -v squid3)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "squid3" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "3128" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF APT-CACHER-NG [[[
 | 
				
			||||||
 | 
					if [ "$(command -v apt-cacher-ng)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "apt-cacher-ng" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "3142" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## IF REDIS-SERVER [[[
 | 
				
			||||||
 | 
					if [ "$(command -v redis-server)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "redis-server" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "6379" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## Security [[[
 | 
				
			||||||
 | 
					### IF FAIL2BAN [[[
 | 
				
			||||||
 | 
					if [ "$(command -v fail2ban-server)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "fail2ban" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF XYMONCLIENT [[[
 | 
				
			||||||
 | 
					if [ "$(command -v xymon)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "xymonlaunch" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF ARPWATCH [[[
 | 
				
			||||||
 | 
					if [ "$(command -v arpwatch)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "arpwatch" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## Proxmox [[[
 | 
				
			||||||
 | 
					### IF PVEDAEMON [[[
 | 
				
			||||||
 | 
					if [ "$(command -v pvedaemon)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "pvedaemon" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "85" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF PVEPROXY [[[
 | 
				
			||||||
 | 
					if [ "$(command -v pveproxy)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "pveproxy" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "8006" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF PVESTATD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v pvestatd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "pvestatd" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## Docker [[[
 | 
				
			||||||
 | 
					### IF DOCKERD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v dockerd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "dockerd" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF DOCKER-PROXY [[[
 | 
				
			||||||
 | 
					if [ "$(command -v docker-proxy)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "docker-proxy" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "3000|5000" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					## Licence Manager [[[
 | 
				
			||||||
 | 
					### IF LMGRD [[[
 | 
				
			||||||
 | 
					if [ "$(command -v lmgrd)" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "lmgrd" '')
 | 
				
			||||||
 | 
					  MSG=$(service_info "27000|33188|57227" "${MSG}")
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF INTEL-LM [[[
 | 
				
			||||||
 | 
					if [ -f "/opt/intel/etc/license.lic" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "INTEL..T" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF ABAQUS-LM [[[
 | 
				
			||||||
 | 
					if [ -f "/opt/origin/etc/license.lic" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "orglab" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF ORIGIN-LM [[[
 | 
				
			||||||
 | 
					if [ -f "/opt/origin/etc/license.lic" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "orglab" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					### IF MATLAB-LM [[[
 | 
				
			||||||
 | 
					if [ -f "/opt/matlab/etc/license.lic" ]; then
 | 
				
			||||||
 | 
					  MSG=$(process_info "MLM" '')
 | 
				
			||||||
 | 
					  printf '%b' "\\n${MSG}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					### ]]]
 | 
				
			||||||
 | 
					## ]]]
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Process need a warning if running [[[
 | 
				
			||||||
 | 
					YELLOW_PROCESS='tmux screen glances htop automysqlbackup vzdump puppet aptitude'
 | 
				
			||||||
 | 
					for PROCESS in ${YELLOW_PROCESS}; do
 | 
				
			||||||
 | 
						if (ps ax | grep -v grep | grep "${PROCESS}" > /dev/null); then
 | 
				
			||||||
 | 
							PRINTF_PROCESS=$(printf '%-22s' "${PROCESS}")
 | 
				
			||||||
 | 
							printf '%b' "\\n${BLACKB}+ ${WHITE}${PRINTF_PROCESS}${RESET}${BLACKB}= ${YELLOW}RUNNING${RESET}"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf '%b' "${RESET}\\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -d "/etc/ansible/facts.d" ] ; then
 | 
				
			||||||
 | 
							printf "${BLACKB}%80s${RESET}\\n" | tr ' ' -
 | 
				
			||||||
 | 
							printf '%b' "    ${CYAN}This system is managed by ${BOLD}Ansible${RESET}${CYAN}, manual changes will be lost${RESET}\\n"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# .. vim: foldmarker=[[[,]]]:foldmethod=marker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# {{ ansible_managed }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Colors definition [[[
 | 
				
			||||||
 | 
					BLACK='\033[49;30m'
 | 
				
			||||||
 | 
					BLACKB='\033[49;90m'
 | 
				
			||||||
 | 
					RED='\033[0;31m'
 | 
				
			||||||
 | 
					REDB='\033[1;31m'
 | 
				
			||||||
 | 
					GREEN='\033[0;32m'
 | 
				
			||||||
 | 
					YELLOW='\033[0;33m'
 | 
				
			||||||
 | 
					BLUE='\033[94;49m'
 | 
				
			||||||
 | 
					MAGENTA='\033[0;35m'
 | 
				
			||||||
 | 
					CYAN='\033[36;49m'
 | 
				
			||||||
 | 
					WHITE='\033[0;37m'
 | 
				
			||||||
 | 
					BOLD='\033[1m'
 | 
				
			||||||
 | 
					RESET='\033[0m'
 | 
				
			||||||
 | 
					# ]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf "${BLACKB}%80s${RESET}\\n" | tr ' ' -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -f /etc/motd.tail ] ; then
 | 
				
			||||||
 | 
						cat /etc/motd.tail
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
		Loading…
	
		Reference in New Issue