The idea of proxying in front of Garage may be warranted, to handle some of the ways that it subdomains further. However, I'm not there yet.
39 lines
1.4 KiB
Bash
39 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# /app/data gets mounted by Cloudron.
|
|
# Any files there at image creation time will disappear.
|
|
# So, copy things in from elsewhere if they're needed at startup.
|
|
|
|
if [[ ! -f /app/data/.initialized ]]; then
|
|
echo "Fresh installation, setting up data directory..."
|
|
# Setup commands here
|
|
touch /app/data/.initialized
|
|
|
|
# Make the working directories for garage. Files will get stored here.
|
|
mkdir -p /app/data/garage/meta
|
|
mkdir -p /app/data/garage/data
|
|
|
|
# Copy the config in. This is symlinked from /etc.
|
|
# cp /garage/garage.toml /app/data/garage.toml
|
|
# Note: it templates in the domain, which needs to be substituted at this point.
|
|
# If the end-user moves the domain... this will break.
|
|
sed -e 's/CLOUDRON_APP_DOMAIN/'"${CLOUDRON_APP_DOMAIN}"'/g' /garage/garage.toml > /app/data/garage.toml
|
|
|
|
# For redirecting /health to admin.DOMAIN/health
|
|
sed -e 's/CLOUDRON_APP_DOMAIN/'"${CLOUDRON_APP_DOMAIN}"'/g' /garage/caddyfile > /app/data/caddyfile
|
|
|
|
# Generate an RPC secret file. This is used for clusters.
|
|
# We don't have clusters, but garage wantses it.
|
|
# It is precious to garage.
|
|
openssl rand -hex 32 > /app/data/garage/rpc-secret
|
|
chmod 600 /app/data/garage/rpc-secret
|
|
|
|
echo "Done with one-time init."
|
|
fi
|
|
|
|
# Chown the things and run.
|
|
chown -R cloudron:cloudron /app/data/garage
|
|
|
|
# gosu cloudron:cloudron caddy run --config /app/data/caddyfile --adapter caddyfile &
|
|
gosu cloudron:cloudron /usr/bin/garage server
|