Skip to content

Commit

Permalink
update moodle to 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sawanoboly committed Feb 17, 2016
1 parent 9a28705 commit 24b0cf6
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .envrc.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export AWS_DEFAULT_PROFILE=prof
export AWS_ACCESS_KEY='access_key'
export AWS_SECRET_ACCESS_KEY='access_key_secret'
export AWS_EC2_KEYPAIR='keyname_of_ec2'
export AWS_EC2_KEYPASS='path/to/key'
export AWS_REGION='ap-northeast-1'
export PRODUCT_VERSION='3.0.2-1'
14 changes: 8 additions & 6 deletions Cheffile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
SITE
remote: http://community.opscode.com/api/v1
specs:
7-zip (1.0.2)
windows (>= 1.2.2)
ark (0.9.0)
7-zip (>= 0.0.0)
ark (1.0.1)
build-essential (>= 0.0.0)
seven_zip (>= 0.0.0)
windows (>= 0.0.0)
chef_handler (1.1.6)
build-essential (2.2.4)
chef_handler (1.3.0)
seven_zip (1.0.4)
windows (>= 1.2.2)
simplelog_handler (1.0.0)
windows (1.36.6)
windows (1.39.1)
chef_handler (>= 0.0.0)

DEPENDENCIES
Expand Down
5 changes: 3 additions & 2 deletions packer_ec2.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}"
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"product_version": "{{env `PRODUCT_VERSION`}}"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-e3106686",
"source_ami": "ami-60b6c60a",
"instance_type": "c3.large",
"ssh_username": "ec2-user",
"ssh_timeout": "10m",
Expand Down
6 changes: 3 additions & 3 deletions site-cookbooks/lw1_moodle/attributes/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

## Sum = Sha256
default[:lw1_moodle][:install] = {
version: '2.9.3',
version_base: 'stable29',
checksum: "48f59bd77df53fb5f608da492f09c21eb7c8994c3ddce39fa7a9fd8e3e0e8f46",
version: '3.0.2',
version_base: 'stable30',
checksum: "6f6eb95f0e354dc519067538ce60c54151b998efed6f981084ec929266d1b149",
base_url: "https://download.moodle.org"
}

Expand Down
16 changes: 8 additions & 8 deletions site-cookbooks/lw1_moodle/attributes/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

default[:lw1_moodle][:plugins][:modules] = {
"questionnaire" => {
version: "2.9.1",
location: "/9599/mod_questionnaire_moodle29_2015051103.zip",
checksum: "dfb81fe43b871d0e6b98015f499cb9de9b93a086df6c55e6af8ea8d9c8994af3"
version: "3.0.0",
location: "9600/mod_questionnaire_moodle30_2015102800.zip",
checksum: "3ec38b5a36e0c3cf8446c88f9b1dc8bcbd488815a9282d0d499000322e544f44"
},
"scheduler" => {
version: "2.9.0",
Expand All @@ -14,15 +14,15 @@
},
"pcast" => {
version: "2.9",
location: "/8649/mod_pcast_moodle29_2015050500.zip",
checksum: "bc32f6fd146d5f0b6f79104576d5ca548bc9e476ea4d50c3c03d43a7fa157052"
location: "/10415/mod_pcast_moodle30_2016013100.zip",
checksum: "b765620765fd5734793954a23ef57e16e82e6ea673dd83bbb91a291e20c327b1"
},
}

default[:lw1_moodle][:plugins][:blocks] = {
"configurable_reports" => {
version: "2.3.7",
location: "/9071/block_configurable_reports_moodle29_2011040119.zip",
checksum: "1769af4f28f9e082d8361cbeb1ecd99a95ce0dcd4e5fcf0c1fa20e481e87b659"
version: "3.0.1",
location: "/10535/block_configurable_reports_moodle30_2016020101.zip",
checksum: "b5602da740372082fef02f21ef2a1ad2708ee435c110f464272b8a7b6661d311"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php
// Sanity check.
if ( false ) {
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Error: PHP is not running</title>
</head>
<body class="wp-core-ui">
<h1 id="logo"><a href="http://amiage.com/" tabindex="-1">AMIMOTO AMI</a></h1>
<h2>Error: PHP is not running</h2>
<p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
</body>
</html>
<?php
}

function wp_check_invalid_utf8( $string, $strip = false ) {
$string = (string) $string;

if ( 0 === strlen( $string ) ) {
return '';
}

// Check for support for utf8 in the installed PCRE library once and store the result in a static
$utf8_pcre = @preg_match( '/^./u', 'a' );
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
if ( !$utf8_pcre ) {
return $string;
}

// preg_match fails when it encounters invalid UTF8 in $string
if ( 1 === @preg_match( '/^./us', $string ) ) {
return $string;
}

// Attempt to strip the bad chars if requested (not recommended)
if ( $strip && function_exists( 'iconv' ) ) {
return iconv( 'utf-8', 'utf-8', $string );
}

return '';
}

function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = 'UTF-8' ) {
$string = (string) $string;

if ( 0 === strlen( $string ) )
return '';

// Don't bother if there are no specialchars - saves some processing
if ( ! preg_match( '/[&<>"\']/', $string ) )
return $string;

// Account for the previous behaviour of the function when the $quote_style is not an accepted value
if ( empty( $quote_style ) )
$quote_style = ENT_NOQUOTES;
elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
$quote_style = ENT_QUOTES;

// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) )
$charset = 'UTF-8';

$_quote_style = $quote_style;

if ( $quote_style === 'double' ) {
$quote_style = ENT_COMPAT;
$_quote_style = ENT_COMPAT;
} elseif ( $quote_style === 'single' ) {
$quote_style = ENT_NOQUOTES;
}

// Handle double encoding ourselves
$string = @htmlspecialchars( $string, $quote_style, $charset );

// Backwards compatibility
if ( 'single' === $_quote_style )
$string = str_replace( "'", '&#039;', $string );

return $string;
}

function esc_attr( $text ) {
$safe_text = wp_check_invalid_utf8( $text );
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
return $safe_text;
}

$instance_id = trim(isset($_POST['instance_id']) ? $_POST['instance_id'] : '');
$err_msg = '';
$nfs_client = false;
if (isset($_POST['instance_id'])) {
//$valid_instance_ids = array(file_get_contents('http://169.254.169.254/latest/meta-data/instance-id'));
$valid_instance_ids = array('<%= @instance_id %>');
if ( file_exists('/opt/aws/cloud_formation.json') ) {
$data = json_decode(file_get_contents('/opt/aws/cloud_formation.json'), true);
if ( isset($data['nfs']) ) {
$valid_instance_ids[] = trim($data['nfs']['server']['instance-id']);
$nfs_client = true;
}
unset($data);
}
if ( in_array($instance_id,$valid_instance_ids) ) {
$host_name = esc_attr($_SERVER['SERVER_NAME']);
// file_put_contents(dirname(dirname(__FILE__)).'/.valid.'.$host_name, 'valid');
unlink(__FILE__);
header('Location: /');
} else {
$err_msg = 'Sorry, that isn&#8217;t a valid instance ID.';
}
}

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Installation</title>
<link rel='stylesheet' id='buttons-css' href='//amimoto-ami.com/wp-includes/css/buttons.min.css?ver=4.1' type='text/css' media='all' />
<link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&#038;subset=latin%2Clatin-ext&#038;ver=4.1' type='text/css' media='all' />
<link rel='stylesheet' id='install-css' href='//amimoto-ami.com/wp-admin/css/install.min.css?ver=4.1' type='text/css' media='all' />
<style type="text/css">
#logo a {
background: url(//amiage.com/wp-content/themes/amiage.com/images/site-title.png) no-repeat !important;
margin: -150px auto 25px;
width: 175px;
height: 104px;
background-size: 104px auto;
}
</style>
</head>
<body class="wp-core-ui">
<h1 id="logo"><a href="http://amiage.com/" tabindex="-1">AMIMOTO AMI</a></h1>

<h1>Welcome to AMIAGE AMI</h1>

<p>Please enter your Instance ID to continue installation.</p>

<?php
if ( !empty($err_msg) ) {
printf('<p class="message">%s</p>'."\n", $err_msg);
}
?>
<form id="setup" method="post" action="install_amiage.php" novalidate="novalidate">
<table class="form-table">
<tr>
<th scope="row"><label for="instance_id"><?php echo $nfs_client ? 'Your NFS Server Instance ID' : 'Your Instance ID'; ?></label></th>
<td>
<input name="instance_id" type="text" id="instance_id" size="25" value="<?php echo esc_attr($instance_id); ?>" />
</tr>
</table>
<p class="step"><input type="submit" name="Submit" value="Next Step" class="button button-large" /></p>
<input type="hidden" name="language" value="" />
</form>
<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
<script type='text/javascript' src='//amimoto-ami.com/wp-includes/js/jquery/jquery.js?ver=1.11.1'></script>
<script type='text/javascript' src='//amimoto-ami.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var _zxcvbnSettings = {"src":"\/\/amimoto-ami.com\/wp-includes\/js\/zxcvbn.min.js"};
/* ]]> */
</script>
<script type='text/javascript' src='//amimoto-ami.com/wp-includes/js/zxcvbn-async.min.js?ver=1.0'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var pwsL10n = {"empty":"\u5f37\u5ea6\u8868\u793a\u5668","short":"\u975e\u5e38\u306b\u5f31\u3044","bad":"\u5f31\u3044","good":"\u666e\u901a","strong":"\u5f37\u529b","mismatch":"\u4e0d\u4e00\u81f4"};
/* ]]> */
</script>
<script type='text/javascript' src='//amimoto-ami.com/wp-admin/js/password-strength-meter.min.js?ver=4.1'></script>
<script type='text/javascript' src='//amimoto-ami.com/wp-includes/js/underscore.min.js?ver=1.6.0'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */
</script>
<script type='text/javascript' src='//amimoto-ami.com/wp-includes/js/wp-util.min.js?ver=4.1'></script>
<script type='text/javascript' src='//amimoto-ami.com/wp-admin/js/user-profile.min.js?ver=4.1'></script>
<script type='text/javascript' src='//amimoto-ami.com/wp-admin/js/language-chooser.min.js?ver=4.1'></script>
</body>
</html>
15 changes: 15 additions & 0 deletions site-cookbooks/lw1_moodle/files/httpd/moodle.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Directory "/var/www/html">
## InstanceID Checker >>>
# You can remove this lines after registration.
RewriteEngine On
RewriteOptions InheritBefore
RewriteCond /var/www/html/install_amiage.php -f
RewriteCond %{REQUEST_URI} !^/install_amiage.php [NC]
RewriteRule .* /install_amiage.php [R=302,L]
## << InstanceID Checker

Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
4 changes: 4 additions & 0 deletions site-cookbooks/lw1_moodle/recipes/moodle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
action [:mount, :enable]
end

cookbook_file "/etc/httpd/conf.d/moodle.conf" do
source "httpd/moodle.conf"
end

directory "/var/www/moodledata" do
action :create
mode 0775
Expand Down
14 changes: 14 additions & 0 deletions site-cookbooks/lw1_moodle/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

package 'git'
package 'tmux'
package 'postfix'
package 'mysql-server'

service 'sendmail' do
action [:stop, :disable]
end

%w[
php56
php56-mysqlnd
Expand All @@ -26,3 +31,12 @@
_file.write_file
end
end

ruby_block "postfix main.cf" do
block do
_file = Chef::Util::FileEdit.new('/etc/postfix/main.cf')
_file.search_file_replace_line(/^#local_recipient_maps =$/, "local_recipient_maps =")
_file.write_file
end
end

4 changes: 4 additions & 0 deletions site-cookbooks/lw1_moodle/recipes/setup_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
source "lw1_tasks/date.ini.erb"
end

cookbook_file "/opt/lw1/tasks/install_amiage.php.erb" do
source "lw1_tasks/install_amiage.php.erb"
end

cron "setup_moodle_on_init" do
action :create
time :reboot
Expand Down
22 changes: 20 additions & 2 deletions site-cookbooks/lw1_moodle/templates/default/tasks/first_boot.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ end
moodle_location = adjust_location
moodle_var = "<%= node[:lw1_moodle][:install][:version] %>"

file '/etc/httpd/conf.d/welcome.conf' do
action :delete
%w[userdir.conf welcome.conf autoindex.conf].map do |conf|
file "/etc/httpd/conf.d/#{conf}" do
action :delete
end
end

service 'mysqld' do
Expand Down Expand Up @@ -72,6 +74,18 @@ template "/etc/php.d/date.ini" do
variables moodle_location
end

## Permission Trouble.
# template "/var/www/html/install_amiage.php" do
# local true
# mode '0644'
# owner "apache"
# group "apache"
# source "/opt/lw1/tasks/install_amiage.php.erb"
# variables ({
# :instance_id => node[:ec2][:instance_id]
# })
# end

bash "modify permissions" do
code <<-'EOL'
chown -R root.apache /var/www/moodle/mod
Expand All @@ -84,6 +98,10 @@ bash "modify permissions" do
EOL
end

service 'postfix' do
action [:start, :enable]
end

service 'httpd' do
action [:enable, :start]
end
Expand Down

0 comments on commit 24b0cf6

Please sign in to comment.