:: Re: [DNG] netman-autostart_0.1.1
Top Pagina
Delete this message
Reply to this message
Auteur: aitor_czr
Datum:  
Aan: Edward Bartolo
CC: dng
Onderwerp: Re: [DNG] netman-autostart_0.1.1
Hi Edward and Rainer:

On 12/27/2015 11:22 AM, aitor_czr wrote:
>
> On 12/27/2015 11:14 AM, Edward Bartolo wrote:
>> Hi Aitor,
>>
>> Did you push your last patch that makes netman use debconf?
>
> Shortly (i was working in vdev).
>
>> Do you
>> grant me permission to apply your patch to my uploaded sources?
>>
>
> Yes, you have permissions to apply the patch.


Here you are the patch for netman-gui.postinst:

diff --git a/debian/netman-gui.postinst b/debian/netman-gui.postinst
index fdca77f..1103335 100644
--- a/debian/netman-gui.postinst
+++ b/debian/netman-gui.postinst
@@ -1,38 +1,45 @@
-#!/bin/sh
-if [ "$1" = "configure" ]; then
-    /sbin/ldconfig
-fi
+#!/bin/sh -e


-while true; do
- read -p "Do you want netman to use a systray icon? (Y/n)" yn
- case $yn in
-    [Nn]* ) line="exec=netman";
-            file="/etc/xdg/autostart/netman.desktop";
-            break;;
-        * ) line="exec=netman --use-tray-icon";
-            file="/usr/share/applications/netman.desktop";
-            break;;
- esac
-done
+. /usr/share/debconf/confmodule


-while true; do
- read -p "Do you want netman to automatically connect on startup? (Y/n)" yn
- case $yn in
-    [Nn]* ) break;;
-        * ) line=${line}" --auto-conn";
-            break;;
- esac
-done
+db_version 2.0
+#db_capb backup
+db_capb escape


-> ${file}
-echo "[Desktop Entry]"                    >>  ${file}
-echo "Name=Netman"                        >>  ${file}
-echo "Terminal=false"                     >>  ${file}
-echo "${line}"                            >>  ${file}
-echo "Icon=/usr/share/pixmaps/netman.ico" >>  ${file}
-echo "Type=Application"                   >>  ${file}
-echo "Categories=Application;Network;"    >>  ${file}
-echo "Version=0.1.1"                      >>  ${file}
+line="exec=netman";
+file="/usr/share/applications/netman.desktop";


-#DEBHELPER#
-exit 0
\ No newline at end of file
+STATE=1
+while [ "$STATE" != 0 -a "$STATE" != 7 ]; do
+    case $STATE in
+    1) db_input high netman-gui/netman-autostart || true
+    ;;
+    2) db_get netman-gui/netman-autostart
+        if [ "$RET" = "true" ]; then
+            file="/etc/xdg/autostart/netman.desktop";
+            mv /usr/share/applications/netman.desktop /etc/xdg/autostart/
+        fi
+    ;;
+    3) db_input high netman-gui/netman-autoconnect || true
+    ;;
+    4) db_get netman-gui/netman-autoconnect
+        if [ "$RET" = "true" ]; then
+            line=${line}" --auto-conn";
+        fi
+    ;;
+    5) db_input high netman-gui/netman-systray-icon || true
+    ;;
+    6) db_get netman-gui/netman-systray-icon
+        if [ "$RET" = "true" ]; then
+            line=${line}" --use-tray-icon";
+        fi
+    ;;
+    esac
+
+    if db_go; then
+        STATE=$(($STATE + 1))
+    else
+        STATE=$(($STATE - 1))
+    fi
+done
+db_stop


And the content of netman-gui.templates:

Template: netman-gui/title
Type: boolean
Description: netman-gui

Template: netman-gui/netman-autostart
Type: boolean
Description: Do you want netman-gui to start automatically on DE/WM login?

Template: netman-gui/netman-autoconnect
Type: boolean
Description: Do you want netman-gui to connect automatically once it is
started?

Template: netman-gui/netman-systray-icon
Type: boolean
Description: Do you want netman-gui to use a system tray icon?

Cheers,

     Aitor.


P.D.- I attach three files. Because i also changed netman-gui.postrm
diff --git a/debian/netman-gui.postinst b/debian/netman-gui.postinst
index fdca77f..1103335 100644
--- a/debian/netman-gui.postinst
+++ b/debian/netman-gui.postinst
@@ -1,38 +1,45 @@
-#!/bin/sh
-if [ "$1" = "configure" ]; then
-    /sbin/ldconfig
-fi
+#!/bin/sh -e


-while true; do
- read -p "Do you want netman to use a systray icon? (Y/n)" yn
- case $yn in
-    [Nn]* ) line="exec=netman";
-            file="/etc/xdg/autostart/netman.desktop";
-            break;;
-        * ) line="exec=netman --use-tray-icon";
-            file="/usr/share/applications/netman.desktop";
-            break;;
- esac
-done
+. /usr/share/debconf/confmodule


-while true; do
- read -p "Do you want netman to automatically connect on startup? (Y/n)" yn
- case $yn in
-    [Nn]* ) break;;
-        * ) line=${line}" --auto-conn";
-            break;;
- esac
-done
+db_version 2.0
+#db_capb backup
+db_capb escape


-> ${file}
-echo "[Desktop Entry]"                    >>  ${file}
-echo "Name=Netman"                        >>  ${file}
-echo "Terminal=false"                     >>  ${file}
-echo "${line}"                            >>  ${file}
-echo "Icon=/usr/share/pixmaps/netman.ico" >>  ${file}
-echo "Type=Application"                   >>  ${file}
-echo "Categories=Application;Network;"    >>  ${file}
-echo "Version=0.1.1"                      >>  ${file}
+line="exec=netman";
+file="/usr/share/applications/netman.desktop";


-#DEBHELPER#
-exit 0
\ No newline at end of file
+STATE=1
+while [ "$STATE" != 0 -a "$STATE" != 7 ]; do
+    case $STATE in
+    1) db_input high netman-gui/netman-autostart || true
+    ;;
+    2) db_get netman-gui/netman-autostart
+        if [ "$RET" = "true" ]; then
+            file="/etc/xdg/autostart/netman.desktop";
+            mv /usr/share/applications/netman.desktop /etc/xdg/autostart/
+        fi    
+    ;;
+    3) db_input high netman-gui/netman-autoconnect || true
+    ;;
+    4) db_get netman-gui/netman-autoconnect
+        if [ "$RET" = "true" ]; then
+            line=${line}" --auto-conn";
+        fi
+    ;;
+    5) db_input high netman-gui/netman-systray-icon || true
+    ;;
+    6) db_get netman-gui/netman-systray-icon
+        if [ "$RET" = "true" ]; then
+            line=${line}" --use-tray-icon";
+        fi
+    ;;
+    esac
+    
+    if db_go; then
+        STATE=$(($STATE + 1))
+    else
+        STATE=$(($STATE - 1))
+    fi
+done
+db_stop

Template: netman-gui/title
Type: boolean
Description: netma-gui

Template: netman-gui/netman-autostart
Type: boolean
Description: Do you want netman-gui to start automatically on DE/WM login?

Template: netman-gui/netman-autoconnect
Type: boolean
Description: Do you want netman-gui to connect automatically once it is started?

Template: netman-gui/netman-systray-icon
Type: boolean
Description: Do you want netman-gui to use a system tray icon?
#!/bin/sh

set -e

if [ -e /etc/xdg/autostart/netman.desktop ]; then
    rm -f /etc/xdg/autostart/netman.desktop
fi


# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
    db_purge
fi
# End automatically added section



exit 0