From 141ac0927a6c619bf54f9020050b510c7ac14d6a Mon Sep 17 00:00:00 2001 From: jfontaine35 <76435797+jfontaine35@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:41:04 +0100 Subject: [PATCH] Update .profile --- .profile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.profile b/.profile index 296da11..f782f56 100644 --- a/.profile +++ b/.profile @@ -2,12 +2,14 @@ # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. -# the files are located in the bash-doc package. +# the files are located in thebash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 marker_file=~/.utils_ok +host1="1.1.1.1" +host2="www.google.com" if [ -f "$marker_file" ]; then echo "Mise à jour des outils déjà faite." @@ -56,6 +58,19 @@ echo "Bienvenue sur : $(hostname -f) ($(hostname -I)) !" echo "******************************************************" echo "Note: Toutes actions sur ce serveur sont enregistrees." echo "------------------------------------------------------" + +ping -c 1 "$host1" > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo -e "\033[0;31mAucune connexion Internet n'est disponible.\033[0m" +else + ping -c 1 "$host2" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "\033[0;31mAucune connexion DNS n'est disponible.\033[0m" + else + echo -e "\033[0;32mConnexion à internet : OK.\033[0m" + fi +fi + updates=$(apt-get upgrade --dry-run --only-security 2> /dev/null | grep ^Inst | wc -l) if [ $updates -gt 0 ]; then echo -e "\033[0;31mIl y a $updates mises à jour de sécurité en attente.\033[0m"