#!/bin/bash

. /usr/lib/eole/diagnose.sh

TestFreeSpace(){
    cwd="${1}"
    printf ".  %${len_pf}s => " "Espace sur $cwd"
    if [ ! -d "$cwd" ];then
        EchoRouge "répertoire introuvable"
        return
    fi
    freespace=$(df -h -BG "$cwd" |tail -n1 |awk '{print $4}')
    #Remove all from . or , to end. Keep only INT part
    freespace=`echo $freespace|sed 's/\(.*\)[,.G].*/\1/'`
    if [ ${freespace} -gt 50 ];then
        EchoVert "${freespace}Go"
    elif [ ${freespace} -gt 20 ];then
        EchoOrange "${freespace}Go"
    else
        EchoRouge "${freespace}Go"
    fi
}

EchoGras "*** FOG services"
TestService "Serveur FTP (VSFTP)" "$(CreoleGet adresse_ip_eth0):21"
TestUDP TFTP 69
TestHTTPPage "Interface web" "http://$(CreoleGet web_url)/fog/index.html"
TestFreeSpace /images
echo
