diff --git a/.gitignore b/.gitignore index 7f98992..0cb49c3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ backup/ *_BuildConfig.json tmp/ +# External scripts +genesis_from_files.py + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/manage b/manage index 82291c4..348a368 100755 --- a/manage +++ b/manage @@ -82,6 +82,25 @@ usage () { $0 generateDid [seed] - Optional [seed]; if one is not provided a random one will be generated using openssl. + generateGenesisFiles - Generates pool and domain genesis files from data input via csv files. + $0 generategenesisfiles + + This is a convenience command wrapped around the Steward Tools script for generating genesis files found here; + https://github.com/sovrin-foundation/steward-tools/tree/master/create_genesis + + The script is downloaded and hosted in a running container which has the required packages installed. + + Examples of the csv files can be downloaded from here; + https://docs.google.com/spreadsheets/d/1LDduIeZp7pansd9deXeVSqGgdf0VdAHNMc7xYli3QAY/edit#gid=0 + Download each sheet separately in csv format and fill them out with the data specific to your network. + + The input csv files must be placed into the ./tmp/ folder. + The resulting output 'pool_transactions_genesis' and 'domain_transactions_genesis' files will be placed + in the ./tmp/ folder. + + Example: + $0 generategenesisfiles "./tmp/CANdy Beta Genesis File Node info - Trustees.csv" "./tmp/CANdy Beta Genesis File Node info - Stewards.csv" + indy-cli - Run Indy-Cli commands in a Indy-Cli container environment. $0 indy-cli -h @@ -459,6 +478,44 @@ function generateDid() { runCliCommand python cli-scripts/generate_did.py --seed ${seed} } +function generateGenesisFiles() { + trustee_csv="${1}" + steward_csv="${2}" + genesis_from_files_filename="genesis_from_files.py" + genesis_from_files_url="https://raw.githubusercontent.com/sovrin-foundation/steward-tools/master/create_genesis/genesis_from_files.py" + + if [ -z "${trustee_csv}" ] || [ -z "${steward_csv}" ]; then + echoYellow "You must supply both the trustee and steward csv files." + exit 1 + fi + + if [[ "${trustee_csv}" != ./tmp/* ]]; then + trustee_csv="./tmp/${trustee_csv}" + fi + + if [ ! -f "${trustee_csv}" ]; then + echoYellow "${trustee_csv} not found, please make sure you placed ${trustee_csv} in the ./tmp folder." + exit 1 + fi + + if [[ "${steward_csv}" != ./tmp/* ]]; then + steward_csv="./tmp/${steward_csv}" + fi + + if [ ! -f "${steward_csv}" ]; then + echoYellow "${steward_csv} not found, please make sure you placed ${steward_csv} in the ./tmp folder." + exit 1 + fi + + echo "Downloading the latest version of ${genesis_from_files_filename} from ${genesis_from_files_url} ..." + curl -s -L -o ./cli-scripts/${genesis_from_files_filename} ${genesis_from_files_url} + + # Escape spaces in path ... + trustee_csv_esc=$(echo ${trustee_csv##*/} | sed 's/ /\\ /g') + steward_csv_esc=$(echo ${steward_csv##*/} | sed 's/ /\\ /g') + runCliCommand cli-scripts/${genesis_from_files_filename} --pool /tmp/pool_transactions --domain /tmp/domain_transactions --trustees /tmp/${trustee_csv_esc} --stewards /tmp/${steward_csv_esc} +} + function backup() { ( _msg=$@ @@ -741,6 +798,11 @@ case "${COMMAND}" in generatedid) generateDid $@ ;; + generategenesisfiles) + trustee_csv="${1}" + steward_csv="${2}" + generateGenesisFiles "${trustee_csv}" "${steward_csv}" + ;; backup) backup "$@"