@@ -39,7 +39,7 @@ WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/
3939
4040script_option_debug=' true'
4141accepted_terms=' false'
42- local_ip =' '
42+ local_ip_address =' '
4343
4444# ##################################################################################################################################################################################################
4545# #
@@ -98,6 +98,16 @@ check_is_debug_mode(){
9898 fi
9999}
100100
101+ generateRandomPass () {
102+ local length=" ${1:- 32} " # Default to 32
103+ local password
104+
105+ # Generate random password using /dev/urandom
106+ password=$( tr -dc ' A-Za-z0-9!@#$%^&*()_+=-' < /dev/urandom | head -c " $length " )
107+
108+ echo " $password "
109+ }
110+
101111ensure_docker_installed () {
102112 if ! command -v docker & > /dev/null; then
103113 echo -e " ${YELLOW} #${RESET} Docker not found. Installing Docker...\\ n"
@@ -235,6 +245,22 @@ download_management_compose_file() {
235245 exit 1
236246 fi
237247 echo -e " ${GREEN} #${RESET} Docker compose file downloaded successfully to $compose_file_path .\\ n"
248+
249+ local app_key=$( generateRandomPass 32)
250+ local db_root_password=$( generateRandomPass 16)
251+ local db_user_password=$( generateRandomPass 16)
252+
253+ # Inject dynamic env values into the compose file
254+ echo -e " ${YELLOW} #${RESET} Configuring docker-compose file env variables...\\ n"
255+ sed -i " s|HOST=replaceme|HOST=${local_ip_address} |g" " $compose_file_path "
256+ sed -i " s|URL=replaceme|URL=http://${local_ip_address} :8080|g" " $compose_file_path "
257+ sed -i " s|APP_KEY=replaceme|APP_KEY=${app_key} |g" " $compose_file_path "
258+
259+ sed -i " s|DB_PASSWORD=replaceme|DB_PASSWORD=${db_user_password} |g" " $compose_file_path "
260+ sed -i " s|MYSQL_ROOT_PASSWORD=replaceme|MYSQL_ROOT_PASSWORD=${db_root_password} |g" " $compose_file_path "
261+ sed -i " s|MYSQL_PASSWORD=replaceme|MYSQL_PASSWORD=${db_user_password} |g" " $compose_file_path "
262+
263+ echo -e " ${GREEN} #${RESET} Docker compose file configured successfully.\\ n"
238264}
239265
240266download_wait_for_it_script () {
@@ -300,7 +326,7 @@ get_local_ip() {
300326 local_ip_address=$( hostname -I | awk ' {print $1}' )
301327 if [[ -z " $local_ip_address " ]]; then
302328 echo -e " ${RED} #${RESET} Unable to determine local IP address. Please check your network configuration."
303- # Don't exit if we can't determine the local IP address, it's not critical for the installation
329+ exit 1
304330 fi
305331}
306332
@@ -328,13 +354,13 @@ check_is_debug_mode
328354get_install_confirmation
329355accept_terms
330356ensure_docker_installed
357+ get_local_ip
331358create_nomad_directory
332359download_wait_for_it_script
333360download_entrypoint_script
334361download_helper_scripts
335362download_management_compose_file
336363start_management_containers
337- get_local_ip
338364success_message
339365
340366# free_space_check() {
0 commit comments