Commit 937fcca5 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

New promise to check page content for lamp

parent 4e632fb1
......@@ -49,6 +49,7 @@ setup(name=name,
'certificate_authority.request = slapos.recipe.certificate_authority:Request',
'check_port_listening = slapos.recipe.check_port_listening:Recipe',
'check_url_available = slapos.recipe.check_url_available:Recipe',
'check_page_content = slapos.recipe.check_page_content:Recipe',
'cloud9 = slapos.recipe.cloud9:Recipe',
'cron = slapos.recipe.dcron:Recipe',
'cron.d = slapos.recipe.dcron:Part',
......
##############################################################################
#
# Copyright (c) 2011 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
import sys
class Recipe(GenericBaseRecipe):
"""
Create script that will check if content at "url" is available
(e.g page has a link to itself).
"""
def install(self):
config = {
'url': self.options['url'],
'shell_path': self.options['dash_path'],
'curl_path': self.options['curl_path'],
}
# XXX-Cedric in this script, curl won't check certificate
promise = self.createExecutable(
self.options['path'],
self.substituteTemplate(self.getTemplateFilename('check_page_content.in'), config)
)
return [promise]
#!%(shell_path)s
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
URL="%(url)s"
if [ -z $URL ]; then
echo "No URL specified." >&2
exit 3
fi
%(curl_path)s -k -sL $URL | grep "$URL" > /dev/null
if [ $? != 0 ]; then
echo "Content at $URL seems to be corrupted" >&2
exit 1
fi
......@@ -66,7 +66,7 @@ mode = 0644
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-apache-php.cfg
output = ${buildout:directory}/template-apache-php.cfg
md5sum = 8bb0b03689d2be9566ed1ef3e96b4403
md5sum = 159c5326e6faff2ba9c1f52b113c01fa
mode = 0644
[template-apache-backup]
......
......@@ -12,6 +12,7 @@ parts =
slapmonitor
slapreport
frontend-promise
content-promise
publish-connection-informations
eggs-directory = ${buildout:eggs-directory}
......@@ -256,6 +257,12 @@ url = $${request-frontend:connection-site_url}
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl
[content-promise]
recipe = slapos.cookbook:check_page_content
path = $${basedirectory:promises}/content
url = $${request-frontend:connection-site_url}
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl
[slap-parameter]
# Default value if no domain is specified
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment