Joined to this message the files '/tmp/file0R0LCY' and '/tmp/file3CxYOG'
referenced in the previous email.

--
Julien
#!/bin/sh -e
# phpwiki database configuration load script
dbc_dbuser=''
dbc_dbpass=''
dbc_basepath=''
dbc_dbname=''
dbc_dbserver=''
dbc_dbport=''
dbc_dbtype=''

function print_results
{
    echo "dbc_dbuser='$dbc_dbuser'"
    echo "dbc_dbpass='$dbc_dbpass'"
    echo "dbc_basepath='$dbc_basepath'"
    echo "dbc_dbname='$dbc_dbname'"
    echo "dbc_dbserver='$dbc_dbserver'"
    echo "dbc_dbport='$dbc_dbport'"
    echo "dbc_dbtype='$dbc_dbtype'"
}

n=`egrep "^[[:space:]]*DATABASE_TYPE[[:space:]]*=[[:space:]]*dba"     
/etc/phpwiki/config.ini | wc -l | sed 's/ //g'`
if [ "$n" -ne "0" ]; then
    # Still using DBA, dbconfig-common can't help us much...
    print_results
    return 0
fi

dsn=`grep "^[\w]*DATABASE_DSN" /etc/phpwiki/config.ini | cut -f2 -d'='`
dsn=`echo "$dsn" | tr -d '" '`

# Extract the database type
dbc_dbtype=`echo "$dsn" | cut -f1 -d':'`
dsn=`echo "$dsn" | cut -f2- -d':' | sed 's#^//##g' | sed 's#^//#/#g'`

if [ "$dbc_dbtype" = "sqlite" ]; then
    # Break into basepath and database filename
    dbc_basepath=`dirname $dsn`
    dbc_dbname=`basename $dsn`
else
    # DSN in format <dbtype>://[user[:[EMAIL PROTECTED]<host>[:port]/<dbname>
    # May have username/password to extract
    if echo "$dsn" | grep -q "@"; then
        # We have at least a username
        auth=`echo "$dsn" | cut -f1 -d'@'`
        if echo "$auth" | grep -q ":"; then
            # Username and password
            dbc_dbuser=`echo "$auth" | cut -f1 -d':'`
            dbc_dbpass=`echo "$auth" | cut -f2 -d':'`
        else
            dbc_dbuser="$auth"
        fi
        dsn=`echo "$dsn" | cut -f2 -d'@'`
    fi
    # Up to the next / is the host and port
    host=`echo "$dsn" | cut -f1 -d'/'`
    if echo "$host" | grep -q ":"; then
        # Host and port
        dbc_dbserver=`echo "$host" | cut -f1 -d':'`
        dbc_dbport=`echo "$host" | cut -f2 -d':'`
    else
        dbc_dbserver="$host"
    fi
    # And finally the db name
    dbc_dbname=`echo "$dsn" | cut -f2 -d'/'`
fi

print_results
exit 0
#!/bin/sh -e
# phpwiki database configuration load script
dbc_dbuser=''
dbc_dbpass=''
dbc_basepath=''
dbc_dbname=''
dbc_dbserver=''
dbc_dbport=''
dbc_dbtype=''

function print_results
{
    echo "dbc_dbuser='$dbc_dbuser'"
    echo "dbc_dbpass='$dbc_dbpass'"
    echo "dbc_basepath='$dbc_basepath'"
    echo "dbc_dbname='$dbc_dbname'"
    echo "dbc_dbserver='$dbc_dbserver'"
    echo "dbc_dbport='$dbc_dbport'"
    echo "dbc_dbtype='$dbc_dbtype'"
}

n=`egrep "^[[:space:]]*DATABASE_TYPE[[:space:]]*=[[:space:]]*dba"     
/etc/phpwiki/config.ini | wc -l | sed 's/ //g'`
if [ "$n" -ne "0" ]; then
    # Still using DBA, dbconfig-common can't help us much...
    print_results
    return 0
fi

dsn=`grep "^[\w]*DATABASE_DSN" /etc/phpwiki/config.ini | cut -f2 -d'='`
dsn=`echo "$dsn" | tr -d '" '`

# Extract the database type
dbc_dbtype=`echo "$dsn" | cut -f1 -d':'`
dsn=`echo "$dsn" | cut -f2- -d':' | sed 's#^//##g' | sed 's#^//#/#g'`

if [ "$dbc_dbtype" = "sqlite" ]; then
    # Break into basepath and database filename
    dbc_basepath=`dirname $dsn`
    dbc_dbname=`basename $dsn`
else
    # DSN in format <dbtype>://[user[:[EMAIL PROTECTED]<host>[:port]/<dbname>
    # May have username/password to extract
    if echo "$dsn" | grep -q "@"; then
        # We have at least a username
        auth=`echo "$dsn" | cut -f1 -d'@'`
        if echo "$auth" | grep -q ":"; then
            # Username and password
            dbc_dbuser=`echo "$auth" | cut -f1 -d':'`
            dbc_dbpass=`echo "$auth" | cut -f2 -d':'`
        else
            dbc_dbuser="$auth"
        fi
        dsn=`echo "$dsn" | cut -f2 -d'@'`
    fi
    # Up to the next / is the host and port
    host=`echo "$dsn" | cut -f1 -d'/'`
    if echo "$host" | grep -q ":"; then
        # Host and port
        dbc_dbserver=`echo "$host" | cut -f1 -d':'`
        dbc_dbport=`echo "$host" | cut -f2 -d':'`
    else
        dbc_dbserver="$host"
    fi
    # And finally the db name
    dbc_dbname=`echo "$dsn" | cut -f2 -d'/'`
fi

print_results
exit 0

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to