Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
libre
webschlocker3
Commits
d219d421
Commit
d219d421
authored
Apr 23, 2016
by
Michał 'rysiek' Woźniak
Browse files
checking database schema version before setting it up, so that a valid db doesn't get overwritten!
parent
6f94dfb7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
entrypoint.sh
entrypoint.sh
+10
-3
No files found.
entrypoint.sh
View file @
d219d421
...
...
@@ -227,9 +227,16 @@ echo "+-- creating and setting permissions on the tmp directory '$WEBSCHLOCKER_T
mkdir
-p
"
$WEBSCHLOCKER_TMP_DIR
"
chown
-R
"
$WEBSCHLOCKER_USER
:
$WEBSCHLOCKER_GROUP
"
"
$WEBSCHLOCKER_TMP_DIR
"
# prep the database (as the correct user)
echo
"+-- setting up the database"
su
-p
-c
"env PATH=
\"
$PATH
\"
bundle exec rake db:setup RAILS_ENV=production"
"
$WEBSCHLOCKER_USER
"
# which version of the db we have?
echo
"+-- checking db schema version..."
WEBSCHLEUDER_SCHEMA_VERSION
=
"
$(
su
-p
-c
"env PATH=
\"
$PATH
\"
bundle exec rake db:version RAILS_ENV=production"
"
$WEBSCHLOCKER_USER
"
|
awk
'/^Current version:/ {print $3}'
)
"
if
[[
$WEBSCHLEUDER_SCHEMA_VERSION
>
0
]]
;
then
echo
" +-- database schema version found:
$WEBSCHLEUDER_SCHEMA_VERSION
, no need for set-up"
else
# prep the database (as the correct user)
echo
" +-- database schema not found, setting up the database"
su
-p
-c
"env PATH=
\"
$PATH
\"
bundle exec rake db:setup RAILS_ENV=production"
"
$WEBSCHLOCKER_USER
"
fi
# make sure the envvars are available within su
export
WEBSCHLOCKER_BIND_ADDRESS WEBSCHLOCKER_BIND_PORT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment