Joey Hafner
97e4cc547a
1. homelab [Gitea](https://gitea.jafner.tools/Jafner/homelab), [Github (docker_config)](https://github.com/Jafner/docker_config), [Github (wiki)](https://github.com/Jafner/wiki), [Github (cloud_tools)](https://github.com/Jafner/cloud_tools), [Github (self-hosting)](https://github.com/Jafner/self-hosting). - Rename? Jafner.net? Wouldn't that be `Jafner/Jafner.net/Jafner.net`? 2. Jafner.dev [Github](https://github.com/Jafner/Jafner.dev). 3. dotfiles [Gitea](https://gitea.jafner.tools/Jafner/dotfiles), [Github](https://github.com/Jafner/dotfiles). 4. nvgm [Gitea](https://gitea.jafner.tools/Jafner/nvgm) 5. pamidi [Gitea](https://gitea.jafner.tools/Jafner/pamidi), [Github](https://github.com/Jafner/pamidi) 6. docker-llm-amd [Gitea](https://gitea.jafner.tools/Jafner/docker-llm-amd) 7. doradash [Gitea](https://gitea.jafner.tools/Jafner/doradash) 8. clip-it-and-ship-it [Gitea (PyClipIt)](https://gitea.jafner.tools/Jafner/PyClipIt), [Github](https://github.com/Jafner/clip-it-and-ship-it). 9. razer battery led [Github](https://github.com/Jafner/Razer-BatteryLevelRGB) 10. 5etools-docker [Github](https://github.com/Jafner/5etools-docker) 11. jafner-homebrew [Github](https://github.com/Jafner/jafner-homebrew)
69 lines
2.5 KiB
Bash
69 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Print current user ID
|
|
id
|
|
|
|
# Ensure clean, non-root ownership of the htdocs directory.
|
|
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
|
|
rm /usr/local/apache2/htdocs/index.html
|
|
fi
|
|
|
|
# If the user doesn't want to update from a source,
|
|
# check for local version.
|
|
# If local version is found, print version and start server.
|
|
# If no local version is found, print error message and exit.
|
|
if [ "$OFFLINE_MODE" = "TRUE" ]; then
|
|
echo " === Offline mode is enabled. Will try to launch from local files. Checking for local version..."
|
|
if [ -f /usr/local/apache2/htdocs/package.json ]; then
|
|
VERSION=$(jq -r .version package.json) # Get version from package.json
|
|
echo " === Starting version $VERSION"
|
|
httpd-foreground
|
|
else
|
|
echo " === No local version detected. Exiting."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Move to the working directory for working with files.
|
|
cd /usr/local/apache2/htdocs
|
|
|
|
echo " === Checking directory permissions for /usr/local/apache2/htdocs"
|
|
ls -ld /usr/local/apache2/htdocs
|
|
|
|
DL_LINK=${DL_LINK:-https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git}
|
|
IMG_LINK=${IMG_LINK:-https://github.com/5etools-mirror-2/5etools-img}
|
|
|
|
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 [[ "$IMG" == "TRUE" ]]; then # if user wants images
|
|
echo " === Pulling images from GitHub... (This will take a while)"
|
|
git submodule add -f $IMG_LINK /usr/local/apache2/htdocs/img
|
|
fi
|
|
|
|
echo " === Pulling latest 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"
|
|
|
|
httpd-foreground |