| 1 |
#!/bin/sh -e |
| 2 |
# Demo config module. This is more a regression/stress test than anything. |
| 3 |
|
| 4 |
# Note this stanza is only here to make this script work in an uninstalled |
| 5 |
# debconf source tree, and is not needed in production code. |
| 6 |
PATH=$PATH:. |
| 7 |
if [ -e confmodule ]; then |
| 8 |
# shellcheck source-path=SCRIPTDIR/.. |
| 9 |
. confmodule |
| 10 |
else |
| 11 |
. /usr/share/debconf/confmodule |
| 12 |
fi |
| 13 |
|
| 14 |
db_version 2.0 |
| 15 |
#db_capb backup |
| 16 |
db_capb escape |
| 17 |
db_settitle demo/title |
| 18 |
|
| 19 |
# This implements a simple state machine so the back button can be handled. |
| 20 |
STATE=1 |
| 21 |
while [ "$STATE" != 0 ] && [ "$STATE" != 10 ]; do |
| 22 |
case $STATE in |
| 23 |
1) |
| 24 |
db_input high demo/boolean || true |
| 25 |
;; |
| 26 |
2) |
| 27 |
db_input high demo/multiselect || true |
| 28 |
;; |
| 29 |
3) |
| 30 |
db_info demo/info |
| 31 |
db_input critical demo/string || true |
| 32 |
db_input low demo/password || true |
| 33 |
db_input low demo/text || true |
| 34 |
db_subst demo/select colors red, Yellow, green |
| 35 |
db_input high demo/select || true |
| 36 |
;; |
| 37 |
4) |
| 38 |
db_beginblock |
| 39 |
db_input low demo/boolean || true |
| 40 |
db_input low demo/boolean || true |
| 41 |
db_endblock |
| 42 |
db_input low demo/note || true |
| 43 |
;; |
| 44 |
5) |
| 45 |
# Will be displayed again. |
| 46 |
db_input high demo/password || true |
| 47 |
|
| 48 |
;; |
| 49 |
6) |
| 50 |
db_progress START 0 10 demo/progress/title |
| 51 |
sleep 1 |
| 52 |
db_progress SET 2 |
| 53 |
sleep 1 |
| 54 |
db_progress INFO demo/progress/info |
| 55 |
db_progress STEP 3 |
| 56 |
sleep 1 |
| 57 |
db_progress STEP 1 |
| 58 |
sleep 1 |
| 59 |
db_progress STOP |
| 60 |
;; |
| 61 |
7) |
| 62 |
db_subst demo/subst user 'joeuser\nanotheruser' |
| 63 |
db_metaget demo/subst extended_description |
| 64 |
echo "demo/subst extended_description: $RET" >&2 |
| 65 |
db_input high demo/subst || true |
| 66 |
;; |
| 67 |
8) |
| 68 |
db_input high demo/error || true |
| 69 |
;; |
| 70 |
9) |
| 71 |
db_input low demo/error || true |
| 72 |
;; |
| 73 |
esac |
| 74 |
|
| 75 |
if db_go; then |
| 76 |
STATE=$((STATE + 1)) |
| 77 |
else |
| 78 |
STATE=$((STATE - 1)) |
| 79 |
fi |
| 80 |
# echo "ON STATE: $STATE" |
| 81 |
done |
| 82 |
|
| 83 |
# This is EVIL, never echo in your own config scripts! |
| 84 |
db_get demo/string |
| 85 |
echo "string is $RET" |
| 86 |
db_get demo/boolean |
| 87 |
echo "$RET" |
| 88 |
db_get demo/multiselect |
| 89 |
echo "$RET" |
| 90 |
|
| 91 |
db_stop |