forked from UniverseBow/wa2k.com-Website
36 lines
632 B
Text
36 lines
632 B
Text
|
|
#!/usr/bin/env bash
|
||
|
|
# Required Binaries:
|
||
|
|
# | simple-http-server
|
||
|
|
# | sass
|
||
|
|
|
||
|
|
# ===== Configuration ===== #
|
||
|
|
ADDR="127.0.0.1" # bind address
|
||
|
|
PORT="8000" # bind port
|
||
|
|
WEBROOT="www" # root web directory
|
||
|
|
USE_INDEX=true
|
||
|
|
NO_CACHE=true
|
||
|
|
declare -a SRV_ARGS=()
|
||
|
|
|
||
|
|
function host {
|
||
|
|
local args=( "$@" )
|
||
|
|
# Apply Flags
|
||
|
|
if [[ "$NO_CACHE" == true ]]; then
|
||
|
|
args+=("--nocache")
|
||
|
|
fi
|
||
|
|
if [[ "$USE_INDEX" == true ]]; then
|
||
|
|
args+=("--index")
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Apply Options
|
||
|
|
args+=(--ip "$ADDR" --port "$PORT")
|
||
|
|
|
||
|
|
simple-http-server "${args[@]}" "$@" -- "$WEBROOT"
|
||
|
|
}
|
||
|
|
|
||
|
|
# trap cleanup EXIT
|
||
|
|
set -ueo pipefail
|
||
|
|
set -x
|
||
|
|
|
||
|
|
# host dev server
|
||
|
|
host "${SRV_ARGS[@]}"
|