|
32 |
. /usr/share/univention-lib/ucr.sh |
32 |
. /usr/share/univention-lib/ucr.sh |
33 |
|
33 |
|
34 |
logfile="/var/log/univention/software-updates.log" |
34 |
logfile="/var/log/univention/software-updates.log" |
|
|
35 |
exec > >(ts "%b %d %H:%M:%S:" >> "$logfile") 2>&1 |
35 |
|
36 |
|
|
|
37 |
update_status_file="$(mktemp univention-ucc-software-update.XXXXXXXXXX)" |
38 |
touch $update_status_file |
39 |
|
36 |
# This script supports software updates for both systems with and without overlayfs |
40 |
# This script supports software updates for both systems with and without overlayfs |
37 |
# If a system with overlaysfs is booted, it is marked for read/write operation and rebooted |
41 |
# If a system with overlaysfs is booted, it is marked for read/write operation and rebooted |
38 |
|
|
|
39 |
export DEBIAN_FRONTEND="noninteractive" |
42 |
export DEBIAN_FRONTEND="noninteractive" |
|
|
43 |
export LC_ALL=C |
44 |
export LANG=C |
40 |
|
45 |
|
|
|
46 |
message() { |
47 |
echo "$1" |
48 |
plymouth message --text="$1" |
49 |
} |
50 |
|
41 |
apt_get_update() { |
51 |
apt_get_update() { |
42 |
plymouth message --text="Checking for available software updates" |
52 |
nextupdate=$(expr $(cat "$update_status_file") + 600) |
43 |
apt-get update 2>>$logfile 1>>$logfile |
53 |
if [ $(date +%s) -ge $nextupdate ]; then |
|
|
54 |
message "Checking for available software updates" |
55 |
apt-get update |
56 |
date +%s > "$update_status_file" |
57 |
fi |
44 |
} |
58 |
} |
45 |
|
59 |
|
46 |
check_for_rw_mount_and_reboot() { |
60 |
check_for_rw_mount_and_reboot() { |
47 |
# When running on overlayfs, switch to R/W mode |
61 |
# When running on overlayfs, switch to R/W mode |
48 |
if LC_ALL=C mount | grep -q "on /root-ro"; then |
62 |
if mount | grep -q "on /root-ro"; then |
49 |
plymouth message --text="Rebooting to install software updates" |
63 |
message "Rebooting to install software updates" |
50 |
/usr/sbin/univention-ucc-boot-option --write --option mount --value rw |
64 |
/usr/sbin/univention-ucc-boot-option --write --option mount --value rw |
51 |
/usr/sbin/univention-ucc-boot-option --write --option swinstreset --value true |
65 |
/usr/sbin/univention-ucc-boot-option --write --option swinstreset --value true |
|
|
66 |
rm -f "$update_status_file" |
52 |
sync |
67 |
sync |
53 |
reboot |
68 |
reboot |
54 |
exit 0 |
69 |
exit 0 |
|
61 |
apt_get_update |
76 |
apt_get_update |
62 |
|
77 |
|
63 |
# Test, whether we need to update the installed packages. |
78 |
# Test, whether we need to update the installed packages. |
64 |
new=`LANG=C apt-get dist-upgrade --dry-run | grep "packages will be [installed|upgraded]"` |
79 |
new=`apt-get dist-upgrade --dry-run | grep "packages will be [installed|upgraded]"` |
65 |
if [ -n "$new" ]; then |
80 |
if [ -n "$new" ]; then |
66 |
|
81 |
|
67 |
check_for_rw_mount_and_reboot |
82 |
check_for_rw_mount_and_reboot |
68 |
|
83 |
|
69 |
plymouth message --text="Installing available software updates - this may take some time. Do not turn of the computer" |
84 |
message "Installing available software updates - this may take some time. Do not turn of the computer" |
70 |
apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir -y --force-yes -u dist-upgrade 2>>$logfile 1>>$logfile |
85 |
apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir -y --force-yes -u dist-upgrade |
71 |
apt-get clean 2>>$logfile 1>>$logfile |
86 |
apt-get clean |
72 |
fi |
87 |
fi |
73 |
fi |
88 |
fi |
74 |
|
89 |
|
75 |
# Test whether, we need to remove packages. If so, switch to r/w mode if using overlayfs |
90 |
# Test whether, we need to remove packages. If so, switch to r/w mode if using overlayfs |
76 |
|
91 |
|
77 |
remove=`get_host_policy_var univentionCorporateClientSoftwareUpdateRemoveList` |
92 |
remove=`get_host_policy_var univentionCorporateClientSoftwareUpdateRemoveList` |
78 |
rmneeded=0 |
93 |
rmneeded="" |
79 |
for I in $remove |
94 |
for I in $remove |
80 |
do |
95 |
do |
81 |
PKGRM=`echo $I | tr -d "="` |
96 |
PKGRM=`echo $I | tr -d "="` |
82 |
|
97 |
|
83 |
if LC_ALL=C dpkg-query -W -f='${Status}' $PKGRM | grep -q "installed"; then |
98 |
if dpkg-query -W -f='${Status}' $PKGRM | grep -q "installed"; then |
84 |
rmneeded=1 |
99 |
rmneeded="$rmneeded $I" |
85 |
fi |
100 |
fi |
86 |
done |
101 |
done |
87 |
|
102 |
|
88 |
# Test, whether we need to remove packages |
103 |
# Test, whether we need to remove packages |
89 |
if [ 1 -eq $rmneeded ]; then |
104 |
if [ -n $rmneeded ]; then |
90 |
|
105 |
|
91 |
check_for_rw_mount_and_reboot |
106 |
check_for_rw_mount_and_reboot |
92 |
|
107 |
|
93 |
for I in $remove |
108 |
for I in $rmneeded |
94 |
do |
109 |
do |
95 |
PKGRM=`echo $I | tr -d "="` |
110 |
PKGRM=`echo $I | tr -d "="` |
96 |
plymouth message --text="Removing package $PKGRM" |
111 |
message "Removing package $PKGRM" |
97 |
apt-get --yes remove $PKGRM 2>>$logfile 1>>$logfile |
112 |
apt-get --yes remove $PKGRM |
98 |
done |
113 |
done |
99 |
fi |
114 |
fi |
100 |
|
115 |
|
101 |
install=`get_host_policy_var univentionCorporateClientSoftwareUpdateInstallList` |
116 |
install=`get_host_policy_var univentionCorporateClientSoftwareUpdateInstallList` |
102 |
|
117 |
|
103 |
# Test whether, we need to install packages. |
118 |
# Test whether, we need to install packages. |
104 |
instneeded=0 |
119 |
instneeded="" |
105 |
for I in $install |
120 |
for I in $install |
106 |
do |
121 |
do |
107 |
apt_get_update |
122 |
apt_get_update |
108 |
PKGINST=`echo $I | tr -d "="` |
123 |
PKGINST=`echo $I | tr -d "="` |
109 |
|
124 |
|
110 |
new=`LANG=C apt-get install --dry-run $PKGINST | grep "packages will be [installed|upgraded]"` |
125 |
new=`apt-get install --dry-run $PKGINST | grep "packages will be [installed|upgraded]"` |
111 |
if [ -n "$new" ]; then |
126 |
if [ -n "$new" ]; then |
112 |
instneeded=1 |
127 |
instneeded="$instneeded $I" |
113 |
fi |
128 |
fi |
114 |
done |
129 |
done |
115 |
|
130 |
|
116 |
if [ 1 -eq $instneeded ]; then |
131 |
if [ -n "$instneeded" ]; then |
117 |
|
132 |
|
118 |
check_for_rw_mount_and_reboot |
133 |
check_for_rw_mount_and_reboot |
119 |
|
134 |
|
120 |
for I in $install |
135 |
for I in $instneeded |
121 |
do |
136 |
do |
122 |
PKGINST=`echo $I | tr -d "="` |
137 |
PKGINST=`echo $I | tr -d "="` |
123 |
plymouth message --text="Installing package $PKGINST" |
138 |
message "Installing package $PKGINST" |
124 |
apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir -y --force-yes install $PKGINST 2>>$logfile 1>>$logfile |
139 |
apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir -y --force-yes install $PKGINST |
125 |
done |
140 |
done |
126 |
fi |
141 |
fi |
127 |
|
142 |
|
128 |
# Reset flag that triggers a r/w mount for systems booted with overlayfs |
143 |
# Reset flag that triggers a r/w mount for systems booted with overlayfs |
129 |
if ! LC_ALL=C mount | grep -q "on /root-ro"; then |
144 |
if ! mount | grep -q "on /root-ro"; then |
130 |
if is_ucr_true 'ucc/thinclientoverlayfs'; then |
145 |
if is_ucr_true 'ucc/thinclientoverlayfs'; then |
131 |
resetclient=`/usr/sbin/univention-ucc-boot-option --read --option swinstreset` |
146 |
resetclient=`/usr/sbin/univention-ucc-boot-option --read --option swinstreset` |
132 |
if [[ -n $resetclient && "true" = $resetclient ]]; then |
147 |
if [[ -n $resetclient && "true" = $resetclient ]]; then |
|
138 |
fi |
153 |
fi |
139 |
fi |
154 |
fi |
140 |
|
155 |
|
|
|
156 |
rm -f "$update_status_file" |
141 |
exit 0 |
157 |
exit 0 |