instance-apachephp.cfg.in 16 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
[buildout]

parts =
  certificate-authority
  ca-stunnel
  logrotate
  logrotate-entry-apache
  logrotate-entry-stunnel
  cron
  cron-entry-logrotate
  promise

  ca-apache
  phpmyadmin.inc
  configure-sites  
  publish-connection-informations
  dashboard-parameters    
  
  configuration-promise
  frontend-ajaxupload-promise
  frontend-phpmyadmin-promise
#  frontend-website-promise
  url-dashboard-promise
  ajaxplorer-load-promise
#  content-promise

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true


#----------------
#--
#-- Creation of all needed directories.

[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
var = $${buildout:directory}/var
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
tmp = $${buildout:directory}/tmp

[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log
services = $${rootdirectory:etc}/service
run = $${rootdirectory:var}/run
backup = $${rootdirectory:srv}/backup
promises = $${rootdirectory:etc}/promise

[directory]
recipe = slapos.cookbook:mkdirectory
cron-entries = $${rootdirectory:etc}/cron.d
crontabs = $${rootdirectory:etc}/crontabs
cronstamps = $${rootdirectory:etc}/cronstamps
ca-dir = $${rootdirectory:srv}/ssl
httpd-log = $${basedirectory:log}/apache
php-ini-dir = $${rootdirectory:etc}/php
tmp-php = $${rootdirectory:tmp}/php
logrotate-entries = $${rootdirectory:etc}/logrotate.d
logrotate-backup = $${basedirectory:backup}/logrotate
report = $${rootdirectory:etc}/report
stunnel-conf = $${rootdirectory:etc}/stunnel
xml-report = $${rootdirectory:var}/xml_report
www = $${rootdirectory:srv}/www
www-data = $${rootdirectory:srv}/www-data
www-dsh = $${rootdirectory:srv}/www-dsh
ssl = $${rootdirectory:etc}/ssl
phantomjs-scripts = $${rootdirectory:etc}/phantomjs

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests
private = $${directory:ca-dir}/private
certs = $${directory:ca-dir}/certs
newcerts = $${directory:ca-dir}/newcerts
crl = $${directory:ca-dir}/crl


#----------------
#--
#-- Deploy cron.

[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${basedirectory:services}/crond

[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${rootdirectory:bin}/cron_simplelogger
log = $${basedirectory:log}/crond.log


#----------------
#--
#-- Deploy logrotate.

[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}

[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${rootdirectory:bin}/logrotate
conf = $${rootdirectory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status


#----------------
#--
#-- Deploy stunnel.

[stunnel]
recipe = slapos.cookbook:stunnel
client = true
stunnel-binary = ${stunnel:location}/bin/stunnel
remote-host = $${mariadb-urlparse:host}
remote-port = $${mariadb-urlparse:port}
local-host = $${slap-network-information:local-ipv4}
local-port = 3306
log-file = $${basedirectory:log}/stunnel.log
config-file = $${directory:stunnel-conf}/stunnel.conf
key-file = $${directory:stunnel-conf}/stunnel.key
cert-file = $${directory:stunnel-conf}/stunnel.crt
pid-file = $${basedirectory:run}/stunnel.pid
wrapper = $${rootdirectory:bin}/raw_stunnel
post-rotate-script = $${rootdirectory:bin}/stunnel_post_rotate

[logrotate-entry-stunnel]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = stunnel
log = $${stunnel:log-file}
frequency = daily
rotate-num = 30
notifempty = true
create = true
post = $${stunnel:post-rotate-script}


#----------------
#--
#-- Certificate stuff.

[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${basedirectory:services}/ca
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

[ca-stunnel]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
executable = $${stunnel:wrapper}
wrapper = $${basedirectory:services}/stunnel
key-file = $${stunnel:key-file}
cert-file = $${stunnel:cert-file}

[ca-apache]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${httpd-conf:key_file}
cert-file = $${httpd-conf:cert_file}
executable = $${apache-php:wrapper}
wrapper = $${basedirectory:services}/apache


#----------------
#--
#-- Request MariaDB instance and parse its URL.

[request-mariadb]
<= slap-connection
recipe = slapos.cookbook:request
name = MariaDB
software-url = $${slap-connection:software-release-url}
software-type = mariadb
return = url
sla = computer_guid
sla-computer_guid = $${slap-connection:computer-id}

[mariadb-urlparse]
recipe = slapos.cookbook:urlparse
url = $${request-mariadb:connection-url}


#----------------
#--
#-- Deploy Apache + PHP application.
[dashboard_credential]
recipe = slapos.cookbook:generate.password
storage-path = $${rootdirectory:etc}/.dashboard.passwd
user = $${slap-parameter:dashboard-user}
bytes = 4

[htpasswd]
recipe = plone.recipe.command
output = $${rootdirectory:etc}/.dhtpasswd
command =
  ${apache:location}/bin/htpasswd -cb $${:output} $${dashboard_credential:user} $${dashboard_credential:passwd}
update-command = $${:command}

[httpd-conf]
recipe = slapos.recipe.template
url = ${template-httpd-conf:location}/${template-httpd-conf:filename}
output = $${rootdirectory:etc}/apache.conf
mode = 0600

document_root = $${rootdirectory:srv}/www/
public_html = $${:document_root}data/files/public_html/
phpmyadmin_root = $${directory:www-data}
dashboard_root = $${directory:www-dsh}
dashboard_pwd = $${htpasswd:output}
pid_file = $${basedirectory:run}/apache.pid
lock_file = $${basedirectory:run}/apache.lock
ipv6 = $${slap-network-information:global-ipv6}
ipv4 = $${slap-network-information:local-ipv4}
port = 8080
port2 = 8060
port3 = 8070
port4 = 8090
port_https = 4443
error_log = $${directory:httpd-log}/error.log
access_log = $${directory:httpd-log}/access.log
php_ini_dir = $${directory:php-ini-dir}
php_lib_path = ${apache-php:location}/lib/php
key_file = $${directory:ssl}/services.key
cert_file = $${directory:ssl}/services.crt


# Deploy Apache + PHP application
[apache-php]
recipe = slapos.cookbook:apachephp
source = ${application:location}
template = 
configuration = 

htdocs = $${directory:www}
pid-file = $${basedirectory:run}/apache.pid
lock-file = $${basedirectory:run}/apache.lock
ip = $${httpd-conf:ipv6}
port = $${httpd-conf:port}
url = http://[$${:ip}]:$${:port}/
error-log = $${directory:httpd-log}/error.log
access-log = $${directory:httpd-log}/access.log
php-ini-dir = $${directory:php-ini-dir}
tmp-dir = $${directory:tmp-php}
wrapper = $${rootdirectory:bin}/apache_raw

httpd-binary = ${apache:location}/bin/httpd

default-conf = false
httpd-conf = $${httpd-conf:output}

mysql-username = $${mariadb-urlparse:username}
mysql-password = $${mariadb-urlparse:password}
mysql-database = $${mariadb-urlparse:path}
mysql-host = $${stunnel:local-host}
mysql-port = $${stunnel:local-port}

environment = 
  PATH=${apache-php:location}/bin:${imagemagick:location}/bin

[rand_password]
recipe = slapos.cookbook:generate.password
storage-path = $${rootdirectory:etc}/.cookie.phpmyadmin
bytes = 6
 

[phpmyadmin.inc]
recipe = slapos.recipe.template
url = ${template-phpmyadmin:location}/${template-phpmyadmin:filename}
output = $${httpd-conf:phpmyadmin_root}/config.inc.php
mode = 0600

mysql_host = $${stunnel:local-host}
mysql_port = $${stunnel:local-port}
rand_pwd = $${rand_password:passwd}

[logrotate-entry-apache]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = apache
log = $${apache-php:error-log} $${apache-php:access-log}
frequency = daily
rotate-num = 30
sharedscripts = true
notifempty = true
create = true


#----------------
#--
#-- Request frontends.

[request-frontend]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Frontend-public_html
software-url = $${slap-parameter:frontend-software-url}
slave = true
config = url custom_domain
config-url = http://[$${apache-php:ip}]:$${apache-php:port}/
return = site_url
config-custom_domain = $${slap-parameter:site-domain}

[request-frontend-ajaxupload]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Frontend-FileManager
software-url = $${slap-parameter:frontend-software-url}
slave = true
config = url https-only custom_domain
config-https-only = true
config-url = https://[$${httpd-conf:ipv6}]:$${httpd-conf:port2}/
return = site_url
config-custom_domain = 

[request-frontend-phpmyadmin]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Frontend-Phpmyadmin
software-url = $${slap-parameter:frontend-software-url}
slave = true
config = url https-only custom_domain
config-https-only = true
config-url = https://[$${httpd-conf:ipv6}]:$${httpd-conf:port3}/
return = site_url
config-custom_domain = 

[request-frontend-dashboard]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Frontend-Dashboard
software-url = $${slap-parameter:frontend-software-url}
slave = true
config = url https-only custom_domain
config-https-only = true
config-url = https://[$${httpd-conf:ipv6}]:$${httpd-conf:port4}/
return = site_url
config-custom_domain = 


#----------------
#--
#-- Deploy slapmonitor.

#[slapmonitor]
#recipe = slapos.cookbook:slapmonitor
#pid-file = $${basedirectory:run}/apache.pid
#database-path = $${basedirectory:log}/slapmonitor.db
#slapmonitor-path = ${buildout:bin-directory}/slapmonitor
#path = $${basedirectory:services}/slapmonitor
#
#[slapmonitor-xml]
#recipe = slapos.cookbook:slapmonitor-xml
#database-path = $${basedirectory:log}/slapmonitor.db
#slapmonitor-xml-path = ${buildout:bin-directory}/slapmonitor-xml
#path = $${directory:report}/slapmonitor-xml


#----------------
#--
#-- Publish instance parameters.

[publish-connection-informations]
recipe = slapos.cookbook:publish
backend_ipv6 = https://$${dashboard_credential:user}:$${dashboard_credential:passwd}@[$${apache-php:ip}]:$${httpd-conf:port4}
url_ipv6 = http://[$${apache-php:ip}]:$${httpd-conf:port}/
backend_url = $${request-frontend-dashboard:connection-site_url}
url_web = $${request-frontend:connection-site_url}
backend_login = $${dashboard_credential:user}
backend_password = $${dashboard_credential:passwd}

[dashboard-parameters]
recipe = slapos.recipe.template
url = ${template-dashboard:location}/${template-dashboard:filename}
output = $${directory:www-dsh}/config.php
mode = 0600

public_html_backend = $${apache-php:url}
public_html = $${request-frontend:connection-site_url}
phpmyadmin_backend = https://[$${apache-php:ip}]:$${httpd-conf:port3}
phpmyadmin  = $${request-frontend-phpmyadmin:connection-site_url}
filemanager_backend = https://[$${apache-php:ip}]:$${httpd-conf:port2}
filemanager = $${request-frontend-ajaxupload:connection-site_url}
mysql_username = $${apache-php:mysql-username}
mysql_password = $${apache-php:mysql-password}
mysql_database = $${apache-php:mysql-database}
mysql_host = $${apache-php:mysql-host}
mysql_port = $${apache-php:mysql-port}
apache_error_log = $${apache-php:error-log}
apache_access_log = $${apache-php:access-log}
joomla_folder = ${joomla:location}
moodle_folder = ${moodle:location}
prestashop_folder = ${prestashop:location}/prestashop
drupal_folder = ${drupal:location}
wp_folder = ${wordpress:location}
#XXX - This folder should exist in Ajaxplorer directory
upload_folder = $${directory:www}/data/files/upload/
www_folder = $${httpd-conf:public_html}

#----------------
#--
#-- Deploy promises scripts.

[promise]
recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/apache
hostname = $${apache-php:ip}
port = $${apache-php:port}

[check-url-promise]
recipe = slapos.cookbook:check_url_available
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl

[frontend-website-promise]
<= check-url-promise
path = $${basedirectory:promises}/frontend-website
url = $${request-frontend:connection-site_url}

[frontend-phpmyadmin-promise]
<= check-url-promise
path = $${basedirectory:promises}/frontend-phpmyadmin
url = $${request-frontend-phpmyadmin:connection-site_url}

[frontend-ajaxupload-promise]
<= check-url-promise
path = $${basedirectory:promises}/frontend-ajaxupload
url = $${request-frontend-ajaxupload:connection-site_url}

[url-dashboard-promise]
<= check-url-promise
path = $${basedirectory:promises}/check-url-dashboard
url = https://$${dashboard_credential:user}:$${dashboard_credential:passwd}@[$${apache-php:ip}]:$${httpd-conf:port4}

[content-promise]
recipe = slapos.cookbook:check_page_content
path = $${basedirectory:promises}/content
url = $${request-frontend-ajaxupload:connection-site_url}
match = AjaXplorer
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl


[slap-parameter]
# Default value if no domain is specified
site-domain =
frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
dashboard-user = admin
ajaxplorer-user = admin
ajaxplorer-pwd = insecure
# wordpress | joomla | drupal | moodle | prestashop
default-app = 
locale = fr_FR.UTF-8

#
# * Configure Ajaxplorer, setup imagemagik in ajaxplorer
# * Copy phpmyadmin files sources into phpmyadmin_root folder
#
[configuration-js]
recipe = slapos.recipe.template
url = ${template-configure:location}/${template-configure:filename}
content-url = https://[$${apache-php:ip}]:$${httpd-conf:port2}/index.php?ignore_tests=true
user = $${slap-parameter:ajaxplorer-user}
password = $${slap-parameter:ajaxplorer-pwd}
storage-type = serial
output = $${directory:phantomjs-scripts}/configure.js
mode = 0644

[configuration-promise]
recipe = slapos.cookbook:check_page_content_phantomjs
path = $${basedirectory:promises}/configuration-promise
dash-path = ${dash:location}/bin/dash
phantomjs-path = ${phantomjs:location}/phantomjs-slapos
phantomjs-options = --ignore-ssl-errors=true
script-path = $${configuration-js:output}

[ajaxplorer-load-js]
recipe = slapos.recipe.template
url = ${template-testboot:location}/${template-testboot:filename}
content-url = https://[$${apache-php:ip}]:$${httpd-conf:port2}/
mode = 0644
output = $${directory:phantomjs-scripts}/test-boot.js

[ajaxplorer-load-promise]
recipe = slapos.cookbook:check_page_content_phantomjs
path = $${basedirectory:promises}/ajaxplorer-load-promise
dash-path = ${dash:location}/bin/dash
phantomjs-path = ${phantomjs:location}/phantomjs-slapos
phantomjs-options = --ignore-ssl-errors=true
script-path = $${ajaxplorer-load-js:output}

[configure-sites]
recipe = plone.recipe.command
convert = ${imagemagick:location}/bin/convert
command = mkdir -p $${httpd-conf:public_html} && \
  chmod -R 700 $${httpd-conf:public_html} && \
  sed -i 's#/usr/bin/convert#$${:convert}#' $${apache-php:htdocs}/plugins/editor.imagick/manifest.xml && \
  sed -i 's#enabled="false"#enabled="true"#' $${apache-php:htdocs}/plugins/editor.imagick/manifest.xml && \
  sed -i 's#//define("AJXP_LOCALE", "en_EN.UTF-8");#define("AJXP_LOCALE", "$${slap-parameter:locale}");#' $${apache-php:htdocs}/conf/bootstrap_conf.php && \  
  sed -i 's#default="en"#default="fr"#' $${apache-php:htdocs}/plugins/boot.conf/manifest.xml && \
  sed -i 's#default="en"#default="fr"#' $${apache-php:htdocs}/plugins/core.ajaxplorer/manifest.xml && \
  cp -nr ${phpmyadmin:location}/* $${httpd-conf:phpmyadmin_root}  && \
  cp -nr ${dashboard:location}/* $${httpd-conf:dashboard_root} && \
  APP="$${slap-parameter:default-app}" && FOLDER="${buildout:parts-directory}/$APP" && \
  if [ -z "$APP" ]; then echo "NO Default App"; else if [ -d "$FOLDER" ]; then [ "$(ls -A $${httpd-conf:public_html} )" ] && echo "Skip install defaul app..." || cp -r $FOLDER/* $${httpd-conf:public_html}/; fi fi
update-command = $${:command}