From d6ff702d7f0937451c8595c7b3cbfb9f2813a07b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 15 Jun 2009 13:34:52 -0700 Subject: [PATCH 1/4] Return network from network setup function Return the network from the network setup function. Also, special-case for when we get a server name the same as the wildcard. --- classes/Status_network.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/classes/Status_network.php b/classes/Status_network.php index d2b942bfb1..96b6d9a05b 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -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 == strncmp($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; } } } From 6532f0dff63576c94debe521d1ff8d9f594fe422 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 15 Jun 2009 14:29:25 -0700 Subject: [PATCH 2/4] strncmp -> strcasecmp --- classes/Status_network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Status_network.php b/classes/Status_network.php index 96b6d9a05b..bf05ad61e0 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -50,7 +50,7 @@ class Status_network extends DB_DataObject if (0 == strncasecmp(strrev($wildcard), strrev($servername), strlen($wildcard))) { // special case for exact match - if (0 == strncmp($servername, $wildcard)) { + if (0 == strcasecmp($servername, $wildcard)) { $sn = Status_network::staticGet('nickname', ''); } else { $parts = explode('.', $servername); From 01c03223c2c559deec0191dd7a100e152981e1e2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 15 Jun 2009 15:13:24 -0700 Subject: [PATCH 3/4] Script to set up new status networks --- scripts/setup.cfg.sample | 11 +++++++++++ scripts/setup_status_network.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 scripts/setup.cfg.sample create mode 100644 scripts/setup_status_network.sh diff --git a/scripts/setup.cfg.sample b/scripts/setup.cfg.sample new file mode 100644 index 0000000000..4194bc146d --- /dev/null +++ b/scripts/setup.cfg.sample @@ -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 + diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh new file mode 100644 index 0000000000..d80612b940 --- /dev/null +++ b/scripts/setup_status_network.sh @@ -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 From 177e4adf40bd41fc711c91fc6d16729b7f1b5796 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 15 Jun 2009 15:13:49 -0700 Subject: [PATCH 4/4] change mods for setup script --- scripts/setup_status_network.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/setup_status_network.sh diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh old mode 100644 new mode 100755