View | Details | Raw Unified | Return to bug 30409
Collapse All | Expand All

(-)a/branches/ucs-3.1/ucs/base/univention-debmirror/77univention-debmirror.inst (-1 / +1 lines)
 Lines 36-46   joinscript_init Link Here 
36
36
37
eval "$(univention-config-registry shell hostname domainname)"
37
eval "$(univention-config-registry shell hostname domainname)"
38
. /usr/share/univention-lib/all.sh
38
. /usr/share/univention-lib/all.sh
39
FQDN="$hostname.$domainname"
39
40
40
if is_ucr_true "local/repository"
41
if is_ucr_true "local/repository"
41
then
42
then
42
	REPO="univention-repository.$domainname"
43
	REPO="univention-repository.$domainname"
43
	FQDN="$hostname.$domainname"
44
	# Is there already another repository server?
44
	# Is there already another repository server?
45
	target="$(LC_ALL=C host -t CNAME "$REPO" | sed -ne 's|.* is an alias for \(.*\)\.$|\1|p')"
45
	target="$(LC_ALL=C host -t CNAME "$REPO" | sed -ne 's|.* is an alias for \(.*\)\.$|\1|p')"
46
	if [ -z "$target" ]; then
46
	if [ -z "$target" ]; then
(-)a/branches/ucs-3.1/ucs/base/univention-updater/debian/rules (-1 lines)
 Lines 71-77   override_dh_fixperms: Link Here 
71
	dh_fixperms
71
	dh_fixperms
72
	chmod 755 debian/univention-updater/usr/lib/univention-directory-policy/univention-policy-set-repository-server
72
	chmod 755 debian/univention-updater/usr/lib/univention-directory-policy/univention-policy-set-repository-server
73
	chmod 755 debian/univention-updater/usr/lib/univention-directory-policy/univention-policy-maintenance
73
	chmod 755 debian/univention-updater/usr/lib/univention-directory-policy/univention-policy-maintenance
74
	chmod 755 debian/univention-updater/usr/lib/univention-directory-policy/univention-policy-set-repository-server
75
	chmod 755 debian/univention-updater/usr/share/univention-updater/enable-apache2-umc
74
	chmod 755 debian/univention-updater/usr/share/univention-updater/enable-apache2-umc
76
	chmod 755 debian/univention-updater/usr/share/univention-updater/disable-apache2-umc
75
	chmod 755 debian/univention-updater/usr/share/univention-updater/disable-apache2-umc
77
	chmod 755 debian/univention-updater/usr/share/univention-updater/univention-updater-check
76
	chmod 755 debian/univention-updater/usr/share/univention-updater/univention-updater-check
(-)a/branches/ucs-3.1/ucs/base/univention-updater/debian/univention-updater.postinst (-6 / +3 lines)
 Lines 145-151   fi Link Here 
145
# the UCR debhelper section will be added before the pysupport section,
145
# the UCR debhelper section will be added before the pysupport section,
146
# so we added the pysupport section manually
146
# so we added the pysupport section manually
147
if which update-python-modules >/dev/null 2>&1; then
147
if which update-python-modules >/dev/null 2>&1; then
148
        update-python-modules  univention-updater.public
148
	update-python-modules univention-updater.public
149
fi
149
fi
150
150
151
#DEBHELPER#
151
#DEBHELPER#
 Lines 159-169   fi Link Here 
159
test -x /etc/init.d/univention-directory-listener && /etc/init.d/univention-directory-listener restart
159
test -x /etc/init.d/univention-directory-listener && /etc/init.d/univention-directory-listener restart
160
160
161
# set the repository server
161
# set the repository server
162
eval "$(univention-config-registry shell hostname domainname update/server)"
162
eval "$(univention-config-registry shell hostname domainname)"
163
if [ -n "$update_server" -a "$update_server" != "http://download.univention.de" ]; then
163
if host "univention-repository.$domainname" > /dev/null 2>&1; then
164
	update_server=`echo "$update_server" | LC_ALL=C sed -e 's|^[A-Za-z][0-9A-Za-z+.-]*://\([^/]*\).*|\1|'` # <http://www.ietf.org/rfc/rfc2396.txt#3.1.>
165
	univention-config-registry set repository/online/server?"$update_server"
166
elif host univention-repository.$domainname > /dev/null 2>&1; then
167
	univention-config-registry set repository/online/server?"univention-repository.$domainname"
164
	univention-config-registry set repository/online/server?"univention-repository.$domainname"
168
else
165
else
169
	# univention-config-registry set repository/online/server?"testing.univention.de"
166
	# univention-config-registry set repository/online/server?"testing.univention.de"
(-)a/branches/ucs-3.1/ucs/base/univention-updater/univention-directory-policy/univention-policy-set-repository-server (-47 / +62 lines)
 Lines 2-8    Link Here 
2
# -*- coding: utf-8 -*-
2
# -*- coding: utf-8 -*-
3
#
3
#
4
# Univention Updater
4
# Univention Updater
5
#  read the repository server
5
"""
6
Read the repository server from LDAP policy.
7
"""
6
#
8
#
7
# Copyright 2004-2012 Univention GmbH
9
# Copyright 2004-2012 Univention GmbH
8
#
10
#
 Lines 32-99    Link Here 
32
# <http://www.gnu.org/licenses/>.
34
# <http://www.gnu.org/licenses/>.
33
35
34
import os
36
import os
35
import sys, subprocess
37
import sys
36
import univention.config_registry
38
import subprocess
39
from univention.config_registry import ConfigRegistry, handler_set
37
40
38
configRegistry = univention.config_registry.ConfigRegistry()
39
configRegistry.load()
40
41
41
ldap_hostdn = configRegistry.get('ldap/hostdn')
42
def terminate(result, message=None):
42
43
	"""
43
def exit(result, message = None):
44
	Exit with result and optional message.
44
	script = os.path.basename(sys.argv[0])
45
	"""
45
	if message:
46
	if message:
46
		print '%s: %s' % (script, message)
47
		script = os.path.basename(sys.argv[0])
48
		print >> sys.stderr, '%s: %s' % (script, message)
47
	sys.exit(result)
49
	sys.exit(result)
48
50
49
def query_policy(update):
50
	server = None
51
	p1 = subprocess.Popen(['univention_policy_result', '-D', ldap_hostdn, '-y', '/etc/machine.secret', '-s', ldap_hostdn], stdout=subprocess.PIPE)
52
	result = p1.communicate()[0]
53
51
54
	if p1.returncode != 0:
52
def query_policy(ldap_hostdn):
55
		exit(result, "FAIL: failed to execute `univention_policy_result'")
53
	"""
54
	Retrive policy result for host.
55
	"""
56
	cmd = (
57
			'univention_policy_result',
58
			'-D', ldap_hostdn,
59
			'-y', '/etc/machine.secret',
60
			'-s', ldap_hostdn
61
			)
62
	proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
63
	stdout, _stderr = proc.communicate()
64
65
	if proc.returncode != 0:
66
		terminate(stdout, "FAIL: failed to execute `univention_policy_result'")
56
67
57
	for line in result.split('\n'):
68
	server = update = None
58
		line = line.strip()
69
	for line in stdout.splitlines():
59
		if line.startswith('univentionRepositoryServer='):
70
		key, value = line.split('=', 1)
60
			server = line.split('=', 1)[1].split('"',2)[1]
71
		if key == 'univentionRepositoryServer':
61
		elif line.startswith('univentionUpdateVersion='):
72
			server = value[1:-1]
62
			update = line.split('=', 1)[1].split('"',2)[1]
73
			if server.startswith('http://'):
63
	if server and server.startswith('http://'):
74
				server = server[len('http://'):]
64
		server = server.replace('http://', '', 1)
75
		elif key == 'univentionUpdateVersion':
76
			update = value[1:-1]
65
	return (server, update)
77
	return (server, update)
66
78
79
67
def main():
80
def main():
68
	restore_server = None
81
	"""
69
	online_server = configRegistry.get( 'repository/online/server')
82
	Retrieve repository servr from LDAP policy.
70
	mirror_server = configRegistry.get( 'repository/mirror/server')
83
	"""
71
	local_repo = configRegistry.is_true( 'local/repository')
84
	ucr = ConfigRegistry()
72
	fqdn  = '%s.%s' % (configRegistry['hostname'], configRegistry['domainname'])
85
	ucr.load()
73
	update = '%s-%s' % (configRegistry['version/version'], configRegistry['version/patchlevel'])
74
	# ldap_host_dn, old_server, local_server, local_repo, fqdn, update = query_baseconfig()
75
86
76
	ucr_variables = []
87
	ldap_hostdn = ucr.get('ldap/hostdn')
77
	if not ldap_hostdn:
88
	if not ldap_hostdn:
78
		# can't query policy without host-dn
89
		# can't query policy without host-dn
79
		exit(0)
90
		return
80
91
81
	new_server, update = query_policy(update)
92
	new_server, _update = query_policy(ldap_hostdn)
82
	# without a local repository
93
	if not _update:
83
	if not local_repo:
94
		_update = '%(version/version)s-%(version/patchlevel)s' % ucr
84
		if not new_server or new_server == online_server:
95
85
			# no new server specified
96
	changes = []
86
			exit(0)
97
	if ucr.is_true('local/repository'):
87
		else:
88
			ucr_variables.append( 'repository/online/server=%s' % new_server )
89
	else:
90
		# on a repository server
98
		# on a repository server
91
		if not new_server:
99
		if new_server and new_server != ucr.get('repository/mirror/server'):
92
			ucr_variables.append( 'repository/online/server?%s' % fqdn )
100
			changes.append('repository/mirror/server=%s' % new_server)
93
		elif new_server != mirror_server:
101
		elif not new_server:
94
			ucr_variables.append( 'repository/mirror/server=%s' % new_server )
102
			fqdn  = '%(hostname)s.%(domainname)s' % ucr
103
			changes.append('repository/online/server?%s' % fqdn)
104
	else:
105
		# without a local repository
106
		if new_server and new_server != ucr.get('repository/online/server'):
107
			changes.append('repository/online/server=%s' % new_server)
108
109
	if changes:
110
		handler_set(changes)
95
111
96
	univention.config_registry.handler_set( ucr_variables )
97
112
98
if __name__ == '__main__':
113
if __name__ == '__main__':
99
	main()
114
	main()

Return to bug 30409