From: Nigel McNie Date: Mon, 14 May 2007 10:50:46 +0000 (+1200) Subject: Added drupal profile X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=454104dd0c1339b3c43b475310da94552d1da861;p=vserverctl.git Added drupal profile --- diff --git a/profile/drupal/data/.bash_once b/profile/drupal/data/.bash_once new file mode 100644 index 0000000..b06e74e --- /dev/null +++ b/profile/drupal/data/.bash_once @@ -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 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 index 0000000..b12b34b --- /dev/null +++ b/profile/drupal/data/drupal-new-site.sh @@ -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 index 0000000..371f65d --- /dev/null +++ b/profile/drupal/data/drupal.conf @@ -0,0 +1,16 @@ + + ServerName __VSNAME__.__HOST__.wgtn.cat-it.co.nz + + DocumentRoot /home/__PROFILEOPTION_username__/htdocs + + + RewriteEngine on + RewriteBase / + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] + + AllowOverride all + + + diff --git a/profile/drupal/data/drupal.cron b/profile/drupal/data/drupal.cron new file mode 100644 index 0000000..feb5935 --- /dev/null +++ b/profile/drupal/data/drupal.cron @@ -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 index 0000000..b51de41 --- /dev/null +++ b/profile/drupal/data/postgres.connect.patch @@ -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.For more help, see the Installation and upgrading handbook. 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 index 0000000..4e67d95 --- /dev/null +++ b/profile/drupal/data/settings.php @@ -0,0 +1,168 @@ + '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', '&'); +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 index 0000000..7dc081a --- /dev/null +++ b/profile/drupal/data/vserver.profile @@ -0,0 +1,33 @@ + '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 '

Vserver "__VSNAME__" successfully installed via vserverctl

'; +} diff --git a/profile/drupal/files b/profile/drupal/files new file mode 100644 index 0000000..b89123a --- /dev/null +++ b/profile/drupal/files @@ -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 index 0000000..27d7766 --- /dev/null +++ b/profile/drupal/options @@ -0,0 +1 @@ +username diff --git a/profile/drupal/packages b/profile/drupal/packages new file mode 100644 index 0000000..a27ce99 --- /dev/null +++ b/profile/drupal/packages @@ -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 index 0000000..0ef15a6 --- /dev/null +++ b/profile/drupal/post-vserver @@ -0,0 +1,29 @@ +USR=${PROFILEOPTION_username} +mkdir /home/$USR/htdocs +echo '' > /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 index 0000000..5a66881 --- /dev/null +++ b/profile/drupal/pre-host @@ -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 index 0000000..e69de29 diff --git a/profile/drupal/profile.conf b/profile/drupal/profile.conf new file mode 100644 index 0000000..b96aaa2 --- /dev/null +++ b/profile/drupal/profile.conf @@ -0,0 +1 @@ +parent = webserver diff --git a/profile/drupal/remove-host b/profile/drupal/remove-host new file mode 100644 index 0000000..7398f97 --- /dev/null +++ b/profile/drupal/remove-host @@ -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 index 0000000..86f5f3c --- /dev/null +++ b/profile/drupal/templates @@ -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