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

68 lines
998 B
Bash
Raw Normal View History

2015-04-04 06:03:14 +00:00
#!/bin/bash
set -eu
2016-04-18 06:52:56 +00:00
APP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2015-04-04 06:03:14 +00:00
2016-04-18 06:52:56 +00:00
numcpus() {
cat /proc/cpuinfo | grep '^processor' | wc -l
}
buildsite() {
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
2016-04-18 06:52:56 +00:00
echo "Cleaning wwwroot directory..."
2015-04-04 06:29:33 +00:00
if [[ -d wwwroot ]] ; then
rm -r wwwroot
2016-04-18 06:52:56 +00:00
fi
2015-04-04 06:29:33 +00:00
mkdir -p wwwroot/srv
2016-04-18 06:52:56 +00:00
echo "Copying static resources..."
2015-04-04 06:29:33 +00:00
if [[ ! -d static ]] ; then
mkdir static
fi
2016-04-18 06:52:56 +00:00
cp "${APP_DIR}/static/"* 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..."
2016-04-18 06:52:56 +00:00
local threadcount=$(numcpus)
for i in $(seq 0 "$threadcount") ; do
php "${APP_DIR}/rebuild.php" "$threadcount" "$i" &
2015-04-04 06:29:33 +00:00
done
wait
echo "Site: ${1} finished."
echo ""
popd >/dev/null
}
2016-04-18 06:52:56 +00:00
usage() {
echo "USAGE: ./rebuild.sh path-to-siteroot"
exit 1
}
2015-04-04 06:29:33 +00:00
main() {
2016-04-18 06:52:56 +00:00
if [[ $# -ne 1 ]] ; then
usage
fi
buildsite "$1"
2015-04-04 06:29:33 +00:00
}
main "$@"
2015-04-04 06:03:14 +00:00
read -p "Press any key to continue..."