Skip to content

Commit

Permalink
shell scripts: fix shebangs, move docker-related variables into docke…
Browse files Browse the repository at this point in the history
…r condition (#16)

* *.sh: use /usr/bin/env bash as shebang

This allows these to execute in environments where `bash` is in `$PATH`
(but not necessarily in /usr/bin), such as NixOS.

* gen.sh, serve.sh: move docker image variables into docker codepath

There's few point in setting these if docker isn't found.
  • Loading branch information
flokli authored Feb 7, 2021
1 parent f42fce4 commit 691f3fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions gen.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
#!/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)"

# Determine the docker image to use.
TAG="$(cat ./tag)"
IMAGE="marcaruel/hugo-tidy:${TAG}"

echo "Tips:"
echo " - Use --buildDrafts to render drafts."

# Only use docker if not passing a flag, otherwise the container doesn't work as
# expected.
if [ $# == 0 ]; then
if (which docker > /dev/null); then
# Determine the docker image to use.
TAG="$(cat ./tag)"
IMAGE="marcaruel/hugo-tidy:${TAG}"

echo "Using hugo-tidy"
# See https://github.com/maruel/hugo-tidy/ for more info.
# First, pull the image only if missing.
Expand Down
2 changes: 1 addition & 1 deletion new_post.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2020 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.
Expand Down
10 changes: 5 additions & 5 deletions serve.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash
#!/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)"

# Determine the docker image to use.
TAG="$(cat ./tag)"
IMAGE="marcaruel/hugo-tidy:${TAG}"

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}"
Expand Down

0 comments on commit 691f3fb

Please sign in to comment.