|
|
|
1 |
#!/bin/sh |
1 |
@%@BCWARNING=# @%@ |
2 |
@%@BCWARNING=# @%@ |
2 |
# |
3 |
# |
3 |
# Univention Thin Client Flash |
4 |
# Univention Thin Client Flash |
|
27 |
# along with this program; if not, write to the Free Software |
28 |
# along with this program; if not, write to the Free Software |
28 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
29 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
29 |
|
30 |
|
|
|
31 |
encode_url () |
32 |
{ |
33 |
echo "$1" | sed \ |
34 |
-e 's/%/%25/g' \ |
35 |
-e 's/ /%20/g' \ |
36 |
-e 's/!/%21/g' \ |
37 |
-e 's/"/%22/g' \ |
38 |
-e 's/#/%23/g' \ |
39 |
-e 's/\$/%24/g' \ |
40 |
-e 's/\&/%26/g' \ |
41 |
-e 's/'\''/%27/g' \ |
42 |
-e 's/(/%28/g' \ |
43 |
-e 's/)/%29/g' \ |
44 |
-e 's/\*/%2a/g' \ |
45 |
-e 's/+/%2b/g' \ |
46 |
-e 's/,/%2c/g' \ |
47 |
-e 's/-/%2d/g' \ |
48 |
-e 's/\./%2e/g' \ |
49 |
-e 's/\//%2f/g' \ |
50 |
-e 's/:/%3a/g' \ |
51 |
-e 's/;/%3b/g' \ |
52 |
-e 's//%3e/g' \ |
53 |
-e 's/?/%3f/g' \ |
54 |
-e 's/@/%40/g' \ |
55 |
-e 's/\[/%5b/g' \ |
56 |
-e 's/\\/%5c/g' \ |
57 |
-e 's/\]/%5d/g' \ |
58 |
-e 's/\^/%5e/g' \ |
59 |
-e 's/_/%5f/g' \ |
60 |
-e 's/`/%60/g' \ |
61 |
-e 's/{/%7b/g' \ |
62 |
-e 's/|/%7c/g' \ |
63 |
-e 's/}/%7d/g' \ |
64 |
-e 's/~/%7e/g' |
65 |
} |
66 |
|
67 |
append_to_url () |
68 |
{ |
69 |
local url="$1" |
70 |
local item="$2" |
71 |
local value="$3" |
72 |
local delim="$4" |
73 |
|
74 |
if [ -z "$delim" ]; then |
75 |
delim="&" |
76 |
fi |
77 |
|
78 |
if [ -z "$value" ]; then |
79 |
value=None |
80 |
fi |
81 |
|
82 |
if [ -n "$item" ]; then |
83 |
value=$(encode_url "$value") |
84 |
url="$url$delim$item=$value" |
85 |
fi |
86 |
|
87 |
echo "$url" |
88 |
} |
89 |
|
90 |
ALREADY_LOGGED=0 |
91 |
flash_status () |
92 |
{ |
93 |
# to log or not to log ... |
94 |
case "$thinclient_flash_status_log" in |
95 |
0|no|off|false|disable|disabled) return 0;; |
96 |
esac |
97 |
|
98 |
# check if we already logged the status |
99 |
if [ $ALREADY_LOGGED -ne 0 ]; then |
100 |
return |
101 |
fi |
102 |
|
103 |
# $1 is the status of the thin client (up-to-dat, updated, installation failed, ...) |
104 |
local status=$1 |
105 |
if [ -z "$status" ]; then |
106 |
status=unknown |
107 |
fi |
108 |
|
109 |
# collect data |
110 |
local mac=$(LC_ALL=C ifconfig eth0 | sed -n 's|.*HWaddr \([^ ]*\) .*|\1|p') |
111 |
local ip=$(LC_ALL=C ifconfig eth0|sed -n 's| *inet addr:\([^ ]*\) .*|\1|p') |
112 |
local uri="$url/flashstatus.py" |
113 |
|
114 |
# setup url |
115 |
uri=$(append_to_url "$uri" "mac" "$mac" "?") |
116 |
uri=$(append_to_url "$uri" "ip" "$ip") |
117 |
uri=$(append_to_url "$uri" "hostname" "$hostname") |
118 |
uri=$(append_to_url "$uri" "domainname" "$domainname") |
119 |
uri=$(append_to_url "$uri" "nameserver" "$nameserver") |
120 |
uri=$(append_to_url "$uri" "ldapserver" "$ldapserver") |
121 |
uri=$(append_to_url "$uri" "image" "$image") |
122 |
uri=$(append_to_url "$uri" "version" "$version") |
123 |
uri=$(append_to_url "$uri" "newversion" "$new_version") |
124 |
uri=$(append_to_url "$uri" "url" "$url") |
125 |
uri=$(append_to_url "$uri" "partition" "$partition") |
126 |
uri=$(append_to_url "$uri" "rootpart" "$rootpart") |
127 |
uri=$(append_to_url "$uri" "bootpart" "$bootpart") |
128 |
uri=$(append_to_url "$uri" "status" "$status") |
129 |
|
130 |
# do it |
131 |
wget -q -O - "$uri" |
132 |
|
133 |
ALREADY_LOGGED=1 |
134 |
} |
135 |
|
136 |
|
30 |
flash_abort () |
137 |
flash_abort () |
31 |
{ |
138 |
{ |
32 |
echo |
139 |
echo |
|
37 |
|
144 |
|
38 |
flash_reboot () |
145 |
flash_reboot () |
39 |
{ |
146 |
{ |
|
|
147 |
# log status |
148 |
flash_status "$1" |
149 |
|
40 |
#See https://forge.univention.org/bugzilla/show_bug.cgi?id=18792 for details |
150 |
#See https://forge.univention.org/bugzilla/show_bug.cgi?id=18792 for details |
41 |
|
151 |
|
42 |
#soft-reset: |
152 |
#soft-reset: |
|
61 |
print ' echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"' |
171 |
print ' echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"' |
62 |
@!@ |
172 |
@!@ |
63 |
sleep ${thinclient_flash_update_panic_timeout}s |
173 |
sleep ${thinclient_flash_update_panic_timeout}s |
64 |
flash_reboot |
174 |
flash_reboot "installation failed" |
65 |
} |
175 |
} |
66 |
|
176 |
|
67 |
flash_panic_upgrade () |
177 |
flash_panic_upgrade () |
|
81 |
print ' echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"' |
191 |
print ' echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"' |
82 |
@!@ |
192 |
@!@ |
83 |
sleep ${thinclient_flash_update_panic_timeout}s |
193 |
sleep ${thinclient_flash_update_panic_timeout}s |
84 |
flash_reboot |
194 |
flash_reboot "upgrade failed" |
85 |
} |
195 |
} |
86 |
|
196 |
|
87 |
print_done () |
197 |
print_done () |
|
98 |
print_header () |
208 |
print_header () |
99 |
{ |
209 |
{ |
100 |
clear |
210 |
clear |
|
|
211 |
usplash_write QUIT |
101 |
echo "verbose" > /proc/splash |
212 |
echo "verbose" > /proc/splash |
102 |
clear |
213 |
clear |
103 |
echo |
214 |
echo |
|
123 |
|
234 |
|
124 |
if [ -z "$thinclient_flash_update_url" ]; then |
235 |
if [ -z "$thinclient_flash_update_url" ]; then |
125 |
thinclient_flash_server_ip=$(host ${thinclient_flash_server} | sed -n "s|.* has address ||p") |
236 |
thinclient_flash_server_ip=$(host ${thinclient_flash_server} | sed -n "s|.* has address ||p") |
|
|
237 |
# is name a ip? |
238 |
ip="$(echo $thinclient_flash_server | sed -n 's|[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*|'$thinclient_flash_server'|p')" |
239 |
if [ -n "$ip" ]; then |
240 |
thinclient_flash_server_ip="$thinclient_flash_server" |
241 |
else |
242 |
thinclient_flash_server_ip=$(host ${thinclient_flash_server} | sed -n "s|.* has address ||p") |
243 |
fi |
126 |
url="http://${thinclient_flash_server_ip}/univention-thin-client-flash/" |
244 |
url="http://${thinclient_flash_server_ip}/univention-thin-client-flash/" |
127 |
else |
245 |
else |
128 |
# Busybox can not resolve dns names ... |
246 |
# Busybox can not resolve dns names ... |
|
131 |
# is name a ip? |
249 |
# is name a ip? |
132 |
ip="$(echo $name | sed -n 's|[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*|'$name'|p')" |
250 |
ip="$(echo $name | sed -n 's|[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*|'$name'|p')" |
133 |
if [ -n "$ip" ]; then |
251 |
if [ -n "$ip" ]; then |
|
|
252 |
thinclient_flash_server_ip="$name" |
134 |
url="$thinclient_flash_update_url" |
253 |
url="$thinclient_flash_update_url" |
135 |
else |
254 |
else |
136 |
thinclient_flash_server_ip=$(host $name | sed -n "s|.* has address ||p") |
255 |
thinclient_flash_server_ip=$(host $name | sed -n "s|.* has address ||p") |
|
151 |
echo -n "Retrieve version information: " >>/dev/tty9 |
270 |
echo -n "Retrieve version information: " >>/dev/tty9 |
152 |
new_version=$(wget -qqq -O - "$url/$image.vers") |
271 |
new_version=$(wget -qqq -O - "$url/$image.vers") |
153 |
if [ -z "$new_version" ]; then |
272 |
if [ -z "$new_version" ]; then |
|
|
273 |
flash_status "image version not found" |
154 |
echo "Not found" >>/dev/tty9 |
274 |
echo "Not found" >>/dev/tty9 |
155 |
exit 0 |
275 |
exit 0 |
156 |
else |
276 |
else |
|
227 |
partition=0 |
347 |
partition=0 |
228 |
fi |
348 |
fi |
229 |
|
349 |
|
230 |
nameserver=$(cat /proc/cmdline | grep DNSSERVER | sed -e 's/.*DNSSERVER=//g' | awk '{print $1;}') |
350 |
# save flash server's ip as boot parameter |
231 |
ldapserver=$(cat /proc/cmdline | grep ldapServer | sed -e 's/.*ldapServer=//g' | awk '{print "ldapServer="$1;}') |
351 |
if [ -n "$thinclient_flash_server_ip" ]; then |
232 |
ldapport=$(cat /proc/cmdline | grep ldapPort | sed -e 's/.*ldapPort=//g' | awk '{print "ldapPort="$1;}') |
352 |
flashserverCmdline="flashServer=$thinclient_flash_server_ip" |
233 |
vga=$(cat /proc/cmdline | grep vga | sed -e 's/.*vga=//g' | awk '{print "vga="$1;}') |
353 |
flashserver="$thinclient_flash_server_ip" |
234 |
quiet_cmdline=$(cat /proc/cmdline | grep " quiet") |
|
|
235 |
quiet="" |
236 |
if [ -n "$quiet_cmdline" ]; then |
237 |
quiet="quiet" |
238 |
fi |
354 |
fi |
239 |
|
355 |
|
240 |
|
356 |
|
|
291 |
PATH_BASE=/mnt |
407 |
PATH_BASE=/mnt |
292 |
PATH_MBR=/usr/lib/syslinux/mbr.bin |
408 |
PATH_MBR=/usr/lib/syslinux/mbr.bin |
293 |
|
409 |
|
294 |
echo "default linux initrd=initrd.splash root=$rootpart DNSSERVER=$nameserver $vga $quiet splash=silent $ldapserver $ldapport" > $PATH_EXTLINUX |
410 |
echo "default linux initrd=initrd.splash root=$rootpart $nameserverCmdline $vga $quiet splash=silent $flashserverCmdline $ldapserverCmdline $ldapport $loglevel" > $PATH_EXTLINUX |
295 |
|
411 |
|
296 |
# store current network configuration |
412 |
# store current network configuration |
297 |
echo "FLASH_HOSTNAME=$hostname" > $PATH_NETWORKCONFIG |
413 |
echo "FLASH_HOSTNAME=$hostname" > $PATH_NETWORKCONFIG |
|
353 |
|
469 |
|
354 |
echo |
470 |
echo |
355 |
sync |
471 |
sync |
356 |
flash_reboot |
472 |
flash_reboot "updated" |
357 |
log_action_end_msg 0 |
473 |
log_action_end_msg 0 |
358 |
else |
474 |
else |
|
|
475 |
flash_status "up-to-date" |
359 |
@!@ |
476 |
@!@ |
360 |
if baseConfig.get('locale/default', 'us').startswith('de_'): |
477 |
if baseConfig.get('locale/default', 'us').startswith('de_'): |
361 |
print ' echo "Das System ist aktuell."' |
478 |
print ' echo "Das System ist aktuell."' |