mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Add --webroot parameter.
This commit is contained in:
parent
c8cb8f788a
commit
8349f9268b
4 changed files with 32 additions and 11 deletions
|
@ -4,6 +4,8 @@ To use, call this script with the directory where your ebooks go as its last arg
|
||||||
|
|
||||||
# deploy-ebook-to-www
|
# deploy-ebook-to-www
|
||||||
|
|
||||||
To use, call this script with the directories of the books you want to deploy as its arguments. For example, to deploy all ebooks after using sync-ebooks, run `deploy-ebook-to-www /standardebooks.org/ebooks/*`. To deploy only The Time Machine by H.G Wells, you would run `deploy-ebook-to-www /standardebooks.org/ebooks/h-g-wells_the-time-machine`. Note that deploy-ebook-to-www assumes that your webroot is in /standardebooks.org/. To output progress information, use -v or --verbose.
|
To use, call this script with the directories of the books you want to deploy as its arguments. For example, to deploy all ebooks after using sync-ebooks, run `deploy-ebook-to-www /standardebooks.org/ebooks/*`. To deploy only The Time Machine by H.G Wells, you would run `deploy-ebook-to-www /standardebooks.org/ebooks/h-g-wells_the-time-machine`. To output progress information, use -v or --verbose.
|
||||||
|
|
||||||
|
The default web root is /standardebooks.org. If it is located elsewhere, specify it with the --webroot option. For instance, `deploy-ebook-to-www --webroot /var/www/html /path/to/ebook`. Note that there will be php errors if the git repositories are not in the ebook directory immediately in the web root. Either keep them there or create a symlink.
|
||||||
|
|
||||||
The default group is se. to use a different one, specify it with the --group option. For instance, to use this script inside the included Vagrant VM, which uses the www-data group, use `deploy-ebook-to-www --group www-data /path/to/ebook`.
|
The default group is se. to use a different one, specify it with the --group option. For instance, to use this script inside the included Vagrant VM, which uses the www-data group, use `deploy-ebook-to-www --group www-data /path/to/ebook`.
|
||||||
|
|
|
@ -6,9 +6,10 @@ DESCRIPTION
|
||||||
Deploy a Standard Ebook source repository to the web.
|
Deploy a Standard Ebook source repository to the web.
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] DIRECTORY [DIRECTORY...]
|
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] [--webroot WEBROOT] DIRECTORY [DIRECTORY...]
|
||||||
DIRECTORY is a bare source repository.
|
DIRECTORY is a bare source repository.
|
||||||
GROUP is a groupname. Defaults to "se".
|
GROUP is a groupname. Defaults to "se".
|
||||||
|
WEBROOT is the path to your webroot. Defaults to "/standardebooks.org".
|
||||||
EOF
|
EOF
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -18,6 +19,7 @@ require(){ command -v "$1" > /dev/null 2>&1 || { suggestion=""; if [ -n "$2" ];
|
||||||
|
|
||||||
verbose="false"
|
verbose="false"
|
||||||
group="se"
|
group="se"
|
||||||
|
webRoot="/standardebooks.org"
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
usage
|
usage
|
||||||
|
@ -36,6 +38,11 @@ while [ $# -gt 0 ]; do
|
||||||
group="$2"
|
group="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--webroot)
|
||||||
|
[ -n "$2" ] || die "Web root can't be empty."
|
||||||
|
webRoot="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*) break ;;
|
*) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -44,6 +51,10 @@ if ! [ "$(getent group "${group}")" ]; then
|
||||||
die "Group ${group} does not exist. Either use --group or create the group."
|
die "Group ${group} does not exist. Either use --group or create the group."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [ -d "${webRoot}" ]; then
|
||||||
|
die "${webRoot} does not exist or is not a directory."
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for dependencies
|
# Check for dependencies
|
||||||
require "convert" "Try: apt-get install imagemagick"
|
require "convert" "Try: apt-get install imagemagick"
|
||||||
require "rsvg-convert" "Try: apt-get install librsvg2-bin"
|
require "rsvg-convert" "Try: apt-get install librsvg2-bin"
|
||||||
|
@ -65,7 +76,7 @@ if ! [ -f "${scriptsDir}"/generate-rss.php ]; then
|
||||||
die "\"${scriptsDir}\"/generate-rss.php\" is not a file or could not be found."
|
die "\"${scriptsDir}\"/generate-rss.php\" is not a file or could not be found."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /standardebooks.org/www/images/covers/
|
mkdir -p "${webRoot}"/www/images/covers/
|
||||||
|
|
||||||
for dir in "$@"
|
for dir in "$@"
|
||||||
do
|
do
|
||||||
|
@ -106,7 +117,7 @@ do
|
||||||
|
|
||||||
workDir=$(mktemp -d)
|
workDir=$(mktemp -d)
|
||||||
imgWorkDir=$(mktemp -d)
|
imgWorkDir=$(mktemp -d)
|
||||||
webDir="/standardebooks.org/www/ebooks/${webDir}"
|
webDir="${webRoot}/www/ebooks/${webDir}"
|
||||||
|
|
||||||
if [ "${verbose}" = "true" ]; then
|
if [ "${verbose}" = "true" ]; then
|
||||||
printf "Generating cover image for web ... "
|
printf "Generating cover image for web ... "
|
||||||
|
@ -170,7 +181,7 @@ do
|
||||||
mv "${workDir}"/* "${webDir}/"
|
mv "${workDir}"/* "${webDir}/"
|
||||||
|
|
||||||
# Move the cover images over
|
# Move the cover images over
|
||||||
mv "${imgWorkDir}/${urlSafeIdentifier}"*.jpg "/standardebooks.org/www/images/covers/"
|
mv "${imgWorkDir}/${urlSafeIdentifier}"*.jpg "${webRoot}/www/images/covers/"
|
||||||
|
|
||||||
# Delete the now-empty work dir (empty except for .git)
|
# Delete the now-empty work dir (empty except for .git)
|
||||||
rm --preserve-root --recursive --force "${workDir}" "${imgWorkDir}"
|
rm --preserve-root --recursive --force "${workDir}" "${imgWorkDir}"
|
||||||
|
@ -178,8 +189,8 @@ do
|
||||||
sudo chgrp --preserve-root --recursive "${group}" "${webDir}"
|
sudo chgrp --preserve-root --recursive "${group}" "${webDir}"
|
||||||
sudo chmod --preserve-root --recursive g+ws "${webDir}"
|
sudo chmod --preserve-root --recursive g+ws "${webDir}"
|
||||||
|
|
||||||
sudo chgrp --preserve-root --recursive "${group}" "/standardebooks.org/www/images/covers/"
|
sudo chgrp --preserve-root --recursive "${group}" "${webRoot}/www/images/covers/"
|
||||||
sudo chmod --preserve-root --recursive g+ws "/standardebooks.org/www/images/covers/"
|
sudo chmod --preserve-root --recursive g+ws "${webRoot}/www/images/covers/"
|
||||||
|
|
||||||
if [ "${verbose}" = "true" ]; then
|
if [ "${verbose}" = "true" ]; then
|
||||||
printf "Flushing PHP-FPM opcache and apcu cache ... "
|
printf "Flushing PHP-FPM opcache and apcu cache ... "
|
||||||
|
@ -199,7 +210,7 @@ if [ "${verbose}" = "true" ]; then
|
||||||
printf "Rebuilding OPDS catalog ... "
|
printf "Rebuilding OPDS catalog ... "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bash -c "php \"${scriptsDir}\"/generate-opds.php > /standardebooks.org/www/opds/all.xml; export XMLLINT_INDENT=\$(printf \"\\t\") && xmllint --c14n /standardebooks.org/www/opds/all.xml | (printf \"%s\\n\" \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\" && cat) | xmllint --output /standardebooks.org/www/opds/all.xml --format -"
|
bash -c "php \"${scriptsDir}\"/generate-opds.php --webroot \"${webRoot}\" > \"${webRoot}\"/www/opds/all.xml; export XMLLINT_INDENT=\$(printf \"\\t\") && xmllint --c14n \"${webRoot}\"/www/opds/all.xml | (printf \"%s\\n\" \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\" && cat) | xmllint --output \"${webRoot}\"/www/opds/all.xml --format -"
|
||||||
|
|
||||||
if [ "${verbose}" = "true" ]; then
|
if [ "${verbose}" = "true" ]; then
|
||||||
printf "Done.\n"
|
printf "Done.\n"
|
||||||
|
@ -210,7 +221,7 @@ if [ "${verbose}" = "true" ]; then
|
||||||
printf "Rebuilding new releases RSS feed ... "
|
printf "Rebuilding new releases RSS feed ... "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bash -c "php \"${scriptsDir}\"/generate-rss.php > /standardebooks.org/www/rss/new-releases.xml"
|
bash -c "php \"${scriptsDir}\"/generate-rss.php --webroot \"${webRoot}\" > \"${webRoot}\"/www/rss/new-releases.xml"
|
||||||
|
|
||||||
if [ "${verbose}" = "true" ]; then
|
if [ "${verbose}" = "true" ]; then
|
||||||
printf "Done.\n"
|
printf "Done.\n"
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<?
|
<?
|
||||||
$contentFiles = explode("\n", trim(shell_exec('find /standardebooks.org/www/ebooks/ -name "content.opf" | sort') ?? ''));
|
$longopts = array("webroot:");
|
||||||
|
$options = getopt("", $longopts);
|
||||||
|
$webRoot = $options["webroot"] ?? "/standardebooks.org";
|
||||||
|
|
||||||
|
$contentFiles = explode("\n", trim(shell_exec('find ' . escapeshellarg($webRoot . '/www/ebooks/') . ' -name "content.opf" | sort') ?? ''));
|
||||||
|
|
||||||
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<?
|
<?
|
||||||
|
$longopts = array("webroot:");
|
||||||
|
$options = getopt("", $longopts);
|
||||||
|
$webRoot = $options["webroot"] ?? "/standardebooks.org";
|
||||||
|
|
||||||
$rssLength = 30;
|
$rssLength = 30;
|
||||||
$contentFiles = explode("\n", trim(shell_exec('find /standardebooks.org/www/ebooks/ -name "content.opf" | sort') ?? ''));
|
$contentFiles = explode("\n", trim(shell_exec('find ' . escapeshellarg($webRoot . '/www/ebooks/') . ' -name "content.opf" | sort') ?? ''));
|
||||||
|
|
||||||
$sortedContentFiles = array();
|
$sortedContentFiles = array();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue