From f470c032d1a4ba52fd13ff2d0bb5eedd475983a3 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 28 Apr 2021 00:11:53 -0400 Subject: [PATCH] cleanup some scripts and remove older scripts --- quickstart/docker/image/darkRouter.sh | 49 -------------------- quickstart/docker/image/entryRouter.sh | 50 --------------------- quickstart/docker/image/init.sh | 39 ---------------- quickstart/local/express/express-dev-env.sh | 15 ++++--- quickstart/quickstart.md | 0 quickstart/ziti-cli-functions.sh | 7 +-- 6 files changed, 12 insertions(+), 148 deletions(-) delete mode 100755 quickstart/docker/image/darkRouter.sh delete mode 100755 quickstart/docker/image/entryRouter.sh delete mode 100755 quickstart/docker/image/init.sh create mode 100644 quickstart/quickstart.md diff --git a/quickstart/docker/image/darkRouter.sh b/quickstart/docker/image/darkRouter.sh deleted file mode 100755 index 2859ed93e..000000000 --- a/quickstart/docker/image/darkRouter.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -. ziti.env - -router_name=$(hostname) -echo "Generating a key, a server certificate and client certificate for ${router_name}" -echo ".......... Generating key for ${router_name}" -ziti pki create key --pki-root="${ZITI_PKI}" --ca-name="${intermediate_name}" --key-file="${router_name}" -echo ".......... Generating server certificate for ${router_name}" -ziti pki create server --pki-root="${ZITI_PKI}" --ca-name="${intermediate_name}" --key-file="${router_name}" --server-file="${router_name}-server" --dns "localhost" --dns "${router_name}" --ip "127.0.0.1" -echo ".......... Generating client certificate for ${router_name}" -ziti pki create client --pki-root="${ZITI_PKI}" --ca-name="${intermediate_name}" --key-file="${router_name}" --client-file="${router_name}-client" --client-name="${router_name}" -echo "Creating a file with the root CA, intermediate and the identity cert - some processes require the full chain to be supplied" -cat "${ZITI_PKI}/${intermediate_name}/certs/${router_name}-server.chain.pem" "${ZITI_PKI}/${ca_name}/certs/${ca_name}.cert" > "${ZITI_PKI}/${intermediate_name}/certs/${router_name}-full-chain.pem" - -cat > $ZITI_HOME/${router_name}.yml < "${ZITI_PKI}/${intermediate_name}/certs/${router_name}-full-chain.pem" - -cat > $ZITI_HOME/${router_name}.yml < $ZITI_HOME/${router_name}.log 2>&1 &" -ziti-router run $ZITI_HOME/${router_name}.yml diff --git a/quickstart/docker/image/init.sh b/quickstart/docker/image/init.sh deleted file mode 100755 index a20b8db7f..000000000 --- a/quickstart/docker/image/init.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -commands_to_test=(ziti ziti-router ziti-controller bash tee jq curl cat dos2unix) - -# verify all the commands required in the automation exist before trying to run the full suite -for cmd in "${commands_to_test[@]}" -do - # checking all commands are on the path before continuing... - if ! [[ -x "$(command -v ${cmd})" ]]; then - missing_requirements="${missing_requirements} * ${cmd}\n" - fi -done - -# are requirements ? if yes, stop here and help 'em out -if ! [[ "" = "${missing_requirements}" ]]; then - echo " " - echo "The commands listed below are required to be on the path for this script to function properly." - echo "Please ensure the commands listed are on the path and then try again." - printf "\n${missing_requirements}" - exit 1 -fi - -echo "All required commands are found - continuing" -echo "${missing_requirements}" - -# set a variable to the location of the script running in case it's needed -export curdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -mkdir -p $ZITI_HOME -cd $ZITI_HOME - -# create the $ZITI_HOME/identites.json file - currently REQUIRED for the fabric -cat > ${ZITI_HOME}/identities.yml </dev/null 2>&1 && pwd )" ZITI_QUICKSTART_ENVROOT="${HOME}/.ziti/quickstart" -. "${ZITI_SCRIPT_DIR}/../../ziti-cli-functions.sh" +ZITI_QUICKSTART_SCRIPT_ROOT="$(realpath "${ZITI_SCRIPT_DIR}/../../")" +. "${ZITI_QUICKSTART_SCRIPT_ROOT}/ziti-cli-functions.sh" function issueGreeting { #echo "-------------------------------------------------------------" @@ -58,10 +59,10 @@ function generateEnvFile { export ZITI_EDGE_ROUTER_RAWNAME="${ZITI_NETWORK}" export ZITI_HOME="${HOME}/.ziti/quickstart/${ZITI_NETWORK}" - export ZITI_SCRIPTS="${ZITI_SCRIPT_DIR}/.." + export ZITI_SCRIPTS="$(realpath "${ZITI_SCRIPT_DIR}/..")" export ZITI_SHARED=${ZITI_HOME} export ENV_FILE="${ZITI_HOME}/${ZITI_NETWORK}.env" - "${ZITI_SCRIPT_DIR}/../../docker/image/env.sh" + "${ZITI_QUICKSTART_SCRIPT_ROOT}/docker/image/env.sh" echo -e "environment file created and source from: $(BLUE ${ENV_FILE})" source "${ENV_FILE}" } @@ -83,6 +84,8 @@ function expressConfiguration { else nw="$1" fi + export ZITI_EDGE_ROUTER_RAWNAME="public-edge-router" + export ZITI_EDGE_ROUTER_HOSTNAME="${ZITI_EDGE_ROUTER_RAWNAME}${ZITI_DOMAIN_SUFFIX}" generateEnvFile "${nw}" #checkHostsFile getLatestZiti "yes" @@ -103,17 +106,15 @@ function expressConfiguration { unused=$(ziti edge delete service-edge-router-policy allSvcPublicRouters) unused=$(ziti edge create service-edge-router-policy allSvcPublicRouters --edge-router-roles '#public' --service-roles '#all') - export ZITI_EDGE_ROUTER_RAWNAME="public-edge-router" - export ZITI_EDGE_ROUTER_HOSTNAME="${ZITI_EDGE_ROUTER_RAWNAME}${ZITI_DOMAIN_SUFFIX}" echo "---------- Creating edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." + unused=$(ziti edge delete edge-router "${ZITI_EDGE_ROUTER_HOSTNAME}") unused=$(ziti edge create edge-router "${ZITI_EDGE_ROUTER_HOSTNAME}" -o "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" -t) sleep 1 echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." unused=$(ziti-router enroll "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" --jwt "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" &> "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.enrollment.log") echo "" sleep 1 - unused=$(ziti-router run "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_EDGE_ROUTER_HOSTNAME}.log" 2>&1 &) - + unused=$(ziti-router run "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" > "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.log" 2>&1 &) } function decideOperation { diff --git a/quickstart/quickstart.md b/quickstart/quickstart.md new file mode 100644 index 000000000..e69de29bb diff --git a/quickstart/ziti-cli-functions.sh b/quickstart/ziti-cli-functions.sh index 4f70356e5..58e456522 100644 --- a/quickstart/ziti-cli-functions.sh +++ b/quickstart/ziti-cli-functions.sh @@ -46,10 +46,11 @@ function cleanZitiController { initializeController } function generateControllerConfig { - "${ZITI_SCRIPT_DIR}/../create-controller-config.sh" + "${ZITI_QUICKSTART_SCRIPT_ROOT}/docker/image/create-controller-config.sh" } function generateEdgeRouterConfig { - "${ZITI_SCRIPT_DIR}/../create-edge-router-config.sh edge" + echo "RUNNING: ${ZITI_QUICKSTART_SCRIPT_ROOT}/docker/image/create-edge-router-config.sh" + "${ZITI_QUICKSTART_SCRIPT_ROOT}/docker/image/create-edge-router-config.sh" } function initializeController { ziti-controller edge init "${ZITI_HOME}/controller.yaml" -u "${ZITI_USER}" -p "${ZITI_PWD}" &> "${ZITI_HOME}/controller-init.log" @@ -140,7 +141,7 @@ function getLatestZiti { function generatePki { echo "Generating PKI" - . "${ZITI_SCRIPT_DIR}/../create-pki.sh" + "${ZITI_QUICKSTART_SCRIPT_ROOT}/docker/image/create-pki.sh" } function checkPrereqs {