Commit 3f4e1cc8 authored by Michael Liang's avatar Michael Liang

le-proinfodata: new dialog which asks Inep

Signed-off-by: Michael Liang's avatarMichael Liang <ml09@inf.ufpr.br>
parent 207a61f0
Package: le-proinfodata
Version: 1.2.17
Version: 1.2.20
Maintainer: <proinfodata@c3sl.ufpr.br>
Architecture: i386
Section: main
Priority: important
Depends: dialog, wget, passwd, sudo, cron, bash, coreutils, bzip2
Depends: zenity, wget, passwd, sudo, cron, bash, coreutils, bzip2, xli
Description: Agent of PROINFODATA project designed for the LE project
Coleta de dados do projeto ProInfo/MEC de inclusão digital nas escolas
públicas brasileiras (PROINFODATA) is a project supported by Ministério da
......
......@@ -50,6 +50,8 @@ if test -f "${BACKUP_DIR}/SEED2/client/conf/inep"; then
rm -rf "${BACKUP_DIR}"
fi
echo "session-setup-script=exec_dialog.sh" >> /etc/lightdm/lightdm.conf
# Make sure the owner of ~seed_mec is seed_mec
chown -R seed_mec:seed_mec "${SEED_MEC_HOME}"
......
......@@ -37,7 +37,8 @@ fi
# Files to divert
DIVERTS="
/etc/init/dbus.conf \
/etc/init/tty1.conf
/etc/init/tty1.conf \
/usr/share/zenity/zenity.ui \
"
if [[ "$1" != "upgrade" ]]; then
......
......@@ -71,7 +71,8 @@ fi
# Files to divert
DIVERTS="
/etc/init/dbus.conf \
/etc/init/tty1.conf
/etc/init/tty1.conf \
/usr/share/zenity/zenity.ui \
"
# Divert files
......
......@@ -12,18 +12,10 @@ expect fork
respawn
pre-start script
# Does the INEP file exist?
INEPFILE=/opt/seed_mec/SEED2/client/conf/inep
if ! test -f ${INEPFILE} -a -n "$(cat ${INEPFILE})"; then
/usr/sbin/le-askINEP.sh < /dev/tty1
fi
mkdir -p /var/run/dbus
chown messagebus:messagebus /var/run/dbus
exec dbus-uuidgen --ensure
exec dbus-uuidgen --ensure
end script
exec dbus-daemon --system --fork --activation=upstart
......
......@@ -11,9 +11,4 @@ start on stopped rc RUNLEVEL=[2345] and (
stop on runlevel [!2345]
respawn
INEPFILE=/opt/seed_mec/SEED2/client/conf/inep
# Do not open getty if a dialog is about to be shown
if test -f ${INEPFILE} -a -n "$(cat ${INEPFILE})"; then
exec /sbin/getty -8 38400 tty1
fi
exec /sbin/getty -8 38400 tty1
This diff is collapsed.
#!/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
#
# le-proinfodata 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.
#Filter data in le.zone
function verifica_inep() {
i=0
cat $le_zone | cut -d "|" -f1 | grep $1
retorno=$?
info1=$(cat $le_zone | grep $1 | tr -d " " | cut -d "|" -f1)
info2=$(cat $le_zone | grep $1 | tr -d " " | cut -d "|" -f2)
info3=$(cat $le_zone | grep $1 | tr -d " " | cut -d "|" -f3)
info4=$(cat $le_zone | grep $1 | cut -d "|" -f4)
info5=$(cat $le_zone | grep $1 | tr -d " " | cut -d "|" -f5)
if [ $info1 != $1 ]; then
return 1
fi
#Start progress bar
(while [ $i -lt 100 ]; do
echo $i
sleep 1
i=$((i+30))
done)| zenity --progress --title="INEP" --text="Verificando inep digitado..." --percentage=0 --no-cancel --auto-close --width=600 --height=100
#End progress bar
if [ $retorno -eq 0 ];then
#Check INEP is valid and correct
zenity --list --title="INEP" --text="Essas informações estão corretas?" --cancel-label="Não" --ok-label="Sim" --width=600 --height=200 --column="Inep" --column="Estado" --column="Municipio" --column="Cep" --column="Escola" $info1 $info2 $info3 $info5 "$info4"
if [ $? -eq 0 ];then
echo $info1 > $2
return 0
else
#Check INEP is valid but not correct
return 1
fi
else
#Check INEP is invalid
zenity --warning --title="INEP" --text="O INEP fornecido é inválido. Por favor verifique o número INEP correspondente a sua instituição de ensino e tente novamente ou digite $frase" --width=600 --height=100
return 1
fi
}
frase="\"quero digitar o inep da minha escola depois\""
valido=0
# INEP file
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"
MD5BACKUPF_INEP="${SEED_HOME}/SEED2/.md5sum/.backup/client/conf/inep"
# Proxy file
F_PROXY="${SEED_HOME}/SEED2/client/conf/proxy"
MD5F_PROXY="${SEED_HOME}/SEED2/.md5sum/client/conf/proxy"
BACKUPF_PROXY="${SEED_HOME}/SEED2/.backup/client/conf/proxy"
MD5BACKUPF_PROXY="${SEED_HOME}/SEED2/.md5sum/.backup/client/conf/proxy"
# LE ZONE
le_zone="/etc/le-proinfodata/le.zone"
if [ $valido -eq 0 ]; then
zenity --info --height=100 --no-wrap --title="INEP" --text="O agente de acompanhamento do projeto PROINFODATA foi instalado nesta máquina.\nPara torná-lo funcional, entretanto, é necessário fornecer informações sobre as configurações de proxy,\nalém do número INEP da instituição.\nPara saber mais sobre o projeto, visite o site http://seed.c3sl.ufpr.br."
inep=`zenity --entry --title="INEP" --text="Digite seu INEP ou a mensagem: $frase" --cancel-label="Cancelar" --width=600 --height=100`
while [ $valido -eq 0 ]; do
if [ $? -eq 1 ]; then
inep=`zenity --entry --title="INEP" --text="Digite seu INEP ou a mensagem: $frase" --cancel-label="Cancelar" --width=600 --height=100`
else
#Check strings
inep_c=`echo $inep|tr -d " "`
frase_c=`echo $frase|tr -d " "|tr -d "\""`
if [ $inep_c = $frase_c ]; then
zenity --info --title="INEP" --height=100 --no-wrap --text=" O número INEP será requisitado novamente na próxima vez que este computador for ligado."
valido=1
else
#Check the size of the string
if [ ${#inep} -eq 8 ]; then
verifica_inep $inep $F_INEP
inep_valido=$?
if [ $inep_valido -eq 0 ]; then
valido=1
zenity --question --title="PROXY" --text="Você possui informações de proxy?"
#Configure Proxy
if [ $? -eq 0 ];then
proxy_ok=0
while [ $proxy_ok -eq 0 ]; do
proxy=`zenity --forms --title="PROXY" --text="Preencha as informações de proxy:" --add-entry="Host" --add-entry="Porta" --add-entry="Usuario" --cancel-label="Cancelar"`
if [ $? -eq 1 ];then
zenity --info --title="INEP" --text="Processo concluido!"
exit
fi
host=`echo $proxy | cut -d"|" -f1`
port=`echo $proxy | cut -d"|" -f2`
user=`echo $proxy | cut -d"|" -f3`
echo "phost="$host > $F_PROXY
echo "pport="$port >> $F_PROXY
echo "puid="$user >> $F_PROXY
`zenity --question --title="PROXY" --cancel-label="Não" --ok-label="Sim" --text="Existe senha do proxy ?" --width=600 --height=100`
password_y_n=$?
#Configure the password if exist
if [ $password_y_n -eq 0 ]; then
password_ok=0
while [ $password_ok -eq 0 ]; do
passwords=`zenity --title="PROXY" --forms --text="Digite a senha" --add-password="Digite a senha" --add-password="Confirme a senha" --cancel-label="Cancelar"`
password=`echo $passwords | cut -d"|" -f1`
password_conf=`echo $passwords | cut -d"|" -f2`
echo "PASS "$passwords "P1 "$password "P2 "$password_conf
if [ $password = $password_conf ]; then
echo "ppasswd="$password >> $F_PROXY
password_ok=1
else
zenity --info --title="PROXY" --text="As senhas não conferem!"
fi
done
fi
#Check PROXY is valid and correct
zenity --question --title="INEP" --cancel-label="Não" --ok-label="Sim" --text="Host:$host \nPorta: $port \nUsuario: $user \nEssas informações estão corretas?"
if [ $? -eq 0 ];then
proxy_ok=1
fi
done
fi
zenity --info --title="INEP" --text="Processo concluido!"
else
inep=`zenity --entry --title="INEP" --text="Digite seu INEP ou a mensagem: $frase" --width=600 --height=100 --cancel-label="Cancelar" `
fi
else
inep=`zenity --entry --title="INEP" --text="Digite seu INEP ou a mensagem: $frase" --width=600 --height=100 --cancel-label="Cancelar"`
fi
fi
fi
done
fi
# Generate md5 hashs for the files
md5sum ${F_INEP} | cut -d' ' -f1 > ${MD5F_INEP}
md5sum ${F_PROXY} | cut -d' ' -f1 > ${MD5F_PROXY}
# Backup the files
cp ${F_INEP} ${BACKUPF_INEP}
cp ${F_PROXY} ${BACKUPF_PROXY}
cp ${MD5F_INEP} ${MD5BACKUPF_INEP}
cp ${MD5F_PROXY} ${MD5BACKUPF_PROXY}
chown seed_mec:seed_mec ${F_INEP}
chown seed_mec:seed_mec ${F_PROXY}
#!/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-edubar
#
# 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"
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" &
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 = " &
#Disable Edubar and Panel
kill -stop $P_EDUBAR
pkill le-edubar
kill -stop $P_GPANEL
dialog_inep.sh
#Enable Edubar and Panel
kill -cont $P_EDUBAR
kill -cont $P_GPANEL
#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"
if [ -f $F_INEP ]; then
exit
else
#This "if" is to prevent the script run on logout
if [ -f $F_LOCK ]; then
exit
else
#This 'if' checks if in computer have multiterminal, if 1 then this isn't multiterminal.
if [ $(dpkg -l | grep "le-multiterminal") -eq 1 ]; then
touch $F_LOCK
call_dialog_inep_mult_off
else
touch $F_LOCK
call_dialog_inep_mult_on
fi
fi
fi
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-proinfodata
#
# le-proinfodata 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.
# This script will ask some configurations needed by the PROINFODATA agent
# Check if it's running on the live CD by checking the installation of ubiquity
if dpkg -l ubiquity-le 2>/dev/null | grep -q '^ii'; then
# ubiquity is installed, so we are in the live CD. Exit.
exit 0
fi
DIALOG="dialog --backtitle PROINFODATA --shadow --title"
TTY=/dev/tty1
TIMETOREAD=3
# LE ZONE
LEZONE=/etc/le-proinfodata/le.zone
# INEP file
SEED_HOME=/opt/seed_mec
INEPFILE="${SEED_HOME}/SEED2/client/conf/inep"
MD5INEPFILE="${SEED_HOME}/SEED2/.md5sum/client/conf/inep"
BACKUPINEPFILE="${SEED_HOME}/SEED2/.backup/client/conf/inep"
MD5BACKUPINEPFILE="${SEED_HOME}/SEED2/.md5sum/.backup/client/conf/inep"
# Proxy file
PROXYFILE="${SEED_HOME}/SEED2/client/conf/proxy"
MD5PROXYFILE="${SEED_HOME}/SEED2/.md5sum/client/conf/proxy"
BACKUPPROXYFILE="${SEED_HOME}/SEED2/.backup/client/conf/proxy"
MD5BACKUPPROXYFILE="${SEED_HOME}/SEED2/.md5sum/.backup/client/conf/proxy"
# "I'll do it later" message
LATER="quero digitar o inep da minha escola depois"
# Create a temp file to store some dialog answers.
ans=$(mktemp)
# test_exit exits if the given argument is equal to 255.
# This is used to test if the user pressed the ESC key.
function test_exit() {
if test $1 -eq 255 ; then
# Remove ans file.
rm -f ${ans}
# Start it again and exit.
$0
exit 0
fi
}
# Welcome message
${DIALOG} PROINFODATA --msgbox "
O agente de acompanhamento do projeto PROINFODATA foi instalado nesta
máquina. Para torná-lo funcional, entretanto, é necessário fornecer
informações sobre as configurações de proxy, além do número INEP da
instituição. Para saber mais sobre o projeto, visite o site
http://seed.c3sl.ufpr.br ." 0 0 > ${TTY}
valid=1
while test ${valid} -ne 0; do
# Ask INEP
${DIALOG} INEP --inputbox " Digite seu INEP ou a mensagem '${LATER}':" 0 0 > ${TTY} 2> ${ans}
test_exit $?
INEP=$(cat ${ans})
# INEP empty, try again
if test -z "${INEP}"; then
continue
fi
# "Later" message?
if [[ "${INEP}" == "${LATER}" ]]; then
${DIALOG} ATENÇÃO --msgbox "
O número INEP será requisitado novamente na próxima vez que este computador for ligado." 0 0 > ${TTY}
clear > ${TTY}
exit 0
fi
# Search the INEP in our base
LINE=$(grep "^ ${INEP} " ${LEZONE})
if [[ -z "${LINE}" ]]; then
# Warning!
${DIALOG} ATENÇÃO --msgbox "
O INEP fornecido é inválido. Por favor verifique o número INEP
correspondente a sua instituição de ensino e tente novamente ou digite
'${LATER}'." 0 0 > ${TTY}
valid=1
else
state=$(echo ${LINE} | awk -F'|' '{print $2}')
city=$(echo ${LINE} | awk -F'|' '{print $3}')
school=$(echo ${LINE} | awk -F'|' '{print $4}')
zip=$(echo ${LINE} | awk -F'|' '{print $5}')
${DIALOG} Confirmação --yesno "\
INEP: ${INEP} \n\
Estado: ${state} \n\
Cidade: ${city} \n\
Escola: ${school} \n\
CEP: ${zip} \n\
Essas informações estão corretas?" 0 0 > ${TTY}
valid=$?
test_exit ${valid}
fi
done
# INEP set. Ask for proxy configuration
${DIALOG} proxy --yesno "Você possui informações de proxy?" 0 0 > ${TTY}
has_proxy=$?
test_exit ${has_proxy}
if test ${has_proxy} -eq 0; then
valid=1
while test ${valid} -ne 0; do
declare -a formans
${DIALOG} proxy --form "Preencha as informações de proxy:" 12 55 5 \
"Host:" 1 1 "" 1 20 100 100 \
"Porta:" 2 1 "" 2 20 100 100 \
"Usuario:" 3 1 "" 3 20 100 100 \
> ${TTY} 2> ${ans}
test_exit $?
i=0
while read line; do
formans[${i}]=${line}
(( i++ ))
done < ${ans}
phost=${formans[0]}
pport=${formans[1]}
puid=${formans[2]}
equalpass=1
while test ${equalpass} -ne 0 ; do
${DIALOG} proxy --insecure --passwordform "Preencha a senha do \
proxy, se necessário:" 12 55 5 \
"Senha:" 1 1 "" 1 20 100 100 \
"Confirmar Senha:" 2 1 "" 2 20 100 100 \
> ${TTY} 2> ${ans}
test_exit $?
i=0
while read line; do
formans[${i}]=${line}
(( i++ ))
done < ${ans}
if [[ "${formans[0]}" != "${formans[1]}" ]]; then
${DIALOG} proxy --sleep ${TIMETOREAD} --infobox "As senhas \
não conferem!" 0 0 > ${TTY}
else
equalpass=0
fi
done
ppasswd=${formans[0]}
${DIALOG} Confirmação --yesno "\
Host: ${phost} \n\
Porta: ${pport} \n\
Usuário: ${puid} \n\
Essas informações estão corretas?" 0 0 > ${TTY}
valid=$?
test_exit ${valid}
done
else
phost=
pport=
puid=
ppasswd=
fi
# set files
${DIALOG} PROINFO --msgbox "Processo concluido!" 0 0 > ${TTY}
# Set variables
echo "${INEP}" > ${INEPFILE}
echo "phost=${phost}" > ${PROXYFILE}
echo "pport=${pport}" >> ${PROXYFILE}
echo "puid=${puid}" >> ${PROXYFILE}
echo "ppasswd=${ppasswd}" >> ${PROXYFILE}
# Generate md5 hashs for the files
md5sum ${INEPFILE} | cut -d' ' -f1 > ${MD5INEPFILE}
md5sum ${PROXYFILE} | cut -d' ' -f1 > ${MD5PROXYFILE}
# Backup the files
cp ${INEPFILE} ${BACKUPINEPFILE}
cp ${PROXYFILE} ${BACKUPPROXYFILE}
cp ${MD5INEPFILE} ${MD5BACKUPINEPFILE}
cp ${MD5PROXYFILE} ${MD5BACKUPPROXYFILE}
chown seed_mec:seed_mec ${INEPFILE}
chown seed_mec:seed_mec ${PROXYFILE}
clear > ${TTY}
exit 0
[Desktop Entry]
Type=Application
Exec=exec_dialog.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
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment