[ SEA-GHOST MINI SHELL]

Path : /proc/2/cwd/proc/3/root/proc/3/task/3/root/proc/3/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/cwd/proc/3/root/proc/3/task/3/root/proc/3/root/var/lib/zabbix/repquota.sh

#!/bin/bash

homeFstab=$(awk '$2 ~ /\/home/ &&  $1 !~ /^#/ {print $2}' /etc/fstab)

homesNoQuota=$(repquota $homeFstab 2>&1 | grep "not found or has no quota enabled" | awk '{printf $5" "}')

noQuotaNum=$(echo "$homesNoQuota" | wc -w)

function show_help() {
  echo "Check if some home directory do not has a quota";
  echo "Usage: $SCRIPT_FILENAME [OPTION]"
  echo "OPTIONS:"
  echo "  -??        : get text messages with detail issues data"
  echo "  -h|--help : get list of possible parameters"
  echo "  -c        : get  numeric value for zabbix"
  exit 0
}

function for_zabbix() {
  if [ $noQuotaNum -ge 1 ]; then
    echo 1
  else
    echo 0
  fi
}

function general_use() {
  if [ $noQuotaNum -ge 1 ]; then
    echo "ERROR: Mountpoints (or devices) $homesNoQuota has no quota enabled."
  else
    echo "OK: Quota is enabled for all home mountpoints"
  fi
}

# === MAIN PART =================
# get command line options
while [[ $# -gt 0 ]]; do
    key="$1"
    case "$key" in
        -c)
        for_zabbix
        ;;
        -??)
        general_use
        ;;
        # Show help flag
        -h|--help)
        show_help
        ;;
        *)
        # Do whatever you want with extra options
        echo "Wrong key, please use -h for help menu"
        ;;
    esac
    shift
done


SEA-GHOST - SHELL CODING BY SEA-GHOST