-
Notifications
You must be signed in to change notification settings - Fork 44
/
YaST2.call
executable file
·667 lines (612 loc) · 18.8 KB
/
YaST2.call
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
#!/bin/sh
#================
# FILE : YaST2.call
#----------------
# PROJECT : YaST (Yet another Setup Tool v2)
# COPYRIGHT : (c) 2004 SUSE Linux AG, Germany. All rights reserved
# :
# AUTHORS : Steffen Winterfeldt <snwint@suse.de>
# : Arvin Schnell <arvin@suse.de>
# : Marcus Schaefer <ms@suse.de>
# : Lukas Ocilka <locilka@suse.cz>
# : Arvin Schnell <aschnell@suse.de>
# :
# BELONGS TO : System installation and Administration
# :
# DESCRIPTION : This is the main script to start the YaST2 installer
# : according to the possible installation environments
# : These are:
# : ---
# : - Standard Installation X11 or text based
# : - Via serial line ttyS0/115200 baud, 8N1, RTS/CTS
# : which is the same as the NCURSES mode
# : - VNC Installation via browser
# :
# STATUS : $Id$
#----------------
#
#set -x
. /etc/YaST2/XVersion
#=============================================
# Functions...
#---------------------------------------------
#----[ wait_for_x11 ]----#
function wait_for_x11() {
#------------------------------------------------------
# after a X-Server has been started you can wait until
# the server is ready for requests using this function
# ---
server_running=0
TESTX=/usr/lib/YaST2/bin/testX
while kill -0 $xserver_pid 2>/dev/null ; do
sleep 1
if test -e /tmp/.X11-unix/X0 && test -x $TESTX ; then
$TESTX "$YaST2color" 2>/dev/null
err=$?
# exit code 1 -> XOpenDisplay failed...
if test $err = 1;then
log "\tTestX: XOpenDisplay failed"
server_running=0
continue
fi
# server is running, detach oom-killer from it
echo -n '-17' > /proc/$xserver_pid/oom_adj
server_running=1
# tweak server (see bnc #346186)
xset r on
break
fi
done
}
#----[ prepare_for_x11 ]----#
function prepare_for_x11 () {
#------------------------------------------------------
# prepare X11 installation
# ---
local fbdevname
set_splash 100
#=============================================
# start X-Server and wait until ready
#---------------------------------------------
if [ ! -z "$NEED_XSERVER" ];then
export DISPLAY=:0
[ -z $Xstartpath ] || ln -snf $Xbindir/XFree86 /var/X11R6/bin/X
$Xexecutable -br -deferglyphs 16 2>/dev/tty8 1>&2 vt07 &
xserver_pid=$!
wait_for_x11
if [ "$server_running" = 1 ];then
log "\tX-Server is ready: $xserver_pid"
fi
fi
#=============================================
# set YaST2 Qt/Gtk options for local displays
#---------------------------------------------
if [ ! -z "$NEED_XSERVER" ];then
Y2_UI_ARGS="--noborder --auto-fonts --fullscreen"
fi
}
#----[ prepare_for_qt ]----#
function prepare_for_qt () {
set_inst_qt_env
prepare_for_x11
}
#----[ prepare_for_gtk ]----#
function prepare_for_gtk () {
prepare_for_x11
}
#----[ prepare_for_ncurses ]----#
function prepare_for_ncurses () {
#------------------------------------------------------
# prepare NCURSES installation
# ---
#=============================================
# Create Braille config if not update mode
#---------------------------------------------
if [ $INST_MODE = "normal" ];then
if [ ! -z "$Braille" ];then
log "Braille config needed, setting up braille display"
# downcase $Braille so that brld will find the driver
sed -e "s#brlname=.*#brlname=${Braille,,}#" \
-e "s#brlport=.*#brlport=$Brailledevice#" /etc/sbl.conf \
>/tmp/suse-blinux.conf
mv -f /tmp/suse-blinux.conf /etc/sbl.conf
/etc/init.d/brld start
/etc/init.d/sbl start
fi
fi
#=============================================
# Check for FbIterm
#---------------------------------------------
check_run_fbiterm
log "\tCheck for FB-I-terminal: RUN_FBITERM = $RUN_FBITERM"
}
#----[ prepare_for_ssh ]----#
function prepare_for_ssh () {
#------------------------------------------------------
# prepare SSH installation
# ---
#
:
export Y2STYLE="installation_slim"
}
#----[ prepare_for_vnc ]----#
function prepare_for_vnc () {
#------------------------------------------------------
# prepare VNC installation
# ---
#
#=============================================
# Setup splash screen
#---------------------------------------------
set_splash 100
#=============================================
# Setup y2base options
#---------------------------------------------
# xxx
#Y2_UI_ARGS="--fullscreen --noborder --auto-fonts"
Y2_UI_ARGS="--noborder --auto-fonts"
#=============================================
# Setup VNC server and start it
#---------------------------------------------
setupVNCAuthentication
if [ $VNCPASS_EXCEPTION = 0 ];then
disable_splash
startVNCServer
wait_for_x11
if [ "$server_running" = 1 ];then
log "\tXvnc-Server is ready: $xserver_pid"
fi
fi
}
#----[ check_x11 ]----#
function check_x11 () {
#------------------------------------------------------
# check if the prepared medium X11 (Qt/Gtk) is valid
# ---
if [ ! -z "$NEED_XSERVER" ];then
if [ "$server_running" = 0 ];then
# /.../
# X-Server couldn't be started, selecting
# NCURSES mode as fallback ?
# ---
log "\tX-Server couldn't be started, falling back to ncurses"
Y2_MODE_FLAGS='("text_fallback")'
SELECTED_MEDIUM="NCURSES"
prepare_for_ncurses
Y2_MODE=ncurses
fi
else
/usr/lib/YaST2/bin/testX --fast 2>/dev/null
if test $? = 1;then
log "\tCannot access Display: $DISPLAY, falling back to ncurses"
SELECTED_MEDIUM="NCURSES"
prepare_for_ncurses
Y2_MODE=ncurses
fi
fi
}
#----[ check_network ]----#
function check_network () {
#------------------------------------------------------
# check if the prepared medium SSH is valid. It is valid
# if there is a network interface accessable and we are
# able to use ncurses or X11
# ---
if ! found_iface ; then
# /.../
# No network interface found for SSH or VNC installation
# this is a fatal error here
# ---
log "\tNo network interface found, fatal error"
fatalError
fi
if [ ! -z "$DISPLAY" ];then
log "\tDisplay: $DISPLAY found for network install"
Y2_MODE=qt
fi
if ! check_qt ; then
log "\tQt plugin check failed falling back to Gtk"
Y2_MODE=gtk
if ! check_gtk ; then
log "\tGtk plugin check failed falling back to ncurses"
Y2_MODE=ncurses
fi
fi
}
#----[ check_vnc ]----#
function check_vnc () {
#------------------------------------------------------
# check if the prepared medium VNC is valid
# ---
check_network
if [ $VNCPASS_EXCEPTION = 1 ];then
log "\tVNC access has been disabled due to a password exception"
log "\tPlease make sure the password is at least 8 characters long"
fatalError
fi
if [ "$server_running" = 0 ];then
# /.../
# XVnc server couldn't be started, what to do now, I think
# this is a fatal error here
# ---
log "\tXVnc server couldn't be started, fatal error"
fatalError
fi
}
function ssh_reboot_message()
{
# SecondStageRequired can be set:
# 1. after 1st stage (note 2nd stage is not always required)
# 2. after 2nd stage (when another YaST run is required due to e.g.
# kernel update)
if [ -f /etc/install.inf ] ; then
SecondStageRequired=$(awk ' /^SecondStageRequired:/ { print $2 }' < /etc/install.inf)
fi
if [ -n "$SecondStageRequired" -a "$SecondStageRequired" = "1" ] ; then
echo "*** Preparing SSH installation for reboot ***"
echo "*** NOTE: after reboot, you have to reconnect and call yast.ssh ***"
log "\tPreparing SSH installation for reboot"
fi
}
#----[ start_yast ]----#
function start_yast () {
#------------------------------------------------------
# Start YaST2 refering to the contents of the Y2_*
# startup variables
# ---
local overcommit
read overcommit < /proc/sys/vm/overcommit_memory
echo "*** Starting YaST2 ***"
log "\tAllow big memory allocation: overcommit_memory=1"
echo 1 > /proc/sys/vm/overcommit_memory
if [ "$SPLASH" = yes -a -x /sbin/splash -a -n "$SPLASHCFG" ];then
/sbin/splash -t "YaST running"
fi
export QT_IM_MODULE=xim
if [ "$RUN_FBITERM" = "1" ]; then
OPT_FBITERM="/usr/bin/fbiterm --"
else
OPT_FBITERM=
fi
log "\tStarting YaST2:"
log "\tMODULE_NAME: $Y2_MODULE_NAME"
log "\tMODE_FLAGS: $Y2_MODE_FLAGS"
log "\tMODULE_ARGS: $Y2_MODULE_ARGS"
log "\tMODE: $Y2_MODE"
log "\tUI_ARGS: $Y2_UI_ARGS"
log "\tQT_IM_MODULE: $QT_IM_MODULE"
if [ "$Y2GDB" != "1" ]; then
$OPT_FBITERM y2base \
"$Y2_MODULE_NAME" \
$Y2_MODE_FLAGS \
$Y2_MODULE_ARGS \
$Y2_MODE \
$Y2_UI_ARGS
Y2_EXIT_CODE=$?
else
GDBCMDS=/var/lib/YaST2/gdb-cmds
echo tty /dev/tty10 > $GDBCMDS
echo set args "$Y2_MODULE_NAME" \
$Y2_MODE_FLAGS \
"'"$Y2_MODULE_ARGS"'" \
$Y2_MODE \
$Y2_UI_ARGS >> $GDBCMDS
echo set pagination off >> $GDBCMDS
/usr/bin/gdb -x $GDBCMDS /usr/lib/YaST2/bin/y2base | \
tee /var/log/YaST2/gdb-log
Y2_EXIT_CODE=$?
fi
Y2_ABORT_MESSAGE="YaST seems to be aborted abnormally !"
Y2_OK_MESSAGE="YaST procedure ended successfully"
if [ -s /etc/yast.inf ];then
#=============================================
# check yast.inf contents
#---------------------------------------------
cat /etc/yast.inf | grep -q -i "Aborted: 1"
if [ $? = 0 ];then
log "\t$Y2_ABORT_MESSAGE"
fi
else
#=============================================
# YaST ended successfully
#---------------------------------------------
log "\t$Y2_OK_MESSAGE"
fi
if [ $Y2_EXIT_CODE -eq 0 ];then
start_yast_and_reboot
start_yast_again
fi
if [ $SELECTED_MEDIUM = "SSH" ] && [ ! "$VNC" = 1 ];then
ssh_reboot_message
echo $Y2_EXIT_CODE > /tmp/YaST2_ssh_installation_finished
fi
log "\tReset memory allocation: overcommit_memory=$overcommit"
echo $overcommit > /proc/sys/vm/overcommit_memory
}
#----[ start_yast_and_reboot ]----#
function start_yast_and_reboot () {
#------------------------------------------------------
# This function will reboot the system and start yast
# again by touching the file /var/lib/YaST2/runme_at_boot.
# The function is triggered by the file /var/lib/YaST2/reboot
# ---
if [ -f /var/lib/YaST2/reboot ];then
# kill shell on second virtual console
if test ! -z "$SPID" ; then
log "\tkill shell with PID: $SPID"
kill -KILL $SPID &>/dev/null
fi
rm -f /var/lib/YaST2/reboot
/sbin/shutdown -r now
fi
}
#----[ start_yast_again ]----#
function start_yast_again () {
#------------------------------------------------------
# This function will restart yast again with the same
# options as used before. The function is triggered by
# the file /var/lib/YaST2/restart_yast
# ---
if [ -f /var/lib/YaST2/restart_yast ];then
rm -f /var/lib/YaST2/restart_yast
start_yast
fi
}
#=============================================
# Start the Magic :-)
#=============================================
# 1) Source common script functions
#---------------------------------------------
. /usr/lib/YaST2/startup/common/functions.sh
. /usr/lib/YaST2/startup/common/network.sh
. /usr/lib/YaST2/startup/requires
#=============================================
# 1.1) set splash progress bar to 90%
#---------------------------------------------
set_splash 90
#=============================================
# 1.2) set root HOME directory
#---------------------------------------------
export HOME=/root
#=============================================
# 1.3) set HTTP/FTP proxy and configure syslog
#---------------------------------------------
set_syslog ; set_proxy
#=============================================
# 2) Initialize...
#---------------------------------------------
# 2.1) setup PATH
PATH=$ybindir:$PATH
[ -z Xstartpath ] || PATH=/var/X11R6/bin:$PATH
#=============================================
# 2.3) obtain RAM size in Kb
#---------------------------------------------
MEM_TOTAL=`awk '/^MemTotal:/{ print $2 }' /proc/meminfo`
if [ ${#MEM_TOTAL} -gt 9 ];then
MEM_TOTAL=1000000000
fi
#=============================================
# 2.5) setup installation mode (update y/n)
#---------------------------------------------
INST_MODE="normal"
if [ -f /var/lib/YaST2/update_mode ];then
INST_MODE="update"
fi
#=============================================
# 2.6) import install.inf
#---------------------------------------------
import_install_inf
#=============================================
# 2.7) set LOG prefix
#---------------------------------------------
LOG_PREFIX="Stage [call]"
#=============================================
# 3) Medium prequalification
#---------------------------------------------
# Check which installation mediums can be used. There are
# four mediums available: Qt(0) SSH(1), VNC(2), NCURSES(3) and Gtk(4).
# The following checks will create an array which contains
# the possible mediums. An index of 1 indicates "can be used"
# an index of 0 indicated "cannot be used"
# ---
MEDIUM=(1 1 1 1 1)
#=============================================
# 3.1) prequalification checks for Qt and Gtk
#---------------------------------------------
log "Starting prequalification checks..."
log "==================================="
# 3.1.1) Qt and Gtk plugin check...
if ! check_qt ; then
log "\tQt plugin check failed -> Medium Qt disabled"
MEDIUM[0]=0
fi
if ! check_gtk ; then
log "\tGtk plugin check failed -> Medium Gtk disabled"
MEDIUM[4]=0
fi
# 3.1.3) Memory check >= $MEM_NEEDED for Qt/Gtk/X11...
if [ $MEM_TOTAL -lt "$MEM_NEEDED" ];then
log "\tMemory requirement > $MEM_NEEDED not fulfilled -> Medium Qt and Gtk disabled"
MEDIUM[0]=0
MEDIUM[4]=0
fi
# 3.1.4) Check if we need to start our own X11 server...
if [ -z "$DISPLAY" ];then
NEED_XSERVER=1
fi
# 3.1.5) Check for xorg.conf...
if [ ! -f /etc/X11/xorg.conf ] ; then
if [ -f $Xorgconftempl ] ; then
log "\tCopying $Xorgconftempl to /etc/X11/xorg.conf"
cp $Xorgconftempl /etc/X11/xorg.conf
fi
fi
# 3.1.6) Check for WindowManager configuration
if [ ! -f /etc/icewm/preferences.yast2 ];then
log "\tNo Windowmanager configuration found -> Medium Qt and Gtk disabled"
MEDIUM[0]=0
MEDIUM[4]=0
fi
# 3.1.7) Check for remote display usage
if [ ! -z $Display_IP ];then
log "\tRemote Display usage -> Medium Qt and Gtk enabled"
log "\tExporting DISPLAY to host: $Display_IP:0.0"
export DISPLAY="$Display_IP:0.0"
NEED_XSERVER=""
MEDIUM[0]=1
MEDIUM[4]=1
fi
# 3.1.8) Check for testX binary
if [ ! -x /usr/lib/YaST2/bin/testX ] ; then
log "\tNo testX binary installed -> Medium Qt and Gtk disabled"
MEDIUM[0]=0
MEDIUM[4]=0
fi
#=============================================
# 3.2) prequalification checks for SSH
#---------------------------------------------
# 3.2.1) Check for SSH daemon
if ! /usr/sbin/rcsshd status > /dev/null 2>&1 ; then
log "\tNo SSH daemon running -> Medium SSH disabled"
MEDIUM[1]=0
fi
#=============================================
# 3.3) prequalification checks for VNC
#---------------------------------------------
# 3.3.1) Check for WindowManager configuration
if [ ! -f /etc/icewm/preferences.yast2 ];then
log "\tNo Windowmanager configuration found -> Medium VNC disabled"
MEDIUM[2]=0
fi
# 3.3.2) Check for VNC X-Server binary
if [ ! -x $Xbindir/Xvnc ] ; then
log "\tNo Xvnc server installed -> Medium VNC disabled"
MEDIUM[2]=0
fi
# 3.3.3) Check for testX binary
if [ ! -x /usr/lib/YaST2/bin/testX ] ; then
log "\tNo testX binary installed -> Medium VNC disabled"
MEDIUM[2]=0
fi
#=============================================
# 4) Evaluate medium selection
#---------------------------------------------
# At this point we are evaluating the variables which have
# been imported from the install.inf file into the current
# environment. The standard method of installing the system
# should be Qt based. Refering to the variables Textmode,
# Braille, UseSSH and VNC another medium could be selected
# VNC overrides UseSSH
# ---
log "Evaluate medium selection..."
log "============================"
SELECTED_MEDIUM="QT"
if [ "$Textmode" = 1 ];then
log "\tMedium Textmode (ncurses) has been selected"
SELECTED_MEDIUM="NCURSES"
fi
if [ ! -z "$Braille" ];then
log "\tMedium Braille (ncurses) has been selected"
SELECTED_MEDIUM="NCURSES"
fi
if [ "$UseSSH" = 1 ];then
log "\tMedium SSH has been selected"
SELECTED_MEDIUM="SSH"
fi
if [ "$VNC" = 1 ];then
log "\tMedium VNC has been selected"
SELECTED_MEDIUM="VNC"
fi
#=============================================
# 5) Check selected medium
#---------------------------------------------
# Refering to the prequalification check results we need to
# check if the selected medium is valid according to the
# MEDIUM flag entry. If the medium is not valid we will
# fallback to NCURSES mode
# ---
log "Check selected medium..."
log "========================"
log "\tWished medium is: $SELECTED_MEDIUM"
case $SELECTED_MEDIUM in
QT) {
if [ ${MEDIUM[0]} -eq 0 ];then
log "\tMedium Qt not available, falling back to Gtk"
SELECTED_MEDIUM="GTK"
if [ ${MEDIUM[4]} -eq 0 ];then
log "\tMedium Gtk not available, falling back to ncurses"
SELECTED_MEDIUM="NCURSES"
fi
fi
} ;;
GTK) {
if [ ${MEDIUM[4]} -eq 0 ];then
log "\tMedium Gtk not available, falling back to Qt"
SELECTED_MEDIUM="QT"
if [ ${MEDIUM[0]} -eq 0 ];then
log "\tMedium Qt not available, falling back to ncurses"
SELECTED_MEDIUM="NCURSES"
fi
fi
} ;;
SSH) {
if [ ${MEDIUM[1]} -eq 0 ];then
log "\tMedium SSH not available, falling back to ncurses"
SELECTED_MEDIUM="NCURSES"
fi
} ;;
VNC) {
if [ ${MEDIUM[2]} -eq 0 ];then
log "\tMedium VNC not available, falling back to ncurses"
SELECTED_MEDIUM="NCURSES"
fi
} ;;
esac
log "\tSelected medium is: $SELECTED_MEDIUM"
#=============================================
# 6) Prepare selected medium
#---------------------------------------------
case $SELECTED_MEDIUM in
QT) prepare_for_qt ; Y2_MODE=qt ;;
GTK) prepare_for_gtk ; Y2_MODE=gtk ;;
SSH) prepare_for_ssh ; Y2_MODE=ncurses ;;
VNC) prepare_for_vnc ; Y2_MODE=qt ;;
NCURSES) prepare_for_ncurses ; Y2_MODE=ncurses ;;
esac
#=============================================
# 7) Check prepared medium
#---------------------------------------------
case $SELECTED_MEDIUM in
QT) check_x11 ;;
GTK) check_x11 ;;
SSH) check_network ;;
VNC) check_vnc ;;
esac
# The prepare_for_ncurses in step 6 is kinda useless if step 7 can
# change Y2MODE to ncurses in several ways
#running with threads (#164999, FaTE #301899)
#if [ "$Y2_MODE" = "ncurses" ]; then
# Y2_UI_ARGS=--nothreads
#fi
#=============================================
# 8) Call YaST2
#---------------------------------------------
Y2_MODULE_NAME=${1:-installation}; shift
Y2_MODULE_ARGS=\(\"$*\"\)
start_yast
#=============================================
# 9) Clean sweep
#---------------------------------------------
# 9.1) clear Qt environment...
clr_inst_qt_env
# 9.2) kill X-Server...
if [ "$server_running" = 1 ];then
sleep 1 && kill $xserver_pid
while kill -0 $xserver_pid 2>/dev/null ; do
sleep 1
done
fi
#=============================================
# 10) exit with YaST2 exit code
#---------------------------------------------
exit $Y2_EXIT_CODE