Annotation of /trunk/installer-simple/functions/common-dialogs.sh
Parent Directory | Revision Log
Revision 2452 -
(hide annotations)
(download)
(as text)
Tue Jan 7 15:03:12 2014 UTC (10 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4785 byte(s)
Tue Jan 7 15:03:12 2014 UTC (10 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4785 byte(s)
-apply SYSCONFDIR
1 | niro | 2337 | # $Id$ |
2 | |||
3 | niro | 2389 | OK_LABEL=$"Next" |
4 | CANCEL_LABEL=$"Back" | ||
5 | |||
6 | niro | 2337 | # common dialog boxes |
7 | messagebox() | ||
8 | { | ||
9 | niro | 2392 | local header |
10 | local text | ||
11 | local height | ||
12 | local width | ||
13 | niro | 2337 | |
14 | niro | 2392 | # very basic getops |
15 | local OPTIND opt | ||
16 | while getopts ":h:y:x:" opt | ||
17 | do | ||
18 | case ${opt} in | ||
19 | h) header="${OPTARG}" ;; | ||
20 | y) height="${OPTARG}" ;; | ||
21 | x) width="${OPTARG}" ;; | ||
22 | esac | ||
23 | done | ||
24 | shift $((OPTIND-1)) | ||
25 | text="$@" | ||
26 | |||
27 | niro | 2393 | #[[ -z ${header} ]] && die "no header given" |
28 | niro | 2337 | [[ -z ${text} ]] && die "no text given" |
29 | niro | 2394 | [[ -z ${height} ]] && height=8 |
30 | [[ -z ${width} ]] && width=70 | ||
31 | niro | 2337 | |
32 | [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" | ||
33 | |||
34 | niro | 2452 | echo "DEBUG: paused" >&2; read |
35 | niro | 2337 | dialog \ |
36 | --colors \ | ||
37 | --title "${header}" \ | ||
38 | --backtitle "${TITLE}" \ | ||
39 | --ok-label "${OK_LABEL}" \ | ||
40 | --msgbox "${text}" "${height}" "${width}" | ||
41 | } | ||
42 | |||
43 | niro | 2395 | infobox() |
44 | { | ||
45 | local header | ||
46 | local text | ||
47 | local height | ||
48 | local width | ||
49 | |||
50 | # very basic getops | ||
51 | local OPTIND opt | ||
52 | while getopts ":h:y:x:" opt | ||
53 | do | ||
54 | case ${opt} in | ||
55 | h) header="${OPTARG}" ;; | ||
56 | y) height="${OPTARG}" ;; | ||
57 | x) width="${OPTARG}" ;; | ||
58 | esac | ||
59 | done | ||
60 | shift $((OPTIND-1)) | ||
61 | text="$@" | ||
62 | |||
63 | #[[ -z ${header} ]] && die "no header given" | ||
64 | [[ -z ${text} ]] && die "no text given" | ||
65 | [[ -z ${height} ]] && height=3 | ||
66 | [[ -z ${width} ]] && width=70 | ||
67 | |||
68 | niro | 2452 | echo "DEBUG: paused" >&2; read |
69 | niro | 2395 | dialog \ |
70 | --colors \ | ||
71 | --title "${header}" \ | ||
72 | --backtitle "${TITLE}" \ | ||
73 | --infobox "${text}" "${height}" "${width}" | ||
74 | } | ||
75 | |||
76 | niro | 2337 | inputbox() |
77 | { | ||
78 | niro | 2392 | local header |
79 | local text | ||
80 | local height | ||
81 | local width | ||
82 | niro | 2337 | |
83 | niro | 2392 | # very basic getops |
84 | local OPTIND opt | ||
85 | while getopts ":h:y:x:" opt | ||
86 | do | ||
87 | case ${opt} in | ||
88 | h) header="${OPTARG}" ;; | ||
89 | y) height="${OPTARG}" ;; | ||
90 | x) width="${OPTARG}" ;; | ||
91 | esac | ||
92 | done | ||
93 | shift $((OPTIND-1)) | ||
94 | text="$@" | ||
95 | |||
96 | niro | 2393 | #[[ -z ${header} ]] && die "no header given" |
97 | niro | 2337 | [[ -z ${text} ]] && die "no text given" |
98 | [[ -z ${height} ]] && height=0 | ||
99 | [[ -z ${width} ]] && width=0 | ||
100 | |||
101 | niro | 2452 | echo "DEBUG: paused" >&2; read |
102 | niro | 2337 | dialog \ |
103 | --stdout \ | ||
104 | --colors \ | ||
105 | --title "${header}" \ | ||
106 | --backtitle "${TITLE}" \ | ||
107 | --inputbox "${text}" "${height}" "${width}" | ||
108 | } | ||
109 | |||
110 | passwordbox() | ||
111 | { | ||
112 | niro | 2392 | local header |
113 | local text | ||
114 | local height | ||
115 | local width | ||
116 | niro | 2337 | |
117 | niro | 2392 | # very basic getops |
118 | local OPTIND opt | ||
119 | while getopts ":h:y:x:" opt | ||
120 | do | ||
121 | case ${opt} in | ||
122 | h) header="${OPTARG}" ;; | ||
123 | y) height="${OPTARG}" ;; | ||
124 | x) width="${OPTARG}" ;; | ||
125 | esac | ||
126 | done | ||
127 | shift $((OPTIND-1)) | ||
128 | text="$@" | ||
129 | |||
130 | niro | 2393 | #[[ -z ${header} ]] && die "no header given" |
131 | niro | 2337 | [[ -z ${text} ]] && die "no text given" |
132 | [[ -z ${height} ]] && height=0 | ||
133 | [[ -z ${width} ]] && width=0 | ||
134 | |||
135 | niro | 2452 | echo "DEBUG: paused" >&2; read |
136 | niro | 2337 | dialog \ |
137 | --stdout \ | ||
138 | --colors \ | ||
139 | --title "${header}" \ | ||
140 | --backtitle "${TITLE}" \ | ||
141 | --insecure \ | ||
142 | --passwordbox "${text}" "${height}" "${width}" | ||
143 | } | ||
144 | |||
145 | niro | 2396 | menubox() |
146 | { | ||
147 | local header | ||
148 | local text | ||
149 | local height | ||
150 | local width | ||
151 | local items | ||
152 | local index | ||
153 | local dialog_opts | ||
154 | |||
155 | # very basic getops | ||
156 | local OPTIND opt | ||
157 | while getopts ":h:y:x:i:n" opt | ||
158 | do | ||
159 | case ${opt} in | ||
160 | n) dialog_opts+=" --no-cancel" ;; | ||
161 | h) header="${OPTARG}" ;; | ||
162 | y) height="${OPTARG}" ;; | ||
163 | x) width="${OPTARG}" ;; | ||
164 | esac | ||
165 | done | ||
166 | shift $((OPTIND-1)) | ||
167 | text="$1" | ||
168 | shift | ||
169 | items=( "$@" ) | ||
170 | index="${#items[*]}" | ||
171 | |||
172 | #[[ -z ${header} ]] && header="empty header: add -h yourheader" | ||
173 | [[ -z ${text} ]] && die "no text given" | ||
174 | [[ -z ${height} ]] && height=0 | ||
175 | [[ -z ${width} ]] && width=70 | ||
176 | |||
177 | [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" | ||
178 | [[ -z ${CANCEL_LABEL} ]] && CANCEL_LABEL="Back" | ||
179 | |||
180 | niro | 2452 | echo "DEBUG: paused" >&2; read |
181 | niro | 2396 | eval dialog \ |
182 | --stdout \ | ||
183 | --colors \ | ||
184 | --title "'${header}'" \ | ||
185 | --backtitle "'${TITLE}'" \ | ||
186 | --ok-label "'${OK_LABEL}'" \ | ||
187 | --cancel-label "'${CANCEL_LABEL}'" \ | ||
188 | "${dialog_opts}" \ | ||
189 | --menu "'${text}'" "${height}" "${width}" "${index}" \ | ||
190 | $(for ((i=0;i<index;i++)); do echo "'${items[${i}]%%:*}'";echo "'${items[${i}]#*:}'"; done) | ||
191 | } | ||
192 | |||
193 | niro | 2390 | gaugebox() |
194 | niro | 2337 | { |
195 | niro | 2392 | local header |
196 | local text | ||
197 | local height | ||
198 | local width | ||
199 | niro | 2337 | |
200 | niro | 2392 | # very basic getops |
201 | local OPTIND opt | ||
202 | while getopts ":h:y:x:" opt | ||
203 | do | ||
204 | case ${opt} in | ||
205 | h) header="${OPTARG}" ;; | ||
206 | y) height="${OPTARG}" ;; | ||
207 | x) width="${OPTARG}" ;; | ||
208 | esac | ||
209 | done | ||
210 | shift $((OPTIND-1)) | ||
211 | text="$@" | ||
212 | |||
213 | niro | 2393 | #[[ -z ${header} ]] && die "no header given" |
214 | niro | 2337 | [[ -z ${text} ]] && die "no text given" |
215 | [[ -z ${height} ]] && height=0 | ||
216 | niro | 2394 | [[ -z ${width} ]] && width=70 |
217 | niro | 2337 | |
218 | niro | 2452 | echo "DEBUG: paused" >&2; read |
219 | niro | 2337 | dialog \ |
220 | --colors \ | ||
221 | --title "${header}" \ | ||
222 | --backtitle "${TITLE}" \ | ||
223 | --gauge "${text}" "${height}" "${width}" | ||
224 | } | ||
225 | |||
226 | niro | 2391 | yesnobox() |
227 | niro | 2337 | { |
228 | niro | 2392 | local header |
229 | local text | ||
230 | local height | ||
231 | local width | ||
232 | niro | 2337 | |
233 | niro | 2392 | # very basic getops |
234 | local OPTIND opt | ||
235 | while getopts ":h:y:x:" opt | ||
236 | do | ||
237 | case ${opt} in | ||
238 | h) header="${OPTARG}" ;; | ||
239 | y) height="${OPTARG}" ;; | ||
240 | x) width="${OPTARG}" ;; | ||
241 | esac | ||
242 | done | ||
243 | shift $((OPTIND-1)) | ||
244 | text="$@" | ||
245 | |||
246 | niro | 2393 | #[[ -z ${header} ]] && die "no header given" |
247 | niro | 2337 | [[ -z ${text} ]] && die "no text given" |
248 | [[ -z ${height} ]] && height=0 | ||
249 | [[ -z ${width} ]] && width=0 | ||
250 | |||
251 | niro | 2452 | echo "DEBUG: paused" >&2; read |
252 | niro | 2337 | dialog \ |
253 | --colors \ | ||
254 | --title "${header}" \ | ||
255 | --backtitle "${TITLE}" \ | ||
256 | --defaultno \ | ||
257 | --yesno "${text}" "${height}" "${width}" | ||
258 | } |