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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
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 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
os
import
subprocess
import
pkg_resources
import
zc.buildout
import
zc.recipe.egg
import
sys
class
Recipe
(
BaseSlapRecipe
):
def
getTemplateFilename
(
self
,
template_name
):
return
pkg_resources
.
resource_filename
(
__name__
,
'template/%s'
%
template_name
)
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
_install
(
self
):
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
class
Recipe
(
GenericBaseRecipe
):
def
installApache
(
self
,
document_root
,
ip
=
None
,
port
=
None
):
if
ip
is
None
:
ip
=
self
.
getGlobalIPv6Address
()
if
port
is
None
:
port
=
'9080'
def
_options
(
self
,
options
):
options
[
'password'
]
=
self
.
generatePassword
()
htpasswd_config
=
self
.
createHtpasswd
()
ssl_config
=
self
.
createCertificate
(
size
=
2048
)
def
install
(
self
):
path_list
=
[]
apache_config
=
dict
(
pid_file
=
os
.
path
.
join
(
self
.
run_directory
,
'httpd.pid'
),
lock_file
=
os
.
path
.
join
(
self
.
run_directory
,
'httpd.lock'
),
davlock_db
=
os
.
path
.
join
(
self
.
run_directory
,
'davdb.lock'
),
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'
]
)
htpasswd_file
=
self
.
options
[
'htpasswd-file'
]
# Create or empty the file
open
(
htpasswd_file
,
'w'
).
close
()
path_list
.
append
(
htpasswd_file
)
def
createHtpasswd
(
self
):
htpasswd
=
self
.
createConfigurationFile
(
'htpasswd'
,
''
)
self
.
path_list
.
append
(
htpasswd
)
password
=
self
.
generatePassword
()
user
=
'user'
subprocess
.
check_call
([
self
.
options
[
'apache_htpasswd'
],
'-bc'
,
htpasswd
,
user
=
self
.
options
[
'user'
]
password
=
self
.
options
[
'password'
]
subprocess
.
check_call
([
self
.
options
[
'apache-htpasswd'
],
'-bc'
,
htpasswd_file
,
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'
)
self
.
path_list
.
append
(
certificate_file
)
apache_config
=
dict
(
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'
],
'req'
,
'-x509'
,
'-nodes'
,
'-newkey'
,
'rsa:%s'
%
size
,
'-subj'
,
str
(
subject
),
'-out'
,
certificate_file
,
'-keyout'
,
key_file
])
return
dict
(
key
=
key_file
,
certificate
=
certificate_file
)
# Create logfiles
for
log
in
[
self
.
options
[
'error-log'
],
self
.
options
[
'access-log'
]]:
open
(
log
,
'a'
).
close
()
config_file
=
self
.
createFile
(
self
.
options
[
'conf-file'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'httpd.conf.in'
),
apache_config
)
)
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]
parts =
davstorage
url
certificate-authority
ca-davstorage
cron
logrotate
logrotate-entry-davstorage
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[url]
recipe = slapos.cookbook:publishurl
scheme = webdavs
user = $${davstorage:user}
port = $${davstorage:port}
host = $${davstorage:ip}
password = $${davstorage:password}
[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
dcrond_binary = ${dcron:location}/sbin/crond
logrotate_binary = ${logrotate:location}/usr/sbin/logrotate
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
# Real configuration
key_file = $${certificate_authority:certificate_authority_dir}/davstorage.key
cert_file = $${certificate_authority:certificate_authority_dir}/davstorage.crt
# [ca]
# recipe = slapos.cookbook:ca
# openssl_binary = ${openssl:location}/bin/openssl
# certificate_authority_dir = $${directory:srv}/ssl/
#
# [ca-davstorage]
# recipe = slapos.cookbook:part
# part = $${certificate_authority:part}
# parameters =
# key_file=$${davstorage:key_file}
# cert_file=$${davstorage:cert_file}
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
[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
binary = $${rootdirectory:bin}/cron_simplelogger
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
[switch_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
extends =
../../component/apache/buildout.cfg
../../component/dcron/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/logrotate/buildout.cfg
../../stack/shacache-client.cfg
../../component/lxml-python/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/gzip/buildout.cfg
# Use only quite well working sites.
allow-hosts =
...
...
@@ -24,6 +25,7 @@ allow-hosts =
peak.telecommunity.com
psutil.googlecode.com
www.dabeaz.com
alastairs-place.net
parts =
...
...
@@ -33,9 +35,9 @@ parts =
logrotate
dcron
eggs
gzip
instance-recipe-egg
unzip= true
[eggs]
...
...
@@ -55,14 +57,14 @@ eggs = ${instance-recipe:egg}
# Default template for the instance.
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
md5sum =
4c79e2e42704a2ffe5eebfa0b2e70e28
md5sum =
bed788dee6daf05349c4577e7a7f1299
output = ${buildout:directory}/template.cfg
mode = 0644
[instance
_
davstorage]
[instance
-
davstorage]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-davstorage.cfg
md5sum =
009103c87c8d31fb758e7a0782e77723
md5sum =
2256a147e53c4b02155855ecf1130158
output = ${buildout:directory}/template-davstorage.cfg
mode = 0644
...
...
@@ -103,7 +105,7 @@ netaddr = 0.7.6
# Required by:
# slapos.core==0.14
netifaces = 0.4
#
netifaces = 0.4
# Required by:
# 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