From 7c782609a1002cd2f6ec33f556e58c9af9054642 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 1 Jul 2021 17:58:08 -0500 Subject: [PATCH 1/6] Added first draft of README --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4d0120 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Bank of Skyfall, D&D Edition +## Intro +This is currently a glorified shell script that functions like an interactive CLI application and uses a PostgreSQL database. + +Let's get a couple things, that I know I am going to hear, out of the way first: +#### Will you make a MySQL version? +No. +#### You should use SQLite. Postgres is way overkill for something like this. +Yes. It is. A SQLite version is planned, but I *like* Postgres, so that's what I chose to write for first. +#### Can you set up multiple banks? +Not very easily with this early version, but that will be a thing later on. + +## Setup +First, set up your Postgres DB that you intend to use. I recommend using UNICODE in case a player character insists on using diacritics, or of course, if your native language requires it. I use these options: + +```sh +# Yes, I know some of these options are redundant, but I never remember which ones, it doesn't hurt, and DERPA is easy to remember. +# Please note that your DB password, like is often required, will be stored as plain text in the configuration file. DO NOT RE-USE YOUR PASSWORDS, especially here. +createuser -DERPA [your_user] +createdb -E UNICODE -O [your_user] dnd_bank +``` + +Next, import the table structure included in this repo for a blank bank: +```sh +psql -h [db_host] -p [db_port] -U [your_user] -d [db_name] < dnd_bank.psql +``` + +Finally, set up your configuration file. (This step will be unnecessary via a guided configuration that will be included in a future update) +```sh +cp .dndbank.conf ~/ +vim ~/.dndbank.conf +# Fill out the information +``` + +Now just run the `bank` script and create some accounts. You are good to go! + From b51fc75963584a82a496ab46c6c01901c9d130de Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 1 Jul 2021 18:01:27 -0500 Subject: [PATCH 2/6] Fixed source file name for dndbank.conf --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4d0120..59fca06 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ psql -h [db_host] -p [db_port] -U [your_user] -d [db_name] < dnd_bank.psql Finally, set up your configuration file. (This step will be unnecessary via a guided configuration that will be included in a future update) ```sh -cp .dndbank.conf ~/ +cp [repo_location]/dndbank.conf ~/ vim ~/.dndbank.conf # Fill out the information ``` From f7d8db5eb363cf6be66b5b50b552d7b3d6552cb4 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 1 Jul 2021 18:01:53 -0500 Subject: [PATCH 3/6] Added basic config file --- dndbank.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 dndbank.conf diff --git a/dndbank.conf b/dndbank.conf new file mode 100644 index 0000000..d7a956a --- /dev/null +++ b/dndbank.conf @@ -0,0 +1,12 @@ +# Configure these: + +DB_HOST=localhost +DB_PORT=5432 +DB_USER=testy.mcgee +DB_PASS=12345 +DB_NAME=dnd_bank + + +# DO NOT TOUCH: +export PGPASSWORD=$DB_PASS + From ff1bf6d7e64fa596312110ce9d56dee0010bbec9 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 1 Jul 2021 18:03:21 -0500 Subject: [PATCH 4/6] Removed Intro header -- Redundant --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 59fca06..2f5655b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Bank of Skyfall, D&D Edition -## Intro This is currently a glorified shell script that functions like an interactive CLI application and uses a PostgreSQL database. Let's get a couple things, that I know I am going to hear, out of the way first: From 7ff8c35d9af23d07b68716a04ea90fde6e87d013 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 1 Jul 2021 18:11:35 -0500 Subject: [PATCH 5/6] Added line breaks in long 'code' section comments --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f5655b..b834c51 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,12 @@ Not very easily with this early version, but that will be a thing later on. First, set up your Postgres DB that you intend to use. I recommend using UNICODE in case a player character insists on using diacritics, or of course, if your native language requires it. I use these options: ```sh -# Yes, I know some of these options are redundant, but I never remember which ones, it doesn't hurt, and DERPA is easy to remember. -# Please note that your DB password, like is often required, will be stored as plain text in the configuration file. DO NOT RE-USE YOUR PASSWORDS, especially here. +# Yes, I know some of these options are redundant, but I never +# remember which ones, it doesn't hurt, and DERPA is easy to remember. +# Please note that your DB password, like is often required, will be +# stored as plain text in the configuration file. +#### DO NOT RE-USE YOUR PASSWORDS, especially here. #### + createuser -DERPA [your_user] createdb -E UNICODE -O [your_user] dnd_bank ``` From 7524f4d30afbfed15850f544e63c7c16e33f6f62 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Thu, 8 Jul 2021 03:42:27 -0500 Subject: [PATCH 6/6] Fixed POSIX compliance issue with 'test' command --- bank | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bank b/bank index 5580aad..48d6194 100755 --- a/bank +++ b/bank @@ -22,7 +22,7 @@ hold_menu() { } show_menu() { - #[ "$1" == "init" ] || pre_menu + #[ "$1" = "init" ] || pre_menu printf 'Select a function by number: 1. Create Account @@ -104,7 +104,7 @@ get_name() { NAME=$(eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE id = $1;\"" | grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}" | awk -F '|' '{print $2}') NAME=${NAME#"${NAME%%[! ]*}"} NAME=${NAME%"${NAME##*[! ]}"} #Strip leading/trailing space from $NAME - if [ "$2" == "bold" ]; then + if [ "$2" = "bold" ]; then echo $(tput bold)${NAME}$(tput sgr0) else echo $NAME @@ -113,7 +113,7 @@ get_name() { create_account() { read -p "Enter Account Name ('c' to cancel): " name - ([ "$name" == "c" ] || [ "$name" == "c" ]) && return + ([ "$name" = "c" ] || [ "$name" = "c" ]) && return tstamp=$(date +%Y-%m-%d\ %H:%M:%S) read -p "Creating account: '${name}'. Are you sure? (y/N)" -n1 CONFIRM case $CONFIRM in @@ -134,7 +134,7 @@ create_account() { disable_account() { eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = true ORDER BY name;\"" read -p "Enter Account ID ('c' to cancel): " ID - ([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return + ([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return read -p "$(tput bold)$(tput setaf 3)DISABLING$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM case $CONFIRM in [Yy]) @@ -154,7 +154,7 @@ enable_account() { echo "DISABLED Accounts:" eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = false ORDER BY name;\"" read -p "Enter Account ID ('c' to cancel): " ID - ([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return + ([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return read -p "$(tput bold)Enabling$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM case $CONFIRM in [Yy]) @@ -173,7 +173,7 @@ enable_account() { make_deposit() { eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true ORDER BY name;\"" read -p "Enter Account ID ('c' to cancel): " ID - ([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return + ([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return read -p "Enter amount of gp to deposit: " amount tstamp=$(date +%Y-%m-%d\ %H:%M:%S) read -p "Depositing ${amount}gp into account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM @@ -197,7 +197,7 @@ make_deposit() { make_withdrawal() { eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\"" #Show balances first read -p "Enter Account ID ('c' to cancel): " ID - ([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return + ([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return read -p "Enter amount of gp to withdraw: " amount tstamp=$(date +%Y-%m-%d\ %H:%M:%S) read -p "Withdrawing ${amount}gp from account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM