Fix config generation loop and add gosu dependency

This commit is contained in:
Andreas Dueren
2025-06-16 11:44:45 -06:00
parent b645391476
commit 8fa6d134ad
2 changed files with 43 additions and 3 deletions

View File

@ -24,7 +24,46 @@ BACKUP_PATH="/app/data/config.yaml.bak"
if [ ! -f "$CONFIG_PATH" ]; then
echo "=> Generating example configuration"
# Generate config as root first, then fix permissions
/app/pkg/mautrix-whatsapp -g -c "$CONFIG_PATH" -r "$REGISTRATION_PATH"
/app/pkg/mautrix-whatsapp -g -c "$CONFIG_PATH" -r "$REGISTRATION_PATH" || {
echo "=> Config generation failed, creating minimal config"
cat > "$CONFIG_PATH" << 'EOF'
homeserver:
address: https://matrix.example.com
domain: example.com
appservice:
address: https://example.com
hostname: 0.0.0.0
port: 29318
database:
type: postgres
uri: postgres://user:pass@localhost/db
bridge:
username_template: whatsapp_{{.}}
displayname_template: "{{if .BusinessName}}{{.BusinessName}}{{else}}{{.PushName}}{{end}} (WA)"
logging:
handlers:
file:
filename: /app/data/logs/mautrix-whatsapp.log
EOF
cat > "$REGISTRATION_PATH" << 'EOF'
id: whatsapp
url: https://example.com
as_token: generated_token
hs_token: generated_token
rate_limited: false
sender_localpart: whatsappbot
namespaces:
users:
- exclusive: true
regex: '@whatsapp_.*:.*'
aliases:
- exclusive: true
regex: '#whatsapp_.*:.*'
EOF
}
# Configure for Cloudron environment
if [ -n "${CLOUDRON_POSTGRESQL_URL:-}" ]; then