From 5e5a586b18f2c2be366ea229325523409444d662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20I=C3=B1iguez=20Goia?= Date: Tue, 27 Oct 2020 23:48:48 +0100 Subject: [PATCH] ui: improved GUI deb packages 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 --- ui/debian/config | 9 +++++++++ ui/debian/control | 10 +++++----- ui/debian/postinst | 22 +++++++++------------- ui/debian/postrm | 11 ++++++++++- ui/debian/prerm | 4 +++- ui/debian/templates | 7 +++++++ 6 files changed, 43 insertions(+), 20 deletions(-) create mode 100755 ui/debian/config create mode 100644 ui/debian/templates diff --git a/ui/debian/config b/ui/debian/config new file mode 100755 index 0000000000..cf35b48e42 --- /dev/null +++ b/ui/debian/config @@ -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 diff --git a/ui/debian/control b/ui/debian/control index 82feb12edb..0c03fa171d 100644 --- a/ui/debian/control +++ b/ui/debian/control @@ -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. diff --git a/ui/debian/postinst b/ui/debian/postinst index b145a0d677..26c5807baf 100755 --- a/ui/debian/postinst +++ b/ui/debian/postinst @@ -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 } diff --git a/ui/debian/postrm b/ui/debian/postrm index 145273e4c2..c9a83671a6 100755 --- a/ui/debian/postrm +++ b/ui/debian/postrm @@ -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/ @@ -17,9 +22,13 @@ purge_files() } pkill -15 opensnitch-ui || true +db_purge case "$1" in purge) purge_files ;; + remove) + db_purge + ;; esac diff --git a/ui/debian/prerm b/ui/debian/prerm index 39ab3d8431..922f44814d 100755 --- a/ui/debian/prerm +++ b/ui/debian/prerm @@ -1,7 +1,9 @@ #!/bin/sh - set -e +. /usr/share/debconf/confmodule + +db_purge case "$1" in remove) diff --git a/ui/debian/templates b/ui/debian/templates new file mode 100644 index 0000000000..022ed6e93a --- /dev/null +++ b/ui/debian/templates @@ -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. + .