diff --git a/repos/jekyll/copy/all/usr/local/bin/install-depends b/repos/jekyll/copy/all/usr/local/bin/install-depends new file mode 100755 index 0000000..fadf5fd --- /dev/null +++ b/repos/jekyll/copy/all/usr/local/bin/install-depends @@ -0,0 +1,23 @@ +#!/bin/bash +[ "$JEKYLL_DEBUG" = "true" ] && set -x +set -e + +if [ ! -f /updated ]; then + apk update + apk add build-base ruby-dev + touch /updated + + if [ -f ".apk" ] && [ "$CONNECTED" = "true" ] + then apk --update add $( + cat .apk + ) + fi +fi + +BUNDLE_ARGS="--jobs=1" +if [ -f Gemfile ]; then + [ "$BUNDLE_CACHE" = "true" ] && BUNDLE_ARGS="--jobs=1 --path=vendor/bundle" + bundle check > /dev/null 2>&1 || sudo -EHu jekyll bundle install $BUNDLE_ARGS + cp -a Gemfile.lock /tmp/Gemfile.lock.offline + cp -a Gemfile /tmp/Gemfile.offline +fi diff --git a/repos/jekyll/copy/all/usr/local/bin/jekyll b/repos/jekyll/copy/all/usr/local/bin/jekyll index c373784..1878a98 100755 --- a/repos/jekyll/copy/all/usr/local/bin/jekyll +++ b/repos/jekyll/copy/all/usr/local/bin/jekyll @@ -3,9 +3,9 @@ set -e if [ -z "$CONNECTED" ]; then - CONNECTED=true + export CONNECTED=true wget -qs https://google.com >/dev/null || \ - CONNECTED=false + export CONNECTED=false fi finish() { @@ -39,25 +39,7 @@ rm -rf .bundle status=0 if [ "$CONNECTED" = "true" ]; then - if [ ! -f /updated ]; then - apk update - apk add build-base ruby-dev - touch /updated - - if [ -f ".apk" ] && [ "$CONNECTED" = "true" ] - then apk --update add $( - cat .apk - ) - fi - fi - - BUNDLE_ARGS="--jobs=1" - if [ -f Gemfile ]; then - [ "$BUNDLE_CACHE" = "true" ] && BUNDLE_ARGS="--jobs=1 --path=vendor/bundle" - bundle check > /dev/null 2>&1 || sudo -EHu jekyll bundle install $BUNDLE_ARGS - cp -a Gemfile.lock /tmp/Gemfile.lock.offline - cp -a Gemfile /tmp/Gemfile.offline - fi + /usr/local/bin/install-depends else if [ -f "/tmp/Gemfile.offline" ]; then cp -a /tmp/Gemfile.offline Gemfile