#!/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:.

. /etc/netflow/install.conf

if [ -f /usr/share/netflow/license.txt ]; then
  more /usr/share/netflow/license.txt
fi

echo
echo

if [ -f /netflow/install.flg ];then
  nf_installdb
  nf_installweb
  nf_installcoll
  exit 0
fi

while (( 1 ))
do
    echo "To reconfigure any part you can run script nf_install later."
    echo ""
    echo "*** MAIN MENU ***"
    echo "1. install/upgrade DB tables (only on computer where is primary database)."
    echo "2. install/upgrade web part (only on computer where is web server)."
    echo "3. install/upgrade collector (on computers where collectors will run)."
    echo "4. finish/continue."
    read -p "What is your choice (1-4):" run_id    
    echo ""
    if echo $run_id | egrep -v "^[1-4]$" &> /dev/null; then 
      run_id="0"
    fi
    if [ "$run_id" == "1" ]; then
      nf_installdb
    fi
    if [ "$run_id" == "2" ]; then
      nf_installweb
    fi
    if [ "$run_id" == "3" ]; then
      nf_installcoll
    fi
    if [ "$run_id" == "4" ]; then
      exit 0
    fi
    echo ""
    echo ""    
done
