-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·56 lines (49 loc) · 1.36 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
#
# Running rootless means that we force Jekyll to run
# entirely as 'root'. This is substituted by the container
# to the uid of the actual user.
#
if [ "$JEKYLL_ROOTLESS" ]; then
JEKYLL_UID=0
JEKYLL_GID=0
fi
: ${JEKYLL_UID:=$(id -u jekyll)}
: ${JEKYLL_GID:=$(id -g jekyll)}
export JEKYLL_UID
export JEKYLL_GID
#
# Users can customize our UID's to fit their own so that
# we don't have to chown constantly. Well it's not like
# we do so much of it (anymore) it's slow, but we do
# change permissions which can result in some bad
# behavior on OS X.
#
if [ "$JEKYLL_UID" != "0" ] && [ "$JEKYLL_UID" != "$(id -u jekyll)" ]; then
usermod -o -u "$JEKYLL_UID" jekyll
groupmod -o -g "$JEKYLL_GID" jekyll
chown_args=""
[ "$FULL_CHOWN" ] && chown_args="-R"
for d in "$JEKYLL_DATA_DIR" "$JEKYLL_VAR_DIR"; do
chown $chown_args jekyll:jekyll "$d"
done
fi
#
# Make sure JEKYLL matches the UID/GID
# This will most likely end up as 1
#
if [ "$JEKYLL_ROOTLESS" ]; then
usermod -o -u $JEKYLL_UID jekyll
groupmod -o -g $JEKYLL_GID jekyll
fi
# If pwd has a Gemfile, install it and run via bundler
if [ -f "Gemfile" ]; then
>&2 echo "Installing bundle.."
bundle install
>&2 echo "Launching via bundle.."
su-exec jekyll bundle exec "$@"
# If no Gemfile, run as-is with jekyll user
else
>&2 echo "No Gemfile, launching plain.."
su-exec jekyll "$@"
fi