48 lines
1.4 KiB
Bash
48 lines
1.4 KiB
Bash
#!/bin/sh
|
|
set -x
|
|
|
|
# Check if running as root
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "Not running as root, starting application directly..."
|
|
exec python /app/src/run.py
|
|
fi
|
|
|
|
# Create data directory with correct permissions for the StrixWebSSH user
|
|
if [ ! -d "/data" ]; then
|
|
echo "Creating /data directory..."
|
|
mkdir -p /data
|
|
fi
|
|
|
|
echo "Current /data permissions:"
|
|
ls -la /data || true
|
|
ls -la / | grep data || true
|
|
|
|
# Ensure /data is writable and owned by the StrixWebSSH user (UID 999)
|
|
echo "Setting permissions on /data..."
|
|
chmod 755 /data
|
|
chown strixwebssh:strixwebssh /data
|
|
|
|
# Check if chown worked
|
|
if [ "$(stat -c %U /data)" != "strixwebssh" ]; then
|
|
echo "WARNING: Could not change ownership of /data to strixwebssh"
|
|
echo "Current owner: $(stat -c %U /data)"
|
|
echo "This may happen with bind mounts. Ensure host directory is writable."
|
|
fi
|
|
|
|
echo "Final /data permissions:"
|
|
ls -la /data || true
|
|
|
|
# Configure nginx max upload size from environment
|
|
MAX_UPLOAD_SIZE="${MAX_UPLOAD_SIZE:-100M}"
|
|
|
|
# Start Caddy in background (serves static files and reverse-proxies to local services)
|
|
if command -v caddy >/dev/null 2>&1; then
|
|
echo "Starting Caddy..."
|
|
caddy run --config /etc/caddy/Caddyfile &
|
|
else
|
|
echo "Caddy binary not found; continuing without reverse proxy"
|
|
fi
|
|
|
|
# Start the application (run as the StrixWebSSH user)
|
|
exec gosu strixwebssh python /app/src/run.py
|