File: finish

package info (click to toggle)
base-config 2.53.10.3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,072 kB
  • ctags: 36
  • sloc: sh: 1,755; makefile: 101; perl: 48
file content (125 lines) | stat: -rwxr-xr-x 3,096 bytes parent folder | download
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
#!/bin/sh
# Finish up the install, clean up anything necessary, and get the user to a
# login prompt.
set -e

case "$1" in
'')
	# Nothing to do.
	;;
new)
	# Code that does not need debconf.
	
	# en_US is treated as a special case, because it is the default.
	# If d-i used C for the default, we could remove this special case.
	if [ -n "$LANG" ] && [ "$LANG" != en_US ]; then
		if [ -e /etc/environment ]; then
			grep -v "^LANG=" /etc/environment > /etc/environment.new || true
			mv /etc/environment.new /etc/environment
			echo "LANG=$LANG" >> /etc/environment
		else
			echo "LANG=$LANG" > /etc/environment
		fi

		# fix GDM language problem
		if [ -e /etc/default/gdm ]; then
			sed -i "s,^#*LANG=$,LANG=$LANG,g" /etc/default/gdm
		fi
	fi
	
	# See if there is a preseeded command. If so, run it.
	PRESEED_COMMAND=$($0 get_preseed_command 4>&1 || true)
	if [ -n "$PRESEED_COMMAND" ]; then
		# TODO error handling (needs error dialog)
		eval $PRESEED_COMMAND || true
	fi
	
	DMS=""
	for dm in xdm gdm kdm; do
		if test -x /etc/init.d/$dm; then
			DMS="$dm $DMS"
		fi
	done
	if [ "$DMS" ]; then
		set +e
		# Ask about display manager, display final message, return
		# true if display manager should be started.
		$0 debconf 1
		start_dm=$?
		set -e
		if [ "$start_dm" = 30 ]; then
			exit 30 # back up to main menu
		fi
		if [ "$start_dm" = 0 ]; then
			for dm in $DMS ; do
				/etc/init.d/$dm restart || true
			done
		fi
	else
		# Display final message.
		$0 debconf 0 || exit 30 # back up to main menu
	fi

	# Turn on console screen blanking again
	if which setterm >/dev/null 2>&1; then
		# It seem to be impossible to get the current timeout
		# value before changing it, so the only way to
		# undo the setting is to set the timeout period to some
		# random value. 10 minutes sounds like a good value.
		setterm -blank 10
	fi
	
	# Finally, put the real inittab into place and tell init.
	if [ -f /etc/inittab.real ]; then
		mv -f /etc/inittab.real /etc/inittab
		telinit q >/dev/null
		# Clear the screen, in preparation for the login prompt
		clear
	fi

	;;
get_preseed_command)
	# Get the preseeded command, if any.
	. /usr/share/debconf/confmodule
	if db_get base-config/late_command; then
		echo "$RET" >&4
	fi
	
	;;
debconf)
	# Code that does need debconf.
	. /usr/share/debconf/confmodule
	db_capb backup
	db_settitle base-config/title
	
	ask_dm="$2"
	if [ "$ask_dm" = "1" ]; then
		db_input low base-config/start-display-manager || true
		if ! db_go; then
			db_fset base-config/start-display-manager seen false
			exit 30 # back up to menu
		fi
		db_fset base-config/start-display-manager seen false
	fi
	
	# Display the final message.
	db_input high base-config/login || true
	if ! db_go; then
		db_fset base-config/login seen false
		exit 30 # back up to menu TODO should use state machine
	fi
	db_fset base-config/login seen false

	# Return nonzero if we asked about starting the display manager and
	# it should not be started.
	if [ "$ask_dm" = 1 ]; then
		db_get base-config/start-display-manager
		if [ "$RET" = true ]; then
			exit 0
		else
			exit 1
		fi
	fi

	;;
esac