[Dbconfig-common-devel] "multisite" setups

jm+dbconfig-common-devel at roth.lu jm+dbconfig-common-devel at roth.lu
Sun Mar 14 23:53:54 UTC 2010


Ok...

I checked that; the issue for now merely seems to be to build a nice
wrapper around dbc. What I have come up with thus far is using the
following code in the maintainer scripts (this example, especially the
dbc_generate_include part, is for phpbb and may certainly be generalized):

dbc_multisite_conf=/var/lib/phpbb3/dbc_sites.conf
dbc_multi_go () {
    package="$1"
    shift
    for i in $(cat ${dbc_multisite_conf}); do
        if [ "$1" = "configure" ]; then
            dbc_generate_include="php:/etc/phpbb3/database_$i.inc.php"
        fi
        dbc_packagetitle="$package site $i"
        dbc_go ${package}_$i $@
    done
}

The only major change needs to happen in the config file where one has
to ask for the sites to be installed. That could be done like this:

        while true; do
            for f in multisite_action multisite_add multisite_mod
multisite_rem multisite_list; do
                db_fset phpbb3/$f seen false # reset "seen" tags
            done
            db_input high phpbb3/multisite_action || true
            db_go || true
            db_get phpbb3/multisite_action
            case "$RET" in
                "add")
                    db_set phpbb3/multisite_add # set to empty
                    ret=""
                    while [ "$ret" != "true" ]; do
                        db_input high phpbb3/multisite_add || true
                        [ $? = 30 ] && break
                        db_go || true
                        db_get phpbb3/multisite_add
                        check_site_syntax "$RET"
                    done
                    site=$(translate_site "$RET")
                    site_add $site
                    dbc_packagetitle="phpbb3 site $site"
                    dbc_go phpbb3_$site $@
                    site=''
                    ;;
                "list")
                    db_subst phpbb3/multisite_list sitelist $(get_site_list)
                    db_input high phpbb3/multisite_list || true
                    db_go || true
                    ;;
                "done")
                    break;
                    ;;
                *)
                    ;;
            esac
        done

This is in fact the only place where I still call dbc_go directly -- all
the other files just use dbc_multi_go instead of dbc_go.

However, it is unclear what I would need to do when I do not want to
remove all of the sites but only SOME. Maybe via dpkg-reconfigure and
including a "remove" option in the menu above? But how to make the call
to dbc_go actually purge the stuff when called from the config script?

One other thing is the install and upgrade scripts in
/usr/share/dbconfig common/data/PACKAGE/{install,upgrade}/. The code
would need to look after the base package and not the site on
install/upgrade, otherwise it wouldn't find those scripts...

Your turn ;-)

JM

PS. In any case, you will still need to give the app itself the same
logic for reading the database config than the maintainer scripts use to
generate the database config, here via the function translate_site and
the file database_<site>.inc.php.

PS2. Obviously one would also need to be able to import the single site
from a package that is upgraded to use the multisite feature. (just
brainstorming)

On 3/12/2010 9:49 AM, sean finney wrote:
> On Wed, Mar 10, 2010 at 12:41:58AM +0100, jm+dbconfig-common-devel at roth.lu wrote:
>> I was wondering if or how dbconfig can be used for a 'multisite' setup
>> of applications like phpbb or drupal.
> 
> there's some support for it in the code, but it's not exactly documented
> and you'd be the first person to use it. lucky you!



More information about the Dbconfig-common-devel mailing list