machines 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/.gitignore +11 -0
  2. data/EXAMPLES.md +18 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +14 -0
  5. data/INSTALL.md +25 -0
  6. data/LICENSE +23 -0
  7. data/README.md +271 -0
  8. data/Rakefile +60 -0
  9. data/TODO.md +92 -0
  10. data/bin/machines +6 -0
  11. data/lib/machines/app_settings.rb +54 -0
  12. data/lib/machines/base.rb +13 -0
  13. data/lib/machines/checks.rb +63 -0
  14. data/lib/machines/cloud_machine.rb +33 -0
  15. data/lib/machines/command.rb +86 -0
  16. data/lib/machines/commandline.rb +148 -0
  17. data/lib/machines/configuration.rb +49 -0
  18. data/lib/machines/core.rb +117 -0
  19. data/lib/machines/database.rb +17 -0
  20. data/lib/machines/file_operations.rb +104 -0
  21. data/lib/machines/help.rb +30 -0
  22. data/lib/machines/installation.rb +151 -0
  23. data/lib/machines/log_command.rb +22 -0
  24. data/lib/machines/logger.rb +65 -0
  25. data/lib/machines/machinesfile.rb +25 -0
  26. data/lib/machines/named_buffer.rb +9 -0
  27. data/lib/machines/questions.rb +15 -0
  28. data/lib/machines/services.rb +24 -0
  29. data/lib/machines/upload.rb +29 -0
  30. data/lib/machines/version.rb +4 -0
  31. data/lib/machines.rb +19 -0
  32. data/lib/packages/abiword.rb +11 -0
  33. data/lib/packages/amazon_mp3.rb +4 -0
  34. data/lib/packages/awstats.rb +16 -0
  35. data/lib/packages/base.rb +14 -0
  36. data/lib/packages/chrome.rb +12 -0
  37. data/lib/packages/cruisecontrol.rb +22 -0
  38. data/lib/packages/dependencies.rb +10 -0
  39. data/lib/packages/docky.rb +36 -0
  40. data/lib/packages/dotfiles.rb +26 -0
  41. data/lib/packages/file_roller.rb +12 -0
  42. data/lib/packages/finalise.rb +4 -0
  43. data/lib/packages/firefox.rb +4 -0
  44. data/lib/packages/gedit.rb +11 -0
  45. data/lib/packages/git.rb +4 -0
  46. data/lib/packages/gmate.rb +33 -0
  47. data/lib/packages/gnome.rb +10 -0
  48. data/lib/packages/gnumeric.rb +11 -0
  49. data/lib/packages/hosts.rb +13 -0
  50. data/lib/packages/load_machines.rb +38 -0
  51. data/lib/packages/monit.rb +10 -0
  52. data/lib/packages/mysql.rb +46 -0
  53. data/lib/packages/nginx.rb +22 -0
  54. data/lib/packages/nginx_logrotate.rb +26 -0
  55. data/lib/packages/openbox.rb +35 -0
  56. data/lib/packages/passenger.rb +14 -0
  57. data/lib/packages/passenger_nginx.rb +8 -0
  58. data/lib/packages/postfix.rb +10 -0
  59. data/lib/packages/questions.rb +5 -0
  60. data/lib/packages/rbenv.rb +27 -0
  61. data/lib/packages/rvm.rb +20 -0
  62. data/lib/packages/save_machines.rb +4 -0
  63. data/lib/packages/slim.rb +6 -0
  64. data/lib/packages/sqlserver.rb +5 -0
  65. data/lib/packages/subtle.rb +29 -0
  66. data/lib/packages/sudo_mods.rb +6 -0
  67. data/lib/packages/time.rb +6 -0
  68. data/lib/packages/time_daily.rb +5 -0
  69. data/lib/packages/timezone.rb +10 -0
  70. data/lib/packages/unison.rb +5 -0
  71. data/lib/packages/virtualbox.rb +11 -0
  72. data/lib/packages/virtualbox_guest.rb +7 -0
  73. data/lib/packages/webapps.rb +36 -0
  74. data/lib/template/Machinesfile +48 -0
  75. data/lib/template/certificates/example.com.crt +0 -0
  76. data/lib/template/certificates/example.com.key +0 -0
  77. data/lib/template/certificates/selfsigned.crt +14 -0
  78. data/lib/template/certificates/selfsigned.key +16 -0
  79. data/lib/template/config.yml +98 -0
  80. data/lib/template/logrotate/app.erb +10 -0
  81. data/lib/template/logrotate/nginx.erb +12 -0
  82. data/lib/template/machines.yml +179 -0
  83. data/lib/template/misc/awstats.conf.erb +7 -0
  84. data/lib/template/misc/ntp.conf +7 -0
  85. data/lib/template/monit/conf.d/delayed_job.erb +11 -0
  86. data/lib/template/monit/conf.d/mysql.erb +7 -0
  87. data/lib/template/monit/conf.d/nginx +5 -0
  88. data/lib/template/monit/conf.d/postfix +7 -0
  89. data/lib/template/monit/conf.d/ssh +6 -0
  90. data/lib/template/monit/conf.d/system.erb +14 -0
  91. data/lib/template/monit/monitrc.erb +10 -0
  92. data/lib/template/monit/upstart.conf +16 -0
  93. data/lib/template/mysql/dbmaster.cnf +7 -0
  94. data/lib/template/mysql/dbslave.cnf +3 -0
  95. data/lib/template/nginx/app_server.conf.erb +87 -0
  96. data/lib/template/nginx/nginx.conf.erb +46 -0
  97. data/lib/template/nginx/upstart.conf.erb +21 -0
  98. data/lib/template/packages/custom.rb +17 -0
  99. data/lib/template/packages/productivity.rb +18 -0
  100. data/lib/template/slim/themes/dark/background.jpg +0 -0
  101. data/lib/template/slim/themes/dark/panel.png +0 -0
  102. data/lib/template/slim/themes/dark/slim.theme +39 -0
  103. data/lib/template/users/phil/dotfiles/bash_aliases +45 -0
  104. data/lib/template/users/phil/dotfiles/config/Trolltech.conf +4 -0
  105. data/lib/template/users/phil/dotfiles/config/gtk-3.0/settings.ini +9 -0
  106. data/lib/template/users/phil/dotfiles/config/openbox/autostart.sh +14 -0
  107. data/lib/template/users/phil/dotfiles/config/openbox/rc.xml +482 -0
  108. data/lib/template/users/phil/dotfiles/config/terminator/config +10 -0
  109. data/lib/template/users/phil/dotfiles/fonts.conf +15 -0
  110. data/lib/template/users/phil/dotfiles/gitconfig +27 -0
  111. data/lib/template/users/phil/dotfiles/gtkrc-2.0 +16 -0
  112. data/lib/template/users/phil/dotfiles/local/share/applications/mimeapps.list +4 -0
  113. data/lib/template/users/phil/dotfiles/unison/default.prf +33 -0
  114. data/lib/template/users/www/authorized_keys +0 -0
  115. data/lib/template/users/www/dotfiles/bash_aliases +40 -0
  116. data/lib/template/webapps.yml +75 -0
  117. data/machines.gemspec +44 -0
  118. data/spec/acceptance/dev_machine_spec.rb +22 -0
  119. data/spec/lib/machines/app_settings_spec.rb +106 -0
  120. data/spec/lib/machines/checks_spec.rb +105 -0
  121. data/spec/lib/machines/cloud_machine_spec.rb +36 -0
  122. data/spec/lib/machines/command_spec.rb +184 -0
  123. data/spec/lib/machines/commandline_spec.rb +299 -0
  124. data/spec/lib/machines/configuration_spec.rb +61 -0
  125. data/spec/lib/machines/core_spec.rb +299 -0
  126. data/spec/lib/machines/database_spec.rb +51 -0
  127. data/spec/lib/machines/file_operations_spec.rb +124 -0
  128. data/spec/lib/machines/help_spec.rb +22 -0
  129. data/spec/lib/machines/installation_spec.rb +176 -0
  130. data/spec/lib/machines/log_command_spec.rb +16 -0
  131. data/spec/lib/machines/logger_spec.rb +70 -0
  132. data/spec/lib/machines/machinesfile_spec.rb +34 -0
  133. data/spec/lib/machines/questions_spec.rb +73 -0
  134. data/spec/lib/machines/services_spec.rb +26 -0
  135. data/spec/lib/machines/upload_spec.rb +86 -0
  136. data/spec/lib/packages/abiword_spec.rb +20 -0
  137. data/spec/lib/packages/amazon_mp3_spec.rb +17 -0
  138. data/spec/lib/packages/awstats_spec.rb +26 -0
  139. data/spec/lib/packages/base_spec.rb +21 -0
  140. data/spec/lib/packages/chrome_spec.rb +30 -0
  141. data/spec/lib/packages/cruisecontrol_spec.rb +33 -0
  142. data/spec/lib/packages/dependencies_spec.rb +20 -0
  143. data/spec/lib/packages/docky_spec.rb +32 -0
  144. data/spec/lib/packages/dotfiles_spec.rb +44 -0
  145. data/spec/lib/packages/file_roller_spec.rb +69 -0
  146. data/spec/lib/packages/firefox_spec.rb +16 -0
  147. data/spec/lib/packages/gedit_spec.rb +20 -0
  148. data/spec/lib/packages/git_spec.rb +16 -0
  149. data/spec/lib/packages/gmate_spec.rb +39 -0
  150. data/spec/lib/packages/gnome_spec.rb +22 -0
  151. data/spec/lib/packages/gnumeric_spec.rb +21 -0
  152. data/spec/lib/packages/hosts_spec.rb +41 -0
  153. data/spec/lib/packages/load_machines_spec.rb +118 -0
  154. data/spec/lib/packages/monit_spec.rb +34 -0
  155. data/spec/lib/packages/mysql_spec.rb +69 -0
  156. data/spec/lib/packages/nginx_logrotate_spec.rb +80 -0
  157. data/spec/lib/packages/nginx_spec.rb +46 -0
  158. data/spec/lib/packages/openbox_spec.rb +41 -0
  159. data/spec/lib/packages/passenger_nginx_spec.rb +20 -0
  160. data/spec/lib/packages/passenger_spec.rb +26 -0
  161. data/spec/lib/packages/postfix_spec.rb +19 -0
  162. data/spec/lib/packages/questions_spec.rb +29 -0
  163. data/spec/lib/packages/rbenv_spec.rb +32 -0
  164. data/spec/lib/packages/rvm_spec.rb +31 -0
  165. data/spec/lib/packages/save_machines_spec.rb +51 -0
  166. data/spec/lib/packages/slim_spec.rb +22 -0
  167. data/spec/lib/packages/sqlserver_spec.rb +17 -0
  168. data/spec/lib/packages/timezone_spec.rb +27 -0
  169. data/spec/lib/packages/unison_spec.rb +17 -0
  170. data/spec/lib/packages/virtualbox_guest_spec.rb +25 -0
  171. data/spec/lib/packages/virtualbox_spec.rb +23 -0
  172. data/spec/lib/packages/webapps_spec.rb +70 -0
  173. data/spec/spec_helper.rb +103 -0
  174. data/spec/support/coverage.rb +8 -0
  175. data/spec/support/fake_out.rb +22 -0
  176. data/spec/support/fakefs_additions.rb +10 -0
  177. data/spec/support/minitest.rb +69 -0
  178. data/spec/support/vm_control.rb +54 -0
  179. data/tmp/.gitkeep +0 -0
  180. metadata +581 -0
@@ -0,0 +1,179 @@
1
+ # BE CAREFUL: THIS FILE IS ALSO WRITTEN TO BY MACHINES
2
+ # This config file is used to read and also write machine settings.
3
+ # You can replace these comments with your own. Comment lines will be retained upto
4
+ # the ---.
5
+ #
6
+ # THIS CONTAINS A NUMBER OF PASSWORDS. SETTING PROPER PERMISSIONS IS HIGHLY RECOMMENDED.
7
+ #
8
+ # Each machine represents a physical (or virtual) computer in your server architecture. This file
9
+ # is used to determine where to point database connections from app servers. Because of this,
10
+ # database servers must be created before application servers.
11
+ #
12
+ # Edit this file to setup your initial machines. If using EC2, Machines will populate the
13
+ # address setting with the new instance that is created.
14
+ #
15
+ # For example:
16
+ # machines build maindb # creates the master database and sets address in machines.yml
17
+ # then:
18
+ # machines build production # creates the app server and sets db to point to maindb
19
+ #
20
+ # machines:
21
+ # <machine_name>:
22
+ # hostname: Used to set the hostname of the machine (e.g. main.electricvisions.com)
23
+ # address: IP or DNS name of the machine (this is populated automatically when creating EC2 machines)
24
+ # user: User to login as and to identify the users/ folder to use
25
+ # environment: Rails.env to use
26
+ # apps: An array of app names to setup on this machine (nil for all, [] for none)
27
+ # roles: Roles of the server (Roles known by standard template are: app, db, dbmaster, dbslave)
28
+ # db_server: Db server that will be used or replicated from (e.g. db_server: maindb).
29
+ # root_pass: Root password for db servers - Leave blank to generate one
30
+ # replication_user: User to connect with when replicating
31
+ # replication_pass: Password to connect with when replicating
32
+ # ec2: tells Machines to create a new ec2 instance (unless address is already set)
33
+ # type: Size of EC2 instance
34
+ # 32 bit instances - t1.micro, m1.small, m1.medium
35
+ # 64 bit instances - m1.large, m1.xlarge, c1.xlarge, cc1.4xlarge, cg1.4xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge
36
+ # ami: Amazon Machine Image - Choose your preferred AMI at http://alestic.com/ (e.g. ami-11f0cc65 - EU West 32 bit Ubuntu 11.10 EBS)
37
+ # region: Location of instance (e.g. ec2.eu-west-1.amazonaws.com)
38
+ # public_key_path: Path to public key file
39
+ # private_key_path: Path to private key file
40
+ # username: Instance username (Canonical uses 'ubuntu' in it's AMIs)
41
+ # security_group: Security group you setup on Amazon - (e.g. ev-public)
42
+
43
+ ---
44
+ machines:
45
+ testvm:
46
+ hostname: main.electricvisions.com
47
+ address: machinesvm
48
+ user: phil
49
+ password: password
50
+ environment: development
51
+ apps:
52
+ - condensd
53
+ - fountainwiki
54
+ - velocitytracking
55
+ roles:
56
+ - app
57
+ - db
58
+ db_server: testvm
59
+
60
+ philworkstation:
61
+ hostname: main.electricvisions.com
62
+ address:
63
+ user: phil
64
+ environment: development
65
+ apps:
66
+ - electricvisions
67
+ - condensd
68
+ - fountainwiki
69
+ - merrol
70
+ - somafila
71
+ - velocitytracking
72
+ - eutopia
73
+ - sanity
74
+ - tvs
75
+ roles:
76
+ - app
77
+ - db
78
+ db_server: philworkstation
79
+ root_pass: secure
80
+
81
+ maindb:
82
+ hostname: dbmaster.electricvisions.com
83
+ address:
84
+ user: www
85
+ environment: production
86
+ apps:
87
+ - electricvisions
88
+ - condensd
89
+ - fountainwiki
90
+ - merrol
91
+ - somafila
92
+ - velocitytracking
93
+ roles:
94
+ - db
95
+ - dbmaster
96
+ root_pass: secure
97
+ replication_user: repl
98
+ replication_pass: secure
99
+ cloud:
100
+ flavor_id: t1.micro
101
+ image_id: ami-11f0cc65 # EU WEST 1 Ubuntu x32 11.10 EBS
102
+ region: eu-west-1
103
+ public_key_path: ssh/id_rsa.pub
104
+ private_key_path: ssh/id_rsa
105
+ username: ubuntu
106
+
107
+ backupdb:
108
+ hostname: dbslave.electricvisions.com
109
+ address:
110
+ user: www
111
+ environment: production
112
+ apps:
113
+ - electricvisions
114
+ - condensd
115
+ - fountainwiki
116
+ - merrol
117
+ - somafila
118
+ - velocitytracking
119
+ roles:
120
+ - db
121
+ - dbslave
122
+ root_pass: secure
123
+ db_server: maindb
124
+ cloud:
125
+ flavor_id: t1.micro
126
+ image_id: ami-11f0cc65 # EU WEST 1 Ubuntu x32 11.10 EBS
127
+ region: eu-west-1
128
+ public_key_path: ssh/id_rsa.pub
129
+ private_key_path: ssh/id_rsa
130
+ username: ubuntu
131
+
132
+ staging:
133
+ hostname: staging.electricvisions.com
134
+ address:
135
+ user: www
136
+ environment: staging
137
+ apps:
138
+ - electricvisions
139
+ - condensd
140
+ - fountainwiki
141
+ - merrol
142
+ - somafila
143
+ - velocitytracking
144
+ roles:
145
+ - app
146
+ - db
147
+ db_server: staging
148
+ root_pass: secure
149
+ cloud:
150
+ flavor_id: t1.micro
151
+ image_id: ami-11f0cc65 # EU WEST 1 Ubuntu x32 11.10 EBS
152
+ region: eu-west-1
153
+ public_key_path: ssh/id_rsa.pub
154
+ private_key_path: ssh/id_rsa
155
+ username: ubuntu
156
+
157
+ production:
158
+ hostname: electricvisions.com
159
+ address:
160
+ user: www
161
+ environment: production
162
+ apps:
163
+ - electricvisions
164
+ - condensd
165
+ - fountainwiki
166
+ - merrol
167
+ - somafila
168
+ - velocitytracking
169
+ roles:
170
+ - app
171
+ db_server: maindb
172
+ cloud:
173
+ flavor_id: t1.micro
174
+ image_id: ami-11f0cc65 # EU WEST 1 Ubuntu x32 11.10 EBS
175
+ region: eu-west-1
176
+ public_key_path: ssh/id_rsa.pub
177
+ private_key_path: ssh/id_rsa
178
+ username: ubuntu
179
+
@@ -0,0 +1,7 @@
1
+ LogFile="/var/log/<%= $conf.webserver.name %>/<%= name %>.access.log"
2
+ LogFormat=1
3
+ SiteDomain="<%= server_name %>"
4
+ HostAliases="localhost 127.0.0.1 <%= server_name %>"
5
+ DNSLookup=1
6
+ DirData="<%= $conf.appsroot %>/<%= name %>_stats/data"
7
+
@@ -0,0 +1,7 @@
1
+ tinker panic 0
2
+ restrict 127.0.0.1
3
+ restrict default kod nomodify notrap
4
+ server 0.pool.ntp.org
5
+ server 1.pool.ntp.org
6
+ server 2.pool.ntp.org
7
+ server 3.pool.ntp.org
@@ -0,0 +1,11 @@
1
+ <% $conf.webapps.each do |appname, app| %>
2
+ <% if app.monitor_delayed_job %>
3
+ <% path = "PATH=#{$conf.user_home}/.rbenv/bin:#{$conf.user_home}/.rbenv/shims:$PATH" %>
4
+ <% env = "RAILS_ENV=#{$conf.environment}" %>
5
+ <% script = "cd #{app.path}/current && #{path} #{env} bundle exec script/delayed_job" %>
6
+ check process delayed_job with pidfile <%= app.path %>/shared/pids/delayed_job.pid
7
+ start program = "/bin/bash -c '<%= script %> start'" as uid <%= $conf.user %> and gid <%= $conf.user %>
8
+ stop program = "/bin/bash -c '<%= script %> stop'"
9
+ <% end %>
10
+ <% end %>
11
+
@@ -0,0 +1,7 @@
1
+ check process mysql with pidfile /var/run/mysqld/mysqld.pid
2
+ group database
3
+ start program = "/sbin/start mysql"
4
+ stop program = "/sbin/stop mysql"
5
+ if failed host <%= $conf.db_server.address %> port 3306 protocol mysql then restart
6
+ if 5 restarts within 5 cycles then timeout
7
+
@@ -0,0 +1,5 @@
1
+ check process nginx with pidfile /var/run/nginx.pid
2
+ start program = "/sbin/start nginx"
3
+ stop program = "/sbin/stop nginx"
4
+ group www
5
+
@@ -0,0 +1,7 @@
1
+ check process postfix with pidfile /var/spool/postfix/pid/master.pid
2
+ group mail
3
+ start program = "/sbin/start postfix"
4
+ stop program = "/sbin/stop postfix"
5
+ if failed port 25 protocol smtp then restart
6
+ if 5 restarts within 5 cycles then timeout
7
+
@@ -0,0 +1,6 @@
1
+ check process sshd with pidfile /var/run/sshd.pid
2
+ start program "/sbin/start ssh"
3
+ stop program "/sbin/stop ssh"
4
+ if failed port 22 protocol ssh then restart
5
+ if 5 restarts within 5 cycles then timeout
6
+
@@ -0,0 +1,14 @@
1
+ check system localhost
2
+ if loadavg (1min) > 4 then alert
3
+ if loadavg (5min) > 2 then alert
4
+ if memory usage > 80% then alert
5
+ if swap usage > 25% then alert
6
+ if cpu usage (user) > 70% then alert
7
+ if cpu usage (system) > 30% then alert
8
+ if cpu usage (wait) > 20% then alert
9
+
10
+ <% $conf.monit.check.paths.split(' ').each do |path| %>
11
+ check filesystem rootfs with path <%= path %>
12
+ if space < 5% then alert
13
+ <% end %>
14
+
@@ -0,0 +1,10 @@
1
+ set daemon 120
2
+ set logfile syslog facility log_daemon
3
+
4
+ set mailserver <%= $conf.monit.mailserver %>
5
+ set alert <%= $conf.monit.mailto %>
6
+
7
+ set httpd port 2812 and allow <%= $conf.monit.webserver.username %>:<%= $conf.monit.webserver.password %>
8
+
9
+ include /etc/monit/conf.d/*
10
+
@@ -0,0 +1,16 @@
1
+ # http://mmonit.com/wiki/Monit/Upstart
2
+
3
+ description "Monit service manager"
4
+
5
+ limit core unlimited unlimited
6
+
7
+ start on runlevel [2345]
8
+ stop on runlevel [!2345]
9
+
10
+ expect daemon
11
+ respawn
12
+
13
+ exec /usr/bin/monit -c /etc/monit/monitrc
14
+
15
+ pre-stop exec /usr/bin/monit -c /etc/monit/monitrc quit
16
+
@@ -0,0 +1,7 @@
1
+ [mysqld]
2
+ server-id = 1
3
+ log_bin = /var/log/mysql/mysql-bin.log
4
+ bind-address = 0.0.0.0
5
+ innodb_flush_log_at_trx_commit = 1
6
+ sync_binlog = 1
7
+
@@ -0,0 +1,3 @@
1
+ [mysqld]
2
+ server-id = 2
3
+
@@ -0,0 +1,87 @@
1
+ # Redirect from www
2
+ server {
3
+ server_name www.<%= server_name %>;
4
+ return 301 <%= ssl == 'force' ? 'https' : '$scheme' %>://<%= server_name %>$request_uri;
5
+ }
6
+
7
+ <% if ssl == 'force' %>
8
+ # Redirect from http
9
+ server {
10
+ listen 80;
11
+ server_name <%= server_name %>;
12
+ return 301 https://<%= server_name %>$request_uri;
13
+ }
14
+
15
+ <% end %>
16
+ server {
17
+ <% unless ssl == 'force' %>
18
+ listen 80;
19
+ <% end %>
20
+ <% if ssl %>
21
+ listen 443;
22
+ <% end %>
23
+ server_name <%= server_name %>;
24
+ root <%= root %>;
25
+ rails_env <%= $conf.environment %>;
26
+ passenger_enabled on;
27
+ add_header Cache-Control public; # Ensure browsers cache secure pages
28
+
29
+ <% if ssl %>
30
+ ssl on;
31
+ ssl_certificate /usr/local/nginx/conf/<%= ssl_crt %>;
32
+ ssl_certificate_key /usr/local/nginx/conf/<%= ssl_key %>;
33
+
34
+ passenger_set_cgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
35
+ passenger_set_cgi_param HTTP_HOST $http_host;
36
+ passenger_set_cgi_param HTTP_X_REAL_IP $remote_addr;
37
+ passenger_set_cgi_param HTTP_X_FORWARDED_PROTO https;
38
+ passenger_set_cgi_param HTTP_X_URL_SCHEME $scheme;
39
+
40
+ proxy_redirect off;
41
+ proxy_max_temp_file_size 0;
42
+
43
+ <% end %>
44
+ access_log /var/log/nginx/<%= name %>.access.log main;
45
+ error_log /var/log/nginx/<%= name %>.error.log notice;
46
+
47
+ <% if monit_web %>
48
+ location /monit/ {
49
+ rewrite /monit(.*) $1 break;
50
+ proxy_pass http://127.0.0.1:2812;
51
+ proxy_redirect off;
52
+ proxy_set_header Host $host;
53
+ proxy_set_header X-Real-IP $remote_addr;
54
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55
+ }
56
+
57
+ <% end %>
58
+ <% if stats %>
59
+ location /stats {
60
+ alias <%= "#{path}_stats/public" %>;
61
+ index <%= "awstats.#{server_name}.html" %>;
62
+ }
63
+
64
+ location /icon {
65
+ root /usr/share/awstats;
66
+ }
67
+
68
+ <% end %>
69
+ # Cache assets: see http://developer.yahoo.com/performance/rules.html#expires
70
+ location ~ ^/(images|javascripts|stylesheets)/ {
71
+ expires 10y;
72
+ }
73
+
74
+ # Rewrite all the requests to the maintenance.html page if it exists.
75
+ if (-f $document_root/system/maintenance.html) {
76
+ return 503;
77
+ }
78
+ # Allow images and css in maintenance.html file
79
+ if ($request_filename ~* \.(css|jpg|gif|png)$) {
80
+ break;
81
+ }
82
+ error_page 503 @503;
83
+ location @503 {
84
+ rewrite ^(.*)$ /system/maintenance.html break;
85
+ }
86
+ }
87
+
@@ -0,0 +1,46 @@
1
+ user <%= $conf.machine.user %>;
2
+ worker_processes 4; # Match this with the number of CPUs or increase for large static files
3
+ pid /var/run/nginx.pid; # Used by monit
4
+
5
+ events {
6
+ worker_connections 1024;
7
+ }
8
+
9
+ http {
10
+ include mime.types;
11
+ default_type application/octet-stream;
12
+
13
+ sendfile on;
14
+ tcp_nopush on;
15
+ tcp_nodelay off;
16
+ keepalive_timeout 65;
17
+ keepalive_requests 0; # http://technosophos.com/content/nginx-tcpnopush-sendfile-and-memcache-right-configuration
18
+
19
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
20
+ '$status $body_bytes_sent "$http_referer" '
21
+ '"$http_user_agent" "$http_x_forwarded_for"';
22
+
23
+ gzip on;
24
+ gzip_http_version 1.0;
25
+ gzip_comp_level 2;
26
+ gzip_proxied any;
27
+ gzip_types text/plain text/css application/x-javascript text/xml
28
+ application/xml application/xml+rss text/javascript;
29
+
30
+ client_body_buffer_size 128k; # Buffer size that will be written to before using a temporary file
31
+ client_max_body_size 5M; # Max content to be served. Increase if media content is to be served
32
+ # client_body_timeout 60; # Time allowed to respond in seconds. Increase for long requests
33
+
34
+ passenger_root <%= $conf.passenger.root %>;
35
+ passenger_ruby <%= $conf.passenger.ruby %>;
36
+
37
+ passenger_max_pool_size 8; # Max number of simultaneous instances
38
+ passenger_pool_idle_time 0; # Do not shutdown instances unless needed
39
+ <% $conf.webapps.each do |app_name, app| %>
40
+ <% scheme = app.ssl == 'force' ? 'https' : 'http' %>
41
+ passenger_pre_start <%= scheme %>://<%= app.server_name %>; # Hit the server so it's ready
42
+ <% end %>
43
+
44
+ include <%= File.join($conf.webserver.path, $conf.webserver.servers_dir, '*.conf') %>;
45
+ }
46
+
@@ -0,0 +1,21 @@
1
+ description "nginx http daemon"
2
+
3
+ start on (filesystem and net-device-up IFACE=lo)
4
+ stop on runlevel [!2345]
5
+
6
+ env DAEMON=<%= $conf.webserver.path %>/sbin/nginx
7
+ env PID=/var/run/nginx.pid
8
+
9
+ # Needed to allow Nginx to start however, the wrong PID will be tracked
10
+ expect fork
11
+
12
+ # Test the nginx configuration (Upstart will exit if this fails)
13
+ pre-start exec $DAEMON -t
14
+
15
+ # Ensure nginx is shutdown gracefully
16
+ # Upstart will be tracking the wrong PID so the following is needed to stop nginx
17
+ post-stop exec start-stop-daemon --stop --pidfile $PID --name nginx --exec $DAEMON --signal QUIT
18
+
19
+ # Start Nginx
20
+ exec $DAEMON
21
+
@@ -0,0 +1,17 @@
1
+ only :user => 'phil' do
2
+ task :workspace, 'Setup home folders' do
3
+ %w(downloads music pictures reference videos).each do |folder|
4
+ run mkdir folder
5
+ run append "file://#{$conf.user_home}/#{folder} folder", to: '.gtk-bookmarks'
6
+ end
7
+ end
8
+
9
+ sudo install [
10
+ 'flashplugin-installer', # Play Flash in a Web browser
11
+ 'libsqlite3-dev', # Needed if SQLite Gem is used
12
+ 'ubuntu-restricted-extras', # play/record MP3, DVD, Flash, Quicktime, WMA, WMV, etc
13
+ ]
14
+
15
+ run append 'startx', :to => '.profile'
16
+ end
17
+
@@ -0,0 +1,18 @@
1
+ task :productivity, 'Install some productivity apps and set associations'do
2
+ sudo install [
3
+ 'audacious', # media player
4
+ 'brasero', # CD/DVD Burning tool
5
+ 'evince', # PDF viewer
6
+ 'gimp', # bitmap graphics editor
7
+ 'gitk', # GUI for git
8
+ 'inkscape', # vector graphics editor
9
+ 'meld', # Diff tool used by git
10
+ 'mysql-navigator', # GUI for MySQL
11
+ ]
12
+
13
+ run append 'application/pdf=evince.desktop', :to => '.local/share/applications/mimeapps.list'
14
+ run append 'image/png=gimp.desktop', :to => '.local/share/applications/mimeapps.list'
15
+ run append 'image/jpeg=gimp.desktop', :to => '.local/share/applications/mimeapps.list'
16
+ run append 'image/svg=inkscape.desktop', :to => '.local/share/applications/mimeapps.list'
17
+ end
18
+
@@ -0,0 +1,39 @@
1
+ # Dark SLiM theme
2
+
3
+ # Messages (ie: shutdown)
4
+ msg_color #AAAAAA
5
+ msg_font Ubuntu:size=18:bold:dpi=75
6
+
7
+ # valid values: stretch, tile
8
+ background_style stretch
9
+
10
+ # Input controls
11
+ input_panel_x 50%
12
+ input_panel_y 50%
13
+ input_name_x 160
14
+ input_name_y 107
15
+ input_pass_x 160
16
+ input_pass_y 163
17
+ input_font Ubuntu:size=14:dpi=75
18
+ input_fgcolor #444444
19
+
20
+ # Username / password request
21
+ username_font Ubuntu:size=16:bold:dpi=75
22
+ username_color #cccccc
23
+ username_x 35
24
+ username_y 110
25
+ username_shadow_xoffset -1
26
+ username_shadow_yoffset -1
27
+ username_shadow_color #333333
28
+
29
+ password_font Ubuntu:size=16:bold:dpi=75
30
+ password_color #cccccc
31
+ password_x 35
32
+ password_y 165
33
+ password_shadow_xoffset -1
34
+ password_shadow_yoffset -1
35
+ password_shadow_color #333333
36
+
37
+ username_msg Username:
38
+ password_msg Password:
39
+
@@ -0,0 +1,45 @@
1
+ # Output raw control characters in less (colors log files that use escape codes)
2
+ alias less='less -R'
3
+
4
+ alias g='gedit'
5
+
6
+ # Create binstubs for bundler
7
+ alias bb='bundle --binstubs=.bin'
8
+
9
+ # Halve the size of all images in the current folder
10
+ alias halfsize='ls *.* | xargs -n1 --replace convert -verbose {} -resize 50% {}'
11
+
12
+ # Slideshow with feh image viewer
13
+ # Press ENTER to load current image into Gimp. H to pause slideshow
14
+ # slide <file or folder>
15
+ function slide {
16
+ feh --action "gimp '%f'" --fullscreen --auto-zoom --borderless --slideshow-delay 5 --sort name
17
+ }
18
+
19
+ # Search a Rails project excluding non-source directories
20
+ function s {
21
+ grep --color=auto --exclude-dir={coverage,db,doc,.git,log,tmp,vendor,.yardoc} -r $* .
22
+ }
23
+
24
+ # Reset network interface
25
+ function ifr {
26
+ sudo ifdown eth0
27
+ sudo ifup eth0
28
+ }
29
+
30
+ # Get git branch name
31
+ parse_git_branch() {
32
+ git symbolic-ref -q HEAD 2> /dev/null | sed 's/refs\/heads\/\(.*\)/ \1/'
33
+ }
34
+
35
+ # Colour-coded prompt
36
+ # machine-name current-dir rubyversion@gemset [branch] $
37
+ PURPLE="\[\e[0;35m\]"
38
+ BLUE="\[\e[0;34m\]"
39
+ RED="\[\e[0;31m\]"
40
+ YELLOW="\[\e[0;33m\]"
41
+ NORMAL="\[\e[m\]"
42
+ BRANCH="\$(parse_git_branch)"
43
+ # RVM="\$(~/.rvm/bin/rvm-prompt v g)" # Uncomment to enable rubyversion@gemset
44
+ PS1="$PURPLE\h $BLUE\w$RED$RVM$YELLOW$BRANCH $PURPLE\$$NORMAL "
45
+
@@ -0,0 +1,4 @@
1
+ [Qt]
2
+ font="Ubuntu,9,-1,5,25,0,0,0,0,0"
3
+ style=GTK+
4
+
@@ -0,0 +1,9 @@
1
+ [Settings]
2
+ gtk-theme-name = Adwaita
3
+ gtk-icon-theme-name = elementary-mono-dark
4
+ gtk-fallback-icon-theme = gnome
5
+ # next option is applicable only if selected theme supports it
6
+ gtk-application-prefer-dark-theme = true
7
+ # set font name and dimension
8
+ gtk-font-name = 'Ubuntu Light 9'
9
+
@@ -0,0 +1,14 @@
1
+ # ~/.config/openbox/autostart.sh
2
+
3
+ # Lock screen after 5 minutes using slock (type password and press enter to unlock (no feedback))
4
+ # xautolock -time 5 -locker slock &
5
+
6
+ # Set a background image
7
+ feh --bg-scale $HOME/Pictures/wallpaper.jpg
8
+
9
+ # Run the compositing manager
10
+ xcompmgr &
11
+
12
+ # Start Docky the dock launcher
13
+ docky &
14
+