notes/gollum/build_and_run.sh

64 lines
1.0 KiB
Bash
Executable File

#! /bin/bash
set -e
set -u
cd "$(dirname "${BASH_SOURCE[0]}")"
dir="$PWD"
if [ ! -e ./goftp ]; then
pushd $GOPATH/src/local/goftp
CGO_ENABLED=0 GOOS=linux go build -o "$dir/goftp" -a -installsuffix cgo
popd
fi
img_tag="${1:-"dev:dev"}"
docker build -t "$img_tag" .
mkdir -p $PWD/mnt
sudo chmod -R 777 $PWD/mnt
rm -rf $PWD/mnt/this
mkdir -p $PWD/mnt/this/is\ a/test/path
rm -f $PWD/mnt/this/{_Header.md,file.md}
echo '# hello' > $PWD/mnt/this/file.md
pushd $PWD/mnt
if [ ! -e Home.md ]; then
echo 'immediate pages
<<ImmediatePages()>>
immediate pages from /this/
<<ImmediatePages("/this/")>>
path segments
<<PathSegments()>>
drop down
<<DropDown("title", "hidden")>>
h1, h2, h3, para
# Hello
## h2
### h3
paragraph
' > Home.md
fi
popd
function clean() {
docker rm -f gollum-dev
}
trap clean EXIT
if [ -z "${BUILD:-""}" ]; then
docker run --rm -it \
--name gollum-dev \
-e PORT=38080 \
-p 38180:38080 \
-p 38181:38081 \
-v $PWD/mnt:/wiki \
$img_tag
fi