Debian Codegraph @

dracut/modules.d/59kiwi-lib/kiwi-dialog-lib.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 type getarg >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || . /lib/dracut-lib.shscip-shell source . . `/lib/dracut-lib.sh`.
4
5 function run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). {
6 # """
7 # Run the dialog program via the systemd service either in a
8 # framebuffer terminal or on the console. The return code of
9 # the function is the return code of the dialog call. The
10 # output of the dialog call is stored in a file and can be
11 # one time read via the get_dialog_result function
12 # """
13 stop_plymouthscip-shell shell shell-project 0.0.0 stop_plymouth().
14 local dialog_result=/tmp/dialog_resultscip-shell filesystem . . `/tmp/dialog_result`.
15 local dialog_exit_code=/tmp/dialog_codescip-shell filesystem . . `/tmp/dialog_code`.
16 {
17 echoscip-shell system . . echo. "dialog $* 2>$dialog_result"
18 echoscip-shell system . . echo. "echo -n \$? >$dialog_exit_code"
19 } >/run/dracut-interactivescip-shell filesystem . . `/run/dracut-interactive`.
20 _run_interactivescip-shell shell shell-project 0.0.0 _run_interactive().
21 return "$(catscip-shell system . . cat. $dialog_exit_code)"
22 }
23
24 function setup_progress_fifoscip-shell shell shell-project 0.0.0 setup_progress_fifo(). {
25 local fifo=$1
26 export current_progress_fifo="${fifo}"
27 [scip-shell system . . `[`. -e "${fifo}" ] || mkfifoscip-shell system . . mkfifo. "${fifo}"
28 }
29
30 function stop_dialogscip-shell shell shell-project 0.0.0 stop_dialog(). {
31 _stop_interactivescip-shell shell shell-project 0.0.0 _stop_interactive().
32 }
33
34 function run_progress_dialogscip-shell shell shell-project 0.0.0 run_progress_dialog(). {
35 # """
36 # Run the gauge dialog via systemd reading progress
37 # status information from stdin
38 # """
39 stop_plymouthscip-shell shell shell-project 0.0.0 stop_plymouth().
40 declare fifo=${current_progress_fifo}
41 local title=$1
42 local backtitle=$2
43 local progress_at="${fifo}"
44 if [scip-shell system . . `[`. ! -e "${progress_at}" ];then
45 return
46 fi
47 {
48 echoscip-shell system . . echo. -n "cat ${fifo} | dialog --backtitle \"${backtitle}\" "
49 echoscip-shell system . . echo. -n "--gauge \"${title}\"" 7 65 0
50 echoscip-shell system . . echo.
51 } >/run/dracut-interactivescip-shell filesystem . . `/run/dracut-interactive`.
52 _run_interactivescip-shell shell shell-project 0.0.0 _run_interactive().
53 }
54
55 function get_dialog_resultscip-shell shell shell-project 0.0.0 get_dialog_result(). {
56 local dialog_result=/tmp/dialog_resultscip-shell filesystem . . `/tmp/dialog_result`.
57 [scip-shell system . . `[`. -e "${dialog_result}" ] && catscip-shell system . . cat. ${dialog_result}; rmscip-shell system . . rm. -f ${dialog_result}
58 }
59
60 function stop_plymouthscip-shell shell shell-project 0.0.0 stop_plymouth(). {
61 if ! getargbool 0 rd.kiwi.allow_plymouth; then
62 if command -v plymouth &>/dev/nullscip-shell filesystem . . `/dev/null`.;then
63 plymouth --quit --wait
64 fi
65 fi
66 }
67
68 #=========================================
69 # Methods considered private
70 #-----------------------------------------
71 function _setup_interactive_servicescip-shell shell shell-project 0.0.0 _setup_interactive_service(). {
72 local service=/run/systemd/system/dracut-run-interactive.servicescip-shell filesystem . . `/run/systemd/system/dracut-run-interactive.service`.
73 local script=/run/dracut-interactivescip-shell filesystem . . `/run/dracut-interactive`.
74 mkdirscip-shell system . . mkdir. -p /run/systemd/systemscip-shell filesystem . . `/run/systemd/system`.
75 [scip-shell system . . `[`. -e ${service} ] && return
76 {
77 echoscip-shell system . . echo. "[Unit]"
78 echoscip-shell system . . echo. "Description=Dracut Run Interactive"
79 echoscip-shell system . . echo. "DefaultDependencies=no"
80 echoscip-shell system . . echo. "After=systemd-vconsole-setup.service"
81 echoscip-shell system . . echo. "Wants=systemd-vconsole-setup.service"
82 echoscip-shell system . . echo. "Conflicts=emergency.service emergency.target"
83 echoscip-shell system . . echo. "[Service]"
84 echoscip-shell system . . echo. "EnvironmentFile=/dialog_profile"
85 echoscip-shell system . . echo. "Environment=HOME=/"
86 echoscip-shell system . . echo. "Environment=DRACUT_SYSTEMD=1"
87 echoscip-shell system . . echo. "Environment=NEWROOT=/sysroot"
88 echoscip-shell system . . echo. "WorkingDirectory=/"
89 if _fbiterm_okscip-shell shell shell-project 0.0.0 _fbiterm_ok().; then
90 echoscip-shell system . . echo. "ExecStart=fbiterm -- /bin/bash ${script} "
91 else
92 echoscip-shell system . . echo. "ExecStart=/bin/bash ${script}"
93 fi
94 echoscip-shell system . . echo. "Type=oneshot"
95 echoscip-shell system . . echo. "StandardInput=tty-force"
96 echoscip-shell system . . echo. "StandardOutput=inherit"
97 echoscip-shell system . . echo. "StandardError=inherit"
98 echoscip-shell system . . echo. "KillMode=process"
99 echoscip-shell system . . echo. "IgnoreSIGPIPE=no"
100 echoscip-shell system . . echo. "KillSignal=SIGHUP"
101 } > ${service}
102 }
103
104 function _run_interactivescip-shell shell shell-project 0.0.0 _run_interactive(). {
105 _setup_interactive_servicescip-shell shell shell-project 0.0.0 _setup_interactive_service().
106 systemctl start dracut-run-interactive.service
107 }
108
109 function _stop_interactivescip-shell shell shell-project 0.0.0 _stop_interactive(). {
110 systemctl stop dracut-run-interactive.service
111 }
112
113 function _fbiterm_okscip-shell shell shell-project 0.0.0 _fbiterm_ok(). {
114 if [scip-shell system . . `[`. ! -e /dev/fb0scip-shell filesystem . . `/dev/fb0`. ];then
115 # no framebuffer device found
116 return 1
117 fi
118 if ! command -v fbiterm &>/dev/nullscip-shell filesystem . . `/dev/null`.;then
119 # no framebuffer terminal program found
120 return 1
121 fi
122 if ! fbiterm echo &>/dev/nullscip-shell filesystem . . `/dev/null`.;then
123 # fbiterm can't be called with echo test cmd
124 return 1
125 fi
126 return 0
127 }
128
129 function dialog_timeoutscip-shell shell shell-project 0.0.0 dialog_timeout(). {
130 local timeout=60
131 custom_timeout=$(getarg "rd.kiwi.dialog.timeout=")
132 [scip-shell system . . `[`. -n "${custom_timeout}" ] && timeout="${custom_timeout}"
133 echoscip-shell system . . echo. "${timeout}"
134 }
135
136 function show_log_and_quitscip-shell shell shell-project 0.0.0 show_log_and_quit(). {
137 local text_message="$1"
138 local log_file="$2"
139 local timeout
140 timeout=$(dialog_timeoutscip-shell shell shell-project 0.0.0 dialog_timeout().)
141 if [scip-shell system . . `[`. "${timeout}" = "off" ];then
142 run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --backtitle "\"${text_message}\"" \
143 --textbox "${log_file}" 15 80
144 else
145 run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --timeout "${timeout}" --backtitle "\"${text_message}\"" \
146 --textbox "${log_file}" 15 80
147 fi
148 if getargbool 0 rd.debug; then
149 die "${text_message}"
150 else
151 reboot -f
152 fi
153 }
154
155 function report_and_quitscip-shell shell shell-project 0.0.0 report_and_quit(). {
156 local text_message="$1"
157 local timeout
158 timeout=$(dialog_timeoutscip-shell shell shell-project 0.0.0 dialog_timeout().)
159 if [scip-shell system . . `[`. "${timeout}" = "off" ];then
160 run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --msgbox "\"${text_message}\"" 5 80
161 else
162 run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --timeout "${timeout}" --msgbox "\"${text_message}\"" 5 80
163 fi
164 if getargbool 0 rd.debug; then
165 die "${text_message}"
166 else
167 reboot -f
168 fi
169 }
170
171 function ask_and_rebootscip-shell shell shell-project 0.0.0 ask_and_reboot(). {
172 local text_message="$1"
173 if ! run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --yesno "\"${text_message}\"" 7 80; then
174 die "${text_message}"
175 else
176 reboot -f
177 fi
178 }
179
180 function ask_and_shutdownscip-shell shell shell-project 0.0.0 ask_and_shutdown(). {
181 local text_message="$1"
182 if ! run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --yesno "\"${text_message}\"" 7 80; then
183 die "${text_message}"
184 else
185 systemctl poweroff
186 fi
187 }
188
189 function ask_for_credentialsscip-shell shell shell-project 0.0.0 ask_for_credentials(). {
190 local text_message="$1"
191 run_dialogscip-shell shell shell-project 0.0.0 run_dialog(). --insecure --passwordbox "\"${text_message}\"" 7 60
192 }