From 77504e4823ec95b8e8c1be44fd67b2be881ae69d Mon Sep 17 00:00:00 2001
From: Michael Liang <ml09@inf.ufpr.br>
Date: Mon, 11 Nov 2013 10:59:31 -0200
Subject: [PATCH] le-proinfodata: Fixed exec_dialog.sh execution as root in
 Multiterminal.

Signed-off-by: Michael Liang <ml09@inf.ufpr.br>
---
 le-multiterminal/package/DEBIAN/control       |  2 +-
 .../scripts/PostLogin/exec_dialog.script      | 83 +++++++++++++++++++
 le-proinfodata/package/DEBIAN/control         |  2 +-
 .../package/usr/local/bin/dialog_inep.sh      |  2 +-
 .../package/usr/local/bin/exec_dialog.sh      | 18 ++--
 .../usr/share/gnome/autostart/INEP.desktop    |  6 +-
 .../usr/share/gnome/autostart/stop_screen.sh  | 30 +++++++
 7 files changed, 126 insertions(+), 17 deletions(-)
 create mode 100644 le-multiterminal/package/etc/userful/scripts/PostLogin/exec_dialog.script
 create mode 100644 le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh

diff --git a/le-multiterminal/package/DEBIAN/control b/le-multiterminal/package/DEBIAN/control
index 3961c46f..188e3ce8 100755
--- a/le-multiterminal/package/DEBIAN/control
+++ b/le-multiterminal/package/DEBIAN/control
@@ -1,7 +1,7 @@
 Package: le-multiterminal
 Priority: important
 Section: main
-Version: 0.0.21
+Version: 0.0.22
 Maintainer: LE Maintainer <le-maintainer@c3sl.ufpr.br>
 Description: Userful multiplier for Linux Educacional 5
 Architecture: all
diff --git a/le-multiterminal/package/etc/userful/scripts/PostLogin/exec_dialog.script b/le-multiterminal/package/etc/userful/scripts/PostLogin/exec_dialog.script
new file mode 100644
index 00000000..3bd8e733
--- /dev/null
+++ b/le-multiterminal/package/etc/userful/scripts/PostLogin/exec_dialog.script
@@ -0,0 +1,83 @@
+#!/bin/bash
+# Copyright (C) 2004-2012 Centro de Computacao Cientifica e Software Livre
+# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+# This file is part of le-proinfodata
+#
+# exec_dialog.sh is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+F_MULT="/tmp/.mult.lock"
+F_LOCK="/tmp/.dialog.lock"
+F_INEP="/opt/seed_mec/SEED2/client/conf/inep"
+BACKGROUND="/usr/share/backgrounds/le5-wallpaper1600X1200.png"
+function call_dialog_inep_mult_off () {
+	#Disable mouse right-click
+	xmodmap -e "pointer = 1 2 11 4 5 6 7 8 9" &
+	xmodmap -e "keycode 64 = " &
+	#Set background
+	xli -onroot -fillscreen $BACKGROUND
+	dialog_inep.sh
+	#Reset background to default
+	xli -onroot -background black
+	#Enable mouse right-click
+	xmodmap -e "pointer = 1 2 3 4 5 6 7 8 9" &
+	xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L"
+}
+
+function call_dialog_inep_mult_on () {
+	#Disable mouse right-click
+	xmodmap -e "pointer = 1 2 11 4 5 6 7 8 9" &
+	xmodmap -e "keycode 64 = " &
+	dialog_inep.sh
+	#Get PID
+	P_EDUBAR=$(ps aux | grep "/usr/share/gnome/autostart/le-edubar_position.sh" | tr -s -t " " "|" | cut -d"|" -f2)
+	P_GPANEL=$(pgrep gnome-panel)
+	#Enable Edubar and Panel
+	kill -cont $P_GPANEL
+	kill -cont $P_EDUBAR
+	#Enable mouse right-click
+	xmodmap -e "pointer = 1 2 3 4 5 6 7 8 9" &
+	xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L"
+}
+
+export LANG="pt_BR.UTF-8"
+# SANITY CHECK -------------------------------------------------------
+# Do not run script if we are on live-cd
+# or the INEP code is already set
+# or we are logging out
+if dpkg --get-selections "ubiquity-le" | grep -q 'install$' ||
+   [ -f $F_INEP ] ||
+   [ -f $F_LOCK ]; then
+    exit 0
+fi
+# --------------------------------------------------------------------
+sleep 3
+# Check whether the computer is running on a the multiterminal
+if dpkg --get-selections "le-multiterminal" | grep -q 'install$'; then
+	# In the first call (lightdm) in multiterminal this is script must leave, to be called again after.
+    if [ -f $F_MULT ];then
+		touch $F_LOCK
+		echo "0" > $F_LOCK
+        call_dialog_inep_mult_on
+    else
+    	touch $F_MULT
+		exit 0
+    fi
+else
+    touch $F_LOCK
+	echo "1" > $F_LOCK
+    call_dialog_inep_mult_off
+fi
+
+exit 0
diff --git a/le-proinfodata/package/DEBIAN/control b/le-proinfodata/package/DEBIAN/control
index 273120c7..07a29892 100644
--- a/le-proinfodata/package/DEBIAN/control
+++ b/le-proinfodata/package/DEBIAN/control
@@ -1,5 +1,5 @@
 Package: le-proinfodata
-Version: 1.2.28
+Version: 1.2.29
 Maintainer: <proinfodata@c3sl.ufpr.br>
 Architecture: i386
 Section: main
diff --git a/le-proinfodata/package/usr/local/bin/dialog_inep.sh b/le-proinfodata/package/usr/local/bin/dialog_inep.sh
index af8a674c..ad338894 100755
--- a/le-proinfodata/package/usr/local/bin/dialog_inep.sh
+++ b/le-proinfodata/package/usr/local/bin/dialog_inep.sh
@@ -58,7 +58,7 @@ function verifica_inep() {
 frase="\"quero digitar o inep da minha escola depois\""
 valido=0
 # INEP file
-seed_home=/opt/seed_mec
+SEED_HOME=/opt/seed_mec
 F_INEP="${SEED_HOME}/SEED2/client/conf/inep"
 MD5F_INEP="${SEED_HOME}/SEED2/.md5sum/client/conf/inep"
 BACKUPF_INEP="${SEED_HOME}/SEED2/.backup/client/conf/inep"
diff --git a/le-proinfodata/package/usr/local/bin/exec_dialog.sh b/le-proinfodata/package/usr/local/bin/exec_dialog.sh
index 79638e18..3bd8e733 100755
--- a/le-proinfodata/package/usr/local/bin/exec_dialog.sh
+++ b/le-proinfodata/package/usr/local/bin/exec_dialog.sh
@@ -1,7 +1,6 @@
 #!/bin/bash
 # Copyright (C) 2004-2012 Centro de Computacao Cientifica e Software Livre
 # Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
-#session-setup-script = exec_dialog.sh
 # This file is part of le-proinfodata
 #
 # exec_dialog.sh is free software; you can redistribute it and/or
@@ -22,10 +21,6 @@ F_MULT="/tmp/.mult.lock"
 F_LOCK="/tmp/.dialog.lock"
 F_INEP="/opt/seed_mec/SEED2/client/conf/inep"
 BACKGROUND="/usr/share/backgrounds/le5-wallpaper1600X1200.png"
-#Get PID
-P_EDUBAR=$(ps aux | grep "/usr/share/gnome/autostart/le-edubar_position.sh" | tr -s -t " " "|" | cut -d"|" -f2)
-P_GPANEL=$(pgrep -u $USER gnome-panel)
-
 function call_dialog_inep_mult_off () {
 	#Disable mouse right-click
 	xmodmap -e "pointer = 1 2 11 4 5 6 7 8 9" &
@@ -44,14 +39,13 @@ function call_dialog_inep_mult_on () {
 	#Disable mouse right-click
 	xmodmap -e "pointer = 1 2 11 4 5 6 7 8 9" &
 	xmodmap -e "keycode 64 = " &
-	#Disable Edubar and Panel
-	kill -stop $P_EDUBAR
-	pkill le-edubar
-	kill -stop $P_GPANEL
 	dialog_inep.sh
+	#Get PID
+	P_EDUBAR=$(ps aux | grep "/usr/share/gnome/autostart/le-edubar_position.sh" | tr -s -t " " "|" | cut -d"|" -f2)
+	P_GPANEL=$(pgrep gnome-panel)
 	#Enable Edubar and Panel
-	kill -cont $P_EDUBAR
 	kill -cont $P_GPANEL
+	kill -cont $P_EDUBAR
 	#Enable mouse right-click
 	xmodmap -e "pointer = 1 2 3 4 5 6 7 8 9" &
 	xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L"
@@ -68,12 +62,13 @@ if dpkg --get-selections "ubiquity-le" | grep -q 'install$' ||
     exit 0
 fi
 # --------------------------------------------------------------------
-
+sleep 3
 # Check whether the computer is running on a the multiterminal
 if dpkg --get-selections "le-multiterminal" | grep -q 'install$'; then
 	# In the first call (lightdm) in multiterminal this is script must leave, to be called again after.
     if [ -f $F_MULT ];then
 		touch $F_LOCK
+		echo "0" > $F_LOCK
         call_dialog_inep_mult_on
     else
     	touch $F_MULT
@@ -81,6 +76,7 @@ if dpkg --get-selections "le-multiterminal" | grep -q 'install$'; then
     fi
 else
     touch $F_LOCK
+	echo "1" > $F_LOCK
     call_dialog_inep_mult_off
 fi
 
diff --git a/le-proinfodata/package/usr/share/gnome/autostart/INEP.desktop b/le-proinfodata/package/usr/share/gnome/autostart/INEP.desktop
index 04602783..d4efa0a1 100644
--- a/le-proinfodata/package/usr/share/gnome/autostart/INEP.desktop
+++ b/le-proinfodata/package/usr/share/gnome/autostart/INEP.desktop
@@ -1,10 +1,10 @@
 [Desktop Entry]
 Type=Application
-Exec=exec_dialog.sh
+Exec=/usr/share/gnome/autostart/stop_screen.sh
 Hidden=false
 NoDisplay=true
 X-GNOME-Autostart-enabled=true
 Name[pt_BR]=INEP
 Name=INEP
-Comment[pt_BR]= Chama o exec_dialog.sh
-Comment= Call exec_dialog.sh
+Comment[pt_BR]= Para Le-edubar e Gnome-panel
+Comment= Stop Le-edubar and Gnome-panel
diff --git a/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh b/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh
new file mode 100644
index 00000000..0e9c0c18
--- /dev/null
+++ b/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Copyright (C) 2004-2012 Centro de Computacao Cientifica e Software Livre
+# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+#session-setup-script = exec_dialog.sh
+# This file is part of le-proinfodata
+#
+# exec_dialog.sh is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+F_LOCK="/tmp/.dialog.lock"
+P_EDUBAR=$(ps aux | grep "/usr/share/gnome/autostart/le-edubar_position.sh" | tr -s -t " " "|" | cut -d"|" -f2)
+P_GPANEL=$(pgrep -u $USER gnome-panel)
+NUM=$(cat $F_LOCK)
+#Disable Edubar and Panel in Multiterminal
+if [ $NUM -eq 0 ]; then
+	kill -stop $P_EDUBAR
+	pkill le-edubar
+	kill -stop $P_GPANEL
+fi
-- 
GitLab