|
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}" |