File: show-menu

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 (75 lines) | stat: -rwxr-xr-x 2,217 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
#!/bin/sh -e
# This helper program displays the base-config menu. If the selected item
# can also run under debconf, it runs it directly (this is fastest).
# Otherwise, it echos it to file descriptor 5, for base-config to read and
# run it outside of debconf. To indicate that the main menu should no
# longer be shown, it will exit without echoing anything to that file
# descriptor.

. /usr/share/debconf/confmodule

ADVANCE=$1
NEW=$2

db_capb backup

while :; do
	# Title might get reset, so set it each time.
	db_settitle base-config/title
	
	if [ "$ADVANCE" = 1 ]; then
		# Advance default to the next menu item.
		db_get base-config/main-menu
		NEXT=$(grep -A 1 "^$RET," menu-mapping | cut -d , -f 1 | tail -n 1)
		if [ ! -z "$NEXT" ]; then
			db_set base-config/main-menu $NEXT
		fi
	fi
	ADVANCE=1
	
	db_fset base-config/main-menu seen false
	if db_input medium base-config/main-menu; then
		# back all the way out is the same as exiting base-config
		# however, note that I only go if the question will be
		# shown. Else debconf's auto-backup code could emulate a
		# backup based on a prior backup within a menu item.
		db_go || exit 30
	fi
	
	db_get base-config/main-menu
	menu_item=$(grep "^$RET," menu-mapping | cut -d , -f 2)
	
	if grep -q '^Debconf: true' menu/$menu_item.mnu; then
		# Run menu item inside debconf.
		if ! ./menu/$menu_item $NEW 5>/dev/null; then
			ADVANCE=0
			# Drop priority to make sure the menu is displayed
			# since a menu item is failing.
			db_get debconf/priority
			if [ "$RET" = high ] || [ "$RET" = critical ]; then
				db_set debconf/priority medium
			fi
		else
			if [ -s jump-to ]; then
				# Jump to a specified menu item out of
				# order.
				db_set base-config/main-menu "$(grep ",$(cat jump-to)" menu-mapping | cut -d , -f 1 | tail -n 1)"
				rm -f jump-to
				ADVANCE=0
			elif grep -q 'Exit-Menu: true' menu/$menu_item.mnu; then
				# This menu item finished the install, so
				# exit the menu.
				exit 0
			fi
		fi
	else
		# The menu item cannot run inside debconf, so pass it back
		# to base-config on the special communication fd.
		echo $menu_item >&5
		exit 0
	fi

	if grep -q '^Changes-Menu: true' menu/$menu_item.mnu; then
		./prep-menu 0
	fi
done