#16 Deprecate all mention of get.5e.tools

Simplify configuration
Update dead wiki link
Update docs
This commit is contained in:
Joey Hafner 2024-02-16 22:14:59 -08:00
parent 497e602605
commit 1612750e26
4 changed files with 42 additions and 116 deletions

View File

@ -4,7 +4,7 @@ ENV PGID=${PGID:-1000}
COPY init.sh /init.sh COPY init.sh /init.sh
RUN apt-get update && \ RUN apt-get update && \
apt-get -y upgrade && \ apt-get -y upgrade && \
apt-get -y install curl p7zip-full megatools git jq && \ apt-get -y install curl git jq && \
chmod +x /init.sh chmod +x /init.sh
RUN echo "<Location /server-status>\n"\ RUN echo "<Location /server-status>\n"\

View File

@ -1,4 +1,4 @@
This is a simple image for hosting your own 5eTools instance. It is based on the Apache `httpd` image and uses components of the auto-updater script from the [5eTools wiki](https://wiki.5e.tools/index.php/5eTools_Install_Guide). This image is built from [this GitHub repository](https://github.com/Jafner/5etools-docker). This is a simple image for hosting your own 5eTools instance. It is based on the Apache `httpd` image and uses components of the auto-updater script from the [5eTools wiki](https://wiki.tercept.net/en/5eTools/InstallGuide). This image is built from [this GitHub repository](https://github.com/Jafner/5etools-docker).
# Usage # Usage
Below we talk about how to install and configure the container. Below we talk about how to install and configure the container.
@ -52,18 +52,14 @@ volumes:
The image uses environment variables to figure out how you want it to run. The image uses environment variables to figure out how you want it to run.
By default, I assume you want to automatically download the latest files from the Github mirror. Use the environment variables in the `docker-compose.yml` file to configure things. By default, I assume you want to automatically download the latest files from the Github mirror. Use the environment variables in the `docker-compose.yml` file to configure things.
### SOURCE (defaults to GITHUB-NOIMG) ### IMG (defaults to FALSE)
Required unless OFFLINE_MODE=TRUE. Required unless OFFLINE_MODE=TRUE.
Expects one of "GITHUB", "GITHUB-NOIMG", "GET5ETOOLS", or "GET5ETOOLS-NOIMG". Where: Expects one of "TRUE", "FALSE" Where:
> "GITHUB" pulls from https://github.com/5etools-mirror-1/5etools-mirror-1 > "TRUE" pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git and adds https://github.com/5etools-mirror-2/5etools-img as a submodule for image files.
> "GITHUB-NOIMG" pulls from https://github.com/5etools-mirror-1/5etools-mirror-1 without image files. > "FALSE" pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git without image files.
> "GET5ETOOLS" pulls from https://get.5e.tools
> "GET5ETOOLS-NOIMG" pulls from https://get.5e.tools without image files.
The get.5e.tools source has been down (redirecting to 5e.tools) during development. This method is not tested. The get.5e.tools source has been down (redirecting to 5e.tools) during development. This method is not tested.
**Note: As of December 2022, get.5e.tools has been down for several months**. The URL redirects to the main 5etools page, but does not provide packaged archives of the site like it used to. I will update this if or when the original get.5e.tools returns.
### OFFLINE_MODE ### OFFLINE_MODE
Optional. Expects "TRUE" to enable. Optional. Expects "TRUE" to enable.
Setting this to true tells the server to run from the local files if available, or exits if there is no local version. Setting this to true tells the server to run from the local files if available, or exits if there is no local version.
@ -105,5 +101,6 @@ Then your `index.json` should look like:
] ]
} }
``` ```
Note the commas after each entry except the last in each array. Note the commas after each entry except the last in each array.
See the [wiki page](https://wiki.5e.tools/index.php/5eTools_Install_Guide) for more information. See the [wiki page](https://wiki.5e.tools/index.php/5eTools_Install_Guide) for more information.

View File

@ -8,17 +8,8 @@ services:
ports: ports:
- 8080:80/tcp - 8080:80/tcp
environment: environment:
- SOURCE=GITHUB - IMG=FALSE # Set to TRUE to pull images from https://github.com/5etools-mirror-2/5etools-img (as a Git submodule)
# Required unless OFFLINE_MODE=TRUE and the site files are already present. #- OFFLINE_MODE=TRUE # Optional. Expects "TRUE" or "FALSE". Disables checking for new updates.
# Expects one of GITHUB, GITHUB-NOIMG, GET5ETOOLS, or GET5ETOOLS-NOIMG. Where:
# GITHUB pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io and adds https://github.com/5etools-mirror-2/5etools-img as a submodule
# GITHUB-NOIMG pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io without adding the images submodule.
# GET5ETOOLS pulls from https://get.5e.tools
# GET5ETOOLS-NOIMG pulls from https://get.5e.tools without image files.
# The get.5e.tools source has been down (redirecting to 5e.tools) during development.
# This method is not tested.
#- OFFLINE_MODE=TRUE
# Optional. Expects "TRUE" or "FALSE".
# Uncomment this block to use a docker-managed volume: # Uncomment this block to use a docker-managed volume:
#volumes: #volumes:

128
init.sh
View File

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
# based (loosely) on: https://wiki.5e.tools/index.php/5eTools_Install_Guide
# Print current user ID
id
# Ensure clean, non-root ownership of the htdocs directory. # Ensure clean, non-root ownership of the htdocs directory.
# Delete index.html if it's the stock apache file. Otherwise it impedes the git clone.
chown -R $PUID:$PGID /usr/local/apache2/htdocs chown -R $PUID:$PGID /usr/local/apache2/htdocs
# Delete index.html if it's the stock apache file. Otherwise it impedes the git clone.
if grep -Fq '<html><body><h1>It works!</h1></body></html>' "/usr/local/apache2/htdocs/index.html"; then if grep -Fq '<html><body><h1>It works!</h1></body></html>' "/usr/local/apache2/htdocs/index.html"; then
rm /usr/local/apache2/htdocs/index.html rm /usr/local/apache2/htdocs/index.html
fi fi
@ -24,108 +27,43 @@ if [ "$OFFLINE_MODE" = "TRUE" ]; then
fi fi
fi fi
# The SOURCE variable must be set if OFFLINE_MODE is not TRUE
if [ -z "${SOURCE}" ]; then
echo " === SOURCE variable not set. Expects one of \"GITHUB\", \"GET5ETOOLS\", or \"GET5ETOOLS-NOIMG\". Exiting."
exit 1
fi
# Move to the working directory for working with files. # Move to the working directory for working with files.
cd /usr/local/apache2/htdocs cd /usr/local/apache2/htdocs
echo " === Checking directory permissions for /usr/local/apache2/htdocs" echo " === Checking directory permissions for /usr/local/apache2/htdocs"
ls -ld /usr/local/apache2/htdocs ls -ld /usr/local/apache2/htdocs
SOURCE=${SOURCE} DL_LINK=${DL_LINK:-https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git}
echo "SOURCE=$SOURCE" IMG_LINK=${IMG_LINK:-https://github.com/5etools-mirror-2/5etools-img}
case $SOURCE in
GITHUB | GITHUB-NOIMG) # Source is the github mirror
DL_LINK=${GIT_URL:-https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git}
echo " === Using GitHub mirror at $DL_LINK"
if [ ! -d "./.git" ]; then # if no git repository already exists
echo " === No existing git repository, creating one"
git config --global user.email "autodeploy@localhost"
git config --global user.name "AutoDeploy"
git config --global pull.rebase false # Squelch nag message
git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes
git clone $DL_LINK . # clone the repo with no files and no object history
else
echo " === Using existing git repository"
git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes
fi
if ! [[ "$SOURCE" == *"NOIMG"* ]]; then # if user does want images
echo " === Pulling images from GitHub... (This will take a while)"
git submodule add -f https://github.com/5etools-mirror-2/5etools-img /usr/local/apache2/htdocs/img
fi
echo " === Pulling main files from GitHub..."
git checkout
git fetch
git pull --depth=1
VERSION=$(jq -r .version package.json) # Get version from package.json
if [[ `git status --porcelain` ]]; then
git restore .
fi
echo " === Starting version $VERSION" echo " === Using GitHub mirror at $DL_LINK"
httpd-foreground if [ ! -d "./.git" ]; then # if no git repository already exists
;; echo " === No existing git repository, creating one"
git config --global user.email "autodeploy@localhost"
git config --global user.name "AutoDeploy"
git config --global pull.rebase false # Squelch nag message
git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes
git clone $DL_LINK . # clone the repo with no files and no object history
else
echo " === Using existing git repository"
git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes
fi
GET5ETOOLS | GET5ETOOLS-NOIMG) if ! [[ "$IMG" == "TRUE" ]]; then # if user wants images
DL_LINK=https://get.5e.tools echo " === Pulling images from GitHub... (This will take a while)"
echo " === Using get structure to download from $DL_LINK" git submodule add -f $IMG_LINK /usr/local/apache2/htdocs/img
echo " === WARNING: This part of the script has not yet been tested. Please open an issue on the github if you have trouble." fi
# get remote version number
# takes three steps of wizardry. I did not write this, but it works so I don't touch it.
FILENAME=`curl -s -k -I $DL_LINK/src/|grep filename|cut -d"=" -f2 | awk '{print $1}'` # returns like "5eTools.1.134.0.zip" (with quotes)
FILENAME=${FILENAME//[$'\t\r\n"']} # remove quotes, returns like 5eTools.1.134.0.zip
REMOTE_VERSION=`basename ${FILENAME} ".zip"|sed 's/5eTools\.//'` # get version number, returns like 1.134.0
if [ "$REMOTE_VERSION" != "$VERSION" ]; then
echo " === Local version ($VERSION) outdated, updating to $REMOTE_VERSION ..."
rm ./index.html 2> /dev/null || true
echo " === Downloading new remote version..."
mkdir -p ./download
cd ./download/
curl --progress-bar -k -O -J $DL_LINK/src/ -C -
if [ "$SOURCE" != *"NOIMG"* ]; then # download images
echo " === Downloading images... "
curl --progress-bar -k -O -J $DL_LINK/img/ -C -
fi
cd ..
echo " === Extracting site..." echo " === Pulling latest files from GitHub..."
7z x ./download/$FILENAME -o./ -y git checkout
git fetch
git pull --depth=1
VERSION=$(jq -r .version package.json) # Get version from package.json
if [ "$SOURCE" != *"NOIMG"* ]; then # extract images if [[ `git status --porcelain` ]]; then
echo " === Extracting images..." git restore .
7z x ./download/$FILENAME_IMG -o./img -y fi
mv ./img/tmp/5et/img/* ./img
rm -r ./img/tmp
fi
echo " === Configuring..." # honestly I don't know enough HTML/CSS/JS to tell exactly what this part of the script does :L echo " === Starting version $VERSION"
find . -name \*.html -exec sed -i 's/"width=device-width, initial-scale=1"/"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/' {} \;
sed -i 's/<head>/<head>\n<link rel="apple-touch-icon" href="icon\/icon-512.png">/' index.html
sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' index.html
sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' 5etools.html
echo " === Cleaning up downloads" httpd-foreground
find ./download/ -type f ! -name "*.${VER}.zip" -exec rm {} + # delete the downloaded zip files
echo " === Done!"
else
echo " === Local version matches remote, no action."
fi
VERSION=$(jq -r .version package.json) # Get version from package.json
echo " === Starting version $VERSION"
httpd-foreground
;;
*)
echo "SOURCE variable set incorrectly. Exiting..."
exit
;;
esac