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

(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-updater/conffiles/etc/cron.d/univention-updater-check (-14 / +7 lines)
Lines 3-21 Link Here
3
PATH=/usr/sbin:/usr/bin:/sbin:/bin
3
PATH=/usr/sbin:/usr/bin:/sbin:/bin
4
4
5
@!@
5
@!@
6
disabled = ''
6
def check_update(key, cron):
7
debug = ''
7
	BIN = "/usr/share/univention-updater/univention-updater-check"
8
if not configRegistry.is_true('update/check/cron/enabled', False):
8
	disabled = '# ' if not configRegistry.is_true('update/check/%s/enabled' % key, False) else ''
9
        disabled = '# '
9
	debug = ' 2>/dev/null >/dev/null' if configRegistry.get('update/check/%s/debug' % key, 'no').lower() not in ('yes','true','enabled','1','2','3','4') else ''
10
if not configRegistry.get('update/check/cron/debug','no').lower() in ('yes','true','enabled','1','2','3','4'):
10
	print '%(disabled)s%(cron)s   root   [ -x %(BIN)s ] && /usr/sbin/jitter 600 %(BIN)s%(debug)s' % locals()
11
        debug = '2> /dev/null > /dev/null'
12
print '%s%s   root   [ -x /usr/share/univention-updater/univention-updater-check ] && /usr/sbin/jitter 600 /usr/share/univention-updater/univention-updater-check %s' % (disabled, configRegistry.get('update/check/cron/entry', '5 * * * *'), debug)
13
11
14
disabled = ''
12
check_update("cron", configRegistry.get('update/check/cron/entry', '5 * * * *'))
15
debug = ''
13
check_update("boot", "@reboot")
16
if not configRegistry.is_true('update/check/boot/enabled', False):
17
        disabled = '# '
18
if not configRegistry.get('update/check/boot/debug','no').lower() in ('yes','true','enabled','1','2','3','4'):
19
        debug = '2> /dev/null > /dev/null'
20
print '%s@reboot   root   [ -x /usr/share/univention-updater/univention-updater-check ] && /usr/sbin/jitter 30 /usr/share/univention-updater/univention-updater-check %s' % (disabled, debug)
21
@!@
14
@!@
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-updater/debian/ucslint.overrides (+1 lines)
Lines 2-4 Link Here
2
0010-2:tests/test_mirror.py
2
0010-2:tests/test_mirror.py
3
0010-2:tests/mockups.py
3
0010-2:tests/mockups.py
4
0011-14: debian/univention-updater.univention-maintenance.init
4
0011-14: debian/univention-updater.univention-maintenance.init
5
0004-12: conffiles/etc/cron.d/univention-updater-check
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-updater/debian/univention-updater.univention-maintenance.init (-162 / +186 lines)
Lines 33-38 Link Here
33
. /lib/lsb/init-functions
33
. /lib/lsb/init-functions
34
LOG="/var/log/univention/updater.log"
34
LOG="/var/log/univention/updater.log"
35
35
36
issue_warning () {
37
	local ttyname="$1" warning_message=
38
	warning_message+="\n\r"
39
	warning_message+="${color[1]}"
40
	if echo $update_warning_lang | egrep -qi '^de$|^ger'; then
41
		warning_message+="!!!!!!!!!! Achtung\n\r"
42
		warning_message+="!!!!!!!!!! die Aktualisierung des Systems kann je nach\n\r"
43
		warning_message+="!!!!!!!!!! Umfang der Pakete eine lange Zeit in Anspruch\n\r"
44
		warning_message+="!!!!!!!!!! nehmen.\n\r"
45
		warning_message+="!!!!!!!!!!\n\r"
46
		case "$(/sbin/runlevel)" in
47
		*2)
48
			warning_message+="!!!!!!!!!! Das System setzt den Startvorgang nach\n\r"
49
			warning_message+="!!!!!!!!!! der Aktualisierung fort.\n\r"
50
			;;
51
		*0)
52
			warning_message+="!!!!!!!!!! Schalten Sie das System erst aus, wenn die\n\r"
53
			warning_message+="!!!!!!!!!! Ausgabe \"System halted!\" erscheint.\n\r"
54
			warning_message+="!!!!!!!!!! Die meisten Systeme schalten sich\n\r"
55
			warning_message+="!!!!!!!!!! selbstständig aus.\n\r"
56
			;;
57
		*6)
58
			warning_message+="!!!!!!!!!! Das System wird nach der Aktualisierung\n\r"
59
			warning_message+="!!!!!!!!!! automatisch neu gestartet.\n\r"
60
			;;
61
		esac
62
	else
63
		warning_message+="!!!!!!!!!! Warning\n\r"
64
		warning_message+="!!!!!!!!!! The update process might take a\n\r"
65
		warning_message+="!!!!!!!!!! considerable amount of time depending on the\n\r"
66
		warning_message+="!!!!!!!!!! number and size of installed packages.\n\r"
67
		warning_message+="!!!!!!!!!!\n\r"
68
		warning_message+="!!!!!!!!!! Do not switch off the system before\n\r"
69
		warning_message+="!!!!!!!!!! update is completely finished.\n\r"
70
		case "$(/sbin/runlevel)" in
71
		*2)
72
			warning_message+="!!!!!!!!!! System boot will continue after\n\r"
73
			warning_message+="!!!!!!!!!! update is finished.\n\r"
74
			;;
75
		*0)
76
			warning_message+="!!!!!!!!!! System can be safely switched off when\n\r"
77
			warning_message+="!!!!!!!!!! \"System halted!\" is displayed.\n\r"
78
			warning_message+="!!!!!!!!!! Most modern systems switch off\n\r"
79
			warning_message+="!!!!!!!!!! automatically.\n\r"
80
			;;
81
		*6)
82
			warning_message+="!!!!!!!!!! System will reboot automatically\n\r"
83
			warning_message+="!!!!!!!!!! after update finished.\n\r"
84
			;;
85
		esac
86
	fi
87
	warning_message+="${color[0]}"
88
	warning_message+="\n\r"
89
90
	echo -e "$down" > "$ttyname"
91
	echo -e "$warning_message" > "$ttyname"
92
}
93
94
run_silent_update () {
95
	dmesg -n 1
96
	trap "dmesg -n 8" EXIT
97
	run_update "$@"
98
}
99
100
run_update () {
101
	eval "$(univention-config-registry shell)"
102
	reset_reboot
103
	setup_colour
104
	check_reachability || return 1
105
	check_policy "$@" || return 1
106
	check_for_updates || return 1
107
	run_update_with_warning
108
}
109
110
reset_reboot () {
111
	if [ -n "$update_reboot_required" ]; then
112
		univention-config-registry unset update/reboot/required >/dev/null 2>&1
113
	fi
114
}
115
116
setup_colour () {
117
	color=("" "" "")
118
	if echo "$update_warning_coloured" | egrep -i 'yes|true' >/dev/null 2>&1; then
119
		color=("\033[0m" "\033[31;1m" "\033[32;1m")
120
	fi
121
	down="\033[5B"
122
	clear="\033[2J"
123
}
124
125
check_reachability () {
126
	log_action_begin_msg "Checking network for Univention maintenance"
127
	check_reachability_ldap &&
128
		check_reachability_repository
129
	log_action_end_msg $?
130
}
131
check_reachability_ldap () {
132
	log_action_cont_msg "ldap[$ldap_server_name]"
133
	ldap_server_port=${ldap_server_port:-7389}
134
	if ! netcat -q0 -w4 "$ldap_server_name" $ldap_server_port </dev/null >/dev/null 2>&1
135
	then
136
		return 1
137
	fi
138
}
139
check_reachability_repository () {
140
	local repository_server
141
	if [ -n "$proxy_http" ]
142
	then
143
		repository_server="${proxy_http#http://}"
144
		repository_server="${repository_server%:*}" # strip port
145
		repository_server="${repository_server##*@}" # strip login information
146
		log_action_cont_msg "proxy[${repository_server}]"
147
	else
148
		repository_server="$repository_online_server"
149
		log_action_cont_msg "repository[$repository_server]"
150
	fi
151
	if ! ping -c 1 "$repository_server" >/dev/null 2>&1
152
	then
153
		return 1
154
	fi
155
}
156
36
check_policy () {
157
check_policy () {
37
	eval "$(univention_policy_result -D "$ldap_hostdn" -y /etc/machine.secret -s "$ldap_hostdn")"
158
	eval "$(univention_policy_result -D "$ldap_hostdn" -y /etc/machine.secret -s "$ldap_hostdn")"
38
	case "$1" in
159
	case "$1" in
Lines 43-223 check_policy () { Link Here
43
	esac
164
	esac
44
}
165
}
45
166
46
case "$1" in
167
check_for_updates () {
47
	start|restart|stop)
168
	local upd_local upd_net actualise
48
169
	if [ "$local_repository" = "yes" -o "$local_repository" = "true" ]; then
49
		log_action_begin_msg "Checking network for Univention maintenance"
170
		mode="local"
50
171
		/usr/share/univention-updater/univention-updater local --silent --check >/dev/null 2>&1
51
		dmesg -n 1
172
		upd_local=$?
52
		eval "$(univention-config-registry shell)"
173
	else
174
		mode="net"
175
		upd_local=0
176
	fi
177
	/usr/share/univention-updater/univention-updater net --silent --check >/dev/null 2>&1
178
	upd_net=$?
179
	/usr/share/univention-updater/univention-actualise --dist-upgrade --silent --check >/dev/null 2>&1
180
	actualise=$?
181
182
	if [ "${upd_local}${upd_net}${actualise}" = 000 ]; then
183
		echo -e "${color[2]}Nothing to do for Univention Updater.${color[0]}"
184
		exit 0
185
	fi
186
}
53
187
54
		# clean up updater settings
188
run_update_with_warning () {
55
		if [ -n "$update_reboot_required" ]; then
189
	local LOCKFILE="/var/lock/univention-maintenance_$RANDOM" tty
56
			univention-config-registry unset update/reboot/required >/dev/null 2>&1
190
191
	if echo "$update_warning" | egrep -i 'yes|true' >/dev/null 2>&1; then
192
		if [ -n "$update_warning_tty" ]; then
193
			touch "$LOCKFILE"
194
			while [ -f "$LOCKFILE" ]; do
195
				for tty in $update_warning_tty
196
				do
197
					if [ -c "$tty" ]; then
198
						issue_warning "$tty"
199
					fi
200
				done
201
				sleep 2
202
			done &
203
			sleep 4
57
		fi
204
		fi
58
205
59
		log_action_cont_msg "ldap[$ldap_server_name]"
206
		if [ -c "$SSH_TTY" ]; then
60
		ldap_server_port=${ldap_server_port:-7389}
207
			issue_warning "$SSH_TTY"
61
		if ! netcat -q0 -w4 "$ldap_server_name" $ldap_server_port </dev/null >/dev/null 2>&1
62
		then
63
			log_action_end_msg 1
64
			exit 1
65
		fi
66
		if [ -n "$proxy_http" ]
67
		then
68
			repository_server="${proxy_http#http://}"
69
			repository_server="${repository_server%:*}" # strip port
70
			repository_server="${repository_server##*@}" # strip login information
71
			log_action_cont_msg "proxy[${repository_server}]"
72
		else
73
			repository_server="$repository_online_server"
74
			log_action_cont_msg "repository[$repository_server]"
75
		fi
208
		fi
76
		if ! ping -c 1 "$repository_server" >/dev/null 2>&1
209
	else
77
		then
210
		echo -e "${color[1]}Univention Updater is updating the system.${color[0]}"
78
			log_action_end_msg 1
211
	fi
79
			exit 1
80
		fi
81
		log_action_end_msg 0
82
212
83
		check_policy "$1" || exit 0
213
	call_updater_scripts
84
214
85
		colourstart=""
215
	if [ -f "$LOCKFILE" ]; then
86
		colourend=""
216
		rm "$LOCKFILE"
87
		if echo $update_warning_coloured | egrep -i 'yes|true' >/dev/null 2>&1; then
217
	fi
88
			colourstart="\033[31;1m"
218
}
89
			colourend="\033[0m"
90
		fi
91
		down="\033[5B"
92
		clear="\033[2J"
93
94
95
		function issue_warning () {
96
			ttyname="$1"
97
			warning_message=""
98
			warning_message="$warning_message\n\r"
99
			warning_message="$warning_message$colourstart"
100
			if echo $update_warning_lang | egrep -i '^de$|^ger' > /dev/null 2>&1; then
101
				warning_message="$warning_message!!!!!!!!!! Achtung\n\r"
102
				warning_message="$warning_message!!!!!!!!!! die Aktualisierung des Systems kann je nach\n\r"
103
				warning_message="$warning_message!!!!!!!!!! Umfang der Pakete eine lange Zeit in Anspruch\n\r"
104
				warning_message="$warning_message!!!!!!!!!! nehmen.\n\r"
105
				warning_message="$warning_message!!!!!!!!!!\n\r"
106
				if /sbin/runlevel | grep '2$' > /dev/null 2>&1; then
107
					warning_message="$warning_message!!!!!!!!!! Das System setzt den Startvorgang nach\n\r"
108
					warning_message="$warning_message!!!!!!!!!! der Aktualisierung fort.\n\r"
109
				elif /sbin/runlevel | grep '0$'> /dev/null 2>&1; then
110
					warning_message="$warning_message!!!!!!!!!! Schalten Sie das System erst aus, wenn die\n\r"
111
					warning_message="$warning_message!!!!!!!!!! Ausgabe \"System halted!\" erscheint.\n\r"
112
					warning_message="$warning_message!!!!!!!!!! Die meisten Systeme schalten sich\n\r"
113
					warning_message="$warning_message!!!!!!!!!! selbstständig aus.\n\r"
114
				elif /sbin/runlevel | grep '6$'> /dev/null 2>&1; then
115
					warning_message="$warning_message!!!!!!!!!! Das System wird nach der Aktualisierung\n\r"
116
					warning_message="$warning_message!!!!!!!!!! automatisch neu gestartet.\n\r"
117
				fi
118
			else
119
				warning_message="$warning_message!!!!!!!!!! Warning\n\r"
120
				warning_message="$warning_message!!!!!!!!!! The update process might take a\n\r"
121
				warning_message="$warning_message!!!!!!!!!! considerable amount of time depending on the\n\r"
122
				warning_message="$warning_message!!!!!!!!!! number and size of installed packages.\n\r"
123
				warning_message="$warning_message!!!!!!!!!!\n\r"
124
				warning_message="$warning_message!!!!!!!!!! Do not switch off the system before\n\r"
125
				warning_message="$warning_message!!!!!!!!!! update is completely finished.\n\r"
126
				if /sbin/runlevel | grep '2$' > /dev/null 2>&1; then
127
					warning_message="$warning_message!!!!!!!!!! System boot will continue after\n\r"
128
					warning_message="$warning_message!!!!!!!!!! update is finished.\n\r"
129
				elif /sbin/runlevel | grep '0$'> /dev/null 2>&1; then
130
					warning_message="$warning_message!!!!!!!!!! System can be safely switched off when\n\r"
131
					warning_message="$warning_message!!!!!!!!!! \"System halted!\" is displayed.\n\r"
132
					warning_message="$warning_message!!!!!!!!!! Most modern systems switch off\n\r"
133
					warning_message="$warning_message!!!!!!!!!! automatically.\n\r"
134
				elif /sbin/runlevel | grep '6$'> /dev/null 2>&1; then
135
					warning_message="$warning_message!!!!!!!!!! System will reboot automatically\n\r"
136
					warning_message="$warning_message!!!!!!!!!! after update finished.\n\r"
137
138
				fi
139
			fi
140
			warning_message="$warning_message$colourend"
141
			warning_message="$warning_message\n\r"
142
143
			echo -e "$down" > "$ttyname"
144
			echo -e "$warning_message" > "$ttyname"
145
		}
146
147
		if [ "$local_repository" = "yes" -o "$local_repository" = "true" ]; then
148
			mode="local"
149
			/usr/share/univention-updater/univention-updater local --silent --check >/dev/null 2>&1
150
			upd_local=$?
151
		else
152
			mode="net"
153
			upd_local=0
154
		fi
155
		/usr/share/univention-updater/univention-updater net --silent --check >/dev/null 2>&1
156
		upd_net=$?
157
		/usr/share/univention-updater/univention-actualise --dist-upgrade --silent --check >/dev/null 2>&1
158
		actualise=$?
159
160
		if [ "$upd_local$upd_net$actualise" = 000 ]; then
161
			if echo $update_warning_coloured | egrep -i 'yes|true' >/dev/null 2>&1; then
162
				echo -e "\033[32;1mNothing to do for Univention Updater.\033[0m"
163
			else
164
				echo "Nothing to do for Univention Updater."
165
			fi
166
			exit 0
167
		fi
168
219
169
		LOCKFILE="/var/lock/univention-maintenance_$RANDOM"
220
call_updater_scripts () {
170
221
	if [ "$univentionUpdateActivate" = "TRUE" ]
171
		if echo $update_warning | egrep -i 'yes|true' >/dev/null 2>&1; then
222
	then
172
			if [ -n "$update_warning_tty" ]; then
223
		if [ -n "$univentionUpdateVersion" ]
173
				touch "$LOCKFILE"
224
		then
174
				while [ -f "$LOCKFILE" ]; do
225
			log_action_msg "Starting Univention Updater [$univentionUpdateVersion]"
175
					for tty in $update_warning_tty
226
			/usr/share/univention-updater/univention-updater "$mode" --noninteractive --updateto "$univentionUpdateVersion" >>"$LOG" 2>&1
176
					do
177
						if [ -c "$tty" ]; then
178
							issue_warning "$tty"
179
						fi
180
					done
181
					sleep 2
182
				done &
183
				sleep 4
184
			fi
185
186
			if [ -c "$SSH_TTY" ]; then
187
				issue_warning "$SSH_TTY"
188
			fi
189
		else
227
		else
190
			if echo $update_warning_coloured | egrep -qi 'yes|true'; then
228
			log_action_msg "Starting Univention Updater"
191
				echo -e "\033[31;1m""Univention Updater is updating the system.\033[0m"
229
			/usr/share/univention-updater/univention-updater "$mode" --noninteractive >>"$LOG" 2>&1
192
			else
193
				echo "Univention Updater is updating the system."
194
			fi
195
		fi
230
		fi
231
		log_action_cont_msg " Univention Actualise"
232
	else:
233
		log_action_msg "Starting Univention Actualise"
234
	fi
196
235
197
				if [ "$univentionUpdateActivate" = "TRUE" ]
236
	/usr/share/univention-updater/univention-actualise --dist-upgrade --silent >>"$LOG" 2>&1
198
				then
199
					if [ -n "$univentionUpdateVersion" ]
200
					then
201
						log_action_msg "Starting Univention Updater [$univentionUpdateVersion]"
202
						/usr/share/univention-updater/univention-updater "$mode" --noninteracive --updateto "$univentionUpdateVersion" >>"$LOG" 2>&1
203
					else
204
						log_action_msg "Starting Univention Updater"
205
						/usr/share/univention-updater/univention-updater "$mode" --noninteracive >>"$LOG" 2>&1
206
					fi
207
					log_action_cont_msg " Univention Actualise"
208
				else
209
					log_action_msg "Starting Univention Actualise"
210
				fi
211
212
				/usr/share/univention-updater/univention-actualise --dist-upgrade --silent >>"$LOG" 2>&1
213
237
214
		if [ -f "$LOCKFILE" ]; then
238
	log_action_end_msg 0
215
			rm "$LOCKFILE"
239
}
216
		fi
217
240
218
		log_action_end_msg 0
219
		dmesg -n 8
220
241
242
case "$1" in
243
	start|restart|stop)
244
		run_silent_update "$@"
221
		;;
245
		;;
222
	*)
246
	*)
223
		echo "Usage: /etc/init.d/univention-maintenance {start|stop|restart}"
247
		echo "Usage: /etc/init.d/univention-maintenance {start|stop|restart}"
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-updater/univention-directory-policy/univention-policy-maintenance (-68 / +133 lines)
Lines 31-101 Link Here
31
# /usr/share/common-licenses/AGPL-3; if not, see
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
32
# <http://www.gnu.org/licenses/>.
33
33
34
import os, string, sys
34
import os
35
import sys
35
import subprocess
36
import subprocess
36
import univention.config_registry
37
from univention.config_registry import ConfigRegistry
37
38
38
# Name of the cron.d file
39
39
CRON_D='/etc/cron.d/univention-maintenance'
40
class UpdaterPolicy(dict):
40
41
	@property
41
def write_cron_job(configRegistry, cron, updateto, reboot, try_release_update):
42
	def cron_active(self):
42
	file=open(CRON_D, 'w')
43
		return self.get("univentionCronActive") == "1"
43
	file.write('# cron job for update\n')
44
44
	file.write('PATH=/sbin:/usr/sbin:/usr/bin:/bin\n')
45
	@property
45
	if cron != '* * * * * ':
46
	def cron(self):
46
		file.write('%s root ' % cron)
47
		return self.get("univentionCron")
47
		if configRegistry.is_true( 'local/repository' ):
48
48
			target='local'
49
	@property
49
		else:
50
	def release_version(self):
50
			target='net'
51
		return self.get("univentionUpdateVersion")
51
		if updateto:
52
52
			updateto='--updateto=%s' % updateto
53
	@property
53
		if reboot:
54
	def relese_active(self):
54
			reboot='--reboot=%s' % reboot
55
		return self.get("univentionUpdateActivate") == "TRUE"
55
		file.write('/usr/sbin/jitter 600 ')
56
56
		if try_release_update:
57
	@property
57
			file.write('/usr/share/univention-updater/univention-updater %s %s %s --silent --noninteractive; ' % (target, updateto, reboot))
58
	def reboot(self):
58
		file.write('/usr/share/univention-updater/univention-actualise --dist-upgrade --silent\n')
59
		return self.get("univentionInstallationReboot")
59
	file.close()
60
60
61
	def fetch(self, ldap_hostdn):
61
62
		cmd = (
62
configRegistry = univention.config_registry.ConfigRegistry()
63
			'univention_policy_result',
63
configRegistry.load()
64
			'-D', ldap_hostdn,
64
65
			'-y', '/etc/machine.secret',
65
if os.path.exists(CRON_D):
66
			'-s', ldap_hostdn,
66
	os.unlink(CRON_D)
67
		)
67
68
		proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
68
ldap_hostdn = configRegistry.get('ldap/hostdn')
69
		for line in proc.stdout:
69
if ldap_hostdn:
70
			line = line.strip()
70
71
			key, value = line.split('=', 1)
71
	p1 = subprocess.Popen(['univention_policy_result', '-D', ldap_hostdn, '-y', '/etc/machine.secret', '-s', ldap_hostdn], stdout=subprocess.PIPE)
72
			self[key] = value[1:-1] if value[0] == value[-1] == '"' else value
72
73
		if proc.wait() != 0:
73
	updateto=''
74
			print >> sys.stderr, 'failed to execute univention_policy_result'
74
	cron_active=''
75
			sys.exit(proc.returncode)
75
	reboot=''
76
76
	cron=None
77
77
	try_release_update = False
78
class UniventionUpdaterPolicy(object):
78
79
	CRON_D = '/etc/cron.d/univention-maintenance'
79
	for line in p1.stdout:
80
80
		line=line.strip(' ').strip('\n')
81
	def __init__(self):
81
		key, value = line.split('=', 1)
82
		self.ucr = ConfigRegistry()
82
		if line.startswith('univentionCronActive='):
83
		self.ucr.load()
83
			cron_active=line.replace('univentionCronActive=', '').replace('"','')
84
		self.ldap_hostdn = self.ucr.get('ldap/hostdn')
84
		elif line.startswith('univentionCron='):
85
		self.policy = UpdaterPolicy()
85
			cron=line.replace('univentionCron=', '').replace('"','')
86
86
		elif line.startswith('univentionUpdateVersion='):
87
	def main(self):
87
			updateto=line.replace('univentionUpdateVersion=', '').replace('"','')
88
		self.remove_previous_cron()
88
		elif line.startswith('univentionInstallationReboot='):
89
		if self.ldap_hostdn:
89
			reboot=line.replace('univentionInstallationReboot=', '').replace('"','')
90
			self.process_host()
90
		elif 'univentionUpdateActive' == key:
91
		sys.exit(0)
91
			try_release_update = value == "TRUE"
92
92
93
	def remove_previous_cron(self):
93
	if p1.wait() != 0:
94
		if os.path.exists(self.CRON_D):
94
		print 'failed to execute univention_policy_result'
95
			os.unlink(self.CRON_D)
95
		sys.exit(p1.returncode)
96
96
97
	def process_host(self):
97
	if cron_active and cron_active == '1':
98
		self.fetch_policy()
98
		if cron:
99
99
			write_cron_job(configRegistry, cron, updateto, reboot, try_release_update)
100
		if not self.policy.cron_active:
100
101
			return
101
sys.exit(0)
102
		if not self.valid_cron():
103
			return
104
105
		self.write_cron_job()
106
107
	def fetch_policy(self):
108
		self.policy.fetch(self.ldap_hostdn)
109
110
	def valid_cron(self):
111
		if not self.policy.cron:
112
			return False
113
		if self.policy.cron == '* * * * * ':
114
			return False
115
		return True
116
117
	def append_to(self, args, prefix, key):
118
		value = self.policy[key]
119
		if value:
120
			args.append(prefix)
121
			args.append(value)
122
123
	def write_cron_job(self):
124
		with open(self.CRON_D, 'w') as cron_file:
125
			cron_file.write('# cron job for update\n')
126
			cron_file.write('PATH=/sbin:/usr/sbin:/usr/bin:/bin\n')
127
			cron_file.write('%s root %s\n' % (self.policy.cron, self.command()))
128
129
	def command(self):
130
		cmd = self.jitter_command()
131
		if self.policy.relese_active:
132
			cmd.extend(self.update_command())
133
			cmd.append(";")
134
		cmd.extend(self.actualise_command())
135
		return " ".join(cmd)
136
137
	def jitter_command(self):
138
		cmd = [
139
			"/usr/sbin/jitter",
140
			"600",
141
		]
142
		return cmd
143
144
	def update_command(self):
145
		cmd = [
146
			'/usr/share/univention-updater/univention-updater',
147
			'--noninteractive',
148
			'--silent',
149
		]
150
		if self.policy.release_version:
151
			cmd.extend(("--updateto", self.policy.release_version))
152
		if self.policy.reboot:
153
			cmd.extend(("--reboot", self.policy.reboot))
154
		cmd.append('local' if self.ucr.is_true('local/repository') else 'net')
155
		return cmd
156
157
	def actualise_command(self):
158
		cmd = [
159
			"/usr/share/univention-updater/univention-actualise",
160
			"--dist-upgrade",
161
			"--silent",
162
		]
163
		return cmd
164
165
166
if __name__ == '__main__':
167
	UniventionUpdaterPolicy().main()
102
- 

Return to bug 34055