summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/XF86Setup/phase5.tcl
blob: 68497560a336e66ae3b9f624ebc81954a18fc546 (plain)
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
# $XConsortium: phase5.tcl /main/4 1996/10/28 05:42:32 kaleb $
#
#
#
#
# $XFree86: xc/programs/Xserver/hw/xfree86/XF86Setup/phase5.tcl,v 3.11 1998/04/05 16:15:52 robin Exp $
#
# Copyright 1996 by Joseph V. Moss <joe@XFree86.Org>
#
# See the file "LICENSE" for information regarding redistribution terms,
# and for a DISCLAIMER OF ALL WARRANTIES.
#

#
# Phase V - Final commands after return to text mode
#

check_tmpdirs
clear_scrn
foreach fname [glob -nocomplain $TmpDir/*] {
	unlink $fname
}
rmdir $TmpDir
rmdir $XF86SetupDir

if { ![getuid] } {
    set idx -1
    if { [llength $DeviceIDs] == 1 } {
	set idx 0
    } else {
	if [string length $Scrn_Accel(Device)] {
	    set idx [lsearch $DeviceIDs $Scrn_Accel(Device)]
	} else {
	    set idx [lsearch $DeviceIDs $Scrn_SVGA(Device)]
	}
    }
    if { $idx >= 0 } {
	set devid [lindex $DeviceIDs $idx]
        global Device_$devid
        set server [set Device_${devid}(Server)]
	set linkname $Xwinhome/bin/X
	set lastlink $linkname
	for {set nlinks 0} \
		{[file exists $linkname] && [file type $linkname]=="link" \
		 && $nlinks<20} \
		{incr nlinks} {
	    set lastlink $linkname
	    set linkname [readlink $linkname]
	}
	catch {
	    if { [file type $linkname]=="link" && ![file exists $linkname] } {
                 set lastlink [readlink $linkname]
	    }
	}
        if { [file type $linkname]=="link" && ![file exists $linkname] } {
                set lastlink [readlink $linkname]
	}

	if { $nlinks < 20 } {
	    set servname [string range [file tail $linkname] 5 end]
	    if ![string compare $servname $server] {
		unset linkname
	    }
	} else {
	    set linkname $Xwinhome/bin/X
	}
    }
    if [info exists linkname] {
	set linkdir [file dirname $lastlink]
	set mklink [mesg \
		"$messages(phase5.1)$server$messages(phase5.2)\
		$linkdir$messages(phase5.3)" yesno]
	if $mklink {
	    set CWD [pwd]
	    cd $linkdir
	    catch "unlink X" ret
	    if [catch "link $Xwinhome/bin/XF86_$server X" ret] {
		mesg $messages(phase5.4) okay
	    } else {
		mesg $messages(phase5.5) okay
	    }
	    cd $CWD
	}
    }
}

clear_scrn
puts $messages(phase5.6)

exit 0