Skip to content

Commit 1028352

Browse files
committed
fix(Scripts): log dir creation improvements during install
1 parent f17a104 commit 1028352

File tree

1 file changed

+21
-37
lines changed

1 file changed

+21
-37
lines changed

install/install_nomad.sh

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ GREEN='\033[1;32m' # Light Green.
2929
###################################################################################################################################################################################################
3030

3131
WHIPTAIL_TITLE="Project N.O.M.A.D Installation"
32+
NOMAD_DIR="/opt/project-nomad"
3233
MANAGEMENT_COMPOSE_FILE_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/management_compose.yaml"
3334
ENTRYPOINT_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/entrypoint.sh"
3435
START_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/start_nomad.sh"
@@ -37,8 +38,6 @@ UPDATE_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project
3738
WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"
3839

3940
script_option_debug='true'
40-
install_actions=''
41-
nomad_dir="/opt/project-nomad"
4241
accepted_terms='false'
4342
local_ip=''
4443

@@ -208,41 +207,27 @@ accept_terms() {
208207
esac
209208
}
210209

211-
get_install_directory() {
212-
# Prompt user for installation directory
213-
nomad_dir=$(whiptail --title "$WHIPTAIL_TITLE" --inputbox "Enter the installation directory for Project N.O.M.A.D. (default: /opt/project-nomad):" 10 60 "$nomad_dir" 3>&1 1>&2 2>&3)
214-
215-
if [[ $? -ne 0 ]]; then
216-
echo -e "${RED}#${RESET} Installation cancelled by user."
217-
exit 1
218-
fi
219-
220-
# Validate the directory
221-
if [[ ! -d "$nomad_dir" ]]; then
222-
echo -e "${YELLOW}#${RESET} Directory $nomad_dir does not exist. It will be attempted to be created during the installation process.\\n"
223-
fi
224-
}
225-
226210
create_nomad_directory(){
227-
if [[ ! -d "$nomad_dir" ]]; then
228-
echo -e "${YELLOW}#${RESET} Creating directory for Project N.O.M.A.D at $nomad_dir...\\n"
229-
sudo mkdir -p "$nomad_dir"
230-
sudo chown "$(whoami):$(whoami)" "$nomad_dir"
231-
232-
# Also ensure the directory has a /storage/logs/ subdirectory
233-
sudo mkdir -p "${nomad_dir}/storage/logs"
234-
235-
# Create a admin.log file in the logs directory
236-
sudo touch "${nomad_dir}/storage/logs/admin.log"
211+
# Ensure the main installation directory exists
212+
if [[ ! -d "$NOMAD_DIR" ]]; then
213+
echo -e "${YELLOW}#${RESET} Creating directory for Project N.O.M.A.D at $NOMAD_DIR...\\n"
214+
sudo mkdir -p "$NOMAD_DIR"
215+
sudo chown "$(whoami):$(whoami)" "$NOMAD_DIR"
237216

238217
echo -e "${GREEN}#${RESET} Directory created successfully.\\n"
239218
else
240-
echo -e "${GREEN}#${RESET} Directory $nomad_dir already exists.\\n"
219+
echo -e "${GREEN}#${RESET} Directory $NOMAD_DIR already exists.\\n"
241220
fi
221+
222+
# Also ensure the directory has a /storage/logs/ subdirectory
223+
sudo mkdir -p "${NOMAD_DIR}/storage/logs"
224+
225+
# Create a admin.log file in the logs directory
226+
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
242227
}
243228

244229
download_management_compose_file() {
245-
local compose_file_path="${nomad_dir}/docker-compose-management.yml"
230+
local compose_file_path="${NOMAD_DIR}/docker-compose-management.yml"
246231

247232
echo -e "${YELLOW}#${RESET} Downloading docker-compose file for management...\\n"
248233
if ! curl -fsSL "$MANAGEMENT_COMPOSE_FILE_URL" -o "$compose_file_path"; then
@@ -253,7 +238,7 @@ download_management_compose_file() {
253238
}
254239

255240
download_wait_for_it_script() {
256-
local wait_for_it_script_path="${nomad_dir}/wait-for-it.sh"
241+
local wait_for_it_script_path="${NOMAD_DIR}/wait-for-it.sh"
257242

258243
echo -e "${YELLOW}#${RESET} Downloading wait-for-it script...\\n"
259244
if ! curl -fsSL "$WAIT_FOR_IT_SCRIPT_URL" -o "$wait_for_it_script_path"; then
@@ -265,7 +250,7 @@ download_wait_for_it_script() {
265250
}
266251

267252
download_entrypoint_script() {
268-
local entrypoint_script_path="${nomad_dir}/entrypoint.sh"
253+
local entrypoint_script_path="${NOMAD_DIR}/entrypoint.sh"
269254

270255
echo -e "${YELLOW}#${RESET} Downloading entrypoint script...\\n"
271256
if ! curl -fsSL "$ENTRYPOINT_SCRIPT_URL" -o "$entrypoint_script_path"; then
@@ -277,9 +262,9 @@ download_entrypoint_script() {
277262
}
278263

279264
download_helper_scripts() {
280-
local start_script_path="${nomad_dir}/start_nomad.sh"
281-
local stop_script_path="${nomad_dir}/stop_nomad.sh"
282-
local update_script_path="${nomad_dir}/update_nomad.sh"
265+
local start_script_path="${NOMAD_DIR}/start_nomad.sh"
266+
local stop_script_path="${NOMAD_DIR}/stop_nomad.sh"
267+
local update_script_path="${NOMAD_DIR}/update_nomad.sh"
283268

284269
echo -e "${YELLOW}#${RESET} Downloading helper scripts...\\n"
285270
if ! curl -fsSL "$START_SCRIPT_URL" -o "$start_script_path"; then
@@ -304,7 +289,7 @@ download_helper_scripts() {
304289

305290
start_management_containers() {
306291
echo -e "${YELLOW}#${RESET} Starting management containers using docker compose...\\n"
307-
if ! sudo docker compose -f "${nomad_dir}/docker-compose-management.yml" up -d; then
292+
if ! sudo docker compose -f "${NOMAD_DIR}/docker-compose-management.yml" up -d; then
308293
echo -e "${RED}#${RESET} Failed to start management containers. Please check the logs and try again."
309294
exit 1
310295
fi
@@ -322,7 +307,7 @@ get_local_ip() {
322307
success_message() {
323308
echo -e "${GREEN}#${RESET} Project N.O.M.A.D installation completed successfully!\\n"
324309
echo -e "${GREEN}#${RESET} Installation files are located at /opt/project-nomad\\n\n"
325-
echo -e "${GREEN}#${RESET} Project N.O.M.A.D's Command Center should automatically start whenever your device reboots. However, if you need to start it manually, you can always do so by running: ${WHITE_R}${nomad_dir}/start_nomad.sh${RESET}\\n"
310+
echo -e "${GREEN}#${RESET} Project N.O.M.A.D's Command Center should automatically start whenever your device reboots. However, if you need to start it manually, you can always do so by running: ${WHITE_R}${NOMAD_DIR}/start_nomad.sh${RESET}\\n"
326311
echo -e "${GREEN}#${RESET} You can now access the management interface at http://localhost:8080 or http://${local_ip_address}:8080\\n"
327312
echo -e "${GREEN}#${RESET} Thank you for supporting Project N.O.M.A.D!\\n"
328313
}
@@ -343,7 +328,6 @@ check_is_debug_mode
343328
get_install_confirmation
344329
accept_terms
345330
ensure_docker_installed
346-
#get_install_directory
347331
create_nomad_directory
348332
download_wait_for_it_script
349333
download_entrypoint_script

0 commit comments

Comments
 (0)