#!/bin/bash
#
source ~/.bash_profile
#
# Vesrion 1.0 
# Script to monitor XRPI remotely from a Linux console
# Remember to do chmod +x xrpimonitor before using it.
#
# Written by VA2OM / VE2PKT September, 17 2020
# update: Now can write to sysop screen, October, 1st 2021
#
/usr/bin/clear
echo
echo
echo -e "Please enter the IP adress of the Linux Box where your XRPI is: 
         If use local just enter localhost"
read IPADD
echo -e "Please enter the name you use to connect the Linux Box: "
read USERNAME
echo -e "What is the directory of your XRPI: "
read PATH

/usr/bin/clear

function stage1 {
while true;do

echo -e "what do you like to monitor?:


    xrpimon 1 = Sysop CHAT Window
    xrpimon 2 = CHAT Monitor Window
    xrpimon 3 = Session Monitor Window
    xrpimon 4 = Nodes Monitor Window
    xrpimon 5 = Routes Monitor Window
    xrpimon 6 = Status Monitor Window
    xrpimon 7 = Security Monitor Window

             Use CTRL C to quit"

read NUMBER

     echo ""
    read -p "Ready to monitor your XRPI? (yes/no/abort) " yno
    case $yno in
        [Yy]*) stage2;;
        [Nn]*) continue;;
        [Aa]*) exit 0;;
            *) echo "Try again";;

    esac
done
}

function stage2 {

/usr/bin/ssh -q -t $USERNAME@$IPADD $PATH/xrpimon $NUMBER 

while true;do
/usr/bin/clear
    echo ""
    echo ""
    read -p "Do you want to monitor something else? " yesno
    case $yesno in
        [Yy]* ) stage1;;
        [Nn]* ) exit 0;;
        * ) echo "Try Again ";;
    esac
done

/usr/bin/clear

}
stage1

