~hacktivista/setup-decidim

d4bcbaff4eac76cee38103cc3e5f2d4678005312 — Felix Freeman 3 years ago 6551d5f
Better support asset sharing between Nginx and Decidim containers
1 files changed, 12 insertions(+), 6 deletions(-)

M decidim.sh
M decidim.sh => decidim.sh +12 -6
@@ 49,18 49,24 @@ echo "Setting bundle path to ~/.gem"
suser bundle config set "path ~/.gem"

cd /opt/$DECIDIM_INSTANCE
chown -R "$DECIDIM_INSTANCE:$DECIDIM_INSTANCE" src
if [ ! -z "$GIT_CLONE_REPO" ]; then
    echo "Cloning existing Decidim instance repo"
    suser git clone "$GIT_CLONE_REPO" src
elif [ $(suser ls -1 src 2>/dev/null | wc -l) -eq 0 ]; then
    suser git clone "$GIT_CLONE_REPO" "$DECIDIM_INSTANCE"
elif [ -z $(suser ls -1 src/public 2>/dev/null) ]; then
    echo "Installing a fresh Decidim copy"
    suser decidim "$DECIDIM_INSTANCE"
    suser mv "$DECIDIM_INSTANCE/*" src/
    sed -e "s/<%= ENV.fetch(\"DATABASE_PASSWORD\") { \"\" } %>/'\0'/" "$DECIDIM_INSTANCE/config/database.yml" > database.yml.new
    suser cat database.yml.new > "$DECIDIM_INSTANCE/config/database.yml"
    rm database.yml.new
fi

if [ -d "$DECIDIM_INSTANCE" ]; then
    suser mv "$DECIDIM_INSTANCE/public/*" src/public
    suser rmdir "$DECIDIM_INSTANCE/public"
    suser mv "$DECIDIM_INSTANCE/*" src/ 2>/dev/null
    suser mv "$DECIDIM_INSTANCE/.*" src/ 2>/dev/null
    suser rmdir "$DECIDIM_INSTANCE"
    sed -e "s/<%= ENV.fetch(\"DATABASE_PASSWORD\") { \"\" } %>/'\0'/" src/config/database.yml > database.yml.new
    suser cat database.yml.new > src/config/database.yml
    rm database.yml.new
fi

echo 'Setting up Decidim'