Files
zeekay 241625e7d9 rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:19 -08:00

64 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
zt_controller_cfg="${ZITI_HOME}/zt-edge-controller.yaml"
# Global Variables
ASCI_RESTORE='\033[0m'
ASCI_RED='\033[00;31m'
function RED { # Generally used for ERROR
echo "${ASCI_RED}${1-}${ASCI_RESTORE}"
}
if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="zt-edge-controller"; fi
if [[ "${ZITI_CTRL_NAME-}" == "" ]]; then export ZITI_CTRL_NAME="${ZITI_NETWORK}-controller"; fi
. "${ZITI_SCRIPTS}/zt-cli-functions.sh"
if [ ! -f "${ZITI_HOME}/access-control.init" ]; then
echo "system has not been initialized. initializing..."
setupEnvironment
persistEnvironmentValues
# don't move the sourcing of the file. yes it's duplicated but it needs to be here
. ${ZITI_HOME}/zt.env
if [ ! -f "${ZITI_HOME}/access-control.init" ]; then
setupEnvironment
persistEnvironmentValues
else
echo "system has been initialized already. just starting the process"
fi
# create pki
createPki
if [ ! -f "${zt_controller_cfg}" ]; then
echo " "
echo "${zt_controller_cfg} doesn't exist. Generating config file"
echo " "
# generates the config file for the controller
createControllerConfig
else
echo " "
echo "${zt_controller_cfg} exists. Not overwriting"
echo " "
fi
# initialize the database with the admin user:
"${ZITI_BIN_DIR}/zt" controller edge init "${ZITI_HOME}/${ZITI_CTRL_NAME}.yaml" -u "${ZITI_USER}" -p "${ZITI_PWD}"
if [[ "$?" != 0 ]]; then
echo -e "$(RED " --- There was an error while initializing the controller ---")"
exit 1
fi
else
echo "system has been initialized. starting the process."
# don't move the sourcing of the file. yes it's duplicated but it needs to be here
. ${ZITI_HOME}/zt.env
fi
echo "controller initialized. unsetting ZITI_USER/ZITI_PWD from env"
unset ZITI_USER
unset ZITI_PWD
# create a place for the internal db
mkdir -p $ZITI_HOME/db
"${ZITI_BIN_DIR}/zt" controller run ${ZITI_VERBOSE:+--verbose} "${ZITI_HOME}/${ZITI_CTRL_NAME}.yaml"