Ajustement de couleur et amélioration d'affichage

This commit is contained in:
Frogg 2026-05-07 10:59:29 +02:00
parent 80b8dc7593
commit 10de4b539c
9 changed files with 85 additions and 60 deletions

View File

@ -58,5 +58,7 @@ display_dashboard
################ ################
if [[ $HAS_WELCOME_CONF_ERROR -eq 1 ]];then if [[ $HAS_WELCOME_CONF_ERROR -eq 1 ]];then
msg_error "TODO PROPOSER UNE INSTALL DE CE QUI MANQUE" msg_error "❎ TODO PROPOSER UNE INSTALL DE CE QUI MANQUE"
msg_error "faire une commande avec proposition, et l autre action pour mettre en place les propositions"
msg_error "basées sur les choses trouvées sur le systeme"
fi fi

50
TODO.md
View File

@ -1,20 +1,11 @@
# ZABBIX # BUG
- config Proxmox (dl le template)
- config ndv
- config gita
> PS1 quand on remonte l historique peut bug
> Si bare sur deux ligne bug du couleur fond
>
# SCRIPT # SCRIPT
- VARIABLE SUPER GLOBALE POUR EVITER LE MAIL A CHAQUE WELCOME - VERIF SI NOM DE L ENV DISPO
- verifier si git est installé
- verifier si Zabbix agent est installé
- n'afficher que les services présents
- ajouter le service de la base de gitea
- faire le redirect port 80
- ajouter https sur gitea
- faire la connexion git sans faire pass a chaque fois
- faire un menu tool d install - faire un menu tool d install
- dont : - dont :
- confg mail - confg mail
@ -22,10 +13,21 @@
- conf ip - conf ip
- conf nom de machine - conf nom de machine
- menu qui propose des choix - menu qui propose des choix
- faire la connexion git sans faire pass a chaque fois en script
# SERVER Ajouter des alias GIT
- mettre les scripts sur tous les linux > mettre le reset
> git fetch origin
> git reset --hard origin/main
git clean -fd
>> rename la machine
hostnamectl set-hostname gitea
> /etc/hosts (changer le nom de la machine)
> > /etc/hostname (changer le nom de la machine)
# config de ADMIN_MAIL dans le ENV
ajouter ADMIN_MAIL dans /etc/environment ajouter ADMIN_MAIL dans /etc/environment
ADMIN_MAIL="admin@frogg.fr" ADMIN_MAIL="admin@frogg.fr"
@ -33,13 +35,15 @@ ADMIN_MAIL="admin@frogg.fr"
jq pour les json en bash jq pour les json en bash
ncdu ncdu
# config de ADMIN_MAIL dans le ENV # GITEA
- faire le redirect port 80
- ajouter https sur gitea
faire une page demo des couleurs # SERVER
- mettre les scripts sur tous les linux
# ZABBIX
- config Proxmox (dl le template)
- config ndv
- config gita
>> rename la machine
hostnamectl set-hostname gitea
> /etc/hosts (changer le nom de la machine)
> > /etc/hostname (changer le nom de la machine)

View File

@ -23,3 +23,6 @@ COLOR_DARK_GREEN_BG='\033[48;5;28m'
COLOR_DARK_GRAY_BG='\033[48;5;239m' COLOR_DARK_GRAY_BG='\033[48;5;239m'
COLOR_LIGHT_BLUE_BG='\033[48;5;31m' COLOR_LIGHT_BLUE_BG='\033[48;5;31m'
COLOR_LIGHT_RED_BG='\033[01;101m' COLOR_LIGHT_RED_BG='\033[01;101m'
# Les Asci sympas :
# 🐧 🌀 🍥 ✅ ❎ ❌ ⭕ ℹ️🔄🚨🆔 🆗 🆕 🆙

View File

@ -10,10 +10,10 @@ msg_status_text()
echo -e "${COLOR_YELLOW}${msg}${NONE}" echo -e "${COLOR_YELLOW}${msg}${NONE}"
;; ;;
error|err) error|err)
echo -e "${COLOR_RED} ${msg}${NONE}" echo -e "${COLOR_LIGHT_RED} ${msg}${NONE}"
;; ;;
info|inf) info|inf)
echo -e "${COLOR_BLUE} ${msg}${NONE}" echo -e "${COLOR_LIGHT_BLUE} ${msg}${NONE}"
;; ;;
*) *)
echo -e "${msg}" echo -e "${msg}"

View File

@ -1,6 +1,6 @@
display_line() display_line()
{ {
local width=27 label_with_dots formatted_label local width=26 label_with_dots formatted_label
# On calcule combien de points ajouter (Largeur - longueur du label) # On calcule combien de points ajouter (Largeur - longueur du label)
# On utilise une astuce simple : on ajoute 27 points au label et on coupe à 27. # On utilise une astuce simple : on ajoute 27 points au label et on coupe à 27.
@ -57,8 +57,8 @@ draw_bar() {
((pct < 0)) && pct=0 ((pct < 0)) && pct=0
# Sélection automatique de la couleur # Sélection automatique de la couleur
local color="${COLOR_BLUE}" local color="${COLOR_LIGHT_BLUE}"
if (( pct >= 90 )); then color="${COLOR_RED}" if (( pct >= 90 )); then color="${COLOR_LIGHT_RED}"
elif (( pct >= 70 )); then color="${COLOR_ORANGE}" elif (( pct >= 70 )); then color="${COLOR_ORANGE}"
elif (( pct >= 50 )); then color="${COLOR_YELLOW}" elif (( pct >= 50 )); then color="${COLOR_YELLOW}"
elif (( pct >= 30 )); then color="${COLOR_LIGHT_GREEN}" elif (( pct >= 30 )); then color="${COLOR_LIGHT_GREEN}"
@ -70,7 +70,7 @@ draw_bar() {
local empty=$((size - filled)) local empty=$((size - filled))
# Affichage de la barre # Affichage de la barre
printf "[" printf "${NONE}["
echo -ne "${color}" echo -ne "${color}"
for ((i=0; i<filled; i++)); do echo -ne "■"; done for ((i=0; i<filled; i++)); do echo -ne "■"; done
echo -ne "${COLOR_GRAY}" echo -ne "${COLOR_GRAY}"
@ -84,6 +84,7 @@ draw_ascii_art() {
L_IPS="${COLOR_YELLOW}IP Addresses.: ${F_IPS}" L_IPS="${COLOR_YELLOW}IP Addresses.: ${F_IPS}"
L_UPT="${COLOR_YELLOW}Uptime.......: ${F_UPT}" L_UPT="${COLOR_YELLOW}Uptime.......: ${F_UPT}"
L_HRD="${COLOR_YELLOW}Hardware.....: ${F_HARD}" L_HRD="${COLOR_YELLOW}Hardware.....: ${F_HARD}"
L_CPU="${COLOR_YELLOW}CPU..........: ${F_CPU}"
L_CPU_BAR="${COLOR_YELLOW}CPU Usage....: ${F_BAR_CPU}" L_CPU_BAR="${COLOR_YELLOW}CPU Usage....: ${F_BAR_CPU}"
L_MEM_BAR="${COLOR_YELLOW}RAM Usage....: ${F_BAR_MEM}" L_MEM_BAR="${COLOR_YELLOW}RAM Usage....: ${F_BAR_MEM}"
L_HDD_BAR="${COLOR_YELLOW}Disk Usage...: ${F_BAR_DSK}" L_HDD_BAR="${COLOR_YELLOW}Disk Usage...: ${F_BAR_DSK}"
@ -94,20 +95,21 @@ draw_ascii_art() {
echo -e "${COLOR_CYAN} ==[ You are connected to ${COLOR_WHITE}$(hostname)${COLOR_CYAN} ]==" echo -e "${COLOR_CYAN} ==[ You are connected to ${COLOR_WHITE}$(hostname)${COLOR_CYAN} ]=="
echo -e "${COLOR_GREEN} _ __ _" echo -e "${COLOR_GREEN} _ __ _"
echo -e "${COLOR_GREEN} ((-)).--.((-)) ${L_DAT}" echo -e "${COLOR_GREEN} ((-)).--.((-)) ${L_DAT}"
echo -e "${COLOR_GREEN} / '' \\ ${F_VER}" echo -e "${COLOR_GREEN} / '' \\ ${F_OS}"
echo -e "${COLOR_GREEN} ( \______/ )" echo -e "${COLOR_GREEN} ( \______/ )"
echo -e "${COLOR_GREEN} \ ( ) / ${L_IPS}" echo -e "${COLOR_GREEN} \ ( ) / ${L_IPS}"
echo -e "${COLOR_GREEN} / /~~~~~~~~\ \ ${L_UPT}" echo -e "${COLOR_GREEN} / /~~~~~~~~\ \ ${L_CPU}"
echo -e "${COLOR_GREEN} /~~\/ / \ \/~~\ ${L_HRD}" echo -e "${COLOR_GREEN} /~~\/ / \ \/~~\ ${L_HRD}"
echo -e "${COLOR_GREEN}( ( ( ) ) ) ${L_USR}" echo -e "${COLOR_GREEN}( ( ( ) ) ) ${L_UPT}"
echo -e "${COLOR_GREEN} \ \ \ \ / / / / ${L_CPU_BAR}" echo -e "${COLOR_GREEN} \ \ \ \ / / / / ${L_USR}"
echo -e "${COLOR_GREEN} _\ \/ \.______./ \/ /_ ${L_MEM_BAR}" echo -e "${COLOR_GREEN} _\ \/ \.______./ \/ /_ ${L_CPU_BAR}"
echo -e "${COLOR_GREEN} ___/ /\__________/\ \___ ${L_HDD_BAR}" echo -e "${COLOR_GREEN} ___/ /\__________/\ \___ ${L_MEM_BAR}"
echo -e "${COLOR_GREEN}=========================== ${L_HDD_BAR}${NONE}"
} }
display_dashboard() { display_dashboard() {
# Déclaration de toutes les variables partagées en local # Déclaration de toutes les variables partagées en local
local F_VER F_IPS F_UPT F_BAR_CPU F_BAR_DSK F_USR F_HARD local F_IPS F_UPT F_BAR_CPU F_BAR_DSK F_USR F_HARD F_OS
# Exécution des sondes # Exécution des sondes
get_os_info get_os_info
@ -123,6 +125,4 @@ display_dashboard() {
# Affichage # Affichage
draw_ascii_art draw_ascii_art
echo -e "${COLOR_GREEN}======================================================================${NONE}"
} }

View File

@ -1,17 +1,5 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
get_os_info() {
local desc=""
if [ -f /etc/lsb-release ]; then source /etc/lsb-release; desc=$DISTRIB_DESCRIPTION; fi
[[ -z "$desc" && -x /usr/bin/lsb_release ]] && desc=$(lsb_release -s -d)
local re='(.*\()(.*)(\).*)'
if [[ $desc =~ $re ]]; then
F_VER=$(printf "%s%s%s%s%s" "${BASH_REMATCH[1]}" "${COLOR_YELLOW}" "${BASH_REMATCH[2]}" "${COLOR_WHITE}" "${BASH_REMATCH[3]}")
else
F_VER="${COLOR_WHITE}${desc}"
fi
}
get_hardware_info() { get_hardware_info() {
local mem_ko ram_pretty disk_ko disk_pretty local mem_ko ram_pretty disk_ko disk_pretty
# RAM Totale (on la récupère en Ko dans /proc/meminfo) # RAM Totale (on la récupère en Ko dans /proc/meminfo)
@ -22,9 +10,13 @@ get_hardware_info() {
disk_ko=$(df -k / | awk 'NR==2 {print $2}') disk_ko=$(df -k / | awk 'NR==2 {print $2}')
disk_pretty=$(format_size "$disk_ko") disk_pretty=$(format_size "$disk_ko")
F_HARD="${COLOR_WHITE}Mem : ${ram_pretty} | Hdd : ${disk_pretty}" F_HARD="${COLOR_WHITE}C:$(nproc)Core M:${ram_pretty} D:${disk_pretty}"
F_CPU="${COLOR_WHITE}$(lscpu | grep 'Model name' | cut -d: -f2 | sed 's/^[ \t]*//; s/[ \t]*@.*//; s/ [0-9.]*GHz//i')"
} }
get_network_info() { get_network_info() {
F_IPS="${COLOR_WHITE}$(hostname -I)" F_IPS="${COLOR_WHITE}$(hostname -I)"
} }
@ -59,3 +51,24 @@ get_disk_info() {
get_user_info() { get_user_info() {
F_USR="${COLOR_WHITE}$(awk -F: '$3 >= 1000 && $7 !~ /(nologin|false)/ {count++} END {print count+1}' /etc/passwd)" F_USR="${COLOR_WHITE}$(awk -F: '$3 >= 1000 && $7 !~ /(nologin|false)/ {count++} END {print count+1}' /etc/passwd)"
} }
get_os_info() {
local distrib_id distrib_name version_id codename
# --- INFOS SYSTÈME ---
distrib_id=$(grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
distrib_name="${distrib_id^}" # Debian, Ubuntu...
version_id=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
codename=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
codename="${codename^}"
logo_os='🐧'
if [ "$distrib_name" = "Debian" ]; then
logo_os='🌀'
fi
# Résultat final : "Debian 12 (Bookworm)"
F_OS="${COLOR_CYAN} ${logo_os}${distrib_name} ${version_id} ${COLOR_LIGHT_BLUE}(${codename})"
}

View File

@ -8,7 +8,7 @@ fi
# Infos # Infos
echo "" echo ""
echo -e "${COLOR_YELLOW}You can use the commands ${COLOR_WHITE}cmd ${COLOR_YELLOW}, ${COLOR_WHITE}conf ${COLOR_YELLOW}or ${COLOR_WHITE}colors ${COLOR_YELLOW}for more information...${NONE}" echo -e "${COLOR_YELLOW}Type ${COLOR_WHITE}cmd${COLOR_YELLOW}, ${COLOR_WHITE}conf ${COLOR_YELLOW}or ${COLOR_WHITE}colors ${COLOR_YELLOW}for more information...${NONE}"
echo "" echo ""

View File

@ -29,22 +29,25 @@ SEP="█►"
# ========================================== # ==========================================
get_git_status() { get_git_status() {
local branch status current_bg current_color local branch status current_bg current_color project
branch=$(git branch --show-current 2>/dev/null) branch=$(git branch --show-current 2>/dev/null)
[[ -z "$branch" ]] && return [[ -z "$branch" ]] && return
project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)
current_bg=$COLOR_DARK_GREEN_BG current_bg=$COLOR_DARK_GREEN_BG
current_color=$COLOR_DARK_GREEN current_color=$COLOR_DARK_GREEN
status="" status="🆗"
if [[ -n $(git status --porcelain 2>/dev/null) ]]; then if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
current_bg=$COLOR_LIGHT_RED_BG current_bg=$COLOR_LIGHT_RED_BG
current_color=$COLOR_LIGHT_RED current_color=$COLOR_LIGHT_RED
status="▼" #status="▼"
status="🔄"
fi fi
echo -ne "${COLOR_DARK_GRAY}${current_bg}${SEP}${COLOR_WHITE} ${status} git:[${branch}]${current_bg}${NONE}${current_color}${SEP}${NONE}" echo -ne "${COLOR_DARK_GRAY}${current_bg}${SEP}${COLOR_WHITE} [${project}/${branch}]${status}${current_bg}${NONE}${current_color}${SEP}${NONE}"
} }
set_ps1() { set_ps1() {

View File

@ -18,7 +18,7 @@ check_ssh_failed_logins() {
failed_con=$($sudo_cmd journalctl _SYSTEMD_UNIT=ssh.service --since "24 hours ago" 2>/dev/null | grep -c "Failed password") failed_con=$($sudo_cmd journalctl _SYSTEMD_UNIT=ssh.service --since "24 hours ago" 2>/dev/null | grep -c "Failed password")
if [[ ${failed_con:-0} -gt 0 ]]; then if [[ ${failed_con:-0} -gt 0 ]]; then
echo -e " ${COLOR_RED}⚡ ATTENTION :${COLOR_GRAY} ${failed_con} tentatives de connexion échouées ces dernières 24h !${NONE}" echo -e " ${COLOR_LIGHT_RED}⚡ ATTENTION :${COLOR_GRAY} ${failed_con} tentatives de connexion échouées ces dernières 24h !${NONE}"
echo -e "${COLOR_GREEN}======================================================================${NONE}" echo -e "${COLOR_GREEN}======================================================================${NONE}"
fi fi
} }
@ -29,8 +29,8 @@ check_active_sessions() {
other_users=$(who | wc -l) other_users=$(who | wc -l)
if [[ ${other_users:-0} -gt 1 ]]; then if [[ ${other_users:-0} -gt 1 ]]; then
echo -e " ${COLOR_RED}⚡ ATTENTION :${COLOR_GRAY} Il y a actuellement $((other_users - 1)) autre(s) session(s) active(s).${NONE}" echo -e " ${COLOR_LIGHT_RED}⚡ ATTENTION :${COLOR_GRAY} Il y a actuellement $((other_users - 1)) autre(s) session(s) active(s).${NONE}"
echo -e "${COLOR_RED} ╔════════════════════════════════════════════════╗" echo -e "${COLOR_LIGHT_RED} ╔════════════════════════════════════════════════╗"
printf " ║ %-10s %-10s %-8s %-15s ║\n" "USER" "DATE" "HEURE" "IP" printf " ║ %-10s %-10s %-8s %-15s ║\n" "USER" "DATE" "HEURE" "IP"
echo " ╠════════════════════════════════════════════════╣" echo " ╠════════════════════════════════════════════════╣"