+
+
+
+
+
|
+ $MSG_HOSTNAME | $MSG_IPADDR | $MSG_MACADDR | $MSG_SPEED | $MSG_DUPLEX |
+ $HOSTNAME | $(ogGetIpAddress) | $(ogGetMacAddress) | $SPEED | $DUPLEX |
+
+
+
+
$MSG_MENUTITLE
+EOT
+
+# Si existe el fichero de configuración creado por el script getConfiguration, ...
+cfgfile=/tmp/getconfig
+if [ -f $cfgfile ]; then
+ # Tomar los datos del fichero.
+ awk -v boot="$MSG_BOOT" '
+ { n=split($0,sep,";");
+ for (i=1; i
%s %s (%s, %s)\n",
+ dua[1],dua[2],boot,dua[5],dua[1],dua[2]);
+ }
+ }
+ }' $cfgfile >>$FILEINFOHTML
+else
+ # Si no, obtener los datos de los discos.
+ for ((d=1; d<=$(ogDiskToDev | wc -w); d++)); do
+ for ((p=1; p<=$(ogGetPartitionsNumber $d); p++)); do
+ VERSION=$(ogGetOsVersion $d $p 2>/dev/null | cut -f2 -d:)
+ [ -n "$VERSION" ] && echo "$MSG_BOOT $VERSION ($d, $p)
" >>$FILEINFOHTML
+ done
+ done
+fi
+# Añadir opción de apagado.
+cat >> $FILEINFOHTML << EOT
+$MSG_POWEROFF
+
+EOT
+
+# Crear contenido de la caché.
+eval $CACHECONTENIDO >> $FILEINFOCACHE
+
diff --git a/client/shared/scripts/generateMenuDefault.py b/client/scripts/generateMenuDefault.py
similarity index 100%
rename from client/shared/scripts/generateMenuDefault.py
rename to client/scripts/generateMenuDefault.py
diff --git a/client/scripts/getFsType b/client/scripts/getFsType
new file mode 100755
index 0000000..b3516a4
--- /dev/null
+++ b/client/scripts/getFsType
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogGetFsType "$@"
+
diff --git a/client/shared/scripts/getFsType.py b/client/scripts/getFsType.py
similarity index 100%
rename from client/shared/scripts/getFsType.py
rename to client/scripts/getFsType.py
diff --git a/client/scripts/getIpAddress b/client/scripts/getIpAddress
new file mode 100755
index 0000000..e428ebf
--- /dev/null
+++ b/client/scripts/getIpAddress
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogGetIpAddress "$@"
+
diff --git a/client/shared/scripts/getIpAddress.py b/client/scripts/getIpAddress.py
similarity index 100%
rename from client/shared/scripts/getIpAddress.py
rename to client/scripts/getIpAddress.py
diff --git a/client/scripts/getOsVersion b/client/scripts/getOsVersion
new file mode 100755
index 0000000..6e6d91d
--- /dev/null
+++ b/client/scripts/getOsVersion
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogGetOsVersion "$@"
+
diff --git a/client/shared/scripts/getOsVersion.py b/client/scripts/getOsVersion.py
similarity index 100%
rename from client/shared/scripts/getOsVersion.py
rename to client/scripts/getOsVersion.py
diff --git a/client/shared/scripts/grubSyntax b/client/scripts/grubSyntax
similarity index 97%
rename from client/shared/scripts/grubSyntax
rename to client/scripts/grubSyntax
index 2ff21fb..8997c97 100755
--- a/client/shared/scripts/grubSyntax
+++ b/client/scripts/grubSyntax
@@ -10,8 +10,6 @@ set -e
#@version 1.1.1 - En los parámetros del kernel se sustituye el UUID por el dispositivo.
#@version 1.1.1 - Detecta cargador de Windows en directorio Part-xx-yy dentro de ESP (#802 #888)
-export PYTHONPATH=/opt/opengnsys/lib/engine/bin/
-
DISK=
PART=
@@ -110,9 +108,8 @@ OG_prepare_grub_to_access_device ()
if [[ $DEVICE == *"nvme"* ]]; then
#DEVICE=`echo $DEVICE | sed -e "s/\/dev\/nvme/hd/g" | sed -e "s/n.*p/,gpt/g"`
#TODO Detectar si es GPT o no...
- read -r D P <<< $(python3 -c 'import DiskLib; d = DiskLib.ogDevToDisk ("'$DEVICE'"); print (d)')
- PTT = $(python3 -c 'import DiskLib; t = DiskLib.ogGetPartitionTableType ("'$D'"); print (t)')
- if [ "$PTT" == "GPT" ]; then
+ read -r D P <<< `ogDevToDisk $DEVICE`
+ if [ "`ogGetPartitionTableType $D`" == "GPT" ]; then
# Si es gpt se sustituye por "hd(X-1),gptY"
#device=`echo $device | sed -e "s/\/dev\/nvme/hd/g" | sed -e "s/n.*p/,gpt/g"`
nvmeDevice=`echo "hd"$(expr $D - 1)",gpt$P"`
@@ -241,7 +238,7 @@ esac
# ADV OSPROBED
if [ -n "${DISK}" ]; then
#Si $DISK esta definido buscar en el disco y la particion parametro 1 y 2
- OSSEARCH=$(python3 -c 'import DiskLib; d = DiskLib.ogDiskToDev ("'$DISK'", "'$PART'"); print (d)')
+ OSSEARCH=$(ogDiskToDev $DISK $PART)
OSPROBED="`os-prober | grep $OSSEARCH | tr ' ' '^' | paste -s -d ' '`"
else
#si no esta definido
diff --git a/client/scripts/initCache b/client/scripts/initCache
new file mode 100755
index 0000000..9caf0be
--- /dev/null
+++ b/client/scripts/initCache
@@ -0,0 +1,111 @@
+#!/bin/bash
+# Scirpt de iniciación de la caché local de disco.
+# Nota: se usa como base para el programa de configuración de equipos de OpenGnsys Admin).
+# Formato: initCache [int_ndisk [int_npart]] {-1 | 0 | int_size} [NOMOUNT]
+# Versión: 0.9.1, 2009/03/17, - Ramón Gómez, Univ. Sevilla - Versión inicial.
+# Versión: 0.9.2, 2010/07/27, - Ramón Gómez, Univ. Sevilla - redefinir parámetro.
+# Version: 1.0.5, 2012/09/18, - Univ. Huelva - Nuevo parametro para indicar el disco donde se creara la CACHE, si no se indica, se usa 1
+# Version: 1.1.0, 2016/06/16, - Ramón Gómez, Univ. Sevilla - Nuevos parámetros: partición de caché (por defecto, 4) y cadena opcional "NOMOUNT" para dejar la caché sin montar.
+
+TIME1=$SECONDS
+PROG="$(basename $0)"
+EXECFORMAT="$PROG [int_ndisk [int_npart]] {-1 | 0 | int_size} [NOMOUNT]"
+
+# Si el último parámetro es la cadena "NOMOUNT", marcar para no montar y descartarlo.
+if [[ "${*^^}" =~ \ NOMOUNT$ ]]; then
+ MOUNT=0
+ PARAMS=$[$#-1]
+else
+ MOUNT=1
+ PARAMS=$#
+fi
+# Tomar valores según el número de parámetros restantes.
+case $PARAMS in
+ 1) # Por defecto, disco 1 partición 4.
+ NDISK=1
+ NPART=4
+ SIZE=$1
+ ;;
+ 2) # Elegir disco y partición 4 por defecto.
+ NDISK=$1
+ NPART=4
+ SIZE=$2
+ ;;
+ 3) # Elegir disco y partición.
+ NDISK=$1
+ NPART=$2
+ SIZE=$3
+ ;;
+ *) # Error de formato.
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $EXECFORMAT"
+ exit $?
+ ;;
+esac
+
+# Si disco o partición no son mayores o iguales que 1, error.
+if [ -n "${NDISK//[-0-9]/}${NPART//[-0-9]/}" ] || [ $NDISK -lt 1 ] || [ $NPART -lt 1 ] ; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $EXECFORMAT"
+ exit $?
+fi
+# Si tamaño no es numérico o tamaño<-1, error.
+if [ -n "${SIZE//[-0-9]/}" ] || [ $SIZE -lt -1 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $EXECFORMAT"
+ exit $?
+fi
+# Si tamaño=0, no hacer nada.
+if [ $SIZE -eq 0 ]; then
+ echo "No modificar la caché local."
+ exit
+fi
+# Si tamaño=-1, borrar caché.
+if [ $SIZE -eq -1 ]; then
+ echo "[10] Trabajar sin caché local."
+ ogUnmountCache 2>/dev/null
+ ogDeleteCache
+else
+ # Si la caché actual está definida en otro disco y partición, se elimina.
+ if [ -n "$(ogFindCache)" -a "$NDISK $NPART" != "$(ogFindCache)" ]; then
+ echo "[10] Detectada otra caché, eliminarla"
+ ogUnmountCache 2>/dev/null
+ ogDeleteCache
+ fi
+ # Tomamos el tamaño actual. Si no existe cache será 0.
+ OLDSIZE=$(ogGetCacheSize 2>/dev/null) || OLDSIZE=0
+
+ # Error si tamaño definido no es >0.
+ if [ ! $SIZE -gt 0 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT: !($SIZE>0)"
+ exit $?
+ fi
+ # Si no existe caché o si cambia su tamaño, crearla.
+ CACHESIZE=$(ogGetCacheSize 2>/dev/null)
+ if [ "$SIZE" != "$CACHESIZE" ]; then
+ echo "[10] Crar partición de caché local."
+ ogUnmountCache 2>/dev/null
+ ogCreateCache $NDISK $NPART $SIZE
+ ogUpdatePartitionTable $NDISK
+ fi
+ # Si caché no montada y no formateada o cambia el tamaño: formatear.
+ CACHE=$(ogFindCache) || exit $?
+ if ! ogIsFormated $CACHE || [ $SIZE -ne $OLDSIZE ]; then
+ echo "[50] Formatear caché local."
+ ogFormatCache
+ fi
+ echo "[70] Comprobar montaje de caché local."
+ ogMountCache 2>/dev/null
+ # Si error al montar, chequear sistema de archivos y volver a montar.
+ if [ $? != 0 ]; then
+ echo "[80] Comprobar consistencia y volver a montar caché local."
+ ogCheckFs $CACHE
+ ogMountCache || exit $?
+ fi
+ # Dejar desmontada la caché si se ha solicitado.
+ if [ $MOUNT == 0 ]; then
+ echo "[90] Dejar desmontada la caché local."
+ ogUnmountCache 2>/dev/null
+ fi
+fi
+# Duración del proceso.
+TIME=$[SECONDS-TIME1]
+echo "[100] Duración de la operación $[TIME/60]m $[TIME%60]s"
+
diff --git a/client/shared/scripts/initCache.py b/client/scripts/initCache.py
similarity index 93%
rename from client/shared/scripts/initCache.py
rename to client/scripts/initCache.py
index 9fb4ed8..8a45ca8 100755
--- a/client/shared/scripts/initCache.py
+++ b/client/scripts/initCache.py
@@ -47,6 +47,7 @@ def main (NDISK, NPART, SIZE, MOUNT):
if SIZE != CACHESIZE:
print("[10] Crear partición de caché local.")
CacheLib.ogUnmountCache()
+ print (f'nati: calling ogCreateCache ({NDISK}, {NPART}, {SIZE})')
CacheLib.ogCreateCache (NDISK, NPART, SIZE)
DiskLib.ogUpdatePartitionTable()
@@ -103,19 +104,23 @@ if __name__ == "__main__":
NPART = int (args[1])
SIZE = int (args[2])
else:
+ print (f'nati: params no es ni 1 ni 2 ni 3 sino ({PARAMS})')
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, EXECFORMAT)
sys.exit (1)
except ValueError:
+ print (f'nati: ValueError')
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, EXECFORMAT)
sys.exit (1)
# Si disco o partición no son mayores o iguales que 1, error.
if NDISK < 1 or NPART < 1:
+ print (f'nati: ndisk<1 or npart<1, ({NDISK}) ({NPART})')
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, EXECFORMAT)
sys.exit (1)
# Si tamaño no es numérico o tamaño<-1, error.
if SIZE < -1:
+ print (f'nati: SIZE<-1 ({SIZE})')
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, EXECFORMAT)
sys.exit (1)
diff --git a/client/scripts/installOfflineMode b/client/scripts/installOfflineMode
new file mode 100755
index 0000000..d9ff245
--- /dev/null
+++ b/client/scripts/installOfflineMode
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#/**
+# installOfflineMode
+#@brief Prepara el equipo cliente para el modo offline.
+#@param no
+#@return
+#@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado.
+#@exception OG_ERR_NOTCACHE No existe cache.
+#@author Irina Gomez. ETSII. Universidad de Sevilla
+#@date 2013/12/5
+#*/ ##
+
+PROG="$(basename $0)"
+if [ "$*" == "help" ]; then
+ ogHelp "$PROG $MSG_HELP_installOfflineMode" \
+ "$PROG [ no param ]"
+ exit 0
+fi
+
+ogEcho log session "$MSG_HELP_installOfflineMode"
+# Cargamos las variables de entorno.
+[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
+DIRTFTP="/opt/oglive/tftpboot"
+DIROGCLIENT="$DIRTFTP/ogclient"
+# Comprobamos que el DIROGCLIENT esta montado desde repo
+df |grep "$(ogGetRepoIp).*$DIRTFTP" &>/dev/null || ogRaiseError $OG_ERR_NOTFOUND "REPO OGclient" || exit $?
+
+# Copiamos el kernel y el initrd.
+ogEcho log session " [10] updateBootCache"
+updateBootCache || ogRaiseError $OG_ERR_NOTCACHE || exit $?
+
+# Creamos los dir necesarios.
+ogEcho log session " [40] mkdir -p $OGCAC/{ogclient, menus, log}."
+[ -d $OGCAC/menus/images/iconos ] || mkdir -p $OGCAC/menus/images/iconos
+[ -d $OGCAC/ogclient ] || mkdir -p $OGCAC/ogclient
+[ -d $OGCAC/log ] || mkdir -p $OGCAC/log
+[ -d $OGCAC/opt/opengnsys/images ] || mkdir -p $OGCAC/opt/opengnsys/images
+
+# Comparamos el cliente en el server y en cache
+ogEcho log session " [60] cp $DIROGCLIENT/ogclient.sqfs $OGCAC/ogclient/"
+SERVEROGCLIENT=$(cat $DIROGCLIENT/ogclient.sqfs.sum 2>/dev/null)
+CACHEOGCLIENT=$(cat $OGCAC/ogclient/ogclient.sqfs.sum 2>/dev/null)
+
+if [ "$CACHEOGCLIENT" != "$SERVEROGCLIENT" ]; then
+ cp $DIROGCLIENT/ogclient.sqfs $OGCAC/ogclient/
+ cp $DIROGCLIENT/ogclient.sqfs.sum $OGCAC/ogclient/
+fi
+
+# Si se ha generado el menu de inicio lo copiamos a cache.
+IPCLIENT=$(ogGetIpAddress)
+MENU=$OGLOG/$IPCLIENT.info.html
+ICONO="images/iconos/logoopengnsys.png"
+[ -f $MENU ] || generateMenuDefault
+ogEcho log session " [90] cp $MENU $OGCAC/menus/$IPCLIENT.html"
+cp $MENU $OGCAC/menus/$IPCLIENT.html
+sed -i s/"..\/images"/"images"/g $OGCAC/menus/$IPCLIENT.html
+wget --no-check-certificate https://$(ogGetRepoIp)/opengnsys/$ICONO -O $OGCAC/menus/$ICONO
+
+
diff --git a/client/shared/scripts/installOfflineMode.py b/client/scripts/installOfflineMode.py
similarity index 100%
rename from client/shared/scripts/installOfflineMode.py
rename to client/scripts/installOfflineMode.py
diff --git a/client/scripts/launchOgagentInstaller b/client/scripts/launchOgagentInstaller
new file mode 100755
index 0000000..b999d3e
--- /dev/null
+++ b/client/scripts/launchOgagentInstaller
@@ -0,0 +1,145 @@
+#!/bin/bash
+# #/**
+# launchOgagentInstaller ndisk npart [windowsadmin]
+#@brief Scheduling OpenGnsys Agent installation at next boot or administrator session.
+#@param integer ndsik disk number
+#@param integer npart partition number
+#@param string windowsadmin administrator user (only for Windows)
+#@author Ramón M. Gómez, ETSII Univ. Sevilla
+#@version 1.1.0 - Initial version.
+#@date 2018-02-16
+#*/ ##
+
+# Global variables.
+PROG="$(basename "$0")"
+if which curl &>/dev/null; then
+ DOWNLOAD="curl -k -f --connect-timeout 1 -o"
+else
+ DOWNLOAD="wget --no-check-certificate -T 1 -O"
+fi
+
+# Show help.
+if [ "$*" == "help" ]; then
+ echo "$PROG: scheduling OpenGnsys Agent installation."
+ echo "Format: $PROG ndisk npart [windowsadmin]"
+ exit 0
+fi
+# Error control.
+if ! typeset -Fp ogRaiseError &>/dev/null; then
+ echo "$PROG: it can only be executed by an ogLive client." >&2
+ exit 1
+fi
+[ $# == 2 -o $# == 3 ] || ogRaiseError $OG_ERR_FORMAT "$PROG ndisk npart [adminuser]" || exit $OG_ERR_FORMAT
+MNTDIR=$(ogMount "$1" "$2") || exit $?
+OGVERSION=$($DOWNLOAD - https://$(ogGetServerIp)/opengnsys/rest/info 2>/dev/null | jq -r .version)
+[ -n "$OGVERSION" ] || ogRaiseError $OG_ERR_NOTFOUND "GET /rest/info" || exit $OG_ERR_NOTFOUND
+
+case "$(ogGetOsType $1 $2)" in
+ Windows) # OGAgent for Windows.
+ HIVE="$(ogGetHivePath "$MNTDIR" "$3")"
+ [ -n "$HIVE" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 $3/NTUSER.DAT" || exit $OG_ERR_NOTFOUND
+ # Downloading OGAgent installer for Windows.
+ OGAGENTFILE="OGAgentSetup-${OGVERSION/pre/}.exe"
+ TMPDIR="$(ogGetPath "$MNTDIR/Windows/Temp")"
+ if ogListSoftware $1 $2 | grep -qi "opengnsys agent"; then
+ echo "OGAgent for Windows is already installed, you need to uninstall it before re-install."
+ else
+ if eval $DOWNLOAD "$TMPDIR/$OGAGENTFILE" "https://$(ogGetServerIp)/opengnsys/descargas/$OGAGENTFILE" 2>/dev/null; then
+ # Run once OGAgent Installer.
+ if hivexsh -w << EOT 2>/dev/null; then
+load $HIVE
+cd \\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce
+setval 1
+Install OGAgent
+string:C:\\Windows\\Temp\\$OGAGENTFILE /S /server $(ogGetServerIp)
+commit
+close
+exit
+EOT
+ echo "Scheduled OGAgent installation after \"$3\" logon"
+ echo " (for connection problems, check configuration file)."
+ else
+ ogRaiseError $OG_ERR_NOTWRITE "$1 $2 .../$3/NTUSER.DAT"
+ exit $OG_ERR_NOTWRITE
+ fi
+ else
+ ogRaiseError $OG_ERR_NOTFOUND "$1 $2 /Windows/Temp/$OGAGENTFILE"
+ exit $OG_ERR_NOTFOUND
+ fi
+ fi
+ ;;
+ Linux) # OGAgent for Linux (only deb and redhat-based backages; TODO suse-based package).
+ if ogListSoftware $1 $2 | grep -qi "ogagent"; then
+ echo "OGAgent for Linux is already installed, you need to uninstall it before re-install."
+ else
+ SYSTEMDDIR="$MNTDIR/lib/systemd"
+ [ -d "$SYSTEMDDIR" -a -d "${SYSTEMDDIR/lib/etc}" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 systemd" || exit $OG_ERR_NOTFOUND
+ # Downloading OGAgent installer for Linux.
+ if [ -e $MNTDIR/etc/debian_version ]; then # Debian-based
+ OGAGENTFILE="ogagent_${OGVERSION/pre/}_all.deb"
+ CODE="if ! dpkg -l ogagent &>/dev/null && [ -f /var/tmp/$OGAGENTFILE ]; then apt-get update; apt-get install -y /var/tmp/$OGAGENTFILE; fi"
+ fi
+ if [ -e $MNTDIR/etc/redhat-release ]; then # RedHat-based
+ OGAGENTFILE="ogagent-${OGVERSION/pre/}-1.noarch.rpm"
+ CODE="if ! rpm -q ogagent &>/dev/null && [ -f /var/tmp/$OGAGENTFILE ]; then yum install -y /var/tmp/$OGAGENTFILE; fi"
+ fi
+ [ -n "$OGAGENTFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 ogagent" || exit $OG_ERR_NOTFOUND
+ TMPDIR="$MNTDIR/var/tmp"
+ if eval $DOWNLOAD "$TMPDIR/$OGAGENTFILE" "https://$(ogGetServerIp)/opengnsys/descargas/$OGAGENTFILE" 2>/dev/null; then
+ # Creating systemd script.
+ cat << EOT > $SYSTEMDDIR/systemd-launchogagent
+#!/bin/bash
+[ $EUID = 0 ] || exit 4
+start() {
+ $CODE
+ sed -i "0,/remote=/ s,remote=.*,remote=https://$(ogGetServerIp)/opengnsys/rest/," /usr/share/OGAgent/cfg/ogagent.cfg
+ service ogagent start
+}
+restart() {
+ service ogagent stop
+ if [ -f /var/tmp/$OGAGENTFILE ]; then
+ apt-get update
+ apt-get install -y --reinstall /var/tmp/$OGAGENTFILE
+ fi
+ sed -i "0,/remote=/ s,remote=.*,remote=https://$(ogGetServerIp)/opengnsys/rest/," /usr/share/OGAgent/cfg/ogagent.cfg
+ service ogagent start
+}
+
+case "\$1" in
+ start|restart) "\$1" ;;
+esac
+EOT
+ chmod +x $SYSTEMDDIR/systemd-launchogagent
+ # Creating systemd service.
+ cat << EOT > $SYSTEMDDIR/system/launchogagent.service
+[Unit]
+Description=Installing and configuring OGAgent
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/lib/systemd/systemd-launchogagent start
+TimeoutStartSec=5min
+
+[Install]
+WantedBy=multi-user.target
+EOT
+ ln -fs /lib/systemd/system/launchogagent.service \
+ ${SYSTEMDDIR/lib/etc}/system/multi-user.target.wants
+ echo "Scheduled OGAgent installation at next boot"
+ echo " (process will be executed in the background, do not shutdown until finish)."
+ else
+ ogRaiseError $OG_ERR_NOTFOUND "$1 $2 /var/tmp/$OGAGENTFILE"
+ exit $OG_ERR_NOTFOUND
+ fi
+ fi
+ ;;
+ MacOS) # OGAgent for macOS (TODO).
+ echo "OGAgent installer for macOS is not implemented yet."
+ ;;
+ *) # OS not detected or OGAgent not implemented.
+ ogRaiseError $OG_ERR_NOTOS "$1 $2"
+ exit $OG_ERR_NOTOS
+ ;;
+esac
+
diff --git a/client/shared/scripts/launchOgagentInstaller.py b/client/scripts/launchOgagentInstaller.py
similarity index 100%
rename from client/shared/scripts/launchOgagentInstaller.py
rename to client/scripts/launchOgagentInstaller.py
diff --git a/client/scripts/listHardwareInfo b/client/scripts/listHardwareInfo
new file mode 100755
index 0000000..34679a0
--- /dev/null
+++ b/client/scripts/listHardwareInfo
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Scirpt de ejemplo para almacenear en fichero temporal el listado de hardware.
+# Nota: se usa como base para el programa de recogida de listado de hardware de OpenGnsys Admin.
+# Formato: listHardwareInfo
+
+PROG=$(basename "$0")
+if [ $# -ne 0 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG "
+ exit $?
+fi
+
+# Directorio del servidor donde se exportan los ficheros de registro.
+SERVERLOGDIR=$(mount | awk -v d=$OGLOG '
+ BEGIN {FS="[: ]"}
+ {if ($4==d) dir=$2}
+ END {print dir}')
+
+# Fichero de listado: hard-IP
+HARDFILE="hard-$(ogGetIpAddress)"
+# Redirigir salida al fichero de listado.
+ogListHardwareInfo>$OGLOG/$HARDFILE || exit $?
+# Salida: camino del fichero de listado en el servidor de repositorio.
+#echo $SERVERLOGDIR/$HARDFILE
+echo $OGLOG/$HARDFILE
diff --git a/client/shared/scripts/listHardwareInfo.py b/client/scripts/listHardwareInfo.py
similarity index 100%
rename from client/shared/scripts/listHardwareInfo.py
rename to client/scripts/listHardwareInfo.py
diff --git a/client/scripts/listPartitions b/client/scripts/listPartitions
new file mode 100755
index 0000000..6f9c318
--- /dev/null
+++ b/client/scripts/listPartitions
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogListPartitions "$@" | sed 's/\(EMPTY:0 \)*$//'
+
diff --git a/client/shared/scripts/listPartitions.py b/client/scripts/listPartitions.py
similarity index 100%
rename from client/shared/scripts/listPartitions.py
rename to client/scripts/listPartitions.py
diff --git a/client/scripts/listPrimaryPartitions b/client/scripts/listPrimaryPartitions
new file mode 100755
index 0000000..d20dd76
--- /dev/null
+++ b/client/scripts/listPrimaryPartitions
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogListPrimaryPartitions "$@"
+
diff --git a/client/shared/scripts/listPrimaryPartitions.py b/client/scripts/listPrimaryPartitions.py
similarity index 100%
rename from client/shared/scripts/listPrimaryPartitions.py
rename to client/scripts/listPrimaryPartitions.py
diff --git a/client/scripts/listSoftwareInfo b/client/scripts/listSoftwareInfo
new file mode 100755
index 0000000..1b97294
--- /dev/null
+++ b/client/scripts/listSoftwareInfo
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Scirpt de ejemplo para almacenear en fichero temporal el listado de software.
+# Nota: se usa como base para el programa de recogida de listado de software de OpenGnsys Admin.
+# Formato: listSoftwareInfo [-r] ndisk npart
+# -r listado reducido (sin parches de Windows)
+
+PROG=$(basename "$0")
+REDUCED="no"
+if [ "$1" = "-r" ]; then
+ REDUCED="yes"
+ shift
+fi
+if [ $# -ne 2 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion"
+ exit $?
+fi
+
+# Directorio del servidor donde se exportan los ficheros de registro.
+SERVERLOGDIR=$(mount | awk -v d=$OGLOG '
+ BEGIN {FS="[: ]"}
+ {if ($4==d) dir=$2}
+ END {print dir}')
+
+# Fichero de listado: soft-IP-ndisco-npart
+SOFTFILE="soft-$(ogGetIpAddress)-$1-$2"
+# Redirigir salida al fichero de listado.
+if [ "$REDUCED" = "no" ]; then
+ ogListSoftware "$1" "$2" >$OGLOG/$SOFTFILE || exit $?
+else
+ ogListSoftware "$1" "$2" | egrep -v "\(KB[0-9]{6}\)" >$OGLOG/$SOFTFILE || exit $?
+fi
+# Salid: camino del fichero de listado en el servidor de repositorio.
+#echo $SERVERLOGDIR/$SOFTFILE
+echo $OGLOG/$SOFTFILE
+
diff --git a/client/shared/scripts/listSoftwareInfo.py b/client/scripts/listSoftwareInfo.py
similarity index 100%
rename from client/shared/scripts/listSoftwareInfo.py
rename to client/scripts/listSoftwareInfo.py
diff --git a/client/scripts/menuBrowser b/client/scripts/menuBrowser
new file mode 100755
index 0000000..f544215
--- /dev/null
+++ b/client/scripts/menuBrowser
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Scirpt de ejemplo para iniciar el browser del cliente con un menú predefinido
+
+PROG=$(basename "$0")
+if [ $# -ne 1 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG urlmenu"
+ exit $?
+fi
+
+url="$1"
+browser -qws $url
diff --git a/client/shared/scripts/menuBrowser.py b/client/scripts/menuBrowser.py
similarity index 100%
rename from client/shared/scripts/menuBrowser.py
rename to client/scripts/menuBrowser.py
diff --git a/client/scripts/poweroff b/client/scripts/poweroff
new file mode 100755
index 0000000..4233058
--- /dev/null
+++ b/client/scripts/poweroff
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Scirpt de ejemplo para apagar un ordenador
+# Nota: se usa como base para el programa de apagado de OpenGnsys Admin.
+
+
+# Registrar ejecución manual de script.
+case "$(ogGetCaller)" in
+ browser|bash) ogEcho log info "Script: $0" ;;
+esac
+
+# No registrar errores.
+export DEBUG="no"
+
+# Desmontar los sistemas de archivos y la caché local.
+echo "[10] Desmontar todos los sistemas de archivos."
+sync
+for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do
+ ogUnmountAll $i &>/dev/null
+done
+echo "[50] Desmontar cache local."
+ogUnmountCache &>/dev/null
+
+# Volver a registrar errores.
+unset DEBUG
+
+echo "[70] Apagando el equipo."
+# Estado correcto de Wake-On-Lan antes de apagar.
+ethtool -s $DEVICE wol g 2>/dev/null
+# Detectar Busybox.
+BUSYBOX=$(which busyboxOLD)
+BUSYBOX=${BUSYBOX:-"busybox"}
+
+# Retardo para dar lugar al registro en cola de acciones.
+sleep 5
+# Parar Browser para evitar "cuelgues".
+[ "$ogstatus" == "offline" ] || pkill browser
+# Apagar.
+$BUSYBOX poweroff
+
diff --git a/client/scripts/reboot b/client/scripts/reboot
new file mode 100755
index 0000000..689da67
--- /dev/null
+++ b/client/scripts/reboot
@@ -0,0 +1,54 @@
+#!/bin/bash
+# Script de ejemplo para reiniciar un ordenador
+# Nota: se usa como base para el programa de reinicio de OpenGnsys Admin.
+
+
+# Registrar ejecución manual de script.
+case "$(ogGetCaller)" in
+ browser|bash) ogEcho log info "Script: $0" ;;
+esac
+
+# Cargamos el valor por defecto del tiempo de sleep
+[ -z $OGSLEEP ] && source /opt/opengnsys/etc/engine.cfg
+
+# Si se recibe un parametro sera el tiempo de sleep antes de realizar el reboot
+if [ $# == 1 ] && [ "${1//[^0-9]/}" == "$1" ]
+then
+ TIME=$1
+ echo "[5] Se ha introducido un retardo de $TIME segundos para reiniciar"
+else
+ # Sin parámetros, o el parámetro introducido no es un número
+ TIME=${OGSLEEP:-5}
+ echo "[5] No se ha introducido un retardo, $TIME segundos para reiniciar"
+fi
+
+# No registrar errores.
+export DEBUG="no"
+
+# Desmontar los sistemas de archivos y la caché local.
+echo "[10] Desmontar todos los sistemas de archivos."
+sync
+for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do
+ ogUnmountAll $i &>/dev/null
+done
+echo "[50] Desmontar cache local."
+ogUnmountCache &>/dev/null
+
+# Volver a registrar errores.
+unset DEBUG
+
+echo "[90] Reiniciar el equipo."
+# Estado correcto de Wake-On-Lan antes de reiniciar.
+ethtool -s $DEVICE wol g 2>/dev/null
+# Detectar Busybox.
+BUSYBOX=$(which busyboxOLD)
+BUSYBOX=${BUSYBOX:-"busybox"}
+
+# Retardo para dar lugar al registro en cola de acciones.
+sleep $TIME
+# Parar Browser para evitar "cuelgues".
+[ "$ogstatus" == "offline" ] || pkill browser
+# Reiniciar.
+$BUSYBOX reboot
+
+
diff --git a/client/scripts/remoteConsole b/client/scripts/remoteConsole
new file mode 100755
index 0000000..dc0fc4b
--- /dev/null
+++ b/client/scripts/remoteConsole
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Script de ejemplo para enviar eco a la consola remota al ejecutar un comando de la shell
+# Formato: remoteConsole
+
+PROG="$(basename $0)"
+if [ $# -ne 0 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG "
+ exit $?
+fi
+
+# Directorio del servidor donde se exportan los ficheros de registro.
+SERVERLOGDIR=$(mount | awk -v d=$OGLOG '
+ BEGIN {FS="[: ]"}
+ {if ($4==d) dir=$2}
+ END {print dir}')
+
+# Fichero de listado: hard-IP
+ECOFILE="eco-$(ogGetIpAddress)"
+# Redirigir salida al fichero de listado.
+/tmp/_hidrascript_ >$OGLOG/$ECOFILE || exit $?
+# Salida: camino del fichero de listado en el servidor de repositorio.
+echo $SERVERLOGDIR/$ECOFILE
diff --git a/client/scripts/restoreImage b/client/scripts/restoreImage
new file mode 100755
index 0000000..d9e7f58
--- /dev/null
+++ b/client/scripts/restoreImage
@@ -0,0 +1,106 @@
+#!/bin/bash
+#/**
+#@file restoreImage
+#@brief Script de ejemplo para restaurar una imagen.
+#@param $1 Repositorio (CACHE, REPO o dirección IP)
+#@param $2 Nombre canónico de la imagen (sin extensión)
+#@param $3 Número de disco
+#@param $4 Número de particion
+#@param $5 Protocolo (UNICAST, UNICAST-DIRECT, MULTICAST o MULTICAST-DIRECT)
+#@param $6 Opciones del protocolo
+#@exception OG_ERR_FORMAT 1 formato incorrecto.
+#@exception OG_ERR_NOTFOUND 2 cambio de repositorio: repositorio no encontrado
+#@exception OG_ERR_NOTFOUND 2 fichero de imagen o partición no detectados.
+#@exception $OG_ERR_MCASTRECEIVERFILE 57 Error en la recepción Multicast de un fichero
+#@exception $OG_ERR_PROTOCOLJOINMASTER 60 Error en la conexión de una sesión Unicast|Multicast con el Master
+#@version 1.1 - Cambio de repositorio para el recurso remoto images si es necesario
+#@author Irina Gomez, ETSII Universidad de Sevilla
+#@date 2015-06-16
+#@version 1.1 - Control de errores en transferencia multicast (ticket #781)
+#@author Irina Gomez, ETSII Universidad de Sevilla
+#@date 2017/04/20
+#**/
+
+TIME1=$SECONDS
+PROG="$(basename $0)"
+if [ $# -lt 4 ]; then
+ ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones protocolo]"
+ exit $?
+fi
+
+#Load engine configurator from engine.cfg file.
+#Carga el configurador del engine desde el fichero engine.cfg
+# Valores por defecto: #IMGPROG="partclone" ; #IMGCOMP="lzop" ; #IMGEXT="img" #IMGREDUCE="TRUE"
+[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
+
+# Clear temporary file used as log track by httpdlog
+# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
+echo " " > $OGLOGCOMMAND
+ogCheckStringInGroup "$(ogGetCaller)" "deployImage restoreImageCustom" || echo -n "" > $OGLOGSESSION;
+
+ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
+
+# Procesar parámetros de entrada
+REPO="${1^^}"
+IMGNAME="$2"
+DISK="$3"
+PART="$4"
+PROTO="${5^^}"
+PROTO=${PROTO:-"UNICAST"}
+PROTOOPT="$6"
+# Si MCASTWAIT menos que tiempo de espera del servidor lo aumento
+if [ "${PROTO%-*}" == "MULTICAST" ] && [[ ${PROTOOPT##*:} =~ ^-?[0-9]+$ ]]; then
+ [ ${MCASTWAIT:-0} -lt ${PROTOOPT##*:} ] && let MCASTWAIT=${PROTOOPT##*:}+5
+fi
+IMGTYPE="${IMGTYPE:-"img"}"
+
+# Unidad organizativa
+[ "$ogunit" != "" ] && OGUNIT="$ogunit/"
+
+# Si es una ip y es igual a la del equipo restaura desde cache
+[ "$REPO" == "$(ogGetIpAddress)" ] && REPO="CACHE"
+# Si es una ip y es distinta a la del recurso samba cambiamos de REPO.
+ogCheckIpAddress $REPO
+if [ $? == 0 -o $REPO == "REPO" ] ; then
+ # Si falla el cambio -> salimos con error repositorio no valido
+ ogChangeRepo $REPO ${OGUNIT%/} || exit $(ogRaiseError $OG_ERR_NOTFOUND '$REPO $OGUNIT'; echo $?)
+ REPO="REPO"
+fi
+
+# Comprobar que existe la imagen del origen.
+IMGFILE=$(ogGetPath "$REPO" "$IMGNAME.$IMGTYPE")
+IMGDIR=$(ogGetParentPath "$REPO" "$IMGNAME")
+if [ "$IMGFILE" == "" -o "$IMGDIR" == "" ]; then
+ ogRaiseError session $OG_ERR_NOTFOUND "$REPO, ${IMGNAME%/*}"
+ exit $?
+fi
+
+# Procesar protocolos de transferencia.
+case "$PROTO" in
+ UNICAST|UNICAST-DIRECT)
+ # Restaurar la imagen.
+ ogEcho log session "[40] ogRestoreImage $REPO $IMGNAME $DISK $PART UNICAST"
+ ogExecAndLog command ogRestoreImage "$REPO" "$IMGNAME" "$DISK" "$PART"
+ RETVAL=$?
+ ;;
+ MULTICAST|MULTICAST-DIRECT)
+ PORT=$(echo $PROTOOPT | cut -f1 -d":")
+ TOOL=$(ogGetImageProgram REPO $IMGNAME)
+ COMPRESS=$(ogGetImageCompressor REPO $IMGNAME)
+ #TODO comprobar parametros anteriores
+ ogEcho log session "[40] ogMcastReceiverPartition $DISK $PART $PORT $TOOL $COMPRESS"
+ ogMcastRequest "$IMGNAME.img" "$PROTOOPT" || exit $?
+ ogExecAndLog command ogMcastReceiverPartition "$DISK" "$PART" "$PORT" "$TOOL" "$COMPRESS"
+ RETVAL=$?
+ ;;
+ *) # Protocolo desconocido.
+ ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO|CACHE imagen ndisco nparticion [ UNICAST|MULTICAST opciones ]"
+ exit $?
+esac
+
+TIME=$[SECONDS-TIME1]
+ogEcho log session "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
+
+# Código de salida del comando prinicpal de restauración.
+exit $RETVAL
+
diff --git a/client/shared/scripts/restoreImage.py b/client/scripts/restoreImage.py
similarity index 100%
rename from client/shared/scripts/restoreImage.py
rename to client/scripts/restoreImage.py
diff --git a/client/scripts/restoreImageCustom.template b/client/scripts/restoreImageCustom.template
new file mode 100644
index 0000000..bb94ad1
--- /dev/null
+++ b/client/scripts/restoreImageCustom.template
@@ -0,0 +1,37 @@
+#!/bin/bash
+#/**
+# restoreImageCustom
+#@brief Plantilla para scirpt de rastauración personalizada de imagen.
+#@param $1 nº de disco
+#@param $2 nº de partición
+#@param $3 Repositorio: CACHE, REPO o dirección IP
+#@param $4 Nombre canónico de la imagen sin extensión
+#@warning Renombrar este fichero como "restoreImageCustom" para sustituir al script estándar "restoreImage".
+#**/
+
+
+# Control de parámetros.
+[ $# -ge 4 -a $# -le 6 ] || ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: restoreImageCustom str_repo str_imagen int_ndisco int_npart [ str_proto [\"str_opciones\"] ]" || exit $?
+
+# Toma de parámetros.
+REPO="${1^^}" # Repositorio (en mayúsculas).
+IMGNAME="$2" # Nombre canónico de imagen (sin extensión).
+DISK="$3" # Nº de disco.
+PART="$4" # Nº de partición.
+PROTO="${5^^}" # Protocolo de comunicaciones (por defecto, UNICAST).
+PROTO=${PROTO:-"UNICAST"}
+PROTOOPT="$6" # Opciones del protocolo separadas por ":" (opcional).
+
+
+# Paso 0: Añadir código para realizar control de errores de los parámetros de entrada (recomendado).
+
+
+# Paso 1: Añadir aquí el código para el proceso previo antes de la restauración de la imagen en los equipos (opcional).
+
+
+# Paso 2: Sustituir, si se desea, la llamada al proceso estándar de restauración de imagen por código personalizado.
+restoreImage "$@"
+
+
+# Aviso: editar la plantilla "configureOsCustom" para añadir el código personalizado para el proceso de postconfiguración de los clientes (no incluir aquí dicho código).
+
diff --git a/client/shared/scripts/restoreImageCustomTemplate.py b/client/scripts/restoreImageCustomTemplate.py
similarity index 100%
rename from client/shared/scripts/restoreImageCustomTemplate.py
rename to client/scripts/restoreImageCustomTemplate.py
diff --git a/client/scripts/runAplicationX.sh b/client/scripts/runAplicationX.sh
new file mode 100755
index 0000000..85f9681
--- /dev/null
+++ b/client/scripts/runAplicationX.sh
@@ -0,0 +1,8 @@
+#/bin/bash
+/usr/X11R6/bin/Xvesa :0 -ac -shadow -screen 1024x768x24 -br -mouse /dev/input/mice &
+/bin/sleep 0.1
+export DISPLAY=:0
+#/usr/bin/lxde-logout
+#/usr/bin/openbox
+/usr/bin/roxterm
+#/usr/sbin/gparted
diff --git a/client/shared/scripts/runApplicationX.py b/client/scripts/runApplicationX.py
similarity index 100%
rename from client/shared/scripts/runApplicationX.py
rename to client/scripts/runApplicationX.py
diff --git a/client/shared/scripts/runhttplog.py b/client/scripts/runhttplog.py
similarity index 100%
rename from client/shared/scripts/runhttplog.py
rename to client/scripts/runhttplog.py
diff --git a/client/scripts/runhttplog.sh b/client/scripts/runhttplog.sh
new file mode 100755
index 0000000..f0f854b
--- /dev/null
+++ b/client/scripts/runhttplog.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+#httd-log-status
+cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.back
+cp /opt/opengnsys/lib/httpd/lighttpd.conf /etc/lighttpd/
+cp /etc/lighttpd/conf-enabled/10-cgi.conf /etc/lighttpd/conf-enabled/10-cgi.conf.back
+cp /opt/opengnsys/lib/httpd/10-cgi.conf /etc/lighttpd/conf-enabled/
+/etc/init.d/lighttpd start
+chmod 755 /opt
+mkdir -p /usr/lib/cgi-bin
+cp /opt/opengnsys/lib/httpd/* /usr/lib/cgi-bin
+#TODO:
+dstat -dn 10 > /tmp/bandwidth &
+echo "WAITING" >> $OGLOGSESSION
+# http-log-status
diff --git a/client/scripts/samples/configureGroup b/client/scripts/samples/configureGroup
new file mode 100755
index 0000000..6563843
--- /dev/null
+++ b/client/scripts/samples/configureGroup
@@ -0,0 +1,65 @@
+#!/bin/bash
+#/**
+#@file configureGroup
+#@brief Script de ejemplo de post-configuracion del sistema operativo especifica de cada grupo de ordenadores.
+#@brief El directorio del grupo en el repositorio se situa en /opt/opengnsys/groups/Nombre_Grupo
+#@brief Se ponen archivos o marcas dentro del directorio del grupo (si queremos que afecte a todas las imagenes)
+#@brief o del subdirectorio de la imagen dentro del grupo. Los archivos se copian en el sitio correcto del sistema
+#@brief y las marcas se comprueba que existen para inicar una accion (ej: cambiar registro)
+#@param str_repo repositorio de imágenes (remoto o caché local)
+#@param path_image camino de la imagen (sin extensión)
+#@param int_ndisk nº de orden del disco
+#@param int_npartition nº de orden de la particion
+#@return
+#@exception OG_ERR_FORMAT Formato incorrecto.
+#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
+#@warning License: GNU GPLv3+
+#*/
+
+# Si se solicita, mostrar ayuda.
+if [ "$*" == "help" ]; then
+ ogHelp "$0" "$0 path_dir str_image int_ndisk int_npart" \
+ "$0 REPO /aula1/winxp 1 1"
+ exit
+fi
+
+# Error si no se reciben 4 parámetros.
+[ $# -eq 4 ] || ogRaiseError $OG_ERR_FORMAT || exit $?
+
+# Procesar parámetros.
+PART=$(ogMount $3 $4) || ogRaiseError $OG_ERR_PARTITION "$3 $4" || exit $?
+IMGNAME=$(basename $2)
+GROUPDIR=$(ogGetGroupDir)
+IMGDIR=$GROUPDIR/$IMGNAME
+
+# Comprobamos que exista GROUPDIR. Si no existe no es error, nada que configurar
+[ ! -x "$GROUPDIR" ] && exit 0
+
+
+TYPE=$(ogGetOsVersion $3 $4)
+
+case "$TYPE" in
+ Linux*) echo "PostConfiguracion de Linux para el grupo $group"
+ # Si existen estos ficheros en el directorio del grupo o de la imagen se copian a la particion
+ [ -e $IMGDIR/menu.lst ] && echo "cp -f $IMGDIR/menu.lst $PART/boot/grub/menu.lst" && cp -f $IMGDIR/menu.lst $PART/boot/grub/menu.lst
+ [ -e $IMGDIR/grub.cfg ] && echo "cp $IMGDIR/grub.cfg $PART/boot/grub/grub.cfg" && cp -f $IMGDIR/grub.cfg $PART/boot/grub/grub.cfg
+ [ -e $IMGDIR/hosts ] && echo "cp -f $IMGDIR/hosts $PART/etc/hosts" && cp -f $IMGDIR/hosts $PART/etc/hosts
+ [ -e $IMGDIR/fstab ] && echo "cp -f $IMGDIR/fstab $PART/etc/fstab" && cp -f $IMGDIR/fstab $PART/etc/fstab
+ [ -e $IMGDIR/xorg.conf ] && echo "cp -f $IMGDIR/xorg.conf $PART/etc/X11/xorg.conf" && cp -f $IMGDIR/xorg.conf $PART/etc/X11/xorg.conf
+ [ -e $IMGDIR/rc.local ] && echo "cp -f $IMGDIR/rc.local $PART/etc/rc.local" && cp -f $IMGDIR/rc.local $PART/etc/rc.local
+ [ -e $IMGDIR/interfaces ] && echo "cp -f $IMGDIR/interfaces $PART/etc/network/interfaces" && cp -f $IMGDIR/interfaces $PART/etc/network/interfaces
+ [ -e $IMGDIR/passwd ] && echo "cp -f $IMGDIR/passwd $PART/etc/passwd" && cp -f $IMGDIR/passwd $PART/etc/passwd
+ ;;
+
+ *Windows\ XP) echo "PostConfiguracion de XP para el grupo $group"
+ # Si existen estos ficheros en el directorio del grupo o de la imagen se copian a la particion
+ [ -e $IMGDIR/SAM ] && echo "cp -f $IMGDIR/SAM $PART/Windows/System32/config/SAM" && cp -f $IMGDIR/SAM $PART/Windows/System32/config/SAM
+ ;;
+ *Windows\ 7*) echo "Postconfiguracion de W7 para el grupo $group"
+ # Si existen estos ficheros en el directorio del grupo o de la imagen se copian a la particion
+ [ -e $IMGDIR/SAM ] && echo "cp -f $IMGDIR/SAM $PART/Windows/System32/config/SAM" && cp -f $IMGDIR/SAM $PART/Windows/System32/config/SAM
+ ;;
+ *) exit 0
+ ;;
+ esac
+
diff --git a/client/scripts/samples/firstRunOnceWindows b/client/scripts/samples/firstRunOnceWindows
new file mode 100644
index 0000000..00a6e07
--- /dev/null
+++ b/client/scripts/samples/firstRunOnceWindows
@@ -0,0 +1,68 @@
+#!/bin/bash
+#/**
+#@file FirstRunOnceWindows
+#@brief Guión de rutinas que se ejecutarán en los windows con teclado y raton desactivados.
+#@param $1 número de disco
+#@param $2 número de particion
+#@exception OG_ERR_FORMAT 1 formato incorrecto.
+#@exception OG_ERR_NOTFOUND 2 fichero de imagen o partición no detectados.
+#@exception OG_ERR_PARTITION 3 # Error en partición de disco.
+#@exception OG_ERR_LOCKED 4 partición bloqueada por otra operación.
+#@version 1.0.1 - primera version: desactivar/activar ratón y teclado
+#@author Antonio J. Doblas Viso.
+#@date 2017-02-23
+#**/
+
+
+
+PROG="$(basename $0)"
+if [ $# -lt 2 ]; then
+ ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion"
+ exit $?
+fi
+
+
+# Asignación de variables
+## Bloque de variables de parámetros
+DISK=$1
+PART=$2
+POSTCONF=postconf.cmd
+### Bloque de variables basada en un archivo de claves: ADMIN PASSADMIN USER PASSUSER
+source $OGETC/os.cfg $DISK $PART
+
+
+
+OSVERSION=$(ogGetOsVersion $1 $2)
+case "$OSVERSION" in
+ *Windows*)
+ # Desactivamos el telcado y el ratón
+ ogSetRegistryValue $(ogMount $DISK $PART) SYSTEM '\ControlSet001\Services\kbdclass\Start' 4
+ ogSetRegistryValue $(ogMount $DISK $PART) SYSTEM '\ControlSet001\Services\mouclass\Start' 4
+
+ ## Indicación del proceso (variable $POSTCONF), usuario que lo ejecutará ($ADMIN) y configuración del windows para que arranque con autologin tras la postconfiguración (1 "$USER" "$PASSUSER")
+ echo "ogInstallMiniSetup $DISK $PART $POSTCONF $ADMIN $PASSADMIN 1 \"$USER\" \"$PASSUSER\" "
+ ogInstallMiniSetup $DISK $PART $POSTCONF $ADMIN $PASSADMIN 1 "$USER" "$PASSUSER"
+ ogAddCmd $DISK $PART $POSTCONF '@echo off'
+ ogAddCmd $DISK $PART $POSTCONF 'start "C:\Program Files\Internet Explorer\iexplore.exe" wwww.opengnsys.es'
+ ogAddCmd $DISK $PART $POSTCONF "timeout /t 200 /NOBREAK"
+ ogAddCmd $DISK $PART $POSTCONF "shutdown -r -t 300"
+ ogAddCmd $DISK $PART $POSTCONF 'start winword.exe'
+ ogAddCmd $DISK $PART $POSTCONF 'taskkill /F /IM winword.exe'
+ ogAddCmd $DISK $PART $POSTCONF 'REG ADD HKLM\SYSTEM\CurrentControlSet\Services\kbdclass\ /v Start /t REG_DWORD /d 3 /f'
+ ogAddCmd $DISK $PART $POSTCONF 'REG ADD HKLM\SYSTEM\CurrentControlSet\Services\mouclass\ /v Start /t REG_DWORD /d 3 /f'
+ ogAddCmd $DISK $PART $POSTCONF 'REG ADD HKLM\SYSTEM\ControlSet001\Services\kbdclass\ /v Start /t REG_DWORD /d 3 /f'
+ ogAddCmd $DISK $PART $POSTCONF 'REG ADD HKLM\SYSTEM\ControlSet001\Services\mouclass\ /v Start /t REG_DWORD /d 3 /f'
+ #ogAddCmd $DISK $PART $POSTCONF '"c:\Program Files\Toolwiz Time Freeze 2017\ToolwizTimeFreeze.exe" /freezealways /usepass='
+ #ogAddCmd $DISK $PART $POSTCONF 'reg query "HKCU\SOFTWARE\Toolwiz\TimefreezeNew"'
+
+ #ogAddCmd $DISK $PART $POSTCONF "cscript \"c:\Archivo de Programas (x86)\agua\aguac\scripts\MSOfficeActivate.vbs\" "
+ #ogAddCmd $DISK $PART $POSTCONF "del \"c:\Program Files (x86)\agua\aguac\scripts\MSWinActivate.vbs\" "
+ #unix2dos /mnt/sda1/Windows/System32/postconf.cmd
+
+ ### reiniciamos el equipo
+ ogAddCmd $DISK $PART $POSTCONF "shutdown -r"
+ ### consultamos
+ cat $(ogMount $DISK $PART)/Windows/System32/$POSTCONF
+
+ ;;
+esac
diff --git a/client/scripts/samples/smartPartition b/client/scripts/samples/smartPartition
new file mode 100644
index 0000000..568ed32
--- /dev/null
+++ b/client/scripts/samples/smartPartition
@@ -0,0 +1,62 @@
+#!/bin/bash
+#/**
+# smartPartition.template
+#@brief particiona los clientes del laboratorio virtual.
+#@param 1
+#@ejemplo:
+#@return: Scripts de ejemplo para establecer particionado según tamaño.
+#@exception OG_ERR_ NOTFOUND Disco duro no encontrador.
+#@note
+#@todo:
+#@version 0.1 primera version
+#@author adv
+#@date 2018/07/08
+
+#Calculamos el numero de discos
+NDISK=$(ogDiskToDev | wc -w)
+
+#Si no hay discos, error
+[ -z $NDISK ] && exit $(ogRaiseError $OG_ERR_NOTFOUND "ogDiskToDev | wc -w")
+
+#asignamos contador al primer disco de OpenGnsys
+COUNTER=1
+until [ $COUNTER -gt $NDISK ]; do
+ ogUnmountAll $COUNTER
+ ogDeletePartitionTable $COUNTER
+ ogCreatePartitionTable $COUNTER MSDOS
+ ogUpdatePartitionTable $COUNTER
+ let COUNTER=COUNTER+1
+done
+
+#Establecemos las Particiones CACHE con tamaños diferentes según la capacidad del disco.
+#Si el PC tiene dos discos duros, el segundo será completo para la CACHE.
+#establecemos rangos de las capacidades con expresiones regulares: https://goo.gl/gJnK7g
+case $NDISK in
+ 1)
+ #Calcular el tamaño máximo del disco duro redondeando a la baja en 500 MB para evitar problemas de calculo"
+ SIZE_DISK1=$(expr $(ogGetDiskSize 1) - 500000)
+ #entre 70 y 73'9GB
+ ogCheckStringInReg $SIZE_DISK1 "^7[0-3][0-9]{6}$" && initCache 1 4 32000000 NOMOUNT
+ #entre 50 y 52'9
+ ogCheckStringInReg $SIZE_DISK1 "^5[0-2][0-9]{6}$" && initCache 1 4 12000000 NOMOUNT
+ ;;
+ 2)
+ #Calcular el tamaño máximo del disco duro redondeando a la baja en 500 MB para evitar problemas de calculo"
+ SIZE_DISK2=$(expr $(ogGetDiskSize 1) - 500000)
+ initCache 2 4 $SIZE_DISK2 NOMOUNT
+ ;;
+esac
+
+#El particionado para los sistemas operativos identicos para todos.
+#Requiere tener una tabla de particiones previa.
+ogCreatePartitions 1 NTFS:19000000 LINUX:19000000 EMPTY:0;
+
+#asignamos contador al primer disco de OpenGnsys
+COUNTER=1
+until [ $COUNTER -gt $NDISK ]; do
+ ogBootMbrGeneric $COUNTER
+ ogSetPartitionActive 1 $COUNTER
+ ogListPartitions $COUNTER
+ ogGetPartitionActive $COUNTER
+ let COUNTER=COUNTER+1
+done
diff --git a/client/scripts/sendFileMcast b/client/scripts/sendFileMcast
new file mode 100755
index 0000000..54e82ac
--- /dev/null
+++ b/client/scripts/sendFileMcast
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+
+
+#Este scripts llama directamente a la función ogMcastSendFile $1 $2
+#1 path absoluto del fichero.
+#2 la session multicast.
+# ogMcastSendFile [ str_repo | int_ndisk int_npart ] /Relative_path_file sessionMulticast
+#@brief Envía un fichero por multicast ORIGEN(fichero) DESTINO(sessionmulticast)
+#@param (2 parámetros) $1 path_aboluto_fichero $2 sesionMcast
+
+
+
+export OPENGNSYS="${OPENGNSYS:-/opt/opengnsys/client}"
+ export OGBIN=$OPENGNSYS/bin
+ export OGETC=$OPENGNSYS/etc
+ export OGLIB=$OPENGNSYS/lib
+ export OGAPI=$OGLIB/engine/bin
+ export OGSCRIPTS=$OPENGNSYS/scripts
+ export OGIMG=$OPENGNSYS/images
+ export OGCAC=$OPENGNSYS/cache
+ export OGLOG=$OPENGNSYS/log
+
+ for i in $OGAPI/*.lib; do
+ . $i
+ done
+
+ if [ "$engine" = "testing" ]
+ then
+ for i in $OGAPI/*.testing; do
+ . $i
+ done
+ fi
+
+export PATH=$PATH:/opt/opengnsys/bin
+
+export OG_ERR_FORMAT=1 # Formato de ejecución incorrecto.
+export OG_ERR_NOTFOUND=2 # Fichero o dispositivo no encontrado.
+export OG_ERR_PARTITION=3 # Error en partición de disco.
+export OG_ERR_LOCKED=4 # Partición o fichero bloqueado.
+export OG_ERR_IMAGE=5 # Error al crear o restaurar una imagen.
+export OG_ERR_NOTOS=6 # Sin sistema operativo.
+export OG_ERR_NOTEXEC=7 # Programa o función no ejecutable.
+
+
+
+# Si se solicita, mostrar ayuda.
+if [ "$*" == "help" ]; then
+ ogHelp "sendFileMcast /absolute_path_file sesionMcast" \
+ "sendFileMcast /opt/opengnsys/images/aula1/hd500.vmx 9000:full-duplex:239.194.17.2:70M:20:300"
+ exit 0
+fi
+
+# los demas errores controlados por la funcion ogMcastSendFile
+
+ogMcastSendFile $1 $2
diff --git a/client/scripts/setBootMode b/client/scripts/setBootMode
new file mode 100755
index 0000000..81eec28
--- /dev/null
+++ b/client/scripts/setBootMode
@@ -0,0 +1,47 @@
+#!/bin/bash
+# #/**
+# setBootMode
+#@brief Script to configure the PXE mode to client
+#@param 1 template
+#@date 2012-02-2-9
+#@version 1.0.1 - Recoge como parametro el nombre interno de la plantilla en vez del nombre de fichero para que funcione correctamente al llamar a setclientmode y anade un nuevo parametro de modo de trabajo (0 o 1) que indica que el cambio del fichero PXE del servidor sera temporal o permanente
+#@author Juan Carlos Garcia - Univ. Zaragoza
+#@date 2015-11-17
+#*/ ##
+
+#REPOIP="$(ogGetRepoIp)"
+
+# Asignamos la IP del servidor de administracion que es el destino del script
+SERVERIP="$(ogGetServerIp)"
+PORT=2011
+TEMPLATE=$(grep -l "^#.* $1 *$" /opt/oglive/tftpboot/menu.lst/templates/*)
+PCNAME="$(hostname)"
+
+PROG="$(basename $0)"
+if [ "$*" == "help" ]; then
+ ogHelp "$PROG" "$PROG template [ 0 | 1 ] (0 - Temporary 1, - Permanent) " \
+ "$PROG ogLive 1" \
+ "$PROG 1hd-1partition 0"
+ exit
+fi
+
+
+# Control básico de errores.
+if [ $# -ne 2 ]; then
+ ogRaiseError $OG_ERR_FORMAT "$MSG_ERR_FORMAT: $PROG TEMPLATE_NAME [ 0 | 1 ] (0 - Temporary, 1 - Permanent)"
+ exit $?
+fi
+
+if [ -z "$TEMPLATE" ]; then
+ ogRaiseError $OG_ERR_NOTFOUND "$MSG_ERR_NOTFOUND: $1"
+ exit $?
+fi
+
+if [ $2 != "0" ] && [ $2 != "1" ]; then
+ ogRaiseError $OG_ERR_NOTFOUND "$MSG_ERR_FORMAT: modo $2 no existe"
+ exit $?
+fi
+# Crea un pipe con el servidor de administracion que llama a setclientmode pasandole los parametros de nombre de plantilla, nombre PC y modo de trabajo (0 o 1)
+hose $SERVERIP $PORT --out sh -c "echo -ne SET_CLIENTMODE $1 $PCNAME $2"
+
+
diff --git a/client/scripts/updateBootCache b/client/scripts/updateBootCache
new file mode 100755
index 0000000..f2e4e72
--- /dev/null
+++ b/client/scripts/updateBootCache
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+#/**
+# updateBootCache
+#@brief acelerador arranque pxe. incorpora a la cache el initrd y el kernel.
+#@param 1
+#@param ejemplo:
+#@return
+#@exception OG_ERR_NOTCACHE # 15 si cache no existe 15
+#@exception OG_ERR_NOTFOUND=2 # Fichero o dispositivo no encontrado.
+#@note
+#@todo:
+#@version 1.0.1 - requiere el gestor de arranque grub2dos
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2010/07/27
+#@version 1.1.0 - Permite varios ogLive dentro de subdirectorios
+#@author Irina Gómez. ETSII Universidad de Sevilla
+#@date 2017/04/27
+#@version 1.1.0 - Se permite varios ogLives en la CACHE
+#@author Antonio J. Doblas Viso. Universidad de Malaga
+#@date 2017/05/31
+#@version 1.1.0 - Limpieza de codigo, control errores
+#@author Antonio J. Doblas Viso. Universidad de Malaga
+#@date 2018-01-21
+#*/ ##
+
+OGLIVEDIR=${oglivedir:-"ogLive"}
+OGBTFTP="/opt/oglive/tftpboot/$OGLIVEDIR"
+OGBCACHE="$OGCAC/boot/$OGLIVEDIR"
+
+#control de errores
+[ -d "$OGBTFTP" ] || exit $(ogRaiseError $OG_ERR_NOTFOUND "$OGBTFTP"; echo $?)
+ogMountCache || exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?)
+
+[ -d $OGBCACHE ] || mkdir -p $OGBCACHE
+
+ # comparamos los del server
+ SERVERVMLINUZ=`cat ${OGBTFTP}/ogvmlinuz.sum 2>/dev/null`
+ SERVERINITRD=`cat ${OGBTFTP}/oginitrd.img.sum 2>/dev/null`
+
+ #comparamos los de la cache
+ CACHEVMLINUZ=`cat ${OGBCACHE}/ogvmlinuz.sum 2>/dev/null`
+ CACHEINITRD=`cat ${OGBCACHE}/oginitrd.img.sum 2>/dev/null`
+
+ echo "MD5 on SERVER: $SERVERVMLINUZ $SERVERINITRD"
+ echo "MD5 on CACHE: $CACHEVMLINUZ $CACHEINITRD"
+
+
+ if [ "$CACHEVMLINUZ" != "$SERVERVMLINUZ" ]
+ then
+ echo "ogvmlinuz updating"
+ cp "${OGBTFTP}/ogvmlinuz" "${OGBCACHE}/ogvmlinuz"
+ cp "${OGBTFTP}/ogvmlinuz.sum" "${OGBCACHE}/ogvmlinuz.sum"
+ DOREBOOT=true
+ fi
+ if [ "$CACHEINITRD" != "$SERVERINITRD" ]
+ then
+ echo "oginitrd updating"
+ cp "${OGBTFTP}/oginitrd.img" "${OGBCACHE}/oginitrd.img"
+ cp "${OGBTFTP}/oginitrd.img.sum" "${OGBCACHE}/oginitrd.img.sum"
+ DOREBOOT=true
+ fi
+
+echo $DOREBOOT
+# [ "$DOREBOOT" == "true" ] && busybox reboot -f
diff --git a/client/shared/scripts/updateBootCache.py b/client/scripts/updateBootCache.py
similarity index 100%
rename from client/shared/scripts/updateBootCache.py
rename to client/scripts/updateBootCache.py
diff --git a/client/scripts/updateCache b/client/scripts/updateCache
new file mode 100755
index 0000000..f1d64ad
--- /dev/null
+++ b/client/scripts/updateCache
@@ -0,0 +1,315 @@
+#!/bin/bash
+#/**
+# updateCache
+#@brief Actualiza la cache del cliente con imagen o fichero iso.
+#@param 1 REPO Origen del fichero. -accesible por nfs-samba-
+#@param 2 str_fichero nombre del fichero a actualizar.
+#@param 3 str_protoco. TORRENT | MULTICAST | UNICAST.
+#@param 4 str_opcionesprotocolo
+#@param 4 str_opcionesupdatecache
+#@ejemplo: oneRemoteFromMaster 172.17.36.11 CACHE /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop
+#@return
+#@exception OG_ERR_FORMAT formato incorrecto.
+#@exception OG_ERR_NOTCACHE No existe cache -15-
+#@exception $OG_ERR_CACHESIZE Tamaño de la paticion menor al archivo a descargar -16-
+#@exception $OG_ERR_MCASTRECEIVERFILE Error en la recepción Multicast de un fichero -57-
+#@exception $OG_ERR_PROTOCOLJOINMASTER Error en la conexión de una sesión Unicast|Multicast con el Master -60-
+#@note
+#@todo:
+#@version 0.9.1 - integracion EAC
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2008/03/17
+#@version 0.9.2 - integracion OpenGnsys
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2010/07/27
+#@version 1.0.1 - Control de espacio requerido
+#@author Antonio J.Doblas Viso
+#@date 2011-05-10
+#@version 2.0.1 - Imagenes sincronizadas
+#@date 2013-02-20
+#@version 1.0.5 - uso de md5 full para las transferencias torrent, en la llamada => ogUpdateCacheIsNecesary
+#@date 2014-07-09
+#@version 1.1 - Cambio de repositorio para el recurso remoto images si es necesario
+#@author Irina Gomez, ETSII Universidad de Sevilla
+#@date 2015-06-16
+#@version 1.1 - Control de errores en transferencia multicast (ticket #781)
+#@author Irina Gomez, ETSII Universidad de Sevilla
+#@date 2017/04/20
+#*/ ##
+
+PROG="$(basename $0)"
+if [ $# -lt 3 ]; then
+ ogRaiseError session $OG_ERR_FORMAT "$MSG_FORMAT: $PROG str_REPO _str_Relative_Path_OGIMG_with_/ PROTOCOLO OPCIONES_PROTOCOLO OPCIONES_UPDATECACHE"
+ exit $?
+fi
+
+#Carga del configurador del engine
+[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
+
+# Clear temporary file used as log track by httpdlog
+# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
+echo " " > $OGLOGCOMMAND
+
+if ! [ "$(ogGetCaller)" == "deployImage" -o "$(ogGetCaller)" == "restoreBaseImage" -o "$(ogGetCaller)" == "restoreDiffImage" ]; then
+ echo -n "" > $OGLOGSESSION;
+
+ # Registro de inicio de ejecución
+ ogEcho log session "[1] $MSG_SCRIPTS_START $0 $*"
+fi
+
+REPOSITORIO="${1^^}"
+PROTOCOLO="${3^^}"
+OPTPROTOCOLO="$4"
+# Si MCASTWAIT menos que tiempo de espera del servidor lo aumento
+if [ "${PROTOCOLO%-*}" == "MULTICAST" ] && [[ ${OPTPROTOCOLO##*:} =~ ^-?[0-9]+$ ]]; then
+ [ ${MCASTWAIT:0} -lt ${OPTPROTOCOLO##*:} ] && let MCASTWAIT=${OPTPROTOCOLO##*:}+5
+fi
+
+# Unidad organizativa.
+[ "$ogunit" != "" ] && OGUNIT="$ogunit/"
+
+# Si es una ip y es distinta a la del recurso samba cambiamos de REPO.
+ogCheckIpAddress $REPOSITORIO
+if [ $? == 0 -o $REPOSITORIO == "REPO" ] ; then
+ # Si falla el cambio -> salimos con error repositorio no valido
+ ogChangeRepo $REPOSITORIO $OGUNIT || exit $(ogRaiseError $OG_ERR_NOTFOUND $REPOSITORIO; echo $?)
+ REPOSITORIO="REPO"
+fi
+REPOIP=$(ogGetRepoIp)
+ogEcho log session $REPOSITORIO $REPOIP $PROTOCOLO $OPTPROTOCOLO
+
+# Si el repositorio local CACHE no existe error 15.
+if ! $(ogFindCache >/dev/null); then
+ ogRaiseError session $OG_ERR_NOTCACHE "CACHE"
+ exit $?
+fi
+
+# comprobar si la imagen existe (.img, .img.diff o directorio)
+REPOFILE=$(ogGetPath "REPO" "/$2")
+[ -n "$REPOFILE" ] || exit $(ogRaiseError session $OG_ERR_NOTFOUND "REPO /$2"; echo $?)
+
+ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_DOUPDATE"
+# Distingo si es monolitica o sincronizable
+file "$REPOFILE" | grep -i -e " BTRFS Filesystem " -e " ext4 filesystem " -e " directory" 2>&1 > /dev/null
+if [ $? == 0 ]; then
+ IMGSYNC=TRUE
+ # Para imagen sincronizada, si hay imagen en cache siempre protocolo = rsync.
+ CACHEFILE="$(ogGetPath "CACHE" "/$2")"
+ [ -n "$CACHEFILE" ] && PROTOCOLO="RSYNC"
+ # Si es sincronizada tipo directorio siempre protocolo = rsync.
+ [ -d $REPOFILE ] && PROTOCOLO="RSYNC" && IMGTYPE="dir"
+
+ # Si es imagen sincronizada siempre da distinto md5. No podemos comprobar -> actualizamos.
+ RETVAL=0
+else
+ # Si la imagen es monolitica y ha elegido protocolo = RSYNC salimos con error.
+ [ $PROTOCOLO == "RSYNC" ] && exit $(ogRaiseError session $OG_ERR_DONTSYNC_IMAGE "REPO $2"; echo $?)
+ IMGSYNC=FALSE
+ ogUpdateCacheIsNecesary "$REPOSITORIO" "$2" "$PROTOCOLO"
+ RETVAL=$?
+fi
+# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1
+[ "$RETVAL" == "1" ] && exit 0
+[ "$RETVAL" -gt "1" ] && exit $OG_ERR_UPDATECACHE
+
+ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZECACHE"
+CACHESIZE=$(ogGetCacheSize)
+CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
+FILESIZE=$(ls -sk $(ogGetPath $REPOSITORIO "$2") | cut -f1 -d" ")
+if [ "$IMGTYPE" == "dir" ]; then
+ ogEcho log session " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR"
+ ogEcho log session " du -sk $REPOFILE"
+ REALFILESIZE=$(du -sk "$REPOFILE"|awk '{print $1}')
+else
+ REALFILESIZE=$(ls -l --block-size=1024 $REPOFILE | cut -f5 -d" ")
+fi
+
+# La sincronizada, si existe la imagen en cache el espacio necesario
+# es la nueva menos lo que ocupa la que ya hay.
+if [ "$PROTOCOLO" == "RSYNC" ]; then
+ if [ "$CACHEFILE" == "" ]; then
+ CACHEFILESIZE=0
+ else
+ if [ "$IMGTYPE" == "dir" ]; then
+ ogEcho log session " * $MSG_SCRIPTS_UPDATECACHE_CHECKSIZEDIR $CACHEFILESIZE"
+ ogEcho log session " du -sk $CACHEFILE"
+ CACHEFILESIZE=$(du -sk $CACHEFILE |awk '{print $1}')
+ else
+ CACHEFILESIZE=$(ls -l --block-size=1024 "$CACHEFILE" | cut -f5 -d" ")
+ fi
+ fi
+ let SIZEREQUIRED=$REALFILESIZE-$CACHEFILESIZE
+ [ $SIZEREQUIRED -lt 0 ] && SIZEREQUIRED=0
+else
+ SIZEREQUIRED=$FILESIZE
+fi
+
+#ERROR CACHESIZE 16 (tamanyo de la CACHE insuficiente)
+if [ "$SIZEREQUIRED" -ge "$CACHESIZE" ]
+then
+ ogEcho log session "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $SIZEREQUIRED > CACHE = $CACHESIZE"
+ ogRaiseError session $OG_ERR_CACHESIZE "CACHE"
+ exit $?
+fi
+
+
+#ERROR CACHESIZE 16 (Espacio libre en CACHE insuficiente)
+if [ "$SIZEREQUIRED" -ge "$CACHESIZEFREE" ]
+then
+ ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_IFNOTCACHEDO: ACTIONCACHEFULL=$ACTIONCACHEFULL"
+ case "$ACTIONCACHEFULL" in
+ NONE)
+ ogEcho log session "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $SIZEREQUIRED > FREE SPACE CACHE = $CACHESIZEFREE"
+ ogRaiseError session $OG_ERR_CACHESIZE "CACHE FULL, NO SPACE FREE"
+ exit $?
+ ;;
+ FORMAT)
+ ogEcho log session "[51] $MSG_HELP_ogFormatCache "
+ ogUnmountCache
+ ogFormatCache
+ ogMountCache
+ NEXTOPERATION=REPEAT
+ ;;
+ DELETE)
+ ogEcho log session "[51] #MSG_HELP_ogDeleteTree $OGCAC$OGIMG/* "
+ rm -fr $OGCAC$OGIMG/*
+ NEXOPERATION=REPEAT
+ ;;
+ *)
+ ogEcho log session "$MSG_WARNING: $MSG_ERR_CACHESIZE: $2 = $FILESIZE > CACHE = $CACHESIZEFREE"
+ ogRaiseError session $OG_ERR_CACHESIZE "CACHE"
+ exit $?
+ ;;
+ esac
+fi
+
+# Comprobamos que imagen cache igual a la del repo. Si sincronizada no podemos comprobar.
+[ "$IMGSYNC" == "TRUE" ] || ogUpdateCacheIsNecesary $REPOSITORIO "$2" "$PROTOCOLO"
+RETVAL=$?
+# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1
+[ "$RETVAL" == "1" ] && exit 0
+[ "$RETVAL" -gt "1" ] && exit $OG_ERR_UPDATECACHE
+
+ogMountCache >/dev/null
+
+## Si no existe, crear subdirectorio para el fichero en la cache.
+IMGDIR=$(ogGetParentPath CACHE "/$2")
+if [ $? != 0 ]; then
+ ogEcho log session "[5] $MSG_HELP_ogMakeDir \"$2 $(dirname "$2")."
+ ogMakeDir CACHE $(dirname "/$2")
+ IMGDIR=$(ogGetParentPath CACHE "/$2") || exit $?
+fi
+
+TIME1=$SECONDS
+
+case "$PROTOCOLO" in
+ TORRENT)
+ ogEcho log session "ogCopyFile $REPOSITORIO $2.torrent absolute $OGCAC/$OGIMG"
+ # tiempos
+ timewait=$(expr $(printf '%d\n' 0x$(ogGetMacAddress | awk -F: '{print $5$6}')) \* 120 / 65535)
+ ogExecAndLog command ogCopyFile $REPOSITORIO "$2.torrent" "$IMGDIR" || exit $?
+ #TODO: comprobar que el tracker definido en el fichero es correcto.
+ #TODO comprobar que el fichero torrent está en cache
+ # retardamos el inicio -aleatorio de 0 a 120 segundos- al tracker para gestionar mas de +-40 equipos
+ P2PWAIT=$[ ( $RANDOM % 120 ) + 1 ]
+ ogEcho log session " [ ] $MSG_SCRIPTS_TASK_SLEEP : $P2PWAIT seconds"
+ sleep $P2PWAIT
+ ogEcho log session " [ ] $MSG_SCRIPTS_TASK_START: ogTorrentStart CACHE $2.torrent $4"
+ ogExecAndLog command ogTorrentStart CACHE "$2.torrent" $4
+ RESUMEUPDATECACHE=$(grep -m 1 -B1 "Download" $OGLOGCOMMAND)
+ RESUMEUPDATECACHEbf=$(grep -m 1 "Download" $OGLOGCOMMAND)
+ if [ "$RESUMEUPDATECACHEbf" == "Download complete." ]; then
+ rm -f $IMGDIR$2".torrent.bf"
+ fi
+ ;;
+ MULTICAST)
+ ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_CHECKMCASTSESSION: $REPOIP:${OPTPROTOCOLO%%:*}"
+ #TODO: ticket 379
+ NUMBER=$[ ( $RANDOM % 30 ) + 1 ]
+ sleep $NUMBER
+ #FIN TODO
+ ogEcho log session ogMcastRequest "$2" $OPTPROTOCOLO
+ ogExecAndLog command ogMcastRequest "$2" $OPTPROTOCOLO || exit $?
+ ogEcho log session ogMcastReceiverFile ${OPTPROTOCOLO%%:*} CACHE "$2"
+ ogExecAndLog command ogMcastReceiverFile ${OPTPROTOCOLO%%:*} CACHE "$2" || exit $?
+ RESUMEUPDATECACHE=$(grep -m 1 -B1 "Transfer complete" $OGLOGCOMMAND.tmp)
+ ;;
+ UNICAST)
+ #ogEcho log session "unicast"
+ ogExecAndLog command ogCopyFile $REPOSITORIO "$2" "$IMGDIR"
+ sleep 5
+ RESUMEUPDATECACHE=$(grep -m 1 "100%" $OGLOGCOMMAND.tmp)
+ ;;
+ RSYNC)
+ # Si parametro de protocolo no era rsync, mensaje de cambio protocolo
+ [ "${3^^}" == "RSYNC" ] || ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_RSYNCPROTOCOLCHANGE"
+ # Opciones de rsync
+ USERRSYNC="opengnsys"
+ PASSWORD=" --password-file=/scripts/passrsync "
+ OPTRSYNC=" --delete --progress "
+ [ "$ogrsyncz" == "true" ] && OPTRSYNC="z $OPTRSYNC"
+ [ "$ogrsyncw" == "true" ] && OPTRSYNC="w$OPTRSYNC"
+
+ if [ -d $REPOFILE ]; then
+ # Si es sincronizada tipo directorio.
+ [ -d "$OGCAC$OGIMG/$2" ] || mkdir "$OGCAC$OGIMG/$2"
+ ogEcho log session "rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$OGUNIT$2/ $OGCAC$OGIMG/$2"
+ rsync -aHAX$OPTRSYNC $PASSWORD "$USERRSYNC@$REPOIP::ogimages/$OGUNIT$2/" "$OGCAC$OGIMG/$2" 2>> $OGLOGCOMMAND | egrep "^sent|^sending|^total%" >> $OGLOGCOMMAND
+ else
+ # Si es sincronizada tipo archivo.
+ [ "${2##*.}" == "img" ] && IMGTYPE="img" || IMGTYPE="diff"
+ IMGNAME="${2%.img*}"
+
+ DIRMOUNT=$(ogGetMountImageDir "$IMGNAME" $IMGTYPE)
+ DIRLOCAL="/tmp/$DIRMOUNT"
+ mkdir "$DIRLOCAL" 2>/dev/null
+ ogEcho log session "$MSG_SCRIPTS_UPDATECACHE_CHECKSIZEIMG"
+
+ # Si la imagen no existe la creo
+ # Si la imagen del repositorio es mayor, redimensiono la imagen de cache
+ if [ "$CACHEFILE" == "" -o $CACHEFILESIZE -lt $REALFILESIZE ]; then
+ ogEcho log session "$MSG_HELP_ogCreateFileImage"
+ ogCreateFileImage CACHE "$IMGNAME" $IMGTYPE $REALFILESIZE
+ TIMEAUX3=$[SECONDS-TIMEAUX3]
+ ogEcho log session " $MSG_SCRIPTS_TASK_END, $MSG_SCRIPTS_TIME_PARTIAL: $[TIMEAUX3/60]m $[TIMEAUX3%60]s"
+ fi
+ # Montamos las imagenes para sincronizarlas. Quitamos / inicial.
+ ogMountImage CACHE "${IMGNAME#\/}" $IMGTYPE || exit $?
+ ogMountImage REPO "${IMGNAME#\/}" $IMGTYPE
+ # Esperamos que se monte la imagen en el servidor
+ ogWaitSyncImage REPO "$IMGNAME" $IMGTYPE "mounted" || exit $?
+ ogEcho log session " rsync -aHAX$OPTRSYNC $USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/ $DIRLOCAL"
+ rsync -aHAX$OPTRSYNC $PASSWORD "$USERRSYNC@$REPOIP::ogimages/$DIRMOUNT/" "$DIRLOCAL" 2>>$OGLOGCOMMAND | egrep "^sent|^sending|^total|%" >> $OGLOGCOMMAND
+ # RETVAL="1" -> OK RETVAL="2" -> error # valores igual que ogUpdateCacheIsNecesary
+ [ ${PIPESTATUS[0]} -eq 0 ] && RETVAL="1"|| RETVAL="2"
+ # Desmonto las imagenes
+ ogUnmountImage CACHE "$IMGNAME" $IMGTYPE
+ ogUnmountImage REPO "$IMGNAME" $IMGTYPE
+ ogUnlockImage CACHE "$2"
+ fi
+ ;;
+esac
+
+TIME1=$[SECONDS-TIME1]
+
+ogEcho log session " [ ] $RESUMEUPDATECACHE "
+ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL updateCache $[TIME1/60]m $[TIME1%60]s"
+ogEcho log session " [ ] $MSG_SCRIPTS_TASK_START $MSG_HELP_ogCalculateChecksum "
+TIME2=$SECONDS
+# Si es imagen sincronizada siempre da distinto md5. No podemos comprobar
+if [ "$IMGSYNC" == "TRUE" ]; then
+ # RETVAL="1" -> OK RETVAL="2" -> error # valores igual que ogUpdateCacheIsNecesary
+ [ $PROTOCOLO == "RSYNC" ] || RETVAL=1
+else
+ ogUpdateCacheIsNecesary $REPOSITORIO "$2" "$PROTOCOLO"
+ RETVAL=$?
+fi
+if [ "$(ogGetCaller)" != "deployImage" ]; then
+ TIME2=$[SECONDS-TIME2]
+ ogEcho log session " [ ] $MSG_SCRIPTS_TIME_PARTIAL $MSG_HELP_ogCalculateChecksum $[TIME2/60]m $[TIME2%60]s"
+fi
+# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizamos-exit 0 || si RETVAL>2 exit 1
+[ "$RETVAL" == "0" ] && exit $OG_ERR_UPDATECACHE
+[ "$RETVAL" == "1" ] && exit 0
+[ "$RETVAL" -gt "1" ] && exit $OG_ERR_UPDATECACHE
+
diff --git a/client/shared/scripts/updateCache.py b/client/scripts/updateCache.py
similarity index 100%
rename from client/shared/scripts/updateCache.py
rename to client/scripts/updateCache.py
diff --git a/client/shared/scripts/__init__.py b/client/shared/scripts/__init__.py
deleted file mode 100755
index e69de29..0000000