File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
#
3
3
# Load Django application data
4
4
#
5
+ # ### SETUP ####################################################################
6
+
5
7
set -o errexit
6
8
set -o errtrace
7
9
set -o nounset
@@ -12,6 +14,8 @@ trap '_es=${?};
12
14
printf " exited with a status of ${_es}\n";
13
15
exit ${_es}' ERR
14
16
17
+ DATA_FILE=' ../cc-legal-tools-data/config/app_data.yaml'
18
+ DIR_REPO=" $( cd -P -- " ${0%/* } /.." && pwd -P) "
15
19
# https://en.wikipedia.org/wiki/ANSI_escape_code
16
20
E0=" $( printf " \e[0m" ) " # reset
17
21
E30=" $( printf " \e[30m" ) " # black foreground
@@ -20,7 +24,6 @@ E107="$(printf "\e[107m")" # bright white background
20
24
21
25
# ### FUNCTIONS ################################################################
22
26
23
-
24
27
check_docker () {
25
28
local _msg
26
29
if ! docker compose exec app true 2> /dev/null; then
@@ -30,29 +33,27 @@ check_docker() {
30
33
fi
31
34
}
32
35
33
-
34
36
error_exit () {
35
37
# Echo error message and exit with error
36
38
echo -e " ${E31} ERROR:${E0} ${* } " 1>&2
37
39
exit 1
38
40
}
39
41
40
-
41
42
print_header () {
42
43
# Print 80 character wide black on white heading with time
43
44
printf " ${E30}${E107} # %-70s$( date ' +%T' ) ${E0} \n" " ${@ } "
44
45
}
45
46
46
-
47
47
# ### MAIN #####################################################################
48
48
49
+ cd " ${DIR_REPO} "
50
+
49
51
check_docker
50
52
51
- print_header ' Load data (LegalCode and Tool models)'
52
- data_file=' ../cc-legal-tools-data/config/app_data.yaml'
53
- du -h " ${data_file} "
53
+ print_header ' Django loaddata - Import LegalCode and Tool model data'
54
+ du -h " ${DATA_FILE} "
54
55
docker compose exec app ./manage.py loaddata \
55
56
--app legal_tools \
56
57
--verbosity 3 \
57
- " ${data_file } "
58
+ " ${DATA_FILE } "
58
59
echo
You can’t perform that action at this time.
0 commit comments