Repository: citahub/cita (language: rust)

Issue:
Why data dir is binding to CITA bin dir?
```
# which cita
/opt/cita-run/cita_secp256k1_sha3/bin/cita
```

```
# pwd
/data
root@cita_node:/data# ls -d1 /data/test-chain/0/
/data/test-chain/0/

root@cita_node:/data# cita bebop setup test-chain/0
No such node directory: test-chain/0
```

this behave was all right in CITA v0.20.x (using `cita setup test-chain/0`).

account to the source code:
https://github.com/cryptape/cita/blob/develop/scripts/cita.sh#L35

I found that

```
NODE_PATH="$(dirname "$CITA_BIN")/${NODE_NAME}"
```

https://github.com/cryptape/cita/blob/develop/scripts/cita.sh#L400:L403

```
# Make sure the node directory exists
if [ ! -d "${NODE_PATH}" ]; then
    echo "No such node directory: ${NODE_NAME}"
    exit 1

```

Why data dir is MUST binding to bin dir? 
This is quite incomprehensible since bin/data/config/log dir should be able to be separated then we can update the bin without touching the data,config or log dir.


here is a quick fix:

```
NODE_PATH="$(realpath ${NODE_NAME})"
```





Discussion / hints:
> Why data dir is MUST binding to bin dir?

Indeed not a must-have.
> > Why data dir is MUST binding to bin dir?
> 
> Indeed not a must-have.

Did you find any quality software requiring you bind your data dir to the bin dir? Most software just asking you to put bin  file to the /bin dir and tell it where to load the data.

let's take mysql install script for example: 

```
# ref: https://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html
shell> scripts/mysql_install_db --user=mysql \
         --basedir=/opt/mysql/mysql \
         --datadir=/opt/mysql/mysql/data
```

it's allowing you to put basedir dir and datadir in different dirs.

And as I mentioned, this is a breaking feature, since it's working in 0.20, but failed in 0.24
I have to do a tricky hacking in a init script to bypass this issue: 
https://github.com/cryptape/cita-monitor/pull/113/files#diff-6776bb1094bf36cefc10df7e2457bbb5R70

Sorry about that. We'll fix it as soon as possible.

#564

Fix patch:
diff --git a/scripts/cita.sh b/scripts/cita.sh
index feb72cb52..05bcbadc0 100755
--- a/scripts/cita.sh
+++ b/scripts/cita.sh
@@ -32,7 +32,7 @@ SERVICES=( forever auth bft chain executor jsonrpc network )
 SCRIPT=$(basename "$0")
 COMMAND=$1
 NODE_NAME=$2
-NODE_PATH="$(dirname "$CITA_BIN")/${NODE_NAME}"
+NODE_PATH=$(realpath "${NODE_NAME}")
 NODE_LOGS_DIR="${NODE_PATH}/logs"
 NODE_DATA_DIR="${NODE_PATH}/data"
 TNODE=$(echo "${NODE_NAME}" | sed 's/\//%2f/g')


Test patch: