Merge branch '0.8.x' of git@gitorious.org:laconica/dev into 0.8.x

This commit is contained in:
Zach Copley 2009-06-15 22:52:14 +00:00
commit 1a51251375
3 changed files with 52 additions and 4 deletions

View File

@ -43,12 +43,19 @@ class Status_network extends DB_DataObject
{
global $config;
$sn = null;
// XXX I18N, probably not crucial for hostnames
// XXX This probably needs a tune up
if (0 == strncasecmp(strrev($wildcard), strrev($servername), strlen($wildcard))) {
$parts = explode('.', $servername);
$sn = Status_network::staticGet('nickname', strtolower($parts[0]));
// special case for exact match
if (0 == strcasecmp($servername, $wildcard)) {
$sn = Status_network::staticGet('nickname', '');
} else {
$parts = explode('.', $servername);
$sn = Status_network::staticGet('nickname', strtolower($parts[0]));
}
} else {
$sn = Status_network::staticGet('hostname', strtolower($servername));
}
@ -70,9 +77,9 @@ class Status_network extends DB_DataObject
$config['site']['logo'] = $sn->logo;
}
return true;
return $sn;
} else {
return false;
return null;
}
}
}

11
scripts/setup.cfg.sample Normal file
View File

@ -0,0 +1,11 @@
# CONFIGURATION FILE for setup_status_network.sh
# Base database name; full name will include nickname
export DBBASE=_example_net
export USERBASE=_example_net
export ADMIN=root
export ADMINPASS=yourpassword
export SITEDB=example_net_site
export AVATARBASE=/var/www/avatar.example.net

30
scripts/setup_status_network.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
source ./setup.cfg
export nickname=$1
export sitename=$2
export password=`pwgen 20`
export database=$nickname$DBBASE
export username=$nickname$USERBASE
# Create the db
mysqladmin -u $ADMIN --password=$ADMINPASS create $database
for f in laconica.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
mysql -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
done
mysql -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password';
GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'%' IDENTIFIED BY '$password';
INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created)
VALUES ('$nickname', '$DBHOST', '$username', '$password', '$database', '$sitename', now());
ENDOFCOMMANDS
mkdir $AVATARBASE/$nickname
chmod a+w $AVATARBASE/$nickname