Skip to content

Instantly share code, notes, and snippets.

@d-sea
Last active January 2, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d-sea/8328145 to your computer and use it in GitHub Desktop.
Save d-sea/8328145 to your computer and use it in GitHub Desktop.
[SmartWP](http://www.shakesoul.net/smartwp) - Chef recipe for origin site : site-cookbooks/swp_scale-org/recipes/default.rb
#
# Cookbook Name:: swp_scale-org
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
############## s3fs install ###########
package "gcc" do
action :install
end
package "libstdc++-devel" do
action :install
end
package "gcc-c++" do
action :install
end
package "fuse" do
action :install
end
package "fuse-devel" do
action :install
end
package "curl-devel" do
action :install
end
package "libxml2-devel" do
action :install
end
package "openssl-devel" do
action :install
end
package "mailcap" do
action :install
end
# install s3fs
bash "install s3fs" do
user 'root'
cwd "/home/#{node['userinfo']['username']}"
environment "HOME" => "/home/#{node['userinfo']['username']}"
code <<-EOH
wget -O - "http://s3fs.googlecode.com/files/s3fs-#{node['s3fs']['version']}.tar.gz" | tar xzf -
cd s3fs-#{node['s3fs']['version']}/
./configure --prefix=/usr
make
make install
touch /etc/passwd-s3fs
echo #{node['userinfo']['accessley_id']}:#{node['userinfo']['secret-accesskey_id']} > /etc/passwd-s3fs
chmod 600 /etc/passwd-s3fs
echo s3fs smartwp:/manage/uploads-st /home/#{node['userinfo']['username']}/Dropbox/SmartWP/demo00/html-staging/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
echo s3fs smartwp:/manage/uploads /home/#{node['userinfo']['username']}/Dropbox/SmartWP/demo00/html-production/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
echo s3fs smartwp:/manage/shakesoul_uploads-st /home/#{node['userinfo']['username']}/Dropbox/SmartWP/shakesoul.net/html-staging/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
echo s3fs smartwp:/manage/shakesoul_uploads-pr /home/#{node['userinfo']['username']}/Dropbox/SmartWP/shakesoul.net/html-production/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
echo s3fs smartwp:/manage/hirofukami_uploads-st /home/#{node['userinfo']['username']}/Dropbox/SmartWP/hirofukami.com/html-staging/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
echo s3fs smartwp:/manage/hirofukami_uploads-pr /home/#{node['userinfo']['username']}/Dropbox/SmartWP/hirofukami.com/html-production/wp-content/uploads -o allow_other -o nonempty >> /etc/rc.local
EOH
not_if {::File.exists?("/etc/passwd-s3fs")}
end
############## nginx and php-fpm ##################
template "nginx.conf" do
path "/etc/nginx/nginx.conf"
source "nginx.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[nginx]'
end
template "nginx demo00.conf" do
path "/etc/nginx/conf.d/demo00.conf"
source "nginx-demo00.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[nginx]'
end
template "nginx hirofukami.conf" do
path "/etc/nginx/conf.d/hirofukami.conf"
source "nginx-hirofukami.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[nginx]'
end
template "nginx shakesoul.conf" do
path "/etc/nginx/conf.d/shakesoul.conf"
source "nginx-shakesoul.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[nginx]'
end
template "php.ini" do
path "/etc/php.ini"
source "php.ini.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[php-fpm]'
end
template "www.conf" do
path "/etc/php-fpm.d/www.conf"
source "php-fpm-www.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, 'service[php-fpm]'
end
directory "/var/lib/nginx" do
owner node['userinfo']['username']
group "root"
action :create
end
directory "/var/lib/nginx/tmp" do
owner node['userinfo']['username']
group "root"
action :create
end
############## Dropbox and WordPress ##############
# install Dropbox Linux
bash "install dropbox" do
user node['userinfo']['username']
group node['userinfo']['username']
cwd "/home/#{node['userinfo']['username']}"
environment "HOME" => "/home/#{node['userinfo']['username']}"
code <<-EOH
wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
mkdir ~/bin
cd ~/bin
wget -O ~/bin/dropbox https://www.dropbox.com/download?dl=packages/dropbox.py
chmod a+x dropbox
EOH
not_if {::File.exists?("/home/#{node['userinfo']['username']}/.dropbox")}
end
# dropbox start
template "/etc/init.d/dropbox" do
path "/etc/init.d/dropbox"
source "dropbox-initd.erb"
owner "root"
group "root"
mode 0755
notifies :reload, 'service[dropbox]'
end
service "dropbox" do
supports :start => true, :stop => true
action [:enable, :start]
end
############# Last process start ###############
service "nginx" do
supports :status => true, :restart => true, :reload => true
action [:enable, :start]
end
service "php-fpm" do
supports :status => true, :restart => true, :reload => true
action [:enable, :start]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment