summaryrefslogtreecommitdiff
path: root/src/lib/lib-ui.sh
blob: 37f316eeafe92246ca510fef3cde65dd336ff4b1 (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
#!/bin/sh

# DIALOG() taken from setup
# an el-cheapo dialog wrapper
#
# parameters: see dialog(1)
# returns: whatever dialog did
DIALOG()
{
	dialog --backtitle "$TITLE" --aspect 15 "$@"
	return $?
}


# taken from setup
printk()
{
    case $1 in
        "on")  echo 4 >/proc/sys/kernel/printk ;;
        "off") echo 0 >/proc/sys/kernel/printk ;;
    esac
}


# geteditor(). taken from original setup code. prepended gui_ because power users just export $EDITOR on the cmdline.
# prompts the user to choose an editor
# sets EDITOR global variable
#
gui_geteditor() {
    DIALOG --menu "Select a Text Editor to Use" 10 35 3 \
        "1" "nano (easier)" \
        "2" "vi" 2>$ANSWER   
    case $(cat $ANSWER) in   
        "1") EDITOR="nano" ;;
        "2") EDITOR="vi" ;;  
        *)   EDITOR="nano" ;;
    esac
}


# Get a list of available disks for use in the "Available disks" dialogs. This
# will print the disks as follows, getting size info from hdparm:
#   /dev/sda: 640133 MBytes (640 GB)
#   /dev/sdb: 640135 MBytes (640 GB)
gui_getavaildisks()
{
    # NOTE: to test as non-root, stick in a 'sudo' before the hdparm call
    for i in $(finddisks); do echo -n "$i: "; hdparm -I $i | grep -F '1000*1000' | sed "s/.*1000:[ \t]*\(.*\)/\1/"; echo "\n"; done
}


# taken from setup code. edited to echo the choice, not perform it
gui_ask_bootloader()
{
    DIALOG --colors --menu "Which bootloader would you like to use?  Grub is the Arch default.\n\n" \
        10 65 2 \
        "GRUB" "Use the GRUB bootloader (default)" \
        "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" 2>$ANSWER
	cat $ANSWER
}


# ask the user a password. return is stored in $PASSWORD or $PASSWORD_TYPE
# $1 type (optional.  eg 'svn', 'ssh').
cli_ask_password ()
{
	if [ -n "$1" ]
	then
		true
	fi		
}

cli_ask_yesno ()
{
}

cli_ask_string ()   
{
}


cli_ask_number ()
{
}


cli_ask_option ()
{
}