Re-order stack.sh 2: target dir setup

Part 2 of a series

Re-order the setup and check bits in the top portion of stack.sh to
have a logical flow with similar things done together.

No behaviour changes are intended aside from the order of execution.
Any such changes are bugs.

* Consolidate DEST dir setup
* Move rpc & database init to just before project init

Change-Id: I2af1d4ed32ec34417c04592bf94fe645bb97f831
Merge "Re-order stack.sh 2: target dir setup"