<commit_before>#
# Cookbook Name:: appsindo
# Recipe:: nginx
# Author:: <NAME> <<EMAIL>>
# Description::
#   Install nginx
#
# Copyright 2014, PT Appsindo Technology as BSD-style found in the LICENSE file
#
# @author <NAME> <<EMAIL>>
#

# adding whoever the user set to the default `www-data` group
localUser  = node['www']['user']
localGroup = node['www']['group']
bash "add user #{localUser} to www-data" do
  code "usermod -a -G www-data #{localUser}"
  code "usermod -a -G #{localGroup} www-data"
end

is_pagespeed = node["nginx"]["is_pagespeed"]

if is_pagespeed then
    # download pagespeed
    git "/tmp/ngx_pagespeed" do
        repository  "git://github.com/pagespeed/ngx_pagespeed.git"
        reference   "master"
        action      :sync
    end

    # download psol
    bash "make & install pagespeed SOL for nginx" do
      cwd  "/tmp/ngx_pagespeed"
      code <<-EOF
          wget https://dl.google.com/dl/page-speed/psol/1.9.32.1.tar.gz
          tar -xzvf 1.9.32.1.tar.gz
      EOF
    end

    # tmp for pagespeed
    directory "/var/tmp/pagespeed/" do
      owner   "root"
      group   "root"
      mode    0775
      action  :create
    end

    # pagespeed
    node.default['nginx']['source']['default_configure_flags'].push("--add-module=/tmp/ngx_pagespeed")
end

# prepare tmp for nginx
directory "/var/tmp/nginx/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/client/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/proxy/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/fcgi/" do<commit_msg>Modify nginx pagespeed to comply with google https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source<commit_after>#
# Cookbook Name:: appsindo
# Recipe:: nginx
# Author:: <NAME> <<EMAIL>>
# Description::
#   Install nginx
#
# Copyright 2014, PT Appsindo Technology as BSD-style found in the LICENSE file
#
# @author <NAME> <<EMAIL>>
#

# adding whoever the user set to the default `www-data` group
localUser  = node['www']['user']
localGroup = node['www']['group']
bash "add user #{localUser} to www-data" do
  code "usermod -a -G www-data #{localUser}"
  code "usermod -a -G #{localGroup} www-data"
end

is_pagespeed = node["nginx"]["is_pagespeed"]
nps_version  = "192.168.127.12"

if is_pagespeed then
    # download Pagespeed and PSOL and compile
    bash "make & install pagespeed for nginx" do
      cwd  "/tmp/ngx_pagespeed"
      code <<-EOF
          wget https://github.com/pagespeed/ngx_pagespeed/archive/release-#{nps_version}-beta.zip
          unzip release-#{nps_version}-beta.zip
          cd ngx_pagespeed-release-#{nps_version}-beta/
          wget https://dl.google.com/dl/page-speed/psol/#{nps_version}.tar.gz
          tar -xzvf #{nps_version}.tar.gz
      EOF
    end

    # tmp for pagespeed
    directory "/var/tmp/pagespeed/" do
      owner   "root"
      group   "root"
      mode    0775
      action  :create
    end

    # pagespeed
    node.default['nginx']['source']['default_configure_flags'].push("--add-module=/tmp/ngx_pagespeed-release-#{nps_version}-beta")
end

# prepare tmp for nginx
directory "/var/tmp/nginx/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/client/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/proxy/" do
  owner   "root"
  group   "root"
  mode    0755
  action  :create
end
directory "/var/tmp/nginx/fcgi/" do
{'fraction_non_alphanumeric': 0.130859375, 'fraction_numerical': 0.017020089285714284, 'mean_word_length': 2.8714902807775378, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 12, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5127418', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1268, 'n_words': 325}