]> git.mjollnir.org Git - vserverctl.git/commitdiff
Added drupal profile
authorNigel McNie <nigel@catalyst.net.nz>
Mon, 14 May 2007 10:50:46 +0000 (22:50 +1200)
committerNigel McNie <nigel@freud.wgtn.cat-it.co.nz>
Mon, 14 May 2007 10:50:46 +0000 (22:50 +1200)
17 files changed:
profile/drupal/data/.bash_once [new file with mode: 0644]
profile/drupal/data/drupal-5.1.tar.gz [new file with mode: 0644]
profile/drupal/data/drupal-new-site.sh [new file with mode: 0755]
profile/drupal/data/drupal.conf [new file with mode: 0644]
profile/drupal/data/drupal.cron [new file with mode: 0644]
profile/drupal/data/postgres.connect.patch [new file with mode: 0644]
profile/drupal/data/settings.php [new file with mode: 0755]
profile/drupal/data/vserver.profile [new file with mode: 0644]
profile/drupal/files [new file with mode: 0644]
profile/drupal/options [new file with mode: 0644]
profile/drupal/packages [new file with mode: 0644]
profile/drupal/post-vserver [new file with mode: 0644]
profile/drupal/pre-host [new file with mode: 0644]
profile/drupal/pre-vserver [new file with mode: 0644]
profile/drupal/profile.conf [new file with mode: 0644]
profile/drupal/remove-host [new file with mode: 0644]
profile/drupal/templates [new file with mode: 0644]

diff --git a/profile/drupal/data/.bash_once b/profile/drupal/data/.bash_once
new file mode 100644 (file)
index 0000000..b06e74e
--- /dev/null
@@ -0,0 +1,3 @@
+# Now install drupal
+curl http://__VSNAME__.__HOST__.wgtn.cat-it.co.nz/install.php?profile=vserver > /dev/null
+chmod 644 /home/$USER/htdocs/sites/default/settings.php
diff --git a/profile/drupal/data/drupal-5.1.tar.gz b/profile/drupal/data/drupal-5.1.tar.gz
new file mode 100644 (file)
index 0000000..866570e
Binary files /dev/null and b/profile/drupal/data/drupal-5.1.tar.gz differ
diff --git a/profile/drupal/data/drupal-new-site.sh b/profile/drupal/data/drupal-new-site.sh
new file mode 100755 (executable)
index 0000000..b12b34b
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo "This script creates a new drupal site. It assumes the site will be created"
+echo "as a new subdomain of $(hostname -d)"
+
+SITENAME=$1
+if [ -z $SITENAME ]; then
+    echo -n "New site name? "
+    read SITENAME
+    
+    if [ -z $SITENAME ]; then
+        echo "No site name given, aborting"
+        exit 1
+    fi
+
+    if grep "$SITENAME.$(hostname -d)" /etc/apache2/sites-enabled/drupal.conf > /dev/null; then
+        echo "This site already exists in /etc/apache2/sites-enabled/drupal.conf, aborting"
+        exit 1
+    fi
+fi
+
+FULLSITENAME="$SITENAME.$(hostname -d)"
+
+# Enter a new virtualhost entry for the site
+echo "Creating new site $FULLSITENAME"
diff --git a/profile/drupal/data/drupal.conf b/profile/drupal/data/drupal.conf
new file mode 100644 (file)
index 0000000..371f65d
--- /dev/null
@@ -0,0 +1,16 @@
+<VirtualHost *>
+    ServerName __VSNAME__.__HOST__.wgtn.cat-it.co.nz
+
+    DocumentRoot /home/__PROFILEOPTION_username__/htdocs
+
+    <Directory /home/__PROFILEOPTION_username__/htdocs>
+        RewriteEngine on
+        RewriteBase /
+        RewriteCond %{REQUEST_FILENAME} !-f
+        RewriteCond %{REQUEST_FILENAME} !-d
+        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
+
+        AllowOverride all
+    </Directory>
+
+</VirtualHost>
diff --git a/profile/drupal/data/drupal.cron b/profile/drupal/data/drupal.cron
new file mode 100644 (file)
index 0000000..feb5935
--- /dev/null
@@ -0,0 +1 @@
+* * * * * root curl --silent --compressed http://__VSNAME__.__HOST__.wgtn.cat-it.co.nz/cron.php
diff --git a/profile/drupal/data/postgres.connect.patch b/profile/drupal/data/postgres.connect.patch
new file mode 100644 (file)
index 0000000..b51de41
--- /dev/null
@@ -0,0 +1,18 @@
+--- includes/install.pgsql.inc 2006-12-28 02:02:34.000000000 +1300
++++ includes/install.pgsql.inc 2007-03-29 17:44:23.000000000 +1200
+@@ -34,11 +34,12 @@
+   $url['path'] = urldecode($url['path']);
+   // Build pgsql connection string and allow for non-standard PostgreSQL port.
+-  $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) .' password='. $url['pass'] . ' host=' . $url['host'];
++  $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) . ' host=' . $url['host'];
++  $conn_string .= isset($url['pass']) ? ' password=' . $url['pass'] : '';
+   $conn_string .= isset($url['port']) ? ' port=' . $url['port'] : '';
+   // Test connecting to the database.
+-  $connection = @pg_connect($conn_string);
++  $connection = pg_connect($conn_string);
+   if (!$connection) {
+     drupal_set_message(st('Failure to connect to your PostgreSQL database server. PostgreSQL reports the following message: %error.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li><li>Are you sure you typed the correct database name?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => 'Connection failed. See log file for failure reason')), 'error');
+     return FALSE;
+
diff --git a/profile/drupal/data/settings.php b/profile/drupal/data/settings.php
new file mode 100755 (executable)
index 0000000..4e67d95
--- /dev/null
@@ -0,0 +1,168 @@
+<?php
+// $Id: settings.php,v 1.39 2007/01/14 02:05:15 unconed Exp $
+
+/**
+ * @file
+ * Drupal site-specific configuration file.
+ *
+ * IMPORTANT NOTE:
+ * This file may have been set to read-only by the Drupal installation
+ * program. If you make changes to this file, be sure to protect it again
+ * after making your modifications. Failure to remove write permissions
+ * to this file is a security risk.
+ *
+ * The configuration file to be loaded is based upon the rules below.
+ *
+ * The configuration directory will be discovered by stripping the
+ * website's hostname from left to right and pathname from right to
+ * left. The first configuration file found will be used and any
+ * others will be ignored. If no other configuration file is found
+ * then the default configuration file at 'sites/default' will be used.
+ *
+ * For example, for a fictitious site installed at
+ * http://www.drupal.org/mysite/test/, the 'settings.php'
+ * is searched in the following directories:
+ *
+ *  1. sites/www.drupal.org.mysite.test
+ *  2. sites/drupal.org.mysite.test
+ *  3. sites/org.mysite.test
+ *
+ *  4. sites/www.drupal.org.mysite
+ *  5. sites/drupal.org.mysite
+ *  6. sites/org.mysite
+ *
+ *  7. sites/www.drupal.org
+ *  8. sites/drupal.org
+ *  9. sites/org
+ *
+ * 10. sites/default
+ *
+ * If you are installing on a non-standard port number, prefix the
+ * hostname with that number. For example,
+ * http://www.drupal.org:8080/mysite/test/ could be loaded from
+ * sites/8080.www.drupal.org.mysite.test/.
+ */
+
+/**
+ * Database settings:
+ *
+ * Note that the $db_url variable gets parsed using PHP's built-in
+ * URL parser (i.e. using the "parse_url()" function) so make sure
+ * not to confuse the parser. If your username, password
+ * or database name contain characters used to delineate
+ * $db_url parts, you can escape them via URI hex encodings:
+ *
+ *   : = %3a   / = %2f   @ = %40
+ *   + = %2b   ( = %28   ) = %29
+ *   ? = %3f   = = %3d   & = %26
+ *
+ * To specify multiple connections to be used in your site (i.e. for
+ * complex custom modules) you can also specify an associative array
+ * of $db_url variables with the 'default' element used until otherwise
+ * requested.
+ *
+ * You can optionally set prefixes for some or all database table names
+ * by using the $db_prefix setting. If a prefix is specified, the table
+ * name will be prepended with its value. Be sure to use valid database
+ * characters only, usually alphanumeric and underscore. If no prefixes
+ * are desired, leave it as an empty string ''.
+ *
+ * To have all database names prefixed, set $db_prefix as a string:
+ *
+ *   $db_prefix = 'main_';
+ *
+ * To provide prefixes for specific tables, set $db_prefix as an array.
+ * The array's keys are the table names and the values are the prefixes.
+ * The 'default' element holds the prefix for any tables not specified
+ * elsewhere in the array. Example:
+ *
+ *   $db_prefix = array(
+ *     'default'   => 'main_',
+ *     'users'     => 'shared_',
+ *     'sessions'  => 'shared_',
+ *     'role'      => 'shared_',
+ *     'authmap'   => 'shared_',
+ *     'sequences' => 'shared_',
+ *   );
+ *
+ * Database URL format:
+ *   $db_url = 'mysql://username:password@localhost/databasename';
+ *   $db_url = 'mysqli://username:password@localhost/databasename';
+ *   $db_url = 'pgsql://username:password@localhost/databasename';
+ */
+$db_url = 'pgsql://general@pg81/__VSNAME__';
+$db_prefix = '';
+
+/**
+ * Base URL (optional).
+ *
+ * If you are experiencing issues with different site domains,
+ * uncomment the Base URL statement below (remove the leading hash sign)
+ * and fill in the URL to your Drupal installation.
+ *
+ * You might also want to force users to use a given domain.
+ * See the .htaccess file for more information.
+ *
+ * Examples:
+ *   $base_url = 'http://www.example.com';
+ *   $base_url = 'http://www.example.com:8888';
+ *   $base_url = 'http://www.example.com/drupal';
+ *   $base_url = 'https://www.example.com:8888/drupal';
+ *
+ * It is not allowed to have a trailing slash; Drupal will add it
+ * for you.
+ */
+# $base_url = 'http://www.example.com';  // NO trailing slash!
+
+/**
+ * PHP settings:
+ *
+ * To see what PHP settings are possible, including whether they can
+ * be set at runtime (ie., when ini_set() occurs), read the PHP
+ * documentation at http://www.php.net/manual/en/ini.php#ini.list
+ * and take a look at the .htaccess file to see which non-runtime
+ * settings are used there. Settings defined here should not be
+ * duplicated there so as to avoid conflict issues.
+ */
+ini_set('arg_separator.output',     '&amp;');
+ini_set('magic_quotes_runtime',     0);
+ini_set('magic_quotes_sybase',      0);
+ini_set('session.cache_expire',     200000);
+ini_set('session.cache_limiter',    'none');
+ini_set('session.cookie_lifetime',  2000000);
+ini_set('session.gc_maxlifetime',   200000);
+ini_set('session.save_handler',     'user');
+ini_set('session.use_only_cookies', 1);
+ini_set('session.use_trans_sid',    0);
+ini_set('url_rewriter.tags',        '');
+
+/**
+ * We try to set the correct cookie domain. If you are experiencing problems
+ * try commenting out the code below or specifying the cookie domain by hand.
+ */
+if (isset($_SERVER['HTTP_HOST'])) {
+  $domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
+  // Per RFC 2109, cookie domains must contain at least one dot other than the
+  // first. For hosts such as 'localhost', we don't set a cookie domain.
+  if (count(explode('.', $domain)) > 2) {
+    ini_set('session.cookie_domain', $domain);
+  }
+}
+
+/**
+ * Variable overrides:
+ *
+ * To override specific entries in the 'variable' table for this site,
+ * set them here. You usually don't need to use this feature. This is
+ * useful in a configuration file for a vhost or directory, rather than
+ * the default settings.php. Any configuration setting from the 'variable'
+ * table can be given a new value.
+ *
+ * Remove the leading hash signs to enable.
+ */
+# $conf = array(
+#   'site_name' => 'My Drupal site',
+#   'theme_default' => 'minnelli',
+#   'anonymous' => 'Visitor',
+# );
+
diff --git a/profile/drupal/data/vserver.profile b/profile/drupal/data/vserver.profile
new file mode 100644 (file)
index 0000000..7dc081a
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+function vserver_profile_modules() {
+    return array(
+        // Enable required core modules first.
+        'block', 'filter', 'node', 'system', 'user', 'watchdog',
+        
+        // Enable optional core modules next.
+        //'blog', 'color', 'comment', 'forum', 'help', 'menu', 'taxonomy',
+
+        // Then, enable any contributed modules here.
+        // 'og', 'views', 'views_ui', 'views_rss',
+    );
+}
+
+function vserver_profile_details() {
+    return array(
+        'name' => 'Vserver Drupal Instance: __VSNAME__',
+        'description' => 'Automatically installed via vserverctl on __HOST__',
+    );
+}
+
+function vserver_profile_final() {
+    user_save(new stdClass(),
+        array(
+            'name' => 'admin',
+            'pass' => 'admin',
+            'mail' => '__PROFILEOPTION_username__@catalyst.net.nz',
+            'status' => 1
+        )
+    );
+    return '<p>Vserver "__VSNAME__" successfully installed via vserverctl</p>';
+}
diff --git a/profile/drupal/files b/profile/drupal/files
new file mode 100644 (file)
index 0000000..b89123a
--- /dev/null
@@ -0,0 +1,3 @@
+drupal-5.1.tar.gz /root/
+postgres.connect.patch /root/
+drupal-new-site.sh /home/nigel/
diff --git a/profile/drupal/options b/profile/drupal/options
new file mode 100644 (file)
index 0000000..27d7766
--- /dev/null
@@ -0,0 +1 @@
+username
diff --git a/profile/drupal/packages b/profile/drupal/packages
new file mode 100644 (file)
index 0000000..a27ce99
--- /dev/null
@@ -0,0 +1,11 @@
+apache2
+libapache2-mod-php5
+php5-pgsql
+php5-gd
+file
+cogito
+make
+python
+build-essential
+debhelper
+fakeroot
diff --git a/profile/drupal/post-vserver b/profile/drupal/post-vserver
new file mode 100644 (file)
index 0000000..0ef15a6
--- /dev/null
@@ -0,0 +1,29 @@
+USR=${PROFILEOPTION_username}
+mkdir /home/$USR/htdocs
+echo '<?php phpinfo(); ?>' > /home/$USR/htdocs/index.php
+
+cd /home/$USR
+
+tar zxvf /root/drupal-5.1.tar.gz
+mv drupal-5.1/* htdocs/
+mv drupal-5.1/.htaccess htdocs/
+rmdir drupal-5.1
+mkdir htdocs/profiles/vserver
+cp /root/vserver.profile htdocs/profiles/vserver/
+cp /root/settings.php    htdocs/sites/default/
+
+( cd htdocs;  patch -p0 < /root/postgres.connect.patch )
+
+chown -R $USR:$USR /home/$USR
+chmod 777 /home/$USR/htdocs/sites/default/settings.php
+
+# Make data directory
+mkdir htdocs/files
+chown www-data:www-data htdocs/files
+
+# Configure apache2
+rm /etc/apache2/sites-enabled/000-default
+echo -e "NameVirtualHost *\nServerName drupal" > /etc/apache2/conf.d/vhost
+
+a2enmod rewrite
+/etc/init.d/apache2 force-reload
diff --git a/profile/drupal/pre-host b/profile/drupal/pre-host
new file mode 100644 (file)
index 0000000..5a66881
--- /dev/null
@@ -0,0 +1,6 @@
+# Create the database for the mahara install
+vserver pg81 suexec postgres createdb ${VSNAME} -Ogeneral -EUNICODE
+
+# Remove the tmp filesystem mounting
+grep -v tmp /etc/vservers/${VSNAME}/fstab > /etc/vservers/${VSNAME}/fstab.new
+mv /etc/vservers/${VSNAME}/fstab.new /etc/vservers/${VSNAME}/fstab
diff --git a/profile/drupal/pre-vserver b/profile/drupal/pre-vserver
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/profile/drupal/profile.conf b/profile/drupal/profile.conf
new file mode 100644 (file)
index 0000000..b96aaa2
--- /dev/null
@@ -0,0 +1 @@
+parent               = webserver
diff --git a/profile/drupal/remove-host b/profile/drupal/remove-host
new file mode 100644 (file)
index 0000000..7398f97
--- /dev/null
@@ -0,0 +1,2 @@
+# Drop the database
+vserver pg81 suexec postgres dropdb ${VSNAME}
diff --git a/profile/drupal/templates b/profile/drupal/templates
new file mode 100644 (file)
index 0000000..86f5f3c
--- /dev/null
@@ -0,0 +1,5 @@
+drupal.conf    /etc/apache2/sites-enabled/
+vserver.profile /root/
+settings.php    /root/
+.bash_once      /home/nigel/
+drupal.cron     /etc/cron.d/drupal