mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Update Vagrant files.
This commit is contained in:
parent
58b678d90b
commit
3171b7e583
4 changed files with 79 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ www/rss/*.xml
|
|||
vendor/
|
||||
composer.lock
|
||||
.vagrant/
|
||||
*.log
|
||||
|
|
|
@ -179,6 +179,12 @@ After you have installed both, you can start and manage a VM running a server li
|
|||
|
||||
## Some further notes
|
||||
|
||||
- The Vagrant script will install [se](https://github.com/standardebooks/tools) by default. If you don't want that (it pulls in quite a few dependencies), remove the `se-tools` argument in Vagrantfile.
|
||||
|
||||
- `se`, if installed in the VM, and /standardebooks.org/scripts are in the VMs path. This means you can easily use them with `vagrant ssh -c` like this: `vagrant ssh -c "sync-ebooks -vv /standardebooks.org/ebooks; deploy-ebook-to-www -v --group www-data /standardebooks.org/ebooks/*"`, which would populate the test server with all available SE ebooks.
|
||||
|
||||
- It is safe to re-run the provision script if you did not change the nginx or php configuration files (change the files in the provision script and re-provision instead), so you can use `vagrant up --provision` or `vagrant reload --provision to update the VM, including se-tools and epubcheck, without having to delete it.
|
||||
|
||||
- The server runs on `127.0.0.1:8080` if you want to use a different port, change the `host: 8080` statement in the Vagrantfile to the desired port.
|
||||
|
||||
- You can list all locally installed boxes by doing `vagrant box list`.
|
||||
|
|
6
Vagrantfile
vendored
6
Vagrantfile
vendored
|
@ -1,7 +1,9 @@
|
|||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "ubuntu/bionic64"
|
||||
config.vm.provision :shell, path: "scripts/vagrant/provision"
|
||||
config.vm.provision :shell, path: "scripts/vagrant/provision",
|
||||
args: ["se-tools"]
|
||||
config.vm.network :forwarded_port, guest: 80, host: 8080
|
||||
config.vm.synced_folder ".", "/standardebooks.org",
|
||||
owner: "www-data", group: "www-data"
|
||||
owner: "www-data", group: "www-data",
|
||||
mount_options: ["dmode=775,fmode=777"]
|
||||
end
|
||||
|
|
|
@ -1,8 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
apt-get update -y
|
||||
apt-get install -y nginx php-fpm php-apcu php-intl php-mbstring\
|
||||
php-xml git
|
||||
apt-get install -y nginx php-fpm php-apcu php-intl php-mbstring php-xml php-zip composer\
|
||||
zip unzip git
|
||||
|
||||
if [ "$1" = "se-tools" ]
|
||||
then
|
||||
cat << "EOF" | su - vagrant -c /bin/bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# Install some pre-flight dependencies.
|
||||
sudo apt-get install -y python3-pip libxml2-utils librsvg2-bin libimage-exiftool-perl imagemagick jarwrapper default-jre inkscape calibre curl
|
||||
|
||||
# Install required fonts.
|
||||
mkdir -p ~/.local/share/fonts/
|
||||
curl -s -o ~/.local/share/fonts/LeagueSpartan-Bold.otf "https://raw.githubusercontent.com/theleagueof/league-spartan/master/LeagueSpartan-Bold.otf"
|
||||
curl -s -o ~/.local/share/fonts/OFLGoudyStM.otf "https://raw.githubusercontent.com/theleagueof/sorts-mill-goudy/master/OFLGoudyStM.otf"
|
||||
curl -s -o ~/.local/share/fonts/OFLGoudyStM-Italic.otf "https://raw.githubusercontent.com/theleagueof/sorts-mill-goudy/master/OFLGoudyStM-Italic.otf"
|
||||
|
||||
# Refresh the local font cache.
|
||||
sudo fc-cache -f
|
||||
|
||||
rm -rf ~/.local/share/epubcheck
|
||||
|
||||
epubcheck_download_url=$(curl https://api.github.com/repos/w3c/epubcheck/releases/latest \
|
||||
| grep -E --only-matching "\"browser_download_url\":\s*\"(.*?)\"" \
|
||||
| sed "s/\"browser_download_url\":\s*//g" | sed "s/\"//g")
|
||||
if [ ! -f ~/.epubcheck_version ] || ! grep -q "${epubcheck_download_url}" ~/.epubcheck_version; then
|
||||
# Download and install the required version of epubcheck.
|
||||
wget --quiet -O /tmp/epubcheck.zip "${epubcheck_download_url}"
|
||||
unzip -o -d $HOME/.local/share/ /tmp/epubcheck.zip
|
||||
mv -f $HOME/.local/share/epubcheck-* $HOME/.local/share/epubcheck
|
||||
sudo chmod +x $HOME/.local/share/epubcheck/epubcheck.jar
|
||||
sudo ln -fs $HOME/.local/share/epubcheck/epubcheck.jar /usr/local/bin/epubcheck
|
||||
printf "%s" "${epubcheck_download_url}" > ~/.epubcheck_version
|
||||
fi
|
||||
|
||||
# Install the toolset.
|
||||
pip3 install --upgrade standardebooks
|
||||
|
||||
# Install tab completion.
|
||||
sudo ln -fs $HOME/.local/lib/python3.*/site-packages/se/completions/bash/se /usr/share/bash-completion/completions/se
|
||||
|
||||
echo "se has been installed to '~/.local/bin'. It should be in your path."
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat << "EOF" > /etc/php/7.2/fpm/conf.d/99-standardebooks.ini
|
||||
include_path = .:/standardebooks.org/lib
|
||||
|
@ -13,13 +57,15 @@ extension = intl
|
|||
#display_startup_errors = On
|
||||
EOF
|
||||
|
||||
sed -i "s/short_open_tag = Off/short_open_tag = On/g" /etc/php/7.2/cli/php.ini
|
||||
|
||||
cat << "EOF" > /etc/nginx/sites-available/default
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
root /standardebooks.org/www;
|
||||
index index.php index.html index.htm index.nginx-debian.html;
|
||||
index index.php index.html index.htm index.xml index.nginx-debian.html;
|
||||
|
||||
server_name _;
|
||||
|
||||
|
@ -47,6 +93,25 @@ server {
|
|||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
cat << "EOF" | su - vagrant -c /bin/bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
if ! grep "^export PATH=$PATH:~/.local/bin$" ~/.bashrc; then
|
||||
printf '\nexport PATH=$PATH:~/.local/bin' >> ~/.bashrc
|
||||
fi
|
||||
|
||||
ln -fs /standardebooks.org/scripts/sync-ebooks ~/.local/bin/sync-ebooks
|
||||
ln -fs /standardebooks.org/scripts/deploy-ebook-to-www ~/.local/bin/deploy-ebook-to-www
|
||||
EOF
|
||||
|
||||
chown -R www-data:www-data /var/www
|
||||
su - www-data -s /bin/sh -c "cd /standardebooks.org/; composer install"
|
||||
usermod -a -G www-data vagrant
|
||||
|
||||
systemctl enable php7.2-fpm
|
||||
systemctl enable nginx
|
||||
systemctl restart php7.2-fpm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue