|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# desc# reset local sandbox in one of several configs |
| 4 | + |
| 5 | +function usage { |
| 6 | + echo "usage: |
| 7 | +
|
| 8 | + `basename $0` --unified-cfg-file |
| 9 | + `basename $0` --store-cfg-in-mongo [--init-with-unified <cfgName>] |
| 10 | +
|
| 11 | + Setup sandbox configuration for any number of scenarios. Following the execution |
| 12 | + of this script, you will need to quit your shells and fire up new ones. |
| 13 | +
|
| 14 | + The order options are specified on the command line matters. The most significant, |
| 15 | + list in the usage statuements above, needs to be first. |
| 16 | +
|
| 17 | + --unified-cfg-file |
| 18 | + Remove any sandbox options which will setup for use with the config files deployed |
| 19 | + via 'dt-update-secrets'. The config will be loaded from a file. It will not be |
| 20 | + stored in mongo. |
| 21 | +
|
| 22 | + This will set the CSSVC_CFG_FILE variable according to the unified config process: |
| 23 | + https://github.com/TeamCodeStream/codestream-server/blob/develop/api_server/docs/unified-cfg-file.md |
| 24 | +
|
| 25 | + --store-cfg-in-mongo [--init-with-unified <cfgName>] |
| 26 | + Store config in mongo initialized with open-development.json (most basic config). This will |
| 27 | + set the CSSVC_CFG_URL env variable to your local mongo codestream database. When starting |
| 28 | + the api with an empty database, it will initially load a config based on the additional |
| 29 | + args. |
| 30 | +
|
| 31 | + The default (no additional args) is to initialize it from api_server/etc/configs/open-development.json. |
| 32 | + --init-with-unified will find the named config file (eg. onprem-development, codestream-cloud, |
| 33 | + onprem-development-custom, ...) that matches the repos' schema version and use that. |
| 34 | +" |
| 35 | + exit 1 |
| 36 | +} |
| 37 | + |
| 38 | +function store_cfg_in_mongo { |
| 39 | + echo "CSSVC_CFG_URL=mongodb://localhost/codestream" >$CSBE_SANDBOX/sb.options |
| 40 | + [ "$1" == "--init-with-unified" -a -n "$2" ] && echo "CSSVC_CONFIGURATION=$2" >>$CSBE_SANDBOX/sb.options |
| 41 | + echo "Sandbox options:" |
| 42 | + cat $CSBE_SANDBOX/sb.options |
| 43 | +} |
| 44 | + |
| 45 | +[ "$CSBE_ENV" != "local" ] && echo "This script only works for mono-repo local development" && exit 1 |
| 46 | +[ -z "$1" ] && usage |
| 47 | + |
| 48 | +while [ "$#" -gt 0 ]; do |
| 49 | + case "$1" in |
| 50 | + --unified-cfg-file) { [ -f $CSBE_SANDBOX/sb.options ] && rm -f $CSBE_SANDBOX/sb.options; }; echo "$CSBE_SANDBOX/sb.options removed"; exit;; |
| 51 | + --store-cfg-in-mongo) shift; store_cfg_in_mongo "$@"; exit;; |
| 52 | + *) usage;; |
| 53 | + esac |
| 54 | +done |
0 commit comments