diff --git a/scripts/setup_wizard.sh b/scripts/setup_wizard.sh index fd35ad5..d38ae6c 100755 --- a/scripts/setup_wizard.sh +++ b/scripts/setup_wizard.sh @@ -124,9 +124,6 @@ echo "-----------------------------" # Verify required external binaries if ! command -v step >/dev/null 2>&1; then - echo "" >&2 - log_error "Required binary 'step' not found in PATH." - # Prompt the user to install the step CLI get_input "INSTALL_STEP" "The 'step' CLI was not found. Install now? (y/n)" "y" "false" @@ -148,24 +145,33 @@ fi # 1. Collect Inputs # Example: get_input "CERT_DIR" "Enter directory for certificates" "/var/lib/tls" "false" -get_input "CERT_LOCATION" "Name for cert file" "cert.pem" "false" -get_input "KEY_LOCATION" "Name for private key" "key.pem" "false" +get_input "CERT_FILENAME" "Name for cert file" "cert.pem" "false" +get_input "KEY_FILENAME" "Name for private key" "key.pem" "false" -export CERT_LOCATION=$(readlink -f ${CERT_DIR}/$CERT_LOCATION) -export KEY_LOCATION=$(readlink -f ${CERT_DIR}/$KEY_LOCATION) +# These need to get set so that they get filled into the service correctly. +export CERT_LOCATION=$(readlink -f ${CERT_DIR}/$CERT_FILENAME) +export KEY_LOCATION=$(readlink -f ${CERT_DIR}/$KEY_FILENAME) # 2. Confirm confirm_inputs "CERT_LOCATION" "KEY_LOCATION" -if [ ! -f "$CERT_LOCATION" ] || [ ! -f "$KEY_LOCATION" ]; then +if [ ! -e "$CERT_DIR" ]; then (umask 077; mkdir -p "${CERT_DIR}") + log_info "Created ${CERT_DIR}" +fi + +if [ ! -e "${CERT_DIR}/root_ca.crt" ]; then step ca root "${CERT_DIR}/root_ca.crt" +fi + +if [ ! -f "$CERT_LOCATION" ] || [ ! -f "$KEY_LOCATION" ]; then hostname=$(hostname -s) + ip_address=$(ip -4 addr show dev eth0 | awk '/inet /{print $2}' | cut -d/ -f1) step ca certificate "$hostname" \ "${CERT_DIR}/cert.pem" "${CERT_DIR}/key.pem" \ --san "$hostname" \ --san "$hostname.john-stream.com" \ - --san "$IP_ADDRESS" \ + --san "$ip_address" \ --provisioner admin fi