This repository has been archived on 2020-05-24. You can view files and clone it, but cannot push or open issues or pull requests.
codesite/rebuild.sh

62 lines
924 B
Bash
Raw Normal View History

2015-04-04 06:03:14 +00:00
#!/bin/bash
set -eu
PHP=/cygdrive/c/bin/php/php.exe
2015-04-04 06:29:33 +00:00
THREADS=4
2015-04-04 06:03:14 +00:00
2015-04-04 06:29:33 +00:00
buildsite() {
2015-04-04 06:03:14 +00:00
local basedir="$(realpath .)"
local rebuild="${basedir}/rebuild.php"
2015-04-04 06:29:33 +00:00
if [[ "$(uname -o)" == "Cygwin" ]] ; then
rebuild="$(cygpath -w "$rebuild")"
fi
2015-04-04 06:03:14 +00:00
2015-04-04 06:29:33 +00:00
echo "Site: ${1}"
2015-04-04 06:03:14 +00:00
2015-04-04 06:29:33 +00:00
pushd "$1" >/dev/null
echo "Cleaning target directory..."
if [[ -d wwwroot ]] ; then
rm -r wwwroot
fi
mkdir -p wwwroot/srv
if [[ ! -d static ]] ; then
mkdir static
fi
cp "${basedir}/static_global/"* wwwroot || true
2015-04-04 06:29:33 +00:00
cp static/* wwwroot || true
for htm in footer header homepage_blurb ; do
if [[ ! -f "${htm}.htm" ]] ; then
touch "${htm}.htm"
fi
done
echo "Building pages..."
for i in $(seq 0 "$THREADS") ; do
$PHP "$rebuild" "$THREADS" "$i" &
done
wait
echo "Site: ${1} finished."
echo ""
popd >/dev/null
}
main() {
for site in sites/* ; do
buildsite "$site"
done
}
main "$@"
2015-04-04 06:03:14 +00:00
read -p "Press any key to continue..."