launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01092
[Merge] lp:~bac/launchpad/lp-db-setup into lp:launchpad/devel
Brad Crittenden has proposed merging lp:~bac/launchpad/lp-db-setup into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Fix the database set-up script to work with postgresql start-up script changes in 10.10. Kept the old one around, too, but I'm unsure if that is a good idea.
Test: Warning, this will blow away your database and you must be on Maverick.
utilities/launchpad-database-setup <your username>
--
https://code.launchpad.net/~bac/launchpad/lp-db-setup/+merge/35822
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/launchpad/lp-db-setup into lp:launchpad/devel.
=== modified file 'utilities/launchpad-database-setup'
--- utilities/launchpad-database-setup 2010-01-28 17:13:53 +0000
+++ utilities/launchpad-database-setup 2010-09-17 12:34:16 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
if [ -n "$1" ]; then
@@ -20,8 +20,8 @@
for pgversion in 8.4 8.3 8.2
do
- if [ -e /etc/init.d/postgresql-$pgversion ]
- then
+ sudo grep -q "^auto" /etc/postgresql/$pgversion/main/start.conf
+ if [ $? -eq 0 ]; then
break
fi
done
@@ -41,7 +41,7 @@
echo "ensure postgres is running on port 5432."
fi;
-sudo /etc/init.d/postgresql-$pgversion stop
+sudo /etc/init.d/postgresql stop $pgversion
echo Purging postgresql data...
sudo pg_dropcluster $pgversion main --stop-server
@@ -99,7 +99,7 @@
EOF
fi
-sudo /etc/init.d/postgresql-$pgversion start
+sudo /etc/init.d/postgresql start $pgversion
echo Waiting 10 seconds for postgresql to come up...
sleep 10
=== added file 'utilities/launchpad-database-setup-pre-maverick'
--- utilities/launchpad-database-setup-pre-maverick 1970-01-01 00:00:00 +0000
+++ utilities/launchpad-database-setup-pre-maverick 2010-09-17 12:34:16 +0000
@@ -0,0 +1,114 @@
+#!/bin/sh
+#
+# Copyright 2009 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+if [ -n "$1" ]; then
+ USER=$1
+ echo "Creating Launchpad database for $USER"
+else
+ echo "usage: launchpad-database-setup DEVELOPER_USER"
+ echo "THIS SCRIPT WILL DESTROY ALL POSTGRESQL DATA for the given user"
+ echo "If you really want that, run it with the username of your "
+ echo "local developer account."
+ exit 1
+fi
+
+# This attempts to automate instructions provided on
+# https://dev.launchpad.net/DatabaseSetup which are intended for
+# initial Launchpad setup on an otherwise unconfigured postgresql instance
+
+for pgversion in 8.4 8.3 8.2
+do
+ if [ -e /etc/init.d/postgresql-$pgversion ]
+ then
+ break
+ fi
+done
+
+if [ -z "$pgversion" ]
+then
+ echo "Unable to determine your postgres version."
+ exit 1
+fi
+
+echo "Using postgres $pgversion"
+
+# Make sure that we have the correct version running on port 5432
+sudo grep -q "port.*5432" /etc/postgresql/$pgversion/main/postgresql.conf
+if [ $? -ne 0 ]; then
+ echo "Please check /etc/postgresql/$pgversion/main/postgresql.conf and"
+ echo "ensure postgres is running on port 5432."
+fi;
+
+sudo /etc/init.d/postgresql-$pgversion stop
+
+echo Purging postgresql data...
+sudo pg_dropcluster $pgversion main --stop-server
+echo Re-creating postgresql database...
+# Setting locale to C to make the server run in that locale.
+LC_ALL=C sudo pg_createcluster $pgversion main --encoding UNICODE
+
+echo Applying postgresql configuration changes...
+
+sudo cp -a /etc/postgresql/$pgversion/main/pg_hba.conf \
+ /etc/postgresql/$pgversion/main/pg_hba.conf.old
+sudo grep -q Launchpad /etc/postgresql/$pgversion/main/pg_hba.conf || \
+sudo patch /etc/postgresql/$pgversion/main/pg_hba.conf <<'EOF'
+--- pg_hba.conf 2005-11-02 17:33:08.000000000 -0800
++++ /tmp/pg_hba.conf 2005-11-03 07:32:46.932400423 -0800
+@@ -58,7 +58,9 @@
+ # on a non-local interface via the listen_addresses configuration parameter,
+ # or via the -i or -h command line switches.
+ #
+-
++# Launchpad users
++local all all trust
++host all all 127.0.0.1/32 trust
+
+
+
+EOF
+sudo chown --reference=/etc/postgresql/$pgversion/main/pg_hba.conf.old \
+ /etc/postgresql/$pgversion/main/pg_hba.conf
+sudo chmod --reference=/etc/postgresql/$pgversion/main/pg_hba.conf.old \
+ /etc/postgresql/$pgversion/main/pg_hba.conf
+
+sudo grep -q Launchpad /etc/postgresql/$pgversion/main/postgresql.conf || \
+sudo tee -a /etc/postgresql/$pgversion/main/postgresql.conf <<'EOF'
+
+##
+## Launchpad configuration
+##
+# Enable launchpad full text searching in database
+search_path='$user,public,ts2'
+add_missing_from=false
+#enable_seqscan=false
+log_statement='none'
+log_line_prefix='[%t] %q%u@%d '
+fsync = off
+
+EOF
+
+if [ "$pgversion" = 8.2 -o "$pgversion" = 8.3 ]
+then
+ sudo grep -q '^[[:space:]]*max_fsm_relations' /etc/postgresql/$pgversion/main/postgresql.conf || \
+ sudo tee -a /etc/postgresql/$pgversion/main/postgresql.conf <<'EOF'
+max_fsm_relations=2000
+
+EOF
+fi
+
+sudo /etc/init.d/postgresql-$pgversion start
+
+echo Waiting 10 seconds for postgresql to come up...
+sleep 10
+
+echo Creating postgresql user $USER
+sudo -u postgres /usr/lib/postgresql/$pgversion/bin/createuser -a -d $USER
+
+echo
+echo Looks like everything went ok.
+echo Now run '"make schema"' at the top level of the launchpad tree.
+
+exit 0