Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-workroom
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-workroom
Commits
4e69753c
Commit
4e69753c
authored
Jun 22, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
ximper-yad-respondent-func.sh
ximper-yad-respondent-func.sh
+90
-0
No files found.
ximper-yad-respondent-func.sh
0 → 100755
View file @
4e69753c
#!/bin/bash
if
[
$(
id
-u
)
-eq
0
]
;
then
echo
"Нельзя запускать epmgpi от пользователя root."
exit
1
fi
YAD_DEFAULT
=
"/usr/bin/yad --window-icon=epmgpi --title=epmgpi --class=epmgpi"
clean_up_tmp
()
{
rm
-fr
"
$EPMGPI_TMP
"
}
EPMGPI_TMP
=
$(
mktemp
-d
-t
epmgpi.XXXXXXX
)
# shellcheck disable=SC2064
trap
"clean_up_tmp
$EPMGPI_TMP
"
EXIT
EPMGPI_LOG_FILE
=
"
$EPMGPI_TMP
/epmgpi.log"
touch
"
$EPMGPI_LOG_FILE
"
epmgpi_logging
()
{
tee
-a
"
$EPMGPI_LOG_FILE
"
}
ntf
()
{
notify-send
--icon
=
epmgpi
"
$1
"
}
# Уведомление об ошибке
ntf_error
()
{
notify-send
--icon
=
error
"
$1
"
}
epmgpi_answer
()
{
while
true
;
do
last_line
=
$(
tail
-n
1
"
$EPMGPI_LOG_FILE
"
)
if
[[
$last_line
==
*
"[Y/n]"
*
]]
;
then
# Действия, которые нужно выполнить, если найдена строка с [Y/n]
yad
--image
=
"dialog-question"
--text
"
$last_line
"
\
--button
=
"yad-yes:0"
\
--button
=
"yad-no:1"
ANSWER
=
$?
if
[
$ANSWER
-eq
0
]
;
then
echo
"y"
elif
[
$ANSWER
-eq
1
]
;
then
echo
"n"
fi
fi
if
[[
$last_line
==
*
"EXIT"
*
]]
;
then
# Если в тексте найдено слово "EXIT", останавливаем цикл
break
fi
sleep
1
done
}
epmgpi_answer |
(
/usr/bin/pkexec /usr/bin/epm full-upgrade 2>&1
exit_code
=
$?
case
$exit_code
in
0
)
echo
"Команда завершилась успешно"
ntf
"Пакет установлен!"
echo
"EXIT"
>
"
$EPMGPI_LOG_FILE
"
;;
100
)
ntf_error
"Пакет не установлен. Команда завершилась с ошибкой."
echo
"EXIT"
>
"
$EPMGPI_LOG_FILE
"
;;
126
)
ntf_error
"Пакет не установлен. Действие прервано пользователем."
echo
"EXIT"
>
"
$EPMGPI_LOG_FILE
"
;;
*
)
ntf_error
"Пакет не установлен."
echo
"EXIT"
>
"
$EPMGPI_LOG_FILE
"
;;
esac
)
| epmgpi_logging |
sed
-u
's/^/# /'
|
$YAD_DEFAULT
\
--title
=
"Установка пакета"
\
--progress
--width
=
800
--height
=
500
\
--enable-log
=
"Лог"
--log-expanded
--log-on-top
--auto-kill
--auto-close
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment