From 36b42e210750e0972766eb95ebcce2e7cd689ea6 Mon Sep 17 00:00:00 2001 From: chamunks Date: Sat, 2 Jun 2018 18:46:51 -0400 Subject: [PATCH] major rewrite of docker-entrypoint Original entrypoint was basically a placeholder for me anyways. I need to add a few functions for configuration and then start testing. --- www.spee.ch/docker-entrypoint.sh | 52 ++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/www.spee.ch/docker-entrypoint.sh b/www.spee.ch/docker-entrypoint.sh index 7c86e93..5c8c2af 100755 --- a/www.spee.ch/docker-entrypoint.sh +++ b/www.spee.ch/docker-entrypoint.sh @@ -13,30 +13,44 @@ else exit 1 fi -# if Spee.ch is not yet installed, copy it into web root. -# This could be updated to be part of an upgrade mechanism. -if [ ! -e '/app/config/siteConfig.json' ]; then - echof warn "Spee.ch doesn't appear to have a configuration." - echof blank "Don't worry we can install it for you." - if [ "$(ls -A /app)" ]; then - echof warn "/app is not Empty. It contains:" 1>&2 - ls -A 1>&2 - echof info "Making an attempt to nicely merge files using:" - echof run "mv -fnu /usr/local/src/www.spee.ch/* /app/" - mv -fnu /usr/local/src/www.spee.ch/* /app/ - else - echof run "mv /usr/local/src/www.spee.ch/* /app/" - mv /usr/local/src/www.spee.ch/* /app/ - fi - echo "Spee.ch installed into /app" - ## Finally reassert permissions in case there is user added drift. - rddo "test_for_dir" '775 "speech:speech"' - rfdo "test_for_file" '665 "speech:speech"' +function configure_speech() { + # install configuration changes here. + echof info "At some point there will be code here." +} +function final_permset() { + ## Finally reassert permissions in case there is user added drift. + rddo /app "test_for_dir" '775 "speech:speech"' + rfdo /app "test_for_file" '665 "speech:speech"' ## Define any permission exceptions here. # test_for_dir /app/config 775 "speech:speech" # test_for_file /app/config/siteConfig.json 665 "speech:speech" echof info "Copied Spee.ch and set permissions" +} + +# if Spee.ch is not yet installed, copy it into web root. +# This could be updated to be part of an upgrade mechanism. +if [ "$(ls -A /app)" ]; then + echof warn "/app is not Empty. It contains:" 1>&2 + ls -A 1>&2 + if [ ! -e '/app/config/siteConfig.json' ]; then + echof warn "Spee.ch doesn't appear to have a configuration." + echof blank "Don't worry we can install it for you." + configure_speech + else + ## + echof info "Spee.ch config already installed skipping configuration step." + final_permset + fi + echof info "Making an attempt to nicely merge files using:" + echof run "mv -fnu /usr/local/src/www.spee.ch/* /app/" + mv -fnu /usr/local/src/www.spee.ch/* /app/ +else + echof info "Speech wasn't installed, installing fresh copy now." + configure_speech + echof run "mv /usr/local/src/www.spee.ch/* /app/" + mv /usr/local/src/www.spee.ch/* /app/ + final_permset fi echof run 'test_for_dir /app/config/siteConfig.json 775 "speech:speech"'