#!/bin/bash -e

# Create an empty directory (deleting old content!)
rm -rf project-for-bug-report
mkdir project-for-bug-report

# Define trac executables to use
tadm=/bin/trac-admin
td=/usr/sbin/tracd
#tadm=$(pwd)/trac-for-bug-report/trac-admin
#td=$(pwd)/trac-for-bug-report/tracd

# Work in the subdirectory 
cd project-for-bug-report

# Create an empty TRAC environment
"${tadm}" . initenv "AcctMgrPlgin Demo" sqlite:db/trac.db

# Handy shortcut
function setconfig() {
    "${tadm}" . config set "$1" "$2" "$3"
}

# Configure TRAC notifications
setconfig notification smtp_enabled        true
setconfig notification TracNotification    SendmailEmailSender
setconfig notification smtp_from           trac@myserver.localdomain
setconfig notification smtp_default_domain mydomain.com

# Optional stuff from #9052
setconfig account-manager account_changes_notify_addresses admin@myaddress
setconfig account-manager notify_actions                   new,change,delete

# Configure trac-accountmanager-plugin
touch trac.htdigest
setconfig components acct_mgr.\*                        enabled
setconfig components trac.web.auth.loginmodule          disabled
setconfig account-manager password_store HtDigestStore
setconfig account-manager htdigest_file  trac.htdigest

# Run the demo webpage
"${td}" --port 8000 .
