Skip to content

Commit

Permalink
ui: improved GUI deb packages
Browse files Browse the repository at this point in the history
Use debconf to ask questions.

This allow us to:
 - install deb packages using apt frontends (noninteractive, readline,
  etc).
 - display the questions on graphical installers like Gdebi.

closes #75
  • Loading branch information
gustavo-iniguez-goya committed Oct 27, 2020
1 parent 2dd9c43 commit 5e5a586
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
9 changes: 9 additions & 0 deletions ui/debian/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -e

. /usr/share/debconf/confmodule

# set default value, otherwise the question is not shown on first install
db_fset python3-opensnitch-ui/question1 seen false

db_input high python3-opensnitch-ui/question1 || true
db_go
10 changes: 5 additions & 5 deletions ui/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Package: python3-opensnitch-ui
Architecture: all
Section: net
Depends:
libqt5sql5-sqlite, python3:any, python3-setuptools, python3-six, python3-pyqt5,
debconf, libqt5sql5-sqlite, python3:any, python3-setuptools, python3-six, python3-pyqt5,
python3-pyqt5.qtsql, python3-pyinotify, python3-pip, whiptail | dialog
Description: GUI for the opensnitch application firewall
Description: opensnitch application firewall GUI
opensnitch-ui is a GUI for opensnitch written in Python.
It allows the user to view live outgoing connections, as well as search
to make connections.
for details of the intercepted connections.
.
The user can decide if block the outgoing connection based on properties of
The user can decide if block outgoing connections based on properties of
the connection: by port, by uid, by dst ip, by program or a combination
of them.
.
These rules can last forever, until the app restart or just one time.
These rules can last forever, until restart the daemon or just one time.
22 changes: 9 additions & 13 deletions ui/debian/postinst
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

install_pip_pkgs()
{
DIALOG=$(which whiptail || which dialog)

$DIALOG --yesno "OpenSnitch GUI needs to install 3 more packages:
unicode_slugify, grpcio-tools and protobuf.
Note: It's better to install them as regular user instead of root:
pip3 install --user unicode_slugify grpcio-tools
Do you want to install them now?" 15 70
if [ $? -eq 0 ]; then
db_get python3-opensnitch-ui/question1
if [ -z "$RET" -o "$RET" = "true" -o "$RET" = "yes" ]; then
echo "Installing grpcio-tools..."
pip3 install grpcio-tools || echo "Unable to install grpcio, try it manually."
pip3 -q install grpcio-tools || echo "Unable to install grpcio, try it manually."
echo
echo "Installing slugify..."
pip3 install unicode_slugify || echo "Unable to install unicode_slugify, try it manually."
pip3 -q install unicode_slugify || echo "Unable to install unicode_slugify, try it manually."
echo "Done."
else
echo "Not installing extra packages by user choice (debconf)"
fi
exit 0
}
Expand Down
11 changes: 10 additions & 1 deletion ui/debian/postrm
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

purge_files()
{
if [ -e /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
fi

for i in $(ls /home)
do
path=/home/$i/.config/
Expand All @@ -17,9 +22,13 @@ purge_files()
}

pkill -15 opensnitch-ui || true
db_purge

case "$1" in
purge)
purge_files
;;
remove)
db_purge
;;
esac
4 changes: 3 additions & 1 deletion ui/debian/prerm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

db_purge

case "$1" in
remove)
Expand Down
7 changes: 7 additions & 0 deletions ui/debian/templates
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Template: python3-opensnitch-ui/question1
Type: boolean
Description: Do you want to install them now?
OpenSnitch GUI needs to install manually 3 more packages using python3-pip:
.
unicode_slugify, grpcio-tools and protobuf.
.

0 comments on commit 5e5a586

Please sign in to comment.