-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·68 lines (54 loc) · 2.43 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·68 lines (54 loc) · 2.43 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Save environment variables for cron jobs
declare -x > /app/nedrexdb/container_env.sh
setup_db() {
local db_type=$1
local config_file=".$db_type"_config.toml
if [[ "$LOG_LEVEL" == "INFO" || "$LOG_LEVEL" == "DEBUG" ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') | INFO | build.sh - Starting setup of $db_type DB"; fi
# Handle DB updates
if [[ "$SKIP_UPDATE" == "1" ]]; then
if [[ "$CREATE_EMBEDDINGS" == "1" ]]; then
./build.py embed-only --conf "$config_file"
else
./build.py restart-live --conf "$config_file"
fi
else
local build_args=(update --conf "$config_file")
if [[ "$FORCE_REBUILD" == "1" ]]; then
build_args+=(--rebuild)
fi
if [[ "$DOWNLOAD_ON_STARTUP" == "1" || "$FORCE_REBUILD" == "1" ]]; then
# update incl. metadata when setting download flag
if [[ "$db_type" == "licensed" ]]; then
build_args+=(--download)
# when only building open db, download flag must be set
elif [[ "$db_type" == "open" ]]; then
if [[ "$SKIP_LICENSED" == "1" ]]; then
build_args+=(--download)
else
build_args+=(--version_update .licensed_config.toml)
fi
fi
# set versions anyways when no download
else
build_args+=(--version_update true)
fi
if [[ "$CREATE_EMBEDDINGS" == "1" ]]; then
build_args+=(--create_embeddings)
fi
if [[ "$LOG_LEVEL" == "DEBUG" ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') | DEBUG | build.sh - Running build with command: ./build.py ${build_args[@]}"; fi
./build.py "${build_args[@]}"
fi
# Clean volumes if not skipped
if [[ "$SKIP_CLEAN" != "1" ]]; then
if [[ "$LOG_LEVEL" == "INFO" || "$LOG_LEVEL" == "DEBUG" ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') | INFO | build.sh -Cleaning unused nedrex volumes"; fi
./clean_volumes.sh "$db_type"
else
if [[ "$LOG_LEVEL" == "DEBUG" ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') | DEBUG | build.sh - Skipping clean"; fi
fi
if [[ "$LOG_LEVEL" == "INFO" || "$LOG_LEVEL" == "DEBUG" ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') | INFO | build.sh - Finished setup of $db_type DB"; fi
}
# Setup licensed DB if not skipped
[[ "$SKIP_LICENSED" != "1" ]] && setup_db licensed
# Setup open DB if not skipped
[[ "$SKIP_OPEN" != "1" ]] && setup_db open