Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
178 lines (132 sloc) 5.34 KB
#
# Drupal Drupal.me file
# https://github.com/turboapps/turbome/tree/master/drupal
#
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
###################################
# Meta tags
###################################
meta title="Drupal"
meta namespace="drupal"
meta name="drupal"
###################################
# Pull dependency images
###################################
layer apache/apache,php/php,mysql/mysql
using gnu/wget,fart/fart,7-zip/7-zip,python/python:3.4.1
###################################
# Download and install
###################################
cmd pip install requests --quiet
# Set working directory
cmd mkdir c:\Workspace
workdir c:\Workspace
batch
echo import requests >> getVersion.py
echo import re >> getVersion.py
echo host = 'http://www.drupal.org/project/drupal' >> getVersion.py
echo headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0'} >> getVersion.py
echo r = requests.get(host , headers=headers, timeout=10) >> getVersion.py
echo version = ''.join(list(re.findall('(http://ftp.drupal.org/files/projects/drupal-(\d+\.\d+).zip)', r.text)[0][1])) >> getVersion.py
echo print(version) >> getVersion.py
cmd python getVersion.py
var version = last
var url = "http://ftp.drupal.org/files/projects/drupal-" + version + ".zip"
# Download
cmd "wget --no-check-certificate --no-verbose -O drupal.zip %url%"
# Download and extract Drupal
cmd 7z x drupal.zip -oc:\drupal-temp
workdir C:\
cmd mkdir c:\drupal
var extractedpath = "c:\drupal-temp\drupal-" + version + "\*.*"
cmd xcopy /s/e %extractedpath% c:\drupal
cmd del c:\drupal-temp /S /Q
cmd rmdir c:\drupal-temp /S /Q
# Configure database settings
cmd "copy" c:\drupal\sites\default\default.settings.php c:\drupal\sites\default\settings.php
cmd fart.exe c:\drupal\sites\default\settings.php "$databases = array();" "$databases = array ('default' => array ('default' => array ('database' => 'drupal','username' => 'root','password' => '','host' => 'localhost','port' => '','driver' => 'mysql','prefix' => '',),),);" & ver > nul
cmd fart.exe c:\drupal\.htaccess "Order allow,deny" "Require all denied" & ver > nul
###################################
# Initialize Apache
###################################
# Configure Apache
workdir C:\apache\apache2\conf
batch cmd
echo. >> httpd.conf
REM Enable PHP
echo LoadModule php5_module "C:/php/php5apache2_4.dll">> httpd.conf
echo AddHandler application/x-httpd-php .php>> httpd.conf
echo PHPIniDir "C:/php">> httpd.conf
fart.exe --ignore-case httpd.conf "DirectoryIndex " "DirectoryIndex index.php "
REM Set document root to Drupal directory
fart.exe --ignore-case httpd.conf "${SRVROOT}/htdocs" "C:/drupal"
REM Enable mod rewrite for pretty links
fart.exe --ignore-case httpd.conf "#LoadModule rewrite_module modules/mod_rewrite.so" "LoadModule rewrite_module modules/mod_rewrite.so"
fart.exe --ignore-case httpd.conf " Options Indexes FollowSymLinks" " Options All"
fart.exe --ignore-case httpd.conf " AllowOverride None" " AllowOverride All"
ver > nul
###################################
# Initialize PHP
###################################
# Configure PHP
workdir C:\php
batch cmd
REM Uncomment required extension
fart.exe --ignore-case php.ini ";extension=php_mysql.dll" "extension=php_mysql.dll" & ver > nul
fart.exe --ignore-case php.ini ";extension=php_gd2.dll" "extension=php_gd2.dll" & ver > nul
fart.exe --ignore-case php.ini ";extension=php_pdo_mysql.dll" "extension=php_pdo_mysql.dll" & ver > nul
###################################
# Initialize MySQL
###################################
workdir C:\mysql\bin
batch cmd
echo Creating database instruction file
echo CREATE DATABASE drupal;> spn_cmd.txt
REM ### LOOP #######################################
REM Attempt to create the database 5 times, quit if all fail
REM On slow machines, mysqld may not start fast enough to succeed on the first try
:createDB
REM increment count
set /A spn_temp_count=%spn_temp_count%+1
echo Using database instruction file to configure mysql, attempt #%spn_temp_count%
REM sleep for 5 seconds
ping -n 6 127.0.0.1 > nul
REM pass database instruction file to mysql.exe
mysql -u root < spn_cmd.txt
REM if this fails more than 5 times, then fail the setup
IF %spn_temp_count% GEQ 6 GOTO fail
REM if this succeeds, no need to retry
IF %ERRORLEVEL% EQU 0 GOTO succeed
REM retry
goto createDB
REM ################################################
REM issue exit code on failure
:fail
echo MySQL setup failed.
exit /b 1
REM clean up and shutdown on success
:succeed
echo MySQL setup succeeded.
del spn_cmd.txt
REM mysqladmin.exe -u root shutdown
###################################
# Environment Variables
###################################
# No variables needed
###################################
# Clean up
###################################
cmd rmdir c:\Workspace /s /q
cmd rmdir c:\wget /s /q
cmd rmdir c:\python34 /s /q
###################################
# Version
###################################
meta tag=version
meta version=version
###################################
# Startup File
###################################
workdir C:\drupal
startup file ("cmd","/k echo Visit http://localhost:8080/install.php to configure Drupal, if you haven't already.")