Add ldap service quick setup #3
@ -2,23 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
set -eu
 | 
					set -eu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ERROR_COLOR='\033[0;31m';
 | 
					source ../utils/common.sh
 | 
				
			||||||
HIGHLIGHT_COLOR='\033[0;32m';
 | 
					 | 
				
			||||||
INPUT_COLOR='\033[0;33m';
 | 
					 | 
				
			||||||
NO_COLOR='\033[0m';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function print_highlight() {
 | 
					 | 
				
			||||||
  printf "${HIGHLIGHT_COLOR}$1${NO_COLOR}\n"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function print_error() {
 | 
					 | 
				
			||||||
  printf "${ERROR_COLOR}$1${NO_COLOR}\n"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function input() {
 | 
					 | 
				
			||||||
  read -p "$(echo -e ${INPUT_COLOR}$1 ${NO_COLOR})" $2
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
input "Specify the output path:" OUTPUT_PATH
 | 
					input "Specify the output path:" OUTPUT_PATH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -35,6 +19,8 @@ if [[ ! -e "$OUTPUT_PATH" ]]; then
 | 
				
			|||||||
  exit;
 | 
					  exit;
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rm -rvf "$OUTPUT_PATH/*"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
input "Do you have cfssl installed?(y/n): " is_cfssl_installed
 | 
					input "Do you have cfssl installed?(y/n): " is_cfssl_installed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CFSSLEXE=${OUTPUT_PATH}/cfssl
 | 
					CFSSLEXE=${OUTPUT_PATH}/cfssl
 | 
				
			||||||
@ -81,7 +67,9 @@ cd $OUTPUT_PATH
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
input "Give a name to the CA certificate: " CA_CERT_NAME
 | 
					input "Give a name to the CA certificate: " CA_CERT_NAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
${CFSSLEXE} print-defaults csr | ${CFSSLEXE} gencert -initca - | ${CFSSLJSONEXE} -bare ${CA_CERT_NAME}-ca 
 | 
					CA_CERT_NAME=${CA_CERT_NAME}-ca
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					${CFSSLEXE} print-defaults csr | ${CFSSLEXE} gencert -initca - | ${CFSSLJSONEXE} -bare ${CA_CERT_NAME} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CONFIG_CFSSL_JSON=${OUTPUT_PATH}/cfssl.json
 | 
					CONFIG_CFSSL_JSON=${OUTPUT_PATH}/cfssl.json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -100,7 +88,7 @@ input "Give a name to the certificate: " CERT_NAME
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
input "Input the hostname(example.org,127.0.0.1): " CERT_HOSTNAME
 | 
					input "Input the hostname(example.org,127.0.0.1): " CERT_HOSTNAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo '{}' | ${CFSSLEXE} gencert -ca=ldap-ca.pem -ca-key=ldap-ca-key.pem -config=${CONFIG_CFSSL_JSON} \
 | 
					echo '{}' | ${CFSSLEXE} gencert -ca=${CA_CERT_NAME}.pem -ca-key=${CA_CERT_NAME}-key.pem -config=${CONFIG_CFSSL_JSON} \
 | 
				
			||||||
    -hostname="${CERT_HOSTNAME}" - | ${CFSSLJSONEXE} -bare ${CERT_NAME}
 | 
					    -hostname="${CERT_HOSTNAME}" - | ${CFSSLJSONEXE} -bare ${CERT_NAME}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print_highlight "The custom TLS certificates are successfully generated in the path ${OUTPUT_PATH}."
 | 
					print_highlight "The custom TLS certificates are successfully generated in the path ${OUTPUT_PATH}."
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user