rebuild.sh now a standalone file
This commit is contained in:
parent
a0c64ad5b2
commit
a4d6e7a0b2
41
rebuild.sh
41
rebuild.sh
@ -1,33 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
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() {
|
||||
|
||||
local basedir="$(realpath .)"
|
||||
local rebuild="${basedir}/rebuild.php"
|
||||
|
||||
if [[ "$(uname -o)" == "Cygwin" ]] ; then
|
||||
rebuild="$(cygpath -w "$rebuild")"
|
||||
fi
|
||||
|
||||
echo "Site: ${1}"
|
||||
|
||||
pushd "$1" >/dev/null
|
||||
|
||||
echo "Cleaning target directory..."
|
||||
echo "Cleaning wwwroot directory..."
|
||||
|
||||
if [[ -d wwwroot ]] ; then
|
||||
rm -r wwwroot
|
||||
fi
|
||||
|
||||
fi
|
||||
mkdir -p wwwroot/srv
|
||||
|
||||
echo "Copying static resources..."
|
||||
|
||||
if [[ ! -d static ]] ; then
|
||||
mkdir static
|
||||
fi
|
||||
cp "${basedir}/static_global/"* wwwroot || true
|
||||
cp "${APP_DIR}/static/"* wwwroot || true
|
||||
cp static/* wwwroot || true
|
||||
|
||||
for htm in footer header homepage_blurb ; do
|
||||
@ -38,8 +37,9 @@ buildsite() {
|
||||
|
||||
echo "Building pages..."
|
||||
|
||||
for i in $(seq 0 "$THREADS") ; do
|
||||
php "$rebuild" "$THREADS" "$i" &
|
||||
local threadcount=$(numcpus)
|
||||
for i in $(seq 0 "$threadcount") ; do
|
||||
php "${APP_DIR}/rebuild.php" "$threadcount" "$i" &
|
||||
done
|
||||
wait
|
||||
|
||||
@ -49,10 +49,17 @@ buildsite() {
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "USAGE: ./rebuild.sh path-to-siteroot"
|
||||
exit 1
|
||||
}
|
||||
|
||||
main() {
|
||||
for site in sites/* ; do
|
||||
buildsite "$site"
|
||||
done
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
buildsite "$1"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
Reference in New Issue
Block a user