You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.7 KiB

  1. #!/bin/bash
  2. # Allo-GG
  3. # Routine de verification de l'etat des services
  4. # LOG2RAM
  5. if mount | grep -q 'log2ram on /var/log type tmpfs'
  6. then
  7. echo -e "\e[32m\e[32m[OK]\e[39m\e[39m Log2Ram"
  8. else
  9. echo -e "\e[31m\e[31m[ERROR]\e[39m\e[39m Log2Ram"
  10. gpio -g write 18 1
  11. exit
  12. fi
  13. # APACHE
  14. if service apache2 status | grep -q 'running'
  15. then
  16. echo -e "\e[32m[OK]\e[39m Apache"
  17. else
  18. echo -e "\e[31m[ERROR]\e[39m Apache"
  19. gpio -g write 18 1
  20. exit
  21. fi
  22. # CRON
  23. if service cron status | grep -q 'running'
  24. then
  25. echo -e "\e[32m[OK]\e[39m Cron"
  26. else
  27. echo -e "\e[31m[ERROR]\e[39m Cron"
  28. gpio -g write 18 1
  29. exit
  30. fi
  31. # WIRINGPI
  32. if gpio -v | head -n 1 | grep -q 'gpio version: [0-9]'
  33. then
  34. echo -e "\e[32m[OK]\e[39m WiringPi"
  35. else
  36. echo -e "\e[31m[ERROR]\e[39m WiringPi"
  37. gpio -g write 18 1
  38. exit
  39. fi
  40. # INTERNET
  41. # tester 5 ping
  42. if ping -c5 8.8.8.8 | grep -q '0% packet loss'
  43. # Si la reponse est 0 paquets perdu, alors OK
  44. then
  45. echo -e "\e[32m[OK]\e[39m Internet"
  46. # Mais sinon, il y a un probleme
  47. else
  48. # Tentative de relancer le wifi ...
  49. sleep 2
  50. echo
  51. echo -e "\e[93m Probleme sur le Wifi ? Tentative de relancer la connexion en cours ...\e[39m"
  52. ifdown --force wlan0
  53. sleep 2
  54. ifup wlan0
  55. sleep 2
  56. # ... puis refaire un test, en testant 10 ping cette fois
  57. if ping -c10 8.8.8.8 | grep -q '0% packet loss'
  58. # Si la reponse est 0 paquets perdu, alors finalement tout va bien
  59. then
  60. echo -e "\e[32m[OK]\e[39m Internet"
  61. # Mais si le probleme est toujours present, alors on alerte :
  62. else
  63. echo -e "\e[31m[ERROR]\e[39m Internet"
  64. gpio -g write 18 1
  65. exit
  66. fi
  67. fi
  68. # Tout va bien ^_^ Allumage de la LED d'etat.
  69. gpio -g write 18 0
  70. echo
  71. echo -e "\e[42m[Tout va bien ^_^]\e[49m"
  72. echo
  73. exit