|
297 |
''' % {'version': self.ucs_version, 'app': self.app_directory}, shell=True) |
297 |
''' % {'version': self.ucs_version, 'app': self.app_directory}, shell=True) |
298 |
|
298 |
|
299 |
def create_basic_modproxy_settings(self): |
299 |
def create_basic_modproxy_settings(self): |
300 |
self.add_script(setup='''#!/bin/bash |
300 |
setup = open(os.path.join(os.path.dirname(__file__), 'setup.sh'), 'r').read() |
301 |
set -x -e |
301 |
self.add_script(setup=setup % {'app_name': self.app_name}) |
302 |
eval "$(ucr shell)" |
|
|
303 |
if [ "$version_version" = 4.0 ]; then |
304 |
ucr set repository/online/server="$(echo $repository_online_server | sed -e 's|.*//\(.*\)|\\1|')" |
305 |
fi |
306 |
univention-install --yes univention-apache |
307 |
mkdir /var/www/%(app_name)s |
308 |
echo "TEST-%(app_name)s" >>/var/www/%(app_name)s/index.txt |
309 |
/usr/share/univention-docker-container-mode/setup "$@" |
310 |
''' % {'app_name': self.app_name}) |
311 |
|
302 |
|
312 |
def verify_basic_modproxy_settings(self): |
303 |
def verify_basic_modproxy_settings(self): |
313 |
fqdn = '%s.%s' % (self.ucr['hostname'], self.ucr['domainname']) |
304 |
fqdn = '%s.%s' % (self.ucr['hostname'], self.ucr['domainname']) |
|
357 |
os.makedirs('/var/www/meta-inf/%s' % version) |
348 |
os.makedirs('/var/www/meta-inf/%s' % version) |
358 |
|
349 |
|
359 |
if not os.path.exists('/var/www/meta-inf/categories.ini'): |
350 |
if not os.path.exists('/var/www/meta-inf/categories.ini'): |
|
|
351 |
text = open(os.path.join(os.path.dirname(__file__), 'categories.ini'), 'r').read() |
360 |
f = open('/var/www/meta-inf/categories.ini', 'w') |
352 |
f = open('/var/www/meta-inf/categories.ini', 'w') |
361 |
f.write('''[de] |
353 |
f.write(test) |
362 |
Administration=Administration |
|
|
363 |
Business=Business |
364 |
Collaboration=Collaboration |
365 |
Education=Schule |
366 |
System services=Systemdienste |
367 |
UCS components=UCS-Komponenten |
368 |
Virtualization=Virtualisierung''') |
369 |
f.close() |
354 |
f.close() |
370 |
f = open('/var/www/meta-inf/rating.ini', 'w') |
355 |
f = open('/var/www/meta-inf/rating.ini', 'w') |
371 |
f.write('# rating stuff\n') |
356 |
f.write('# rating stuff\n') |
Lines 403-633
Virtualization=Virtualisierung''')
|
Link Here
|
---|
|
403 |
|
388 |
|
404 |
|
389 |
|
405 |
def restore_data_script_4_1(): |
390 |
def restore_data_script_4_1(): |
406 |
return '''#!/usr/bin/python2.7 |
391 |
return open(os.path.join(os.path.dirname(__file__), 'restore_data_script_4_1.py'), 'r').read() |
407 |
from optparse import OptionParser |
392 |
|
408 |
import os |
|
|
409 |
import shutil |
410 |
import string |
411 |
import univention.config_registry |
412 |
import traceback |
413 |
|
414 |
BLACKLIST_UCR_VARIABLES = [ |
415 |
'version/version', |
416 |
'version/erratalevel', |
417 |
'version/patchlevel', |
418 |
'version/releasename', |
419 |
] |
420 |
|
421 |
|
422 |
# Helper function to copy all meta data of a file or directory |
423 |
def copy_permissions(src, dest): |
424 |
s_stat = os.stat(src) |
425 |
os.chown(dest, s_stat.st_uid, s_stat.st_gid) |
426 |
shutil.copymode(src, dest) |
427 |
shutil.copystat(src, dest) |
428 |
d_stat = os.stat(dest) |
429 |
|
430 |
|
431 |
def restore_files(source_dir): |
432 |
if not os.path.exists(source_dir): |
433 |
return |
434 |
for (path, dirs, files) in os.walk(source_dir): |
435 |
for d in dirs: |
436 |
r_path = string.replace(path, source_dir, '/', 1) |
437 |
dest = os.path.join(r_path, d) |
438 |
if not os.path.exists(dest): |
439 |
os.makedirs(dest) |
440 |
src = os.path.join(path, d) |
441 |
copy_permissions(src, dest) |
442 |
for i in files: |
443 |
src = os.path.join(path, i) |
444 |
dest = string.replace(src, source_dir, '', 1) |
445 |
if os.path.islink(src): |
446 |
linkto = os.readlink(src) |
447 |
if os.path.exists(dest) or os.path.islink(dest): |
448 |
print 'rm %s' % dest |
449 |
os.remove(dest) |
450 |
print 'ln -sf %s %s' % (linkto, dest) |
451 |
os.symlink(linkto, dest) |
452 |
else: |
453 |
print 'cp %s %s' % (src, dest) |
454 |
shutil.copy(src, dest) |
455 |
copy_permissions(src, dest) |
456 |
|
457 |
|
458 |
def restore_ucr_layer(ucr_file, options): |
459 |
if not os.path.exists(ucr_file): |
460 |
return |
461 |
f = open(ucr_file, "r") |
462 |
vv = [] |
463 |
for v in f.readlines(): |
464 |
v = v.strip() |
465 |
if not v or v.startswith('#'): |
466 |
continue |
467 |
key, value = v.split(':', 1) |
468 |
if key not in BLACKLIST_UCR_VARIABLES: |
469 |
vv.append('%s=%s' % (key, value)) |
470 |
if vv: |
471 |
print vv |
472 |
univention.config_registry.handler_set(vv, opts=options) |
473 |
|
474 |
if __name__ == '__main__': |
475 |
parser = OptionParser('%prog [options]') |
476 |
parser.add_option('--app', dest='app', help='App ID') |
477 |
parser.add_option('--app-version', dest='app_version', help='Version of App') |
478 |
parser.add_option('--error-file', dest='error_file', help='Name of Error File') |
479 |
opts, args = parser.parse_args() |
480 |
|
481 |
conf_dir = '/var/lib/univention-appcenter/apps/%s/conf/' % opts.app |
482 |
source_dir = '/var/lib/univention-appcenter/apps/%s/conf/files' % opts.app |
483 |
|
484 |
try: |
485 |
restore_files(source_dir) |
486 |
|
487 |
print '** Restore forced UCR layer:' |
488 |
restore_ucr_layer(os.path.join(conf_dir, 'base-forced.conf'), {'force': True}) |
489 |
print '** Restore ldap UCR layer' |
490 |
restore_ucr_layer(os.path.join(conf_dir, 'base-ldap.conf'), {'ldap-policy': True}) |
491 |
print '** Restore normal UCR layer:' |
492 |
restore_ucr_layer(os.path.join(conf_dir, 'base.conf'), {}) |
493 |
except: |
494 |
traceback.print_exc() |
495 |
if opts.error_file: |
496 |
error_file = open(opts.error_file, 'a+') |
497 |
traceback.print_exc(file=error_file) |
498 |
error_file.close() |
499 |
raise |
500 |
''' |
501 |
|
393 |
|
502 |
def store_data_script_4_1(): |
394 |
def store_data_script_4_1(): |
503 |
return '''#!/usr/bin/python2.7 |
395 |
return open(os.path.join(os.path.dirname(__file__), 'store_data_script_4_1.py'), 'r').read() |
504 |
from optparse import OptionParser |
396 |
|
505 |
import glob |
|
|
506 |
import os |
507 |
import shutil |
508 |
import string |
509 |
import traceback |
510 |
|
511 |
|
512 |
# Helper function to copy all meta data of a file or directory |
513 |
def copy_permissions(src, dest): |
514 |
s_stat = os.stat(src) |
515 |
os.chown(dest, s_stat.st_uid, s_stat.st_gid) |
516 |
shutil.copymode(src, dest) |
517 |
shutil.copystat(src, dest) |
518 |
d_stat = os.stat(dest) |
519 |
|
520 |
|
521 |
# Helper function to copy the files and directory |
522 |
def copy_to_persistent_storage(src, dest): |
523 |
l_src = string.split(src, '/') |
524 |
# Ignore first empty entry |
525 |
if l_src[0] == '': |
526 |
l_src = l_src[1:] |
527 |
for j in range(0, len(l_src)): |
528 |
s = os.path.join('/', string.join(l_src[0:j + 1], '/')) |
529 |
d = os.path.join(dest, string.join(l_src[0:j + 1], '/')) |
530 |
if os.path.isdir(s): |
531 |
if not os.path.exists(d): |
532 |
os.makedirs(d) |
533 |
copy_permissions(s, d) |
534 |
elif os.path.islink(s): |
535 |
linkto = os.readlink(s) |
536 |
if os.path.exists(d) or os.path.islink(d): |
537 |
print 'rm %s' % d |
538 |
os.remove(d) |
539 |
print 'ln -sf %s %s' % (linkto, d) |
540 |
os.symlink(linkto, d) |
541 |
else: |
542 |
print 'cp %s %s' % (s, d) |
543 |
shutil.copy(s, d) |
544 |
copy_permissions(s, d) |
545 |
|
546 |
|
547 |
def copy_files(src, dest): |
548 |
for f in glob.glob(src): |
549 |
copy_to_persistent_storage(f, dest) |
550 |
|
551 |
|
552 |
def copy_recursive(src, dest): |
553 |
if not os.path.exists(src): |
554 |
return |
555 |
copy_to_persistent_storage(src, dest) |
556 |
for root, dirs, files in os.walk(src): |
557 |
for f in files: |
558 |
fullpath = os.path.join(root, f) |
559 |
copy_to_persistent_storage(fullpath, dest) |
560 |
|
561 |
if __name__ == '__main__': |
562 |
parser = OptionParser('%prog [options]') |
563 |
parser.add_option('--app', dest='app', help='App ID') |
564 |
parser.add_option('--app-version', dest='app_version', help='Version of App') |
565 |
parser.add_option('--error-file', dest='error_file', help='Name of Error File') |
566 |
opts, args = parser.parse_args() |
567 |
|
568 |
dest = '/var/lib/univention-appcenter/apps/%s/conf/' % opts.app |
569 |
|
570 |
# The files and directories below the files directory are restored |
571 |
# automatically after the new container has been started |
572 |
store = '/var/lib/univention-appcenter/apps/%s/conf/files' % opts.app |
573 |
|
574 |
try: |
575 |
for f in glob.glob('/etc/univention/base*conf'): |
576 |
print 'cp %s %s' % (f, dest) |
577 |
shutil.copy(f, dest) |
578 |
copy_files('/etc/*.secret', store) |
579 |
copy_recursive('/etc/univention/ssl', store) |
580 |
copy_recursive('/var/univention-join', store) |
581 |
copy_recursive('/var/lib/univention-ldap/', store) |
582 |
copy_recursive('/var/lib/univention-directory-listener/', store) |
583 |
copy_recursive('/etc/univention/connector', store) |
584 |
except: |
585 |
traceback.print_exc() |
586 |
if opts.error_file: |
587 |
error_file = open(opts.error_file, 'a+') |
588 |
traceback.print_exc(file=error_file) |
589 |
error_file.close() |
590 |
raise |
591 |
''' |
592 |
|
397 |
|
593 |
def get_dummy_svg(): |
398 |
def get_dummy_svg(): |
594 |
return '''<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
399 |
return open(os.path.join(os.path.dirname(__file__), 'dummy.svg'), 'r').read() |
595 |
<!-- Created with Inkscape (http://www.inkscape.org/) --> |
|
|
596 |
|
597 |
<svg |
598 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
599 |
xmlns:cc="http://creativecommons.org/ns#" |
600 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
601 |
xmlns:svg="http://www.w3.org/2000/svg" |
602 |
xmlns="http://www.w3.org/2000/svg" |
603 |
version="1.1" |
604 |
width="110" |
605 |
height="126.122" |
606 |
id="svg3555"> |
607 |
<defs |
608 |
id="defs3557" /> |
609 |
<metadata |
610 |
id="metadata3560"> |
611 |
<rdf:RDF> |
612 |
<cc:Work |
613 |
rdf:about=""> |
614 |
<dc:format>image/svg+xml</dc:format> |
615 |
<dc:type |
616 |
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
617 |
<dc:title></dc:title> |
618 |
</cc:Work> |
619 |
</rdf:RDF> |
620 |
</metadata> |
621 |
<g |
622 |
transform="translate(-319.28571,-275.01547)" |
623 |
id="layer1"> |
624 |
<g |
625 |
transform="matrix(1,0,0,-1,331.53071,388.89247)" |
626 |
id="g530"> |
627 |
<path |
628 |
d="m 0,0 0,101.633 85.51,0 0,-66.758 C 85.51,15.552 61.655,23.293 61.655,23.293 61.655,23.293 68.958,0 50.941,0 L 0,0 z m 97.755,33.818 0,80.059 -110,0 0,-126.122 63.372,0 c 20.867,0 46.628,27.266 46.628,46.063 M 40.87,21.383 C 33.322,18.73 27.1,21.772 28.349,29.02 c 1.248,7.25 8.41,22.771 9.432,25.705 1.021,2.936 -0.937,3.74 -3.036,2.546 -1.21,-0.698 -3.009,-2.098 -4.554,-3.458 -0.427,0.862 -1.03,1.848 -1.482,2.791 2.52,2.526 6.732,5.912 11.72,7.138 5.958,1.471 15.916,-0.88 11.636,-12.269 -3.056,-8.117 -5.218,-13.719 -6.58,-17.89 -1.361,-4.173 0.256,-5.048 2.639,-3.423 1.862,1.271 3.846,3 5.299,4.342 0.673,-1.093 0.888,-1.442 1.553,-2.698 C 52.452,29.217 45.85,23.163 40.87,21.383 m 15.638,50.213 c -3.423,-2.913 -8.498,-2.85 -11.336,0.143 -2.838,2.992 -2.365,7.779 1.058,10.694 3.423,2.913 8.498,2.85 11.336,-0.141 2.838,-2.993 2.364,-7.781 -1.058,-10.696" |
629 |
id="path532" |
630 |
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /> |
631 |
</g> |
632 |
</g> |
633 |
</svg>''' |