|
|
|
@ -43,20 +43,53 @@ new_account() {
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_user() {
|
|
|
|
|
ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select * from account;\""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_balance() {
|
|
|
|
|
# Bal Menu
|
|
|
|
|
clear
|
|
|
|
|
echo "1) List all users balances."
|
|
|
|
|
echo "2) List a specific user's balance."
|
|
|
|
|
echo ""
|
|
|
|
|
read -n1 -p "Select from the menu above: " ii
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
case $ii in
|
|
|
|
|
1 ) ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username from account join balance using (id);\"" ;;
|
|
|
|
|
2 ) read -p "Enter the user account name: " bal_user
|
|
|
|
|
bal_user1=$(ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username,balance from account join balance using (id);\"")
|
|
|
|
|
echo "$bal_user1" | awk 'FNR == 1 {print}'
|
|
|
|
|
echo "$bal_user1" | grep "$bal_user" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while true
|
|
|
|
|
do
|
|
|
|
|
# Menu
|
|
|
|
|
echo ""
|
|
|
|
|
echo "DDBank Menu: "
|
|
|
|
|
echo "1) Create new user account."
|
|
|
|
|
echo "2) List user accounts."
|
|
|
|
|
echo "3) List user(s) balance."
|
|
|
|
|
echo "9) Clear contents of screen"
|
|
|
|
|
echo "0) Exit"
|
|
|
|
|
echo ""
|
|
|
|
|
read -p "Select from the menu above: " i
|
|
|
|
|
if [ $i == 1 ]; then {
|
|
|
|
|
new_account
|
|
|
|
|
} else {
|
|
|
|
|
echo "Some other thing..."
|
|
|
|
|
} fi
|
|
|
|
|
read -p "Select from the menu above: " -n1 i
|
|
|
|
|
case $i in
|
|
|
|
|
1 ) new_account ;;
|
|
|
|
|
2 ) list_user ;;
|
|
|
|
|
3 ) list_balance ;;
|
|
|
|
|
9 ) clear ;;
|
|
|
|
|
0 ) exit
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
#if [ $i == 1 ]; then {
|
|
|
|
|
# new_account
|
|
|
|
|
#} else {
|
|
|
|
|
# echo "Some other thing..."
|
|
|
|
|
#} fi
|
|
|
|
|