-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathm_15_directories.sh
executable file
·51 lines (40 loc) · 1.81 KB
/
m_15_directories.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
############################################################
# Creates a new directory and grants access to it
############################################################
function create_directory() {
if [[ "$#" -eq 0 ]]; then
exit_with_error "Missing directory path to create. Please use function like create_directory path_to_directory"
fi
local dir_to_create=$1
[[ -d "${dir_to_create}" ]] && return
run_a_script "mkdir -p ${dir_to_create}" --disable_log
run_a_script "chmod -R 777 ${dir_to_create}" --disable_log
run_a_script "chown -R ${USER:-$(id -un)} ${dir_to_create}" --disable_log
}
function _setup_initial_directories() {
create_directory "${SPACEFX_DIR}/bin"
create_directory "${SPACEFX_DIR}/logs"
create_directory "${SPACEFX_DIR}/plugins"
create_directory "${SPACEFX_DIR}/tmp"
create_directory "${SPACEFX_DIR}/tmp/yamls"
create_directory "${SPACEFX_DIR}/xfer"
if [[ ! -L "${SPACEFX_DIR}/scripts/deploy/deploy_spacefx.sh" ]]; then
ln -s "${SPACEFX_DIR}/scripts/deploy_spacefx.sh" "${SPACEFX_DIR}/scripts/deploy/deploy_spacefx.sh"
fi
if [[ ! -L "${SPACEFX_DIR}/scripts/stage/stage_spacefx.sh" ]]; then
ln -s "${SPACEFX_DIR}/scripts/stage_spacefx.sh" "${SPACEFX_DIR}/scripts/stage/stage_spacefx.sh"
fi
}
############################################################
# Helper function to check if a file exists
############################################################
function _check_for_file(){
local file_location=$1
info_log "Checking for ${file_location}..."
if [[ -f "${file_location}" ]]; then
info_log "...found '${file_location}'"
else
exit_with_error "Missing '${file_location}'. Please run applicable staging script and re-deploy env-config to this machine, then rerun deploy"
fi
}