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

61 lines
938 B
Bash
Raw Normal View History

2015-04-04 06:03:14 +00:00
#!/bin/bash
set -eu
THREADS=$(cat /proc/cpuinfo | grep '^processor' | wc -l)
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
2015-10-11 02:25:36 +00:00
php "$rebuild" "$THREADS" "$i" &
2015-04-04 06:29:33 +00:00
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..."