Commit 3b2c08fa authored by Lior Spach's avatar Lior Spach

le-italc-config: Refs #1372 Don't generate script, just copy existing one

Signed-off-by: Lior Spach's avatarLior Spach <ls12@inf.ufpr.br>
parent f1d2ad79
#!/bin/sh
#!/bin/bash
#
# Copyright (C) 2004-2013 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-save-config
#
# le-save-config 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.
# (Monoterminal) - Remove possible created script from lightdm autostart
if [ -f "/etc/lightdm/greeter-exec-scripts/ica-auto-starter.sh" ]; then
......
#!/bin/bash
#
# --------------------------------------------------------------------------- #
# This file is aumotically copied to its correct directory by le-italc-config #
# --------------------------------------------------------------------------- #
#
#
# Copyright (C) 2004-2013 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-save-config
#
# le-save-config 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.
ica &
......@@ -28,35 +28,37 @@ if [ $(id -u) -ne 0 ]; then
fi
#GLOBAL VARIABLES
#Script path to be created for monoterminal:
SCRIPT_MONO_PATH_DIR="/etc/lightdm/greeter-exec-scripts/"
SCRIPT_MONO_PATH="${SCRIPT_MONO_PATH_DIR}ica-auto-starter.sh"
#Script path to be created for multiterminal:
SCRIPT_MULT_PATH="/etc/profile.d/ica-start-multiterminal.sh"
#Script path for monoterminal:
SCRIPT_MONO_PATH_SRC="/etc/le-italc-config/ica-start-monoterminal.sh"
SCRIPT_MONO_PATH_DST="/etc/lightdm/greeter-exec-scripts/ica-start-monoterminal.sh"
#Script path for multiterminal:
SCRIPT_MULT_PATH_SRC="/etc/le-italc-config/ica-start-multiterminal.sh"
SCRIPT_MULT_PATH_DST="/etc/profile.d/ica-start-multiterminal.sh"
#=================================UNCONFIG-FUNCTIONS===============================
unconfig_monoterminal () {
if [ ! -f "$SCRIPT_MONO_PATH" ]; then
if [ ! -f "$SCRIPT_MONO_PATH_DST" ]; then
zenity --warning --title="Aviso" --text="Não foi identificada nenhuma configuração monoterminal"
return 1
else
#Remove key and generated script
#Remove key and script
rm -f /etc/italc/public/teacher/key
rm -f "$SCRIPT_MONO_PATH"
rm -f "$SCRIPT_MONO_PATH_DST"
return 0
fi
}
unconfig_multiterminal () {
if [ ! -f "$SCRIPT_MULT_PATH" ]; then
if [ ! -f "$SCRIPT_MULT_PATH_DST" ]; then
zenity --warning --title="Aviso" --text="Não foi identificada nenhuma configuração multiterminal"
return 1
else
#Remove key and generated script
#Remove key and script
rm -f "/etc/italc/public/teacher/key"
rm -f "$SCRIPT_MULT_PATH"
rm -f "$SCRIPT_MULT_PATH_DST"
return 0
fi
#This function does not remove computers entries from italc.
......@@ -82,7 +84,7 @@ zenity --question --title="Configurador do iTalc" \
#QUESTIONS
#If already exist a configuration
if [ -f "$SCRIPT_MONO_PATH" -o -f "$SCRIPT_MULT_PATH" ]; then
if [ -f "$SCRIPT_MONO_PATH_DST" -o -f "$SCRIPT_MULT_PATH_DST" ]; then
#ASK: Is it configuration?
zenity --question --title="Configurador do iTalc" \
--text="Foi detectada uma configuração prévia do iTalc nessa máquina.
......@@ -139,10 +141,10 @@ zenity --question --title="Configurador do iTalc" \
--ok-label="Confirmar" --cancel-label="Cancelar"
[ $? -eq 1 ] && exit 0
#If confirmed, remove old configurations if necessary
if [ -f "$SCRIPT_MONO_PATH" ]; then
#If confirmed, remove old configurations if exists
if [ -f "$SCRIPT_MONO_PATH_DST" ]; then
unconfig_monoterminal
elif [ -f "$SCRIPT_MULT_PATH" ]; then #Multiteminal
elif [ -f "$SCRIPT_MULT_PATH_DST" ]; then #Multiteminal
unconfig_multiterminal
fi
......@@ -150,48 +152,12 @@ fi
##---START_FUNCTIONS-------------------------------------------------------------------------------------------------##
##===================================================================================================================##
generate_script_monoterminal_client () {
local g_file="$SCRIPT_MONO_PATH"
if [ ! -d "$SCRIPT_MONO_PATH_DIR" ]; then #If directory does not exit
mkdir -p "$SCRIPT_MONO_PATH_DIR" # Create it
fi
echo "#!/bin/sh" > $g_file
echo "ica &" >> $g_file
chmod +x $g_file
copy_script_monoterminal_client () {
cp "$SCRIPT_MONO_PATH_SRC" "$SCRIPT_MONO_PATH_DST"
}
generate_script_multiterminal () {
#Create a script in profile.d
local g_file="$SCRIPT_MULT_PATH"
(
echo "#!/bin/sh"
echo "#Privileged Users don't run ica"
echo "if [ \"\$USER\" = \"admin\" ]; then"
echo " return 0"
echo "fi"
echo
echo "#Resolve Port"
echo "PORT=\"\$(( 11000 + \$(echo \$DISPLAY | awk -F \":\" '{print \$NF}' | cut -b 1) ))\""
echo
echo "#ReSet the default port server for teacher(mobility to teachers computer)"
echo "if [ \"\$USER\" = \"professor\" ]; then"
echo " imc -setconfigvalue Network/CoreServerPort=\${PORT}"
echo "fi"
echo
echo "#Do not execute ica on logout"
echo "if ps -u \$USER -o comm | grep \"^ica\$\"; then"
echo " return 0"
echo "fi"
echo
echo "#Execute ICA"
echo "if [ -n \"\$PORT\" ]; then"
echo " ica -port \$PORT &"
echo "fi"
) > $g_file
chmod +x $g_file
copy_script_multiterminal () {
cp "$SCRIPT_MULT_PATH_SRC" "$SCRIPT_MULT_PATH_DST"
}
config_client_monoterminal () {
......@@ -218,7 +184,7 @@ config_client_monoterminal () {
imc -importpublickey "$key_file"
chmod 755 /etc/italc/public -R
generate_script_monoterminal_client #generate ica autorun script
copy_script_monoterminal_client #copy ica autorun script
}
config_master_monoterminal () {
......@@ -255,13 +221,13 @@ config_multiterminal () {
#Set config and create autorun script
imc -setconfigvalue Authentication/LogonAuthenticationEnabled=0 #Don't ask for login to enter italc. Only teacher can read private key.
generate_script_multiterminal
copy_script_multiterminal
#Give professor right to write to configuration file.
chown professor /etc/xdg/iTALC\ Solutions/iTALC.conf
chmod 0600 /etc/xdg/iTALC\ Solutions/iTALC.conf
if (who --users | awk -F " " '{print $1}' | grep -q "^professor$"); then #If teacher is logged in execute autorun script
su professor -c ".${SCRIPT_MULT_PATH}" #Run script, so teacher doesn't need to relogin
su professor -c ".${SCRIPT_MULT_PATH_DST}" #Run script, so teacher doesn't need to relogin
fi
}
......
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