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

(-)debian/univention-corporate-client.univention-config-registry-variables (+12 lines)
 Lines 15-17    Link Here 
15
Description[en]=Timeout in seconds for upstart job ucc-syspol if the network can not be started (default: 10)
15
Description[en]=Timeout in seconds for upstart job ucc-syspol if the network can not be started (default: 10)
16
Type=str
16
Type=str
17
Categories=system-desktop
17
Categories=system-desktop
18
19
[ucc/update/remove/old/kernel]
20
Description[de]=Alte Kernel-Pakete werden vor der Verwaltung von Software-Paketen mit apt-get entfernt (default: true)
21
Description[en]=Remove old kernel packages before managing software packages with apt-get (default: true)
22
Type=str
23
Categories=system-desktop
24
25
[ucc/update/remove/old/kernel/pkgregex]
26
Description[de]=Regulärer Ausdruck für die Suche nach Kernel-Paketen (default: linux-image-[[:digit:]])
27
Description[en]=Regular expression used for search for kernel packages (default: linux-image-[[:digit:]])
28
Type=str
29
Categories=system-desktop
(-)debian/univention-corporate-client.dirs (+1 lines)
 Lines 3-5    Link Here 
3
usr/share/univention-lib
3
usr/share/univention-lib
4
usr/share/keyrings
4
usr/share/keyrings
5
etc/network/if-up.d
5
etc/network/if-up.d
6
usr/share/univention-corporate-client/apt-pre-invoke.d
(-)debian/univention-corporate-client.postinst (-1 / +2 lines)
 Lines 42-48    Link Here 
42
42
43
univention-config-registry set version/version=1.0
43
univention-config-registry set version/version=1.0
44
univention-config-registry set version/releasename=Weser
44
univention-config-registry set version/releasename=Weser
45
univention-config-registry set ucc/update/remove/old/kernel?true
45
46
46
apt-key add /usr/share/keyrings/ucc-archive-key.gpg
47
apt-key add /usr/share/keyrings/ucc-archive-key.gpg
47
48
48
exit 0
49
exit 0
(-)debian/univention-corporate-client.install (+1 lines)
 Lines 10-12    Link Here 
10
ucc-archive-key.gpg /usr/share/keyrings
10
ucc-archive-key.gpg /usr/share/keyrings
11
univention-ucc-fetch-system-policies usr/sbin
11
univention-ucc-fetch-system-policies usr/sbin
12
univention-ucc-software-update usr/sbin
12
univention-ucc-software-update usr/sbin
13
apt-get-pre-invoke.d/univention-ucc-prune-old-kernel-packages usr/share/univention-corporate-client/apt-pre-invoke.d/
(-)debian/univention-corporate-client.univention-config-registry (+3 lines)
 Lines 4-6    Link Here 
4
Type: file
4
Type: file
5
File: etc/rsyslog.d/100-ucc.conf
5
File: etc/rsyslog.d/100-ucc.conf
6
Variables: grub/append
6
Variables: grub/append
7
8
Type: file
9
File: etc/apt/apt.conf.d/900-ucc-pre-invoke
(-)apt-get-pre-invoke.d/univention-ucc-prune-old-kernel-packages (+83 lines)
Line 0    Link Here 
1
#!/bin/bash
2
#
3
# Univention Corporate Client
4
#  remove old, unused kernel packages
5
#
6
# Copyright 2013 Univention GmbH
7
#
8
# http://www.univention.de/
9
#
10
# All rights reserved.
11
#
12
# The source code of this program is made available
13
# under the terms of the GNU Affero General Public License version 3
14
# (GNU AGPL V3) as published by the Free Software Foundation.
15
#
16
# Binary versions of this program provided by Univention to you as
17
# well as other copyrighted, protected or trademarked materials like
18
# Logos, graphics, fonts, specific documentations and configurations,
19
# cryptographic keys etc. are subject to a license agreement between
20
# you and Univention and not subject to the GNU AGPL V3.
21
#
22
# In the case you use this program under the terms of the GNU AGPL V3,
23
# the program is provided in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU Affero General Public License for more details.
27
#
28
# You should have received a copy of the GNU Affero General Public
29
# License with the Debian GNU/Linux or Univention distribution in file
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
32
33
# returns latest kernel package for given kernel version
34
35
export LC_ALL=C
36
export DEBIAN_FRONTEND=noninteractive
37
38
removeOldKernelPackages () {
39
40
	local kernel_regex="$1"
41
	local running_kernel="$(uname -r)"
42
43
	local pkg=""
44
	local pkg_ver=""
45
	local latest_pkg=""
46
	local latest_pkg_ver=""
47
	local kernel_packages=""
48
	
49
	# remove all $kernel_regex packages except
50
	# the running kernel
51
	for pkg in $(dpkg-query -W -f '${Package}\n' | grep "$kernel_regex" | sort -n); do
52
		if [ "$(dpkg-query -W -f='${Status}\n' "$pkg" 2>/dev/null)" = "install ok installed" ]; then
53
			kernel_packages="$kernel_packages $pkg"
54
			pkg_ver="$(dpkg-query -W -f '${Version}\n' $pkg)"
55
			if dpkg --compare-versions "$pkg_ver" gt "$latest_pkg_ver" ; then
56
				latest_pkg_ver="$pkg_ver"
57
				latest_pkg="$pkg"
58
			fi
59
		fi
60
	done
61
62
	# remove kernel package
63
	for i in $kernel_packages; do
64
		# do not remove running and latest kernel
65
		if ! echo "$i" | grep -q "$running_kernel\|$latest_pkg"; then
66
			echo "removing kernel as requested in $0"
67
			dpkg -P $i || true
68
		fi
69
	done
70
71
}
72
73
remove=$(/usr/sbin/ucr get ucc/update/remove/old/kernel)
74
remove_regex=$(/usr/sbin/ucr get ucc/update/remove/old/kernel/pkgregex)
75
76
if [ -n "$remove" -a "$remove" = "true" ]; then
77
	if [ -z "$remove_regex" ]; then
78
		remove_regex="linux-image-[[:digit:]]"
79
	fi
80
	removeOldKernelPackages "$remove_regex"
81
fi
82
83
exit 0
0
  + *
84
  + *

Return to bug 31012