rebuild.sh now a standalone file

This commit is contained in:
mappu 2016-04-18 18:52:56 +12:00
parent a0c64ad5b2
commit a4d6e7a0b2

View File

@ -1,33 +1,32 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
THREADS=$(cat /proc/cpuinfo | grep '^processor' | wc -l)
APP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
numcpus() {
cat /proc/cpuinfo | grep '^processor' | wc -l
}
buildsite() { buildsite() {
local basedir="$(realpath .)"
local rebuild="${basedir}/rebuild.php"
if [[ "$(uname -o)" == "Cygwin" ]] ; then
rebuild="$(cygpath -w "$rebuild")"
fi
echo "Site: ${1}" echo "Site: ${1}"
pushd "$1" >/dev/null pushd "$1" >/dev/null
echo "Cleaning target directory..." echo "Cleaning wwwroot directory..."
if [[ -d wwwroot ]] ; then if [[ -d wwwroot ]] ; then
rm -r wwwroot rm -r wwwroot
fi fi
mkdir -p wwwroot/srv mkdir -p wwwroot/srv
echo "Copying static resources..."
if [[ ! -d static ]] ; then if [[ ! -d static ]] ; then
mkdir static mkdir static
fi fi
cp "${basedir}/static_global/"* wwwroot || true cp "${APP_DIR}/static/"* wwwroot || true
cp static/* wwwroot || true cp static/* wwwroot || true
for htm in footer header homepage_blurb ; do for htm in footer header homepage_blurb ; do
@ -38,8 +37,9 @@ buildsite() {
echo "Building pages..." echo "Building pages..."
for i in $(seq 0 "$THREADS") ; do local threadcount=$(numcpus)
php "$rebuild" "$THREADS" "$i" & for i in $(seq 0 "$threadcount") ; do
php "${APP_DIR}/rebuild.php" "$threadcount" "$i" &
done done
wait wait
@ -49,10 +49,17 @@ buildsite() {
popd >/dev/null popd >/dev/null
} }
usage() {
echo "USAGE: ./rebuild.sh path-to-siteroot"
exit 1
}
main() { main() {
for site in sites/* ; do if [[ $# -ne 1 ]] ; then
buildsite "$site" usage
done fi
buildsite "$1"
} }
main "$@" main "$@"