Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos
Commits
2e7caf94
Commit
2e7caf94
authored
Oct 19, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working davstorage
With generic recipe
parent
69fb40c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
115 deletions
+195
-115
slapos/recipe/davstorage/__init__.py
slapos/recipe/davstorage/__init__.py
+47
-87
software/davstorage/instance-davstorage.cfg
software/davstorage/instance-davstorage.cfg
+139
-21
software/davstorage/instance.cfg
software/davstorage/instance.cfg
+1
-1
software/davstorage/software.cfg
software/davstorage/software.cfg
+8
-6
No files found.
slapos/recipe/davstorage/__init__.py
View file @
2e7caf94
...
@@ -24,102 +24,62 @@
...
@@ -24,102 +24,62 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
os
import
subprocess
import
subprocess
import
pkg_resources
import
zc.buildout
import
zc.recipe.egg
import
sys
class
Recipe
(
BaseSlapRecipe
):
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
getTemplateFilename
(
self
,
template_name
):
return
pkg_resources
.
resource_filename
(
__name__
,
'template/%s'
%
template_name
)
def
_install
(
self
):
class
Recipe
(
GenericBaseRecipe
):
self
.
path_list
=
[]
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
document_root
=
self
.
createDataDirectory
(
'www'
)
apache_config
=
self
.
installApache
(
document_root
)
self
.
setConnectionUrl
(
scheme
=
'webdavs'
,
host
=
apache_config
[
'ip'
],
port
=
apache_config
[
'port'
],
auth
=
(
apache_config
[
'user'
],
apache_config
[
'password'
]))
return
self
.
path_list
def
installApache
(
self
,
document_root
,
ip
=
None
,
port
=
None
):
def
_options
(
self
,
options
):
if
ip
is
None
:
options
[
'password'
]
=
self
.
generatePassword
()
ip
=
self
.
getGlobalIPv6Address
()
if
port
is
None
:
port
=
'9080'
htpasswd_config
=
self
.
createHtpasswd
()
def
install
(
self
):
ssl_config
=
self
.
createCertificate
(
size
=
2048
)
path_list
=
[]
apache_config
=
dict
(
htpasswd_file
=
self
.
options
[
'htpasswd-file'
]
pid_file
=
os
.
path
.
join
(
self
.
run_directory
,
'httpd.pid'
),
# Create or empty the file
lock_file
=
os
.
path
.
join
(
self
.
run_directory
,
'httpd.lock'
),
open
(
htpasswd_file
,
'w'
).
close
()
davlock_db
=
os
.
path
.
join
(
self
.
run_directory
,
'davdb.lock'
),
path_list
.
append
(
htpasswd_file
)
ip
=
ip
,
port
=
port
,
error_log
=
os
.
path
.
join
(
self
.
log_directory
,
'httpd-error.log'
),
access_log
=
os
.
path
.
join
(
self
.
log_directory
,
'httpd-access.log'
),
document_root
=
document_root
,
modules_dir
=
self
.
options
[
'apache_modules_dir'
],
mime_types
=
self
.
options
[
'apache_mime_file'
],
server_root
=
self
.
work_directory
,
email_address
=
'admin@vifib.net'
,
htpasswd_file
=
htpasswd_config
[
'htpasswd_file'
],
ssl_certificate
=
ssl_config
[
'certificate'
],
ssl_key
=
ssl_config
[
'key'
],
)
httpd_config_file
=
self
.
createConfigurationFile
(
'httpd.conf'
,
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'httpd.conf.in'
),
apache_config
))
self
.
path_list
.
append
(
httpd_config_file
)
apache_runner
=
zc
.
buildout
.
easy_install
.
scripts
(
[(
'httpd'
,
'slapos.recipe.librecipe.execute'
,
'execute'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
self
.
options
[
'apache_binary'
],
'-f'
,
httpd_config_file
,
'-DFOREGROUND'
,
]
)[
0
]
self
.
path_list
.
append
(
apache_runner
)
return
dict
(
ip
=
apache_config
[
'ip'
],
port
=
apache_config
[
'port'
],
user
=
htpasswd_config
[
'user'
],
password
=
htpasswd_config
[
'password'
]
)
def
createHtpasswd
(
self
):
user
=
self
.
options
[
'user'
]
htpasswd
=
self
.
createConfigurationFile
(
'htpasswd'
,
''
)
password
=
self
.
options
[
'password'
]
self
.
path_list
.
append
(
htpasswd
)
subprocess
.
check_call
([
self
.
options
[
'apache-htpasswd'
],
password
=
self
.
generatePassword
()
'-bc'
,
htpasswd_file
,
user
=
'user'
subprocess
.
check_call
([
self
.
options
[
'apache_htpasswd'
],
'-bc'
,
htpasswd
,
user
,
password
user
,
password
])
])
return
dict
(
htpasswd_file
=
htpasswd
,
user
=
user
,
password
=
password
)
def
createCertificate
(
self
,
size
=
1024
,
subject
=
'/C=FR/L=Marcq-en-Baroeul/O=Nexedi'
):
key_file
=
os
.
path
.
join
(
self
.
etc_directory
,
'httpd.key'
)
self
.
path_list
.
append
(
key_file
)
certificate_file
=
os
.
path
.
join
(
self
.
etc_directory
,
'httpd.crt'
)
apache_config
=
dict
(
self
.
path_list
.
append
(
certificate_file
)
pid_file
=
self
.
options
[
'pid-file'
],
lock_file
=
self
.
options
[
'lock-file'
],
davlock_db
=
self
.
options
[
'davdb-lock'
],
ip
=
self
.
options
[
'ip'
],
port
=
self
.
options
[
'port'
],
error_log
=
self
.
options
[
'error-log'
],
access_log
=
self
.
options
[
'access-log'
],
document_root
=
self
.
options
[
'htdocs'
],
modules_dir
=
self
.
options
[
'apache-modules-dir'
],
mime_types
=
self
.
options
[
'apache-mime-file'
],
server_root
=
self
.
options
[
'root'
],
email_address
=
self
.
options
[
'email-address'
],
htpasswd_file
=
htpasswd_file
,
ssl_certificate
=
self
.
options
[
'cert-file'
],
ssl_key
=
self
.
options
[
'key-file'
],
)
subprocess
.
check_call
([
self
.
options
[
'openssl_binary'
],
# Create logfiles
'req'
,
'-x509'
,
'-nodes'
,
for
log
in
[
self
.
options
[
'error-log'
],
self
.
options
[
'access-log'
]]:
'-newkey'
,
'rsa:%s'
%
size
,
open
(
log
,
'a'
).
close
()
'-subj'
,
str
(
subject
),
'-out'
,
certificate_file
,
config_file
=
self
.
createFile
(
self
.
options
[
'conf-file'
],
'-keyout'
,
key_file
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'httpd.conf.in'
),
])
apache_config
)
return
dict
(
key
=
key_file
,
)
certificate
=
certificate_file
)
path_list
.
append
(
config_file
)
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
[
self
.
options
[
'apache-binary'
],
'-f'
,
config_file
,
'-DFOREGROUND'
])
path_list
.
append
(
wrapper
)
return
path_list
software/davstorage/instance-davstorage.cfg
View file @
2e7caf94
[buildout]
[buildout]
parts =
parts =
davstorage
davstorage
url
certificate-authority
ca-davstorage
cron
logrotate
logrotate-entry-davstorage
eggs-directory = ${buildout:eggs-directory}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
offline = true
[url]
recipe = slapos.cookbook:publishurl
scheme = webdavs
user = $${davstorage:user}
port = $${davstorage:port}
host = $${davstorage:ip}
password = $${davstorage:password}
[davstorage]
[davstorage]
recipe = slapos.cookbook:davstorage
recipe = slapos.cookbook:davstorage
user = user
port = 8080
ip = $${slap-network-information:global-ipv6}
# Path
wrapper = $${rootdirectory:bin}/davstorage
error-log = $${directory:davstorage-log}/error.log
access-log = $${directory:davstorage-log}/access.log
pid-file = $${basedirectory:run}/davstorage.pid
lock-file = $${basedirectory:run}/davstorage.lock
davdb-lock = $${basedirectory:run}/davdb.lock
key-file = $${ca-davstorage:key-file}
cert-file = $${ca-davstorage:cert-file}
conf-file = $${directory:davstorage-conf}/davstorage.conf
htdocs = $${directory:htdocs}
root = $${buildout:directory}
email-address = admin+davstorage@vifib.net
htpasswd-file = $${directory:davstorage-conf}/davstorage.htpasswd
promise = $${basedirectory:promises}/davstorage
# Binaries
apache-binary = ${apache:location}/bin/httpd
apache-modules-dir = ${apache:location}/modules/
apache-mime-file = ${apache:location}/conf/mime.types
apache-htpasswd = ${apache:location}/bin/htpasswd
[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}/certificate_authority
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}
[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:binary}
binary = $${basedirectory:services}/crond
[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
# Binaries
dcrond_binary = ${dcron:location}/sbin/crond
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
logrotate_binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
apache_binary = ${apache:location}/bin/httpd
gunzip-binary = ${gzip:location}/bin/gunzip
apache_modules_dir = ${apache:location}/modules/
# Directories
apache_mime_file = ${apache:location}/conf/mime.types
wrapper = $${rootdirectory:bin}/logrotate
apache_htpasswd = ${apache:location}/bin/htpasswd
conf = $${rootdirectory:etc}/logrotate.conf
# Real configuration
logrotate-entries = $${directory:logrotate-entries}
key_file = $${certificate_authority:certificate_authority_dir}/davstorage.key
backup = $${directory:logrotate-backup}
cert_file = $${certificate_authority:certificate_authority_dir}/davstorage.crt
state-file = $${rootdirectory:srv}/logrotate.status
# [ca]
[cron-entry-logrotate]
# recipe = slapos.cookbook:ca
<= cron
# openssl_binary = ${openssl:location}/bin/openssl
recipe = slapos.cookbook:cron.d
# certificate_authority_dir = $${directory:srv}/ssl/
name = logrotate
#
frequency = 0 0 * * *
# [ca-davstorage]
command = $${logrotate:wrapper}
# recipe = slapos.cookbook:part
# part = $${certificate_authority:part}
[cron-simplelogger]
# parameters =
recipe = slapos.cookbook:simplelogger
# key_file=$${davstorage:key_file}
binary = $${rootdirectory:bin}/cron_simplelogger
# cert_file=$${davstorage:cert_file}
output = $${directory:cronoutput}
[logrotate-entry-davstorage]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = davstorage
log = $${davstorage:error-log} $${davstorage:access-log}
frequency = daily
rotate-num = 30
sharedscripts = true
notifempty = true
create = true
[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/
[ca-davstorage]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${directory:davstorage-conf}/davstorage.key
cert-file = $${directory:davstorage-conf}/davstorage.crt
executable = $${davstorage:wrapper}
wrapper = $${basedirectory:services}/davstorage
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promises/
[directory]
recipe = slapos.cookbook:mkdirectory
htdocs = $${rootdirectory:srv}/www/
davstorage-log = $${basedirectory:log}/davstorage/
logrotate-backup = $${basedirectory:backup}/logrotate/
logrotate-entries = $${rootdirectory:etc}/logrotate.d/
davstorage-conf = $${rootdirectory:etc}/davstorage/
ca-dir = $${rootdirectory:srv}/ssl/
cron-entries = $${rootdirectory:etc}/cron.d/
crontabs = $${rootdirectory:etc}/crontabs/
cronstamps = $${rootdirectory:etc}/cronstamps/
cronoutput = $${basedirectory:log}/cron/
software/davstorage/instance.cfg
View file @
2e7caf94
...
@@ -9,4 +9,4 @@ offline = true
...
@@ -9,4 +9,4 @@ offline = true
[switch_softwaretype]
[switch_softwaretype]
recipe = slapos.cookbook:softwaretype
recipe = slapos.cookbook:softwaretype
default = ${instance
_
davstorage:output}
default = ${instance
-
davstorage:output}
software/davstorage/software.cfg
View file @
2e7caf94
...
@@ -8,10 +8,11 @@ versions = versions
...
@@ -8,10 +8,11 @@ versions = versions
extends =
extends =
../../component/apache/buildout.cfg
../../component/apache/buildout.cfg
../../component/dcron/buildout.cfg
../../component/dcron/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/logrotate/buildout.cfg
../../stack/shacache-client.cfg
../../stack/shacache-client.cfg
../../component/lxml-python/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/gzip/buildout.cfg
# Use only quite well working sites.
# Use only quite well working sites.
allow-hosts =
allow-hosts =
...
@@ -24,6 +25,7 @@ allow-hosts =
...
@@ -24,6 +25,7 @@ allow-hosts =
peak.telecommunity.com
peak.telecommunity.com
psutil.googlecode.com
psutil.googlecode.com
www.dabeaz.com
www.dabeaz.com
alastairs-place.net
parts =
parts =
...
@@ -33,9 +35,9 @@ parts =
...
@@ -33,9 +35,9 @@ parts =
logrotate
logrotate
dcron
dcron
eggs
eggs
gzip
instance-recipe-egg
instance-recipe-egg
unzip= true
unzip= true
[eggs]
[eggs]
...
@@ -55,14 +57,14 @@ eggs = ${instance-recipe:egg}
...
@@ -55,14 +57,14 @@ eggs = ${instance-recipe:egg}
# Default template for the instance.
# Default template for the instance.
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
url = ${:_profile_base_location_}/instance.cfg
md5sum =
4c79e2e42704a2ffe5eebfa0b2e70e28
md5sum =
bed788dee6daf05349c4577e7a7f1299
output = ${buildout:directory}/template.cfg
output = ${buildout:directory}/template.cfg
mode = 0644
mode = 0644
[instance
_
davstorage]
[instance
-
davstorage]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-davstorage.cfg
url = ${:_profile_base_location_}/instance-davstorage.cfg
md5sum =
009103c87c8d31fb758e7a0782e77723
md5sum =
2256a147e53c4b02155855ecf1130158
output = ${buildout:directory}/template-davstorage.cfg
output = ${buildout:directory}/template-davstorage.cfg
mode = 0644
mode = 0644
...
@@ -103,7 +105,7 @@ netaddr = 0.7.6
...
@@ -103,7 +105,7 @@ netaddr = 0.7.6
# Required by:
# Required by:
# slapos.core==0.14
# slapos.core==0.14
netifaces = 0.4
#
netifaces = 0.4
# Required by:
# Required by:
# slapos.cookbook==0.24
# slapos.cookbook==0.24
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment