summaryrefslogtreecommitdiffstats
path: root/client/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/shared')
-rwxr-xr-xclient/shared/bin/poweroffconf59
-rwxr-xr-xclient/shared/etc/init/default.sh35
-rwxr-xr-xclient/shared/etc/preinit/default.sh2
-rwxr-xr-xclient/shared/etc/preinit/loadenviron.sh9
-rwxr-xr-xclient/shared/etc/preinit/mountrepo.sh9
-rwxr-xr-xclient/shared/etc/preinit/poweroff.sh35
-rw-r--r--client/shared/lib/httpd/10-cgi.conf18
-rw-r--r--client/shared/lib/httpd/LogCommand.sh35
-rw-r--r--client/shared/lib/httpd/LogSession.sh31
-rw-r--r--client/shared/lib/httpd/bandwidth.sh12
-rw-r--r--client/shared/lib/httpd/httpd-log.sh15
-rw-r--r--client/shared/lib/httpd/httpd-menu.sh14
-rwxr-xr-xclient/shared/lib/httpd/lighttpd.conf167
-rw-r--r--client/shared/lib/httpd/oglive.css11
l---------[-rwxr-xr-x]client/shared/scripts/bootLinux36
-rwxr-xr-xclient/shared/scripts/bootOs12
l---------[-rwxr-xr-x]client/shared/scripts/bootWindows31
-rwxr-xr-xclient/shared/scripts/cloneRemoteFromMaster4
-rwxr-xr-xclient/shared/scripts/configureOs20
-rwxr-xr-xclient/shared/scripts/createImage47
-rwxr-xr-xclient/shared/scripts/deployImage37
-rwxr-xr-xclient/shared/scripts/listPartitions3
-rwxr-xr-xclient/shared/scripts/restoreImage12
-rwxr-xr-xclient/shared/scripts/runAplicationX.sh8
-rwxr-xr-xclient/shared/scripts/runhttplog.sh30
-rwxr-xr-xclient/shared/scripts/updateBootCache55
-rwxr-xr-xclient/shared/scripts/updateCache78
27 files changed, 682 insertions, 143 deletions
diff --git a/client/shared/bin/poweroffconf b/client/shared/bin/poweroffconf
new file mode 100755
index 00000000..c4813e34
--- /dev/null
+++ b/client/shared/bin/poweroffconf
@@ -0,0 +1,59 @@
+#!/bin/bash
+#/**
+#@file poweroffconf
+#@brief Control de parada tras tiempo de inactividad para ahorro de energía.
+#@param int_minutos Minutos de inactividad (opcional).
+#@note La comprobación periódica debe ejecutarse en el "cron" del sistema.
+#@note Fichero de configuración: /etc/poweroff.conf
+#@author Ramón Gómez - Univ. Sevilla
+#@date 2011-10-25
+#@warning License: GNU GPLv3+
+#*/
+
+
+# Variables generales.
+OPENGNSYS=${OPENGNSYS:-/opt/opengnsys} # Instalación de OpenGnSys
+OGETC=${OGETC:-$OPENGNSYS/etc} # Configuración de OpenGnSys
+POWEROFFCONF=/etc/poweroff.conf # Configuración del script
+source $POWEROFFCONF
+
+case $# in
+ 0) # Sin parámetros, comprobar que existe la variable POWEROFFSLEEP.
+ if [ -z "$POWEROFFSLEEP" ]; then
+ ogRaiseError $OG_ERR_FORMAT "Sin tiempo de espera."
+ exit $?
+ fi
+ ;;
+ 1) #TODO Comprobar que el parámetro es entero positivo.
+ # Nuevo timepo de espera.
+ POWEROFFSLEEP=$1
+ perl -pi -e "s/POWEROFFSLEEP=.*/POWEROFFSLEEP=$POWEROFFSLEEP/" $POWEROFFCONF
+ # Si se necesita, recalcular tiempo de parada.
+ if [ -n "POWEROFFTIME" ]; then
+ POWEROFFTIME=$(date --date="$POWEROFFSLEEP min" +"%H%M")
+ perl -pi -e "s/POWEROFFTIME=.*/POWEROFFTIME=$POWEROFFTIME/" $POWEROFFCONF
+ fi
+ exit 0 ;;
+ *) # Error de formato de ejecución.
+ ogRaiseError $OG_ERR_FORMAT "Formato: $0 [int_minutos]"
+ exit $? ;;
+esac
+# Comprobar si hay algún script en ejecución.
+if [ -n "$(pgrep -fl $OPENGNSYS | egrep -v "$OGETC|$0")" ]; then
+ # Eliminar tiempo de inicio de espera, si se está ejecutando operación.
+ perl -pi -e 's/POWEROFFTIME=.*$/POWEROFFTIME=/' $POWEROFFCONF
+else
+ # Si el sistema está en estado de espera, ...
+ NOW=$(date +"%H%M")
+ if [ -z "$POWEROFFTIME" ]; then
+ # Asignar tiempo de inicio, si no estaba definido.
+ POWEROFFTIME=$(date --date="$POWEROFFSLEEP min" +"%H%M")
+ perl -pi -e "s/POWEROFFTIME=.*$/POWEROFFTIME=$POWEROFFTIME/" $POWEROFFCONF
+ else
+ # Apagar el equipo si se sobrepasa el periodo de espera.
+ if [ $NOW -ge $POWEROFFTIME ]; then
+ $OPENGNSYS/scripts/poweroff
+ fi
+ fi
+fi
+
diff --git a/client/shared/etc/init/default.sh b/client/shared/etc/init/default.sh
index 79385796..d1fea1c9 100755
--- a/client/shared/etc/init/default.sh
+++ b/client/shared/etc/init/default.sh
@@ -1,11 +1,21 @@
#!/bin/bash
# TODO Separar esta sección en otro script
+
+
# Lanzar servicios complementarios del cliente.
-echo -ne "og\nog\n" | passwd root
-#Compatibilidad ssh con el boot-tools 1.0.2
+PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \
+ sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
+PASS=${PASS:-"og"}
+echo -ne "$PASS\n$PASS\n" | passwd root 2>/dev/null
+
+# Inicio del servidor sshd
/usr/sbin/sshd
+
+# Desactivado apagado de monitor
#setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1
+
+# Activado WOL en la interfaz usada en arranque pxe
ethtool -s $DEVICE wol g 2>/dev/null
# Fichero de registro de incidencias (en el servidor; si no, en local).
@@ -16,12 +26,29 @@ if ! touch $OGLOGFILE 2>/dev/null; then
fi
LOGLEVEL=5
-#facilitando el entorno Og desde ssh
+#Facilitando el entorno Og desde ssh
cp $OPENGNSYS/etc/preinit/loadenviron.sh /etc/profile.d/
+
+
+
+########## PRUEBAS
# Crear menú por defecto para el cliente
generateMenuDefault
-# Arranque de OpenGnSys Client.
+# Matando plymount para inicir browser o shell
+pkill -9 plymouthd
+
+[ -f /opt/opengnsys/scripts/runhttplog.sh ] && /opt/opengnsys/scripts/runhttplog.sh
+
+########## FIN PRUEBAS
+
+# Arranque de OpenGnSys Client daemon (web services).
+if [ -x $OPENGNSYS/job_executer/init.d/job_executer ]; then
+ echo "Running Opengnsys client daemon (web services)"
+ $OPENGNSYS/job_executer/init.d/job_executer restart
+fi
+
+# Arranque de OpenGnSys Client daemon (socket).
if [ -x "$OPENGNSYS/bin/ogAdmClient" ]; then
echo "$MSG_LAUNCHCLIENT"
[ $ogactiveadmin == "true" ] && boot=admin
diff --git a/client/shared/etc/preinit/default.sh b/client/shared/etc/preinit/default.sh
index 539c12fe..addab9aa 100755
--- a/client/shared/etc/preinit/default.sh
+++ b/client/shared/etc/preinit/default.sh
@@ -5,7 +5,7 @@ set -a
source /opt/opengnsys/etc/preinit/loadenviron.sh
# Scripts de inicio.
-for f in fileslinks loadmodules mountrepo; do
+for f in fileslinks loadmodules mountrepo poweroff; do
$OGETC/preinit/$f.sh
done
diff --git a/client/shared/etc/preinit/loadenviron.sh b/client/shared/etc/preinit/loadenviron.sh
index af891534..c23fcc80 100755
--- a/client/shared/etc/preinit/loadenviron.sh
+++ b/client/shared/etc/preinit/loadenviron.sh
@@ -23,7 +23,8 @@ if [ -d $OPENGNSYS ]; then
export OGCAC=$OPENGNSYS/cache
export OGLOG=$OPENGNSYS/log
- export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/opt/og2fs/2ndfs/opt/drbl/sbin
+ export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/opt/oglive/rootfs/opt/drbl/sbin
+
export PATH=$OGSCRIPTS:$PATH:$OGAPI:$OGBIN
# Exportar parámetros del kernel.
@@ -64,9 +65,15 @@ if [ -d $OPENGNSYS ]; then
# Fichero de registros.
export OGLOGFILE="$OGLOG/$(ogGetIpAddress).log"
+ # Configuracion de la red (valido offline)
+ cat /tmp/initrd.cfg | grep DEVICECFG && export $(cat /tmp/initrd.cfg | grep DEVICECFG)
+ source $DEVICECFG 2>/dev/null
+
# FIXME Pruebas para grupos de ordenadores
#export OGGROUP=$(ogGetGroup)
export OGGROUP="$group"
+
+ ROOTREPO=${ROOTREPO:-"$OGSERVERIMAGES"}
fi
# Declaración de códigos de error.
diff --git a/client/shared/etc/preinit/mountrepo.sh b/client/shared/etc/preinit/mountrepo.sh
index aa0b9886..5c20499a 100755
--- a/client/shared/etc/preinit/mountrepo.sh
+++ b/client/shared/etc/preinit/mountrepo.sh
@@ -9,6 +9,7 @@
#*/
OGIMG=${OGIMG:-/opt/opengnsys/images}
+ROOTREPO=${ROOTREPO:-"$ROOTSERVER"}
# TODO Revisar proceso de arranque para no montar 2 veces el repositorio.
if [ $ogactiveadmin == "true" ]; then
@@ -18,8 +19,12 @@ if [ $ogactiveadmin == "true" ]; then
protocol=${potocol:-"smb"}
printf "$MSG_MOUNTREPO\n" "$protocol" "$boot"
case "$protocol" in
- nfs) mount.nfs ${ROOTSERVER}:$OGIMG $OGIMG -o rw,nolock ;;
- smb) mount.cifs //${ROOTSERVER}/ogimages $OGIMG -o rw,serverino,acl,username=opengnsys,password=og ;;
+ nfs) mount.nfs ${ROOTREPO}:$OGIMG $OGIMG -o rw,nolock ;;
+ smb) PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \
+ sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
+ PASS=${PASS:-"og"}
+ mount.cifs //${ROOTREPO}/ogimages $OGIMG -o rw,serverino,acl,username=opengnsys,password=$PASS
+ ;;
esac
fi
diff --git a/client/shared/etc/preinit/poweroff.sh b/client/shared/etc/preinit/poweroff.sh
new file mode 100755
index 00000000..9e7d700d
--- /dev/null
+++ b/client/shared/etc/preinit/poweroff.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#/**
+#@file poweroff.sh
+#@brief Script de inicio para cargar el proceso comprobación de clientes inactivos.
+#@note Arranca y configura el proceso "cron".
+#@warning License: GNU GPLv3+
+#@version 1.0.2
+#@author Ramon Gomez, ETSII Universidad de Sevilla
+#@date 2011-10-25
+#*/
+
+
+# Si está configurado OpenGnSys ...
+if [ -n "$OPENGNSYS" ]; then
+ #echo "$MSG_POWEROFFCONF"
+
+ # Crear fichero de configuración por defecto (30 min. de espera).
+ POWEROFFCONF=/etc/poweroff.conf
+ cat << FIN > $POWEROFFCONF
+POWEROFFSLEEP=30
+POWEROFFTIME=
+FIN
+
+ # Lanzar el proceso "cron".
+ cron -l
+
+ # Definir la "crontab" lanzando el proceso de comprobación cada minuto.
+ echo "* * * * * [ -x $OGBIN/poweroffconf ] && $OGBIN/poweroffconf" | crontab -
+
+else
+ # FIXME Error: entorno de OpenGnSys no configurado.
+ echo "Error: OpenGnSys environment is not configured." # FIXME: definir mensaje.
+ exit 1
+fi
+
diff --git a/client/shared/lib/httpd/10-cgi.conf b/client/shared/lib/httpd/10-cgi.conf
new file mode 100644
index 00000000..e6f4c85c
--- /dev/null
+++ b/client/shared/lib/httpd/10-cgi.conf
@@ -0,0 +1,18 @@
+# /usr/share/doc/lighttpd-doc/cgi.txt
+
+server.modules += ( "mod_cgi" )
+
+$HTTP["url"] =~ "^/cgi-bin/" {
+alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
+$HTTP["url"] =~ "^/cgi-bin/" {
+cgi.assign = ( ".sh" => "/bin/sh" )
+}
+}
+
+## Warning this represents a security risk, as it allow to execute any file
+## with a .pl/.py even outside of /usr/lib/cgi-bin.
+#
+#cgi.assign = (
+# ".pl" => "/usr/bin/perl",
+# ".py" => "/usr/bin/python",
+#)
diff --git a/client/shared/lib/httpd/LogCommand.sh b/client/shared/lib/httpd/LogCommand.sh
new file mode 100644
index 00000000..9a116f7c
--- /dev/null
+++ b/client/shared/lib/httpd/LogCommand.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+echo "Content-type: text/html"
+echo ""
+echo "<html><head><meta http-equiv='Refresh' content='5,URL=./LogCommand.sh'> <link rel='stylesheet' type='text/css' href='oglive.css' /> <title>Bash as CGI"
+echo "</title></head><body>"
+
+$(strings /tmp/command.log > /tmp/command.log.tmp)
+
+echo "<table>"
+
+echo "<tr>"
+
+
+echo "<TEXTAREA NAME='trackloghead' ROWS='13' COLS='175'>"
+#echo "$(head -n 10 /tmp/command.log.tmp | uniq)"
+echo "$(grep -v '^Elapsed:\|^Total [Tt]ime:\|^-\|^|\|^bytes\|^\[' /tmp/command.log.tmp | uniq | head -n 10)"
+echo "</TEXTAREA>"
+
+echo "</tr>"
+
+
+echo "<tr>"
+
+echo "<TEXTAREA NAME='tracklogtail' ROWS='2' COLS='175'>"
+#echo "$(tail -n 5 /tmp/command.log.tmp | uniq)"
+echo "$(grep '^Elapsed:\|^Total [Tt]ime:\|^-\|^|\|^bytes' /tmp/command.log.tmp | uniq | tail -n 2)"
+echo "</TEXTAREA>"
+
+
+echo "</tr>"
+
+echo "</table>"
+
+
+echo "</body></html>" \ No newline at end of file
diff --git a/client/shared/lib/httpd/LogSession.sh b/client/shared/lib/httpd/LogSession.sh
new file mode 100644
index 00000000..a5d18e68
--- /dev/null
+++ b/client/shared/lib/httpd/LogSession.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+echo "Content-type: text/html"
+echo ""
+echo "<html><head> <meta http-equiv='Refresh' content='5,URL=./LogSession.sh'> <title>Bash as CGI"
+echo "</title>"
+
+echo "<style type='text/css'>"
+echo "<!--"
+echo "TEXTAREA {"
+echo "background-color: navy;"
+echo "border: black 2px solid;"
+echo "color: white;"
+echo "font-family: arial, verdana, ms sans serif;"
+echo "font-size: 8pt;"
+echo "font-weight: normal"
+echo "} "
+echo "-->"
+echo "</style>"
+
+
+
+echo "</head><body>"
+
+echo "<TEXTAREA NAME='contenido' ROWS='115' COLS='175' >"
+echo "$(cat /tmp/session.log | uniq )"
+echo "</TEXTAREA>"
+
+
+
+echo "</body></html>"
+
diff --git a/client/shared/lib/httpd/bandwidth.sh b/client/shared/lib/httpd/bandwidth.sh
new file mode 100644
index 00000000..9e7833c3
--- /dev/null
+++ b/client/shared/lib/httpd/bandwidth.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+echo "Content-type: text/html"
+echo ""
+echo "<html><head><meta http-equiv='Refresh' content='11,URL=./bandwidth.sh'> <link rel='stylesheet' type='text/css' href='oglive.css' /> <title>Bash as CGI </title></head><body>"
+
+echo "<TEXTAREA class='example1' NAME='contenido' ROWS='35' COLS='50' >"
+echo " DISK || NET "
+echo "Read:Write || Recv:Send "
+echo $(tail -n1 /tmp/bandwidth)
+#echo " $(dstat -dn -f 1 1 ) "
+echo "</TEXTAREA>"
+echo "</body></html>" \ No newline at end of file
diff --git a/client/shared/lib/httpd/httpd-log.sh b/client/shared/lib/httpd/httpd-log.sh
new file mode 100644
index 00000000..12e6823c
--- /dev/null
+++ b/client/shared/lib/httpd/httpd-log.sh
@@ -0,0 +1,15 @@
+
+#!/bin/bash
+echo "Content-type: text/html"
+echo ""
+#echo "<html><head><meta http-equiv='Refresh' content='2,URL=./example3.sh'><title>Bash as CGI"
+echo "<html><head><title>OpenGnsys Client</title></head><body>"
+
+echo "<h1> NO APAGAR POR FAVOR. host $(hostname -s)</h1> "
+echo "<IFRAME SRC='bandwidth.sh' WIDTH=250 HEIGHT=80> <A HREF="bandwidth.sh">link</A> </IFRAME> "
+
+
+echo "<IFRAME SRC='LogSession.sh' WIDTH=850 HEIGHT=230> <A HREF="LogSession.sh">link</A> </IFRAME>"
+echo "<IFRAME SRC='LogCommand.sh' WIDTH=850 HEIGHT=250> <A HREF="LogCommand.sh">link</A> </IFRAME>"
+
+echo "</body> \ No newline at end of file
diff --git a/client/shared/lib/httpd/httpd-menu.sh b/client/shared/lib/httpd/httpd-menu.sh
new file mode 100644
index 00000000..c5e58364
--- /dev/null
+++ b/client/shared/lib/httpd/httpd-menu.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+
+#!/bin/bash
+echo "Content-type: text/html"
+echo ""
+
+echo "<html><head><title>OpenGnsys Client</title></head><body>"
+
+$(wget http://172.17.9.205/opengnsys/varios/menubrowser.php -O /tmp/menu.tmp)
+echo "$(cat /tmp/menu.tmp)"
+
+echo "</body>
+
diff --git a/client/shared/lib/httpd/lighttpd.conf b/client/shared/lib/httpd/lighttpd.conf
new file mode 100755
index 00000000..7a11040b
--- /dev/null
+++ b/client/shared/lib/httpd/lighttpd.conf
@@ -0,0 +1,167 @@
+# Debian lighttpd configuration file
+#
+
+############ Options you really have to take care of ####################
+
+## modules to load
+# mod_access, mod_accesslog and mod_alias are loaded by default
+# all other module should only be loaded if neccesary
+# - saves some time
+# - saves memory
+
+server.modules = (
+ "mod_access",
+ "mod_alias",
+ "mod_accesslog",
+ "mod_compress",
+# "mod_rewrite",
+# "mod_redirect",
+# "mod_evhost",
+# "mod_usertrack",
+# "mod_rrdtool",
+# "mod_webdav",
+# "mod_expire",
+# "mod_flv_streaming",
+# "mod_evasive"
+)
+
+## a static document-root, for virtual-hosting take look at the
+## server.virtual-* options
+server.document-root = "/var/www/"
+
+## where to upload files to, purged daily.
+server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
+
+## where to send error-messages to
+server.errorlog = "/var/log/lighttpd/error.log"
+
+## files to check for if .../ is requested
+index-file.names = ( "index.php", "index.html",
+ "index.htm", "default.htm",
+ "index.lighttpd.html" )
+
+
+## Use the "Content-Type" extended attribute to obtain mime type if possible
+# mimetype.use-xattr = "enable"
+
+#### accesslog module
+accesslog.filename = "/var/log/lighttpd/access.log"
+
+## deny access the file-extensions
+#
+# ~ is for backupfiles from vi, emacs, joe, ...
+# .inc is often used for code includes which should in general not be part
+# of the document-root
+url.access-deny = ( "~", ".inc" )
+
+##
+# which extensions should not be handle via static-file transfer
+#
+# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
+static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
+
+
+######### Options that are good to be but not neccesary to be changed #######
+
+## Use ipv6 only if available. (disabled for while, check #560837)
+#include_shell "/usr/share/lighttpd/use-ipv6.pl"
+
+## bind to port (default: 80)
+# server.port = 81
+
+## bind to localhost only (default: all interfaces)
+## server.bind = "localhost"
+
+## error-handler for status 404
+#server.error-handler-404 = "/error-handler.html"
+#server.error-handler-404 = "/error-handler.php"
+
+## to help the rc.scripts
+server.pid-file = "/var/run/lighttpd.pid"
+
+##
+## Format: <errorfile-prefix><status>.html
+## -> ..../status-404.html for 'File not found'
+#server.errorfile-prefix = "/var/www/"
+
+## virtual directory listings
+dir-listing.encoding = "utf-8"
+server.dir-listing = "enable"
+
+## send unhandled HTTP-header headers to error-log
+#debug.dump-unknown-headers = "enable"
+
+### only root can use these options
+#
+# chroot() to directory (default: no chroot() )
+#server.chroot = "/"
+
+## change uid to <uid> (default: don't care)
+server.username = "www-data"
+
+## change uid to <uid> (default: don't care)
+server.groupname = "www-data"
+
+#### compress module
+compress.cache-dir = "/var/cache/lighttpd/compress/"
+compress.filetype = ("text/plain", "text/html", "application/x-javascript", "text/css")
+
+
+#### url handling modules (rewrite, redirect, access)
+# url.rewrite = ( "^/$" => "/server-status" )
+# url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
+
+#
+# define a pattern for the host url finding
+# %% => % sign
+# %0 => domain name + tld
+# %1 => tld
+# %2 => domain name without tld
+# %3 => subdomain 1 name
+# %4 => subdomain 2 name
+#
+# evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"
+
+#### expire module
+# expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")
+
+#### rrdtool
+# rrdtool.binary = "/usr/bin/rrdtool"
+# rrdtool.db-name = "/var/www/lighttpd.rrd"
+
+#### variable usage:
+## variable name without "." is auto prefixed by "var." and becomes "var.bar"
+#bar = 1
+#var.mystring = "foo"
+
+## integer add
+#bar += 1
+## string concat, with integer cast as string, result: "www.foo1.com"
+#server.name = "www." + mystring + var.bar + ".com"
+## array merge
+#index-file.names = (foo + ".php") + index-file.names
+#index-file.names += (foo + ".php")
+
+
+#### external configuration files
+## mimetype mapping
+include_shell "/usr/share/lighttpd/create-mime.assign.pl"
+
+## load enabled configuration files,
+## read /etc/lighttpd/conf-available/README first
+include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
+
+#### handle Debian Policy Manual, Section 11.5. urls
+## by default allow them only from localhost
+## (This must come last due to #445459)
+## Note: =~ "127.0.0.1" works with ipv6 enabled, whereas == "127.0.0.1" doesn't
+#$HTTP["remoteip"] =~ "127.0.0.1" {
+# alias.url += (
+# "/doc/" => "/usr/share/doc/",
+# "/images/" => "/usr/share/images/"
+# )
+# $HTTP["url"] =~ "^/doc/|^/images/" {
+# dir-listing.activate = "enable"
+# }
+#}
+
diff --git a/client/shared/lib/httpd/oglive.css b/client/shared/lib/httpd/oglive.css
new file mode 100644
index 00000000..71f19ce2
--- /dev/null
+++ b/client/shared/lib/httpd/oglive.css
@@ -0,0 +1,11 @@
+TEXTAREA {
+background-color: navy;
+border: black 2px solid;
+color: white;
+font-family: arial, verdana, ms sans serif;
+font-size: 8pt;
+font-weight: normal
+}
+
+ example1 {color:white; background-color:navy;
+ font-weight:bold; text-align:center;} \ No newline at end of file
diff --git a/client/shared/scripts/bootLinux b/client/shared/scripts/bootLinux
index e20b9489..d19be900 100755..120000
--- a/client/shared/scripts/bootLinux
+++ b/client/shared/scripts/bootLinux
@@ -1,35 +1 @@
-#!/bin/bash
-# Scirpt de ejemplo para iniciar Linux desde partición de arranque.
-# (puede usarse como base para el programa de arranque usado por OpenGNSys Admin).
-
-PROG="$(basename $0)"
-if [ $# -ne 2 ]; then
- ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion"
- exit $?
-fi
-
-echo "[0] Inicio del proceso de arranque."
-PART=$(ogDiskToDev "$1" "$2") || exit $?
-
-echo "[10] Desmontar todos los sistemas de archivos."
-sync
-for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do
- ogUnmountAll $i 2>/dev/null
-done
-ETC=$(ogGetPath $1 $2 /etc)
-if [ -n "$ETC" ]; then
- echo "[30] Asignar nombre Linux \"$NAME\"."
- NAME=$(ogGetHostname)
- NAME=${NAME:-"pc"}
- echo "$NAME" >$ETC/hostname 2>/dev/null
- echo "[50] Actaualizar fstab con particion raiz \"$PART\"."
- awk -v P="$PART " '{ if ($2=="/") {sub(/^.*$/, P, $1)}
- print } ' $ETC/fstab >/tmp/fstab
- mv /tmp/fstab $ETC/fstab
-fi
-echo "[70] Desmontar cache local."
-ogUnmountCache
-
-echo "[90] Arrancar sistema operativo."
-ogBoot $1 $2
-
+bootOs \ No newline at end of file
diff --git a/client/shared/scripts/bootOs b/client/shared/scripts/bootOs
index 71a9fe73..78d779be 100755
--- a/client/shared/scripts/bootOs
+++ b/client/shared/scripts/bootOs
@@ -10,9 +10,16 @@ fi
echo "[0] Inicio del proceso de arranque."
PART=$(ogDiskToDev "$1" "$2") || exit $?
-NAME=$(ogGetHostname)
+NAME="$(ogGetHostname)"
NAME=${NAME:-"pc"}
OSTYPE=$(ogGetOsType $1 $2)
+# Borrar marcas de arrranque de todos los Windows instalados en el disco.
+if [ "$OSTYPE" == "Windows" ]; then
+ for (( i=1; i<=$(ogGetPartitionsNumber $1); i++ )); do
+ [ "$(ogGetOsType $1 $i)" == "Windows" ] && ogMount $1 $i &>/dev/null
+ done
+ rm -f /mnt/*/ogboot.*
+fi
echo "[10] Desmontar todos los sistemas de archivos."
sync
@@ -21,7 +28,8 @@ for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do
done
case "$OSTYPE" in
Windows)
- echo "[30] Activar particion de Windows $PART."
+ echo "[30] Mostrar y activar particion de Windows $PART."
+ [ $(ogGetPartitionType $1 $2) == "HNTFS" ] && ogUnhidePartition $1 $2
ogSetPartitionActive $1 $2
echo "[50] Asignar nombre Windows \"$NAME\" y usuario por defecto."
ogSetWindowsName $1 $2 "$NAME"
diff --git a/client/shared/scripts/bootWindows b/client/shared/scripts/bootWindows
index e92e484a..d19be900 100755..120000
--- a/client/shared/scripts/bootWindows
+++ b/client/shared/scripts/bootWindows
@@ -1,30 +1 @@
-#!/bin/bash
-# Scirpt de ejemplo para iniciar Windows con partición de arranque.
-# (puede usarse como base para el programa de arranque usado por OpenGNSys Admin).
-
-PROG="$(basename $0)"
-if [ $# -ne 2 ]; then
- ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion"
- exit $?
-fi
-
-echo "[0] Inicio del proceso de arranque."
-PART=$(ogDiskToDev "$1" "$2") || exit $?
-
-echo "[10] Desmontar todos los sistemas de archivos."
-sync
-for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do
- ogUnmountAll $i 2>/dev/null
-done
-echo "[30] Activar particion de Windows $PART."
-ogSetPartitionActive $1 $2
-echo "[50] Asignar nombre Windows \"$NAME\"."
-NAME=$(ogGetHostname)
-NAME=${NAME:-"pc"}
-ogSetWindowsName $1 $2 "$NAME"
-echo "[70] Desmontar cache local."
-ogUnmountCache
-
-echo "[90] Arrancar sistema operativo."
-ogBoot $1 $2
-
+bootOs \ No newline at end of file
diff --git a/client/shared/scripts/cloneRemoteFromMaster b/client/shared/scripts/cloneRemoteFromMaster
index 6516b587..cc0a936b 100755
--- a/client/shared/scripts/cloneRemoteFromMaster
+++ b/client/shared/scripts/cloneRemoteFromMaster
@@ -247,7 +247,9 @@ case $MASTERIP in
SIZEIMAGE=$(echo $INFOEXTRA | awk '{print $4}')
echo -n "[26] $INFOEXTRA = herramienta= $TOOLCLONE compresor= $COMPRESOR size= $SIZEIMAGE "
ogMount $DISKTARGET $PARTTARGET || ogFormat $DISKTARGET $PARTTARGET
- SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | awk '{y=x; x=$4};END{print y}' | tr -d kB)
+ #SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | awk '{y=x; x=$4};END{print y}' | tr -d kB)
+ SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | grep Disk | awk -F" " '{print $3}' | tr -d kB);
+
echo "[29] comprobando que el tamaño de la imagen $SIZEIMAGE es menor que el de la particion destino $SIZEPARTTARGET"
# comprobamos que el tamaño de a imagen es menor que la del cliente.
if [ "$SIZEIMAGE" -lt "$SIZEPARTTARGET" ]
diff --git a/client/shared/scripts/configureOs b/client/shared/scripts/configureOs
index 64249c9b..c9660d4d 100755
--- a/client/shared/scripts/configureOs
+++ b/client/shared/scripts/configureOs
@@ -15,6 +15,9 @@
#@version 1.0.1 - Configura el sector de la particion y el gestor de windows para iniciarse desde cualquier particion.
#@author Antonio J. Doblas Viso. Universidad de Malaga.
#@date 2011-05-20
+#@version 1.0.2 - Configura el sector de la particion y el gestor de linux para iniciarse desde cualquier particion.
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2011-11-22
@@ -32,15 +35,20 @@ FLAGACTIVE=$(ogGetPartitionActive $1)
# Cambiar nombre en sistemas Windows y quitar usuario de acceso por defecto.
if [ "$(ogGetOsType $1 $2)" = "Windows" ]; then
+ # Cambiar nombre en sistemas Windows.
HOST=$(ogGetHostname)
HOST=${HOST:-"pc"}
- echo " Cambiar nombre Windows a \"$HOST\" "
ogSetWindowsName $1 $2 "$HOST"
- #ogSetWinlogonUser $1 $2 " " # Descomentar para cambiar usuario de inicio.
- # Configurar el boot sector de la particion windows.
- ogFixBootSector $1 $2
- # Configura el gestor de arranque de windows xp vista seven
+ # Descomentar la siguiente línea para cambiar usuario de inicio.
+ #ogSetWinlogonUser $1 $2 " "
+ # Configurar el boot sector de la partición Windows.
+ ogFixBootSector $1 $2
+ # Configurar el gestor de arranque de Windows XP/Vista/7.
ogWindowsBootParameters $1 $2
- # Registra en windows que la particion indicada es su nueva unidad c:\
+ # Registrar en Windows que la partición indicada es su nueva unidad C:\
ogWindowsRegisterPartition $1 $2 C $1 $2
+fi
+
+if [ "$(ogGetOsType $1 $2)" = "Linux" ]; then
+ ogGrubInstallPartition $1 $2
fi \ No newline at end of file
diff --git a/client/shared/scripts/createImage b/client/shared/scripts/createImage
index 3643d1af..3bba9d36 100755
--- a/client/shared/scripts/createImage
+++ b/client/shared/scripts/createImage
@@ -23,10 +23,12 @@
#@version 1.0 - control de errores para el ogAdmServer
#@author
#@date 2011-04-10
-#@version 1.0.1 - Fin de control de errores para el ogAdmServer
-#@author
+#@version 1.0.1 - Control de espacio requerido
+#@author Antonio J.Doblas Viso
#@date 2011-05-10
-
+ #@version 1.0.2 - Separacion de log
+#@author Antonio J.Doblas Viso
+#@date 2011-08-4
#*/ ##
# Test 1. crear una imagen en un REPO sin espacio libre.
@@ -36,6 +38,12 @@
# test 5. intentar crear una imagen, en la que no se puede reducir el FS.
TIME1=$SECONDS
+OGLOGSESSION="/tmp/session.log"
+OGLOGCOMMAND="/tmp/command.log"
+
+
+
+
PROG="$(basename $0)"
if [ $# -ne 4 ]; then
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen"
@@ -47,29 +55,38 @@ IMGPROG="partclone"
IMGCOMP="lzop"
IMGEXT="img"
+echo "[1] Iniciando $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE
+
+
# Si el repositorio es CACHE comprobamos que exista
if [ "$3" == "CACHE" -o "$3" == "cache" ]; then
! ogFindCache >/dev/null && exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?)
fi
+echo " " > $OGLOGCOMMAND
+
# Obtener información de los parámetros de entrada.
PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2"; echo $?)
+echo " " > $OGLOGCOMMAND
+
#Comprobamos acceso de escritura.
DIRTEMP=$(date +%Y%m%d-%H%M%S)
ogMakeDir $3 /$4$DIRTEMP 2>/dev/null || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3"; echo $?) && ogDeleteTree $3 /$4$DIRTEMP
+echo " " > $OGLOGCOMMAND
+
IMGDIR=$(ogGetParentPath "$3" "/$4")
# Si no existe, crear subdirectorio de la imagen.
if [ $? != 0 ]; then
- echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")."
+ echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")." | tee -a $OGLOGSESSION $OGLOGFILE
ogMakeDir "$3" $(dirname "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?)
fi
IMGFILE=$IMGDIR/$(basename "/$4").$IMGEXT
# Renombrar el fichero de imagen si ya existe.
if [ -f "$IMGFILE" ]; then
- echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
+ echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"." | tee -a $OGLOGSESSION $OGLOGFILE
mv "$IMGFILE" "$IMGFILE.ant"
mv "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
fi
@@ -90,9 +107,11 @@ else
exit $?
fi
+echo " " > $OGLOGCOMMAND
+
# Mostrar información.
-echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE"
-echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE"
+echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE" | tee -a $OGLOGSESSION $OGLOGFILE
+echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE
[ "$SIZEREQUIRED" -gt "$SIZEFREE" ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3" || echo $?)
@@ -100,21 +119,25 @@ echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE"
# TODO: que hacer si la cache no tiene espacio libre.
# Comprobar consistencia del sistema de archivos.
-echo "[20] Comprobar sistema de archivos."
+echo "[20] Comprobar sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE
ogUnmount $1 $2
ogCheckFs $1 $2 || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2" && echo $?)
-echo "[30]: Reducir sistema de archivos."
+echo " " > $OGLOGCOMMAND
+
+echo "[30]: Reducir sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE
ogReduceFs $1 $2 || exit $(ogRaiseError $OG_ERR_REDUCEFS "$1 $2"; echo $?)
+echo " " > $OGLOGCOMMAND
+
# Crear la imagen.
-echo "[40] Crear imagen con: ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP"
+echo "[40] Crear imagen con: ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP" | tee -a $OGLOGSESSION $OGLOGFILE
ogCreateImage $1 "$2" $3 $4 "$IMGPROG" "$IMGCOMP" || exit $(ogRaiseError $OG_ERR_IMAGE "ogCreteImage"; echo $?)
-echo "[90] Extender sistema de archivos."
+echo "[90] Extender sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE
ogExtendFs $1 $2 || exit $(ogRaiseError $OG_ERR_EXTENDFS "$1 $2"; echo $?)
TIME=$[SECONDS-TIME1]
-echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
+echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE
diff --git a/client/shared/scripts/deployImage b/client/shared/scripts/deployImage
index 16a403cc..e5a2bec3 100755
--- a/client/shared/scripts/deployImage
+++ b/client/shared/scripts/deployImage
@@ -1,6 +1,31 @@
#!/bin/bash
+#/**
+# deployImage
+#@brief Actualiza la cache del cliente con una imagen, y la restaura en la partición.
+#@param 1
+#@param ejemplo:
+#@return
+#@exception OG_ERR_FORMAT formato incorrecto.
+#@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.2 - Separacion de log
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2010/08/04
+#*/ ##
+
TIME1=$SECONDS
+
+OGLOGSESSION="/tmp/session.log"
+OGLOGCOMMAND="/tmp/command.log"
+
+
PROG="$(basename $0)"
if [ $# -lt 4 ]; then
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]"
@@ -8,20 +33,20 @@ if [ $# -lt 4 ]; then
fi
#controlar param1 REPO
-echo "Realizando un updateCache REPO $2.img $5 $6"
-updateCache REPO $2.img $5 $6
+echo "[1] Realizando un updateCache REPO $2.img $5 $6" | tee -a $OGLOGSESSION $OGLOGFILE
+updateCache REPO $2.img $5 $6 | tee -a $OGLOGCOMMAND
RETVAL=$?
if [ "$RETVAL" != "0" ]
then
- echo "fin del updateCache REPO $2.img $5 $6 con error $RETVAL"
+ echo "[49] Fin del updateCache REPO $2.img $5 $6 con error $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE
# RC=15 No hay cache
# RC=16 no hay espacio sufiente
exit $RETVAL
else
- echo "iniciando un ogRestore CACHE desde deployImage"
- ogRestoreImage CACHE /$2 $3 $4
+ echo "[50] Iniciando un ogRestore CACHE desde deployImage" | tee -a $OGLOGSESSION $OGLOGFILE
+ ogRestoreImage CACHE /$2 $3 $4 &>> $OGLOGCOMMAND
RETVAL=$?
- [ "$RETVAL" == "0" ] && configureOs $3 $4
+ [ "$RETVAL" == "0" ] && configureOs $3 $4 | tee -a $OGLOGCOMMAND
exit $RETVAL
fi \ No newline at end of file
diff --git a/client/shared/scripts/listPartitions b/client/shared/scripts/listPartitions
new file mode 100755
index 00000000..6f9c318f
--- /dev/null
+++ b/client/shared/scripts/listPartitions
@@ -0,0 +1,3 @@
+#!/bin/bash
+ogListPartitions "$@" | sed 's/\(EMPTY:0 \)*$//'
+
diff --git a/client/shared/scripts/restoreImage b/client/shared/scripts/restoreImage
index a01f1a49..f08c0415 100755
--- a/client/shared/scripts/restoreImage
+++ b/client/shared/scripts/restoreImage
@@ -76,14 +76,10 @@ ogRestoreImage "$@" || exit $?
# Restaurar tamaño.
echo "[80] Extender sistema de archivos."
ogExtendFs $3 $4
-# Cambiar nombre en sistemas Windows y quitar usuario de acceso por defecto.
-if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then
- HOST=$(ogGetHostname)
- HOST=${HOST:-"pc"}
- echo "[90] Cambiar nombre Windows a \"$HOST\" y usuario de acceso."
- ogSetWindowsName $3 $4 "$HOST"
- #ogSetWinlogonUser $3 $4 " " # Descomentar para cambiar usuario de inicio.
-fi
+# Llamar al script de post-configuración del sistema operativo.
+echo "[90] Post-configuracion de aranque del sistema."
+configureOs $3 $4
+
TIME=$[SECONDS-TIME1]
echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s"
diff --git a/client/shared/scripts/runAplicationX.sh b/client/shared/scripts/runAplicationX.sh
new file mode 100755
index 00000000..85f96814
--- /dev/null
+++ b/client/shared/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/runhttplog.sh b/client/shared/scripts/runhttplog.sh
new file mode 100755
index 00000000..04d3e530
--- /dev/null
+++ b/client/shared/scripts/runhttplog.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+echo "export OGLOGCOMMAND=/tmp/command.log" >> /etc/profile.d/loadenviron.sh
+echo "export OGLOGSESSION=/tmp/session.log" >> /etc/profile.d/loadenviron.sh
+ export OGLOGCOMMAND=/tmp/command.log
+ export OGLOGSESSION=/tmp/session.log
+
+#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
+cp /opt/opengnsys/lib/httpd/* /usr/lib/cgi-bin
+#TODO:
+dstat -dn 10 > /tmp/bandwidth &
+#Se pasan al loadenviro para su uso en ssh
+#export OGLOGSESSION=/tmp/session.log
+#export OGLOGCOMMAND=/tmp/command.log
+touch $OGLOGCOMMAND
+touch $OGLOGSESSION
+touch ${OGLOGCOMMAND}.tmp
+chmod 777 $OGLOGCOMMAND
+chmod 777 $OGLOGSESSION
+chmod 777 ${OGLOGCOMMAND}.tmp
+touch /tmp/menu.tmp
+chmod 777 /tmp/menu.tmp
+echo "WAITING" >> $OGLOGSESSION
+# http-log-status \ No newline at end of file
diff --git a/client/shared/scripts/updateBootCache b/client/shared/scripts/updateBootCache
index af2267a2..f3edae7c 100755
--- a/client/shared/scripts/updateBootCache
+++ b/client/shared/scripts/updateBootCache
@@ -1,7 +1,54 @@
#!/bin/bash
-OGBTFTP="/opt/og2fs/tftpboot/ogclient/"
+
+#/**
+# updateBootCache
+#@brief acelerador arranque pxe. incorpora a la cache el initrd y el kernel.
+#@param 1
+#@param ejemplo:
+#@return
+#@exception OG_ERR_FORMAT formato incorrecto.
+#@note
+#@todo:
+#@version 1.0.1 - requiere el gestor de arranque grub2dos
+#@author Antonio J. Doblas Viso. Universidad de Malaga.
+#@date 2010/07/27
+#*/ ##
+
+
+
+OGBTFTP="/opt/oglive/tftpboot/ogclient"
ogMountCache || exit 1
-echo $OGCAC
+
[ -d $OGCAC/boot ] || mkdir -p $OGCAC/boot
-[ -f ${OGCAC}/boot/ogvmlinuz ] || cp ${OGBTFTP}ogvmlinuz ${OGCAC}/boot/ogvmlinuz
-[ -f ${OGCAC}/boot/oginitrd.img ] || cp ${OGBTFTP}oginitrd.img ${OGCAC}/boot/oginitrd.img \ No newline at end of file
+
+ # comparamos los del server
+ SERVERVMLINUZ=`cat ${OGBTFTP}/ogvmlinuz.sum`
+ SERVERINITRD=`cat ${OGBTFTP}/oginitrd.img.sum`
+
+ #comparamos los de la cache
+ CACHEVMLINUZ=`cat ${OGCAC}/boot/ogvmlinuz.sum`
+ CACHEINITRD=`cat ${OGCAC}/cache/boot/oginitrd.img.sum`
+
+ echo "MD5 on SERVER: $SERVERVMLINUZ $SERVERINITRD"
+ echo "MD5 on CACHE: $CACHEVMLINUZ $CACHEINITRD"
+
+
+ if [ "$CACHEVMLINUZ" != "$SERVERVMLINUZ" ]
+ then
+ echo "ogvmlinuz updating"
+ cp ${OGBTFTP}ogvmlinuz ${OGCAC}/boot/ogvmlinuz
+ cp ${OGBTFTP}ogvmlinuz.sum ${OGCAC}/boot/ogvmlinuz.sum
+ DOREBOOT=true
+ fi
+ if [ "$CACHEINITRD" != "$SERVERINITRD" ]
+ then
+ echo "oginitrd updating"
+ cp ${OGBTFTP}oginitrd.img ${OGCAC}/boot/oginitrd.img
+ cp ${OGBTFTP}oginitrd.img.sum ${OGCAC}/boot/oginitrd.img.sum
+ DOREBOOT=true
+ fi
+
+echo $DOREBOOT
+# [ "$DOREBOOT" == "true" ] && busybox reboot -f
+
+
diff --git a/client/shared/scripts/updateCache b/client/shared/scripts/updateCache
index bebb1153..2b7f2c3f 100755
--- a/client/shared/scripts/updateCache
+++ b/client/shared/scripts/updateCache
@@ -1,17 +1,29 @@
#!/bin/bash
-# Scirpt para la actualizacion de datos en la cache.
-# Versión: 0.9.1, 2008/03/17, - integracion eac
-# Versión: 0.9.2, 2010/07/27, - integracion opengnsys
-
-
-
-#1 REPO
-#2 nombre del fichero con su extension, tipo /imagen1.img o /ubuntu.iso
-#3 Protocolo TORRENT | MULTICAST | UNICAST
-#4 opciones protocolo
-#5 opciones de update cache
+#/**
+# 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.
+#@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
+#*/ ##
PROG="$(basename $0)"
if [ $# -lt 3 ]; then
@@ -19,9 +31,9 @@ if [ $# -lt 3 ]; then
exit $?
fi
-REPOSITORIO=$1
-PROTOCOLO=$3
-OPTPROTOCOLO=$4
+REPOSITORIO="$1"
+PROTOCOLO="$3"
+OPTPROTOCOLO="$4"
REPOIP=$(ogGetRepoIp)
echo $REPOSITORIO $REPOIP $PROTOCOLO $OPTPROTOCOLO
# Si el repositorio local CACHE no existe salimos.
@@ -39,7 +51,7 @@ ogUpdateCacheIsNecesary $1 $2; RETVAL=$?
CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
-FILESIZE=$(ls -sk $(ogGetPath $1 $2) | cut -f1 -d" ")
+FILESIZE=$(ls -sk $(ogGetPath $REPOSITORIO "$2") | cut -f1 -d" ")
if [ "$FILESIZE" -ge "$CACHESIZEFREE" ]
then
@@ -48,32 +60,35 @@ then
exit $?
fi
-ogUpdateCacheIsNecesary $1 $2; RETVAL=$?
+ogUpdateCacheIsNecesary $REPOSITORIO "$2"; 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 1
-ogMountCache
+ogMountCache >/dev/null
## Si no existe, crear subdirectorio para el fichero en la cache.
-IMGDIR=$(ogGetParentPath "$1" "/$2")
+IMGDIR=$(ogGetParentPath CACHE "/$2")
if [ $? != 0 ]; then
echo "[5] Crear subdirectorio del fichero \"$2 $(dirname "$2")."
- ogMakeDir "CACHE" $(dirname "/$2")
- IMGDIR=$(ogGetParentPath "$1" "/$2") || exit $?
+ ogMakeDir CACHE $(dirname "/$2")
+ IMGDIR=$(ogGetParentPath CACHE "/$2") || exit $?
fi
-
-
case "$PROTOCOLO" in
torrent | TORRENT )
- echo "ogCopyFile $1 $2.torrent absolute $OGCAC$OGIMG"
- ogCopyFile $1 $2.torrent $OGCAC$OGIMG
+ echo "ogCopyFile $1 $2.torrent absolute $OGCAC/$OGIMG"
+ # tiempos
+ timewait=$(expr $(printf '%d\n' 0x$(ogGetMacAddress | awk -F: '{print $5$6}')) \* 120 / 65535)
+ ogCopyFile $REPOSITORIO "$2.torrent" "$IMGDIR"
#TODO: comprobar que el tracker definido en el fichero es correcto.
#TODO comprobar que el fichero torrent está en cache
- echo "ogTorrentStart CACHE $2.torrent $4"
- ogTorrentStart CACHE $2.torrent $4
+ # retardamos el inicio -aleatorio de 0 a 120 segundos- al tracker para gestionar mas de +-40 equipos
+ P2PWAIT=$[ ( $RANDOM % 120 ) + 1 ]
+ echo "Esperando $P2PWAIT segundos para iniciar ogTorrentStart CACHE $2.torrent $4"
+ sleep $P2PWAIT
+ ogTorrentStart CACHE "$2.torrent" $4
;;
multicast | MULTICAST )
echo "determinando puerto principal y auxiliar."
@@ -86,7 +101,7 @@ case "$PROTOCOLO" in
echo "comprobando puerto $PORTAUX en $REPOIP (sesion multicast en puerto $PORT) "
if (nmap -n -sU -p $PORTAUX $REPOIP | grep open)
then
- ogMcastReceiverFile $PORT CACHE $2
+ ogMcastReceiverFile $PORT CACHE "$2"
else
# TODO ticket 379 Realizar la petición basada en identificador de operacion
echo "solicita la apertura: hose $REPOIP 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO""
@@ -95,7 +110,7 @@ case "$PROTOCOLO" in
sleep 10
if (nmap -n -sU -p $PORTAUX $REPOIP | grep open)
then
- ogMcastReceiverFile $PORT CACHE $2
+ ogMcastReceiverFile $PORT CACHE "$2"
else
echo "la peticion ha fallado: hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST $2 $OPTPROTOCOLO"
exit 1
@@ -104,13 +119,14 @@ case "$PROTOCOLO" in
;;
unicast | UNICAST )
echo "unicast"
- ogCopyFile $1 $2 $OGCAC$OGIMG
+ ogCopyFile $REPOSITORIO "$2" "$IMGDIR"
;;
esac
-ogUpdateCacheIsNecesary $1 $2; RETVAL=$?
+ogUpdateCacheIsNecesary $REPOSITORIO "$2"; RETVAL=$?
# si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1
[ "$RETVAL" == "0" ] && exit 1
[ "$RETVAL" == "1" ] && exit 0
-[ "$RETVAL" -gt "1" ] && exit 1 \ No newline at end of file
+[ "$RETVAL" -gt "1" ] && exit 1
+