-
Notifications
You must be signed in to change notification settings - Fork 20
/
serve.sh
executable file
·34 lines (30 loc) · 1.08 KB
/
serve.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
#!/usr/bin/env bash
# Copyright 2017 The Periph Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
set -eu
cd "$(dirname $0)"
echo "Tips:"
echo " - Use --bind=0.0.0.0 to be accessible on the local network."
echo " - Use --buildDrafts to render drafts."
if (which docker > /dev/null); then
echo "Using hugo-tidy"
# Determine the docker image to use.
TAG="$(cat ./tag)"
IMAGE="marcaruel/hugo-tidy:${TAG}"
# See https://github.com/maruel/hugo-tidy/ for more info.
# First, pull the image only if missing.
[ ! -z $(docker images -q "${IMAGE}") ] || docker pull "${IMAGE}"
# Run it.
docker run -t -i --rm -u $(id -u):$(id -g) -v $(pwd):/data --network=host "${IMAGE}" \
server -b $(hostname) "$@"
elif (which hugo > /dev/null); then
echo "Using hugo"
hugo server -s site -d ../www --buildFuture -b $(hostname) --port 3131 "$@"
else
echo "Please either:"
echo " - setup docker"
echo " - install hugo from https://gohugo.io"
echo " - go get github.com/gohugoio/hugo"
exit 1
fi