mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-02 23:09:26 +02:00
feat(install): replace secrets with rand pwds and host
This commit is contained in:
parent
a557ff3ad1
commit
a8bfc083d4
|
|
@ -39,7 +39,7 @@ WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/
|
||||||
|
|
||||||
script_option_debug='true'
|
script_option_debug='true'
|
||||||
accepted_terms='false'
|
accepted_terms='false'
|
||||||
local_ip=''
|
local_ip_address=''
|
||||||
|
|
||||||
###################################################################################################################################################################################################
|
###################################################################################################################################################################################################
|
||||||
# #
|
# #
|
||||||
|
|
@ -98,6 +98,16 @@ check_is_debug_mode(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateRandomPass() {
|
||||||
|
local length="${1:-32}" # Default to 32
|
||||||
|
local password
|
||||||
|
|
||||||
|
# Generate random password using /dev/urandom
|
||||||
|
password=$(tr -dc 'A-Za-z0-9!@#$%^&*()_+=-' < /dev/urandom | head -c "$length")
|
||||||
|
|
||||||
|
echo "$password"
|
||||||
|
}
|
||||||
|
|
||||||
ensure_docker_installed() {
|
ensure_docker_installed() {
|
||||||
if ! command -v docker &> /dev/null; then
|
if ! command -v docker &> /dev/null; then
|
||||||
echo -e "${YELLOW}#${RESET} Docker not found. Installing Docker...\\n"
|
echo -e "${YELLOW}#${RESET} Docker not found. Installing Docker...\\n"
|
||||||
|
|
@ -235,6 +245,22 @@ download_management_compose_file() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo -e "${GREEN}#${RESET} Docker compose file downloaded successfully to $compose_file_path.\\n"
|
echo -e "${GREEN}#${RESET} Docker compose file downloaded successfully to $compose_file_path.\\n"
|
||||||
|
|
||||||
|
local app_key=$(generateRandomPass 32)
|
||||||
|
local db_root_password=$(generateRandomPass 16)
|
||||||
|
local db_user_password=$(generateRandomPass 16)
|
||||||
|
|
||||||
|
# Inject dynamic env values into the compose file
|
||||||
|
echo -e "${YELLOW}#${RESET} Configuring docker-compose file env variables...\\n"
|
||||||
|
sed -i "s|HOST=replaceme|HOST=${local_ip_address}|g" "$compose_file_path"
|
||||||
|
sed -i "s|URL=replaceme|URL=http://${local_ip_address}:8080|g" "$compose_file_path"
|
||||||
|
sed -i "s|APP_KEY=replaceme|APP_KEY=${app_key}|g" "$compose_file_path"
|
||||||
|
|
||||||
|
sed -i "s|DB_PASSWORD=replaceme|DB_PASSWORD=${db_user_password}|g" "$compose_file_path"
|
||||||
|
sed -i "s|MYSQL_ROOT_PASSWORD=replaceme|MYSQL_ROOT_PASSWORD=${db_root_password}|g" "$compose_file_path"
|
||||||
|
sed -i "s|MYSQL_PASSWORD=replaceme|MYSQL_PASSWORD=${db_user_password}|g" "$compose_file_path"
|
||||||
|
|
||||||
|
echo -e "${GREEN}#${RESET} Docker compose file configured successfully.\\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_wait_for_it_script() {
|
download_wait_for_it_script() {
|
||||||
|
|
@ -300,7 +326,7 @@ get_local_ip() {
|
||||||
local_ip_address=$(hostname -I | awk '{print $1}')
|
local_ip_address=$(hostname -I | awk '{print $1}')
|
||||||
if [[ -z "$local_ip_address" ]]; then
|
if [[ -z "$local_ip_address" ]]; then
|
||||||
echo -e "${RED}#${RESET} Unable to determine local IP address. Please check your network configuration."
|
echo -e "${RED}#${RESET} Unable to determine local IP address. Please check your network configuration."
|
||||||
# Don't exit if we can't determine the local IP address, it's not critical for the installation
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,13 +354,13 @@ check_is_debug_mode
|
||||||
get_install_confirmation
|
get_install_confirmation
|
||||||
accept_terms
|
accept_terms
|
||||||
ensure_docker_installed
|
ensure_docker_installed
|
||||||
|
get_local_ip
|
||||||
create_nomad_directory
|
create_nomad_directory
|
||||||
download_wait_for_it_script
|
download_wait_for_it_script
|
||||||
download_entrypoint_script
|
download_entrypoint_script
|
||||||
download_helper_scripts
|
download_helper_scripts
|
||||||
download_management_compose_file
|
download_management_compose_file
|
||||||
start_management_containers
|
start_management_containers
|
||||||
get_local_ip
|
|
||||||
success_message
|
success_message
|
||||||
|
|
||||||
# free_space_check() {
|
# free_space_check() {
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ services:
|
||||||
- PORT=8080
|
- PORT=8080
|
||||||
- LOG_LEVEL=debug
|
- LOG_LEVEL=debug
|
||||||
- DRIVE_DISK=fs
|
- DRIVE_DISK=fs
|
||||||
- APP_KEY=secretlongpasswordsecret
|
- APP_KEY=replaceme
|
||||||
- HOST=0.0.0.0
|
- HOST=replaceme
|
||||||
- URL=http://localhost:8080
|
- URL=replaceme
|
||||||
- DB_HOST=mysql
|
- DB_HOST=mysql
|
||||||
- DB_PORT=3306
|
- DB_PORT=3306
|
||||||
- DB_DATABASE=nomad
|
- DB_DATABASE=nomad
|
||||||
- DB_USER=nomad_user
|
- DB_USER=nomad_user
|
||||||
- DB_PASSWORD=nomad_password
|
- DB_PASSWORD=replaceme
|
||||||
- DB_NAME=nomad
|
- DB_NAME=nomad
|
||||||
- DB_SSL=false
|
- DB_SSL=false
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
@ -53,10 +53,10 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
- MYSQL_ROOT_PASSWORD=secretpassword
|
- MYSQL_ROOT_PASSWORD=replaceme
|
||||||
- MYSQL_DATABASE=nomad
|
- MYSQL_DATABASE=nomad
|
||||||
- MYSQL_USER=nomad_user
|
- MYSQL_USER=nomad_user
|
||||||
- MYSQL_PASSWORD=nomad_password
|
- MYSQL_PASSWORD=replaceme
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/project-nomad/mysql:/var/lib/mysql
|
- /opt/project-nomad/mysql:/var/lib/mysql
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user