summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2014-06-18 10:42:24 +0000
committerramon <ramongomez@us.es>2014-06-18 10:42:24 +0000
commit1602040392ece97f3876f6b756158141a41cac3a (patch)
treedd933aa35b10a8dcb8bfc98c21f51de309f56cad /installer
parent51c2318a7174de452b9ebd41dde9335a97b94e3f (diff)
Versión 1.0.5, #616: Integrar código de la versión 1.0.5 en rama principal.
git-svn-id: https://opengnsys.es/svn/trunk@4309 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'installer')
-rw-r--r--installer/INSTALL.en.txt10
-rw-r--r--installer/INSTALL.es.txt17
-rwxr-xr-xinstaller/install_ticket_wolunicast.sh55
-rwxr-xr-xinstaller/opengnsys_installer.sh433
-rwxr-xr-xinstaller/opengnsys_makecompress.sh9
-rwxr-xr-xinstaller/opengnsys_uninstall.sh57
-rwxr-xr-xinstaller/opengnsys_update.sh215
7 files changed, 568 insertions, 228 deletions
diff --git a/installer/INSTALL.en.txt b/installer/INSTALL.en.txt
index cfff05c5..844c4e74 100644
--- a/installer/INSTALL.en.txt
+++ b/installer/INSTALL.en.txt
@@ -8,19 +8,11 @@ Installing OpenGnsys
--------------------
-For security reasons, it is very important modify defaults users and passwords to access to the system. For this, edit the installation file opengnsys_installer.sh and change the values of configuration variables:
-
- MYSQL_ROOT_PASSWORD - MySQL root user password.
- OPENGNSYS_DB_USER - OpenGnSys access user and OpenGnSys super-user.
- OPENGNSYS_DB_PASSWD - User password.
- OPENGNSYS_CLIENT_PASSWD - Password for client access to remote services.
-
-
Run opengnsys_installer.sh script as "root" to install all its dependencies, to install the OpenGnSys components, and to make the initial configuration.
sudo bash opengnsys_installer.sh
-Follow the post-installation instructions.
+Follow the instructions.
Updating OpenGnSys
diff --git a/installer/INSTALL.es.txt b/installer/INSTALL.es.txt
index 4a809ac1..9c47cbe3 100644
--- a/installer/INSTALL.es.txt
+++ b/installer/INSTALL.es.txt
@@ -17,18 +17,15 @@ O bien, descargar el instalador desde la última reversión del repositorio:
Opcionalmente, puede descargarse la imagen del cliente; si no se realiza este paso, el instalador la descargará automáticamente.
wget http://www.opengnsys.es/downloads/ogLive-versioncliente.iso
-2. Configuración básica.
-
-Como medida de seguridad, debe modificarse los usuarios y claves por defecto de acceso al sistema. Para ello, editar el fichero de instalación opengnsys_installer.sh y modificar los valores de las variables de configuración:
-
- MYSQL_ROOT_PASSWORD - clave del usuario root de MySQL.
- OPENGNSYS_DB_USER - usuario de acceso y super-administrador de OpenGnSys.
- OPENGNSYS_DB_PASSWD - clave del usuario.
- OPENGNSYS_CLIENT_PASSWD - clave de acceso del cliente a servicios remotos.
-
-3. Ejecutar el instalador como root:
+2. Ejecutar el instalador como root:
sudo bash opengnsys_installer.sh
+Dicho script solicitará por teclado la siguiente información para configurar el acceso al servicio (si no se indica un parámetro, toma el valor por defecto):
+ * Clave del usuario root de MySQL.
+ * Usuario de acceso a la consola web y super-administrador de OpenGnSys.
+ * Clave del usuario de acceso a la consola web.
+ * Clave de acceso del cliente a servicios remotos.
+
Actaulización de ficheros
-------------------------
diff --git a/installer/install_ticket_wolunicast.sh b/installer/install_ticket_wolunicast.sh
deleted file mode 100755
index 31621636..00000000
--- a/installer/install_ticket_wolunicast.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-# Instalación del ticket 513: Wake-On-Lan por IP en Unicast.
-
-# Declaración de variables.
-TICKET="513-WOL-Unicast";
-SVNURLSOURCE="http://opengnsys.es/svn/branches/version1.0-tickets/Resueltos/wake_on_lan_por_IP_unicast_ticket513/";
-BASEDIR="/opt/opengnsys/";
-TICKETDIR="${BASEDIR}tickets/";
-TARGETDIR="${TICKETDIR}${TICKET}/";
-LISTTOBACKUP="${TICKETDIR}${TICKET}-BACKUP.txt";
-FILEBACKUP="${TICKETDIR}${TICKET}-BACKUP.tgz";
-SVNURLSOURCEBASE="http://opengnsys.es/svn/trunk/admin/Sources/";
-
-#TODO comprobar version de opengnsys.
-
-echo "Parando los servios."
-/etc/init.d/opengnsys stop
-sleep 5
-
-mkdir -p $TARGETDIR;
-echo "Descargando base de los sources"
-svn export --force $SVNURLSOURCEBASE $TARGETDIR/admin/Sources;
-if [ ! -d $TARGETDIR/admin/Sources ]; then
- echo "Error de acceso a los ficheros fuente" >&2
- exit 1
-fi
-echo "Descando modificaciones del ticket"
-svn export --force $SVNURLSOURCE $TARGETDIR/;
-find $TARGETDIR -name .svn -type d -exec rm -fr {} \;
-
-## Especifico de este tiket
-mv ${TARGETDIR}/admin/WebConsole ${TARGETDIR}/www/
-
-echo "Generando fichero de los archivos involucrados en $LISTTOBACKUP "
-find $TARGETDIR -type f | egrep -v 'Sources|installer-info' | awk -F"$TARGETDIR" '{print $2}' > $LISTTOBACKUP;
-
-#compilamos el ogAdmServer
-cd ${TARGETDIR}/admin/Sources/Services/ogAdmServer
-make
-mkdir -p ${TARGETDIR}sbin/
-cp -a ${TARGETDIR}admin/Sources/Services/ogAdmServer/ogAdmServer ${BASEDIR}sbin/.
-echo "sbin/ogAdmServer" >> $LISTTOBACKUP;
-##
-
-echo "Creando backup en $FILEBACKUP "
-cd $BASEDIR;
-[ -f $FILEBACKUP ] || tar czvf $FILEBACKUP -T $LISTTOBACKUP 2>/dev/null;
-
-echo "Copiando estructura de opengnsys"
-cp -av ${TARGETDIR}/[^installer][^admin]* ${BASEDIR};
-
-echo "Inicando los servicios"
-/etc/init.d/opengnsys start
-sleep 5
-
diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh
index 44baafd4..a0bc643a 100755
--- a/installer/opengnsys_installer.sh
+++ b/installer/opengnsys_installer.sh
@@ -6,35 +6,83 @@
#####################################################################
-
-#### AVISO: Editar configuración de acceso por defecto.
-#### WARNING: Edit default access configuration.
-MYSQL_ROOT_PASSWORD="passwordroot" # Clave root de MySQL
-OPENGNSYS_DB_USER="usuog" # Usuario de acceso a la base de datos
-OPENGNSYS_DB_PASSWD="passusuog" # Clave de acceso a la base de datos
-OPENGNSYS_CLIENT_PASSWD="og" # Clave de acceso del cliente
-
-
-#### AVISO: NO EDITAR.
-#### WARNING: DO NOT EDIT.
-OPENGNSYS_DATABASE="ogAdmBD" # Nombre de la base datos
-OPENGNSYS_CLIENT_USER="opengnsys" # Usuario del cliente para acceso remoto
-
-
+#### AVISO: Puede editar configuración de acceso por defecto.
+#### WARNING: Edit default access configuration if you wish.
+DEFAULT_MYSQL_ROOT_PASSWORD="passwordroot" # Clave por defecto root de MySQL
+DEFAULT_OPENGNSYS_DB_USER="usuog" # Usuario por defecto de acceso a la base de datos
+DEFAULT_OPENGNSYS_DB_PASSWD="passusuog" # Clave por defecto de acceso a la base de datos
+DEFAULT_OPENGNSYS_CLIENT_PASSWD="og" # Clave por defecto de acceso del cliente
# Sólo ejecutable por usuario root
if [ "$(whoami)" != 'root' ]; then
echo "ERROR: this program must run under root privileges!!"
exit 1
fi
-# Solo se deben aceptar números y letras en la clave de acceso del cliente.
-if [ -n "${OPENGNSYS_CLIENT_PASSWD//[a-zA-Z0-9]/}" ]; then
- echo "ERROR: client password must be alphanumeric, edit installer variables."
- exit 1
-fi
+
+echo -e "\\nOpenGnSys Installation"
+echo "=============================="
+
+# Clave root de MySQL
+while : ; do
+ echo -n -e "\\nEnter root password for MySQL (${DEFAULT_MYSQL_ROOT_PASSWORD}): ";
+ read MYSQL_ROOT_PASSWORD
+ if [ -n "${MYSQL_ROOT_PASSWORD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
+ echo -e "\\aERROR: Must be alphanumeric, try again..."
+ else
+ if [ -z $MYSQL_ROOT_PASSWORD ]; then # Si esta vacio ponemos el valor por defecto
+ MYSQL_ROOT_PASSWORD=$DEFAULT_MYSQL_ROOT_PASSWORD
+ fi
+ break
+ fi
+done
+
+# Usuario de acceso a la base de datos
+while : ; do
+ echo -n -e "\\nEnter username for OpenGnSys console (${DEFAULT_OPENGNSYS_DB_USER}): "
+ read OPENGNSYS_DB_USER
+ if [ -n "${OPENGNSYS_DB_USER//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
+ echo -e "\\aERROR: Must be alphanumeric, try again..."
+ else
+ if [ -z $OPENGNSYS_DB_USER ]; then # Si esta vacio ponemos el valor por defecto
+ OPENGNSYS_DB_USER=$DEFAULT_OPENGNSYS_DB_USER
+ fi
+ break
+ fi
+done
+
+# Clave de acceso a la base de datos
+while : ; do
+ echo -n -e "\\nEnter password for OpenGnSys console (${DEFAULT_OPENGNSYS_DB_PASSWD}): "
+ read OPENGNSYS_DB_PASSWD
+ if [ -n "${OPENGNSYS_DB_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
+ echo -e "\\aERROR: Must be alphanumeric, try again..."
+ else
+ if [ -z $OPENGNSYS_DB_PASSWD ]; then # Si esta vacio ponemos el valor por defecto
+ OPENGNSYS_DB_PASSWD=$DEFAULT_OPENGNSYS_DB_PASSWD
+ fi
+ break
+ fi
+done
+
+# Clave de acceso del cliente
+while : ; do
+ echo -n -e "\\nEnter root password for OpenGnSys client (${DEFAULT_OPENGNSYS_CLIENT_PASSWD}): "
+ read OPENGNSYS_CLIENT_PASSWD
+ if [ -n "${OPENGNSYS_CLIENT_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
+ echo -e "\\aERROR: Must be alphanumeric, try again..."
+ else
+ if [ -z $OPENGNSYS_CLIENT_PASSWD ]; then # Si esta vacio ponemos el valor por defecto
+ OPENGNSYS_CLIENT_PASSWD=$DEFAULT_OPENGNSYS_CLIENT_PASSWD
+ fi
+ break
+ fi
+done
+
+echo -e "\\n=============================="
# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
PROGRAMDIR=$(readlink -e $(dirname "$0"))
+PROGRAMNAME=$(basename "$0")
OPENGNSYS_SERVER="www.opengnsys.es"
if [ -d "$PROGRAMDIR/../installer" ]; then
USESVN=0
@@ -46,11 +94,19 @@ SVN_URL="http://$OPENGNSYS_SERVER/svn/trunk/"
WORKDIR=/tmp/opengnsys_installer
mkdir -p $WORKDIR
+# Directorio destino de OpenGnSys.
INSTALL_TARGET=/opt/opengnsys
-LOG_FILE=/tmp/opengnsys_installation.log
-# Base de datos
-OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/ogAdmBD.sql
+# Registro de incidencias.
+OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
+LOG_FILE=/tmp/$(basename $OGLOGFILE)
+
+# Usuario del cliente para acceso remoto.
+OPENGNSYS_CLIENT_USER="opengnsys"
+
+# Nombre de la base datos y fichero SQL para su creación.
+OPENGNSYS_DATABASE="ogAdmBD"
+OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/${OPENGNSYS_DATABASE}.sql
#####################################################################
@@ -59,7 +115,7 @@ OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/ogAdmBD.sql
# Generar variables de configuración del instalador
# Variables globales:
-# - OSDISTRIB, OSCODENAME - datos de la distribución Linux
+# - OSDISTRIB - tipo de distribución GNU/Linux
# - DEPENDENCIES - array de dependencias que deben estar instaladas
# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKGS - comandos para gestión de paquetes
# - INSTALLEXTRADEPS - instalar dependencias no incluidas en la distribución
@@ -69,21 +125,27 @@ OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/ogAdmBD.sql
# - APACHESSLMOD, APACHEENABLESSL, APACHEMAKECERT - habilitar módulo Apache y certificado SSL
# - APACHEENABLEOG, APACHEOGSITE, - habilitar sitio web de OpenGnSys
# - INETDSERV - servicio Inetd
-# - IPTABLESSERV - servicio IPTables
+# - FIREWALLSERV - servicio de cortabuegos IPTables/FirewallD
# - DHCPSERV, DHCPCFGDIR - servicio y configuración de DHCP
-# - MYSQLSERV - servicio MySQL
+# - MYSQLSERV, TMPMYCNF - servicio MySQL y fichero temporal con credenciales de acceso
+# - MARIADBSERV - servicio MariaDB (sustituto de MySQL en algunas distribuciones)
+# - RSYNCSERV, RSYNCCFGDIR - servicio y configuración de Rsync
# - SAMBASERV, SAMBACFGDIR - servicio y configuración de Samba
# - TFTPSERV, TFTPCFGDIR, SYSLINUXDIR - servicio y configuración de TFTP/PXE
function autoConfigure()
{
-# Detectar sistema operativo del servidor (debe soportar LSB).
-OSDISTRIB=$(lsb_release -is 2>/dev/null)
-OSCODENAME=$(lsb_release -cs 2>/dev/null)
+# Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
+if [ -f /etc/os-release ]; then
+ source /etc/os-release
+ OSDISTRIB="$NAME"
+else
+ OSDISTRIB=$(lsb_release -is 2>/dev/null)
+fi
-# Configuración según la distribución de Linux.
+# Configuración según la distribución GNU/Linux.
case "$OSDISTRIB" in
Ubuntu|Debian|LinuxMint)
- DEPENDENCIES=( subversion apache2 php5 libapache2-mod-php5 mysql-server php5-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa syslinux openbsd-inetd update-inetd build-essential g++-multilib libmysqlclient15-dev wget doxygen graphviz bittornado ctorrent samba unzip netpipes debootstrap schroot squashfs-tools )
+ DEPENDENCIES=( subversion apache2 php5 php5-ldap libapache2-mod-php5 mysql-server php5-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa syslinux xinetd build-essential g++-multilib libmysqlclient15-dev wget doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps )
UPDATEPKGLIST="apt-get update"
INSTALLPKG="apt-get -y install --force-yes"
CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install"
@@ -108,24 +170,38 @@ case "$OSDISTRIB" in
APACHEMAKECERT="make-ssl-cert generate-default-snakeoil --force-overwrite"
DHCPSERV=isc-dhcp-server
DHCPCFGDIR=/etc/dhcp
- INETDSERV=openbsd-inetd
+ INETDSERV=xinetd
+ INETDCFGDIR=/etc/xinetd.d
MYSQLSERV=mysql
+ MARIADBSERV=mariadb
+ RSYNCSERV=rsync
+ RSYNCCFGDIR=/etc
SAMBASERV=smbd
SAMBACFGDIR=/etc/samba
SYSLINUXDIR=/usr/lib/syslinux
TFTPCFGDIR=/var/lib/tftpboot
;;
Fedora|CentOS)
- DEPENDENCIES=( subversion httpd mod_ssl php mysql-server mysql-devel mysql-devel.i686 php-mysql dhcp tftp-server tftp syslinux binutils gcc gcc-c++ glibc-devel glibc-devel.i686 glibc-static glibc-static.i686 libstdc++ libstdc++.i686 libstdc++-devel.i686 make wget doxygen graphviz ctorrent samba unzip debootstrap schroot squashfs-tools )
+ DEPENDENCIES=( subversion httpd mod_ssl php php-ldap mysql-server mysql-devel mysql-devel.i686 php-mysql dhcp tftp-server tftp syslinux xinetd binutils gcc gcc-c++ glibc-devel glibc-devel.i686 glibc-static glibc-static.i686 libstdc++ libstdc++.i686 libstdc++-devel.i686 make wget doxygen graphviz ctorrent samba rsync unzip debootstrap schroot squashfs-tools python-crypto )
INSTALLEXTRADEPS=( 'rpm -Uv ftp://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/files/i586/RPMS/netpipes-4.2-alt1.i586.rpm'
- 'pushd /tmp; wget http://download2.bittornado.com/download/BitTornado-0.3.18.tar.gz; tar xvzf BitTornado-0.3.18.tar.gz; cd BitTornado-CVS; python setup.py install; ln -s btlaunchmany.py /usr/bin/btlaunchmany; ln -s bttrack.py /usr/bin/bttrack; popd' )
- UPDATEPKGLIST='test rpm -q --quiet epel-release || echo -e "[epel]\nname=EPEL temporal\nmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-\$releasever&arch=\$basearch\nenabled=1\ngpgcheck=0" >/etc/yum.repos.d/epel.repo'
+ 'pushd /tmp; wget http://download.bittornado.com/download/BitTornado-0.3.18.tar.gz; tar xvzf BitTornado-0.3.18.tar.gz; cd BitTornado-CVS; python setup.py install; ln -fs btlaunchmany.py /usr/bin/btlaunchmany; ln -fs bttrack.py /usr/bin/bttrack; popd' )
+ if [ "$OSDISTRIB" == "CentOS" ]; then
+ UPDATEPKGLIST='test rpm -q --quiet epel-release || echo -e "[epel]\nname=EPEL temporal\nmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-\$releasever&arch=\$basearch\nenabled=1\ngpgcheck=0" >/etc/yum.repos.d/epel.repo'
+ fi
INSTALLPKG="yum install -y"
CHECKPKG="rpm -q --quiet \$package"
- STARTSERVICE="eval service \$service start"
- STOPSERVICE="eval service \$service stop"
- ENABLESERVICE="eval chkconfig \$service on"
- DISABLESERVICE="eval chkconfig \$service off"
+ SYSTEMD=$(which systemctl 2>/dev/null)
+ if [ -n "$SYSTEMD" ]; then
+ STARTSERVICE="eval systemctl start \$service.service"
+ STOPSERVICE="eval systemctl stop \$service.service"
+ ENABLESERVICE="eval systemctl enable \$service.service"
+ DISABLESERVICE="eval systemctl disable \$service.service"
+ else
+ STARTSERVICE="eval service \$service start"
+ STOPSERVICE="eval service \$service stop"
+ ENABLESERVICE="eval chkconfig \$service on"
+ DISABLESERVICE="eval chkconfig \$service off"
+ fi
APACHESERV=httpd
APACHECFGDIR=/etc/httpd/conf.d
APACHEOGSITE=opengnsys.conf
@@ -133,9 +209,17 @@ case "$OSDISTRIB" in
APACHEGROUP="apache"
DHCPSERV=dhcpd
DHCPCFGDIR=/etc/dhcp
+ if firewall-cmd --state &>/dev/null; then
+ FIREWALLSERV=firewalld
+ else
+ FIREWALLSERV=iptables
+ fi
INETDSERV=xinetd
- IPTABLESSERV=iptables
+ INETDCFGDIR=/etc/xinetd.d
MYSQLSERV=mysqld
+ MARIADBSERV=mariadb
+ RSYNCSERV=rsync
+ RSYNCCFGDIR=/etc
SAMBASERV=smb
SAMBACFGDIR=/etc/samba
SYSLINUXDIR=/usr/share/syslinux
@@ -147,14 +231,27 @@ case "$OSDISTRIB" in
*) echo "ERROR: Distribution not supported by OpenGnSys."
exit 1 ;;
esac
+
+# Fichero de credenciales de acceso a MySQL.
+TMPMYCNF=/tmp/.my.cnf.$$
}
+
# Modificar variables de configuración tras instalar paquetes del sistema.
function autoConfigurePost()
{
-[ -e /etc/init.d/$SAMBASERV ] || SAMBASERV=samba # Debian 6
-[ -e $TFTPCFGDIR ] || TFTPCFGDIR=/srv/tftp # Debian 6
-[ -f /selinux/enforce ] && echo 0 > /selinux/enforce # SELinux permisivo
+local f
+
+# Configuraciones específicas para Samba y TFTP en Debian 6.
+[ -z "$SYSTEMD" -a ! -e /etc/init.d/$SAMBASERV ] && SAMBASERV=samba
+[ ! -e $TFTPCFGDIR ] && TFTPCFGDIR=/srv/tftp
+
+# Configuraciones específicas para SELinux permisivo en distintas versiones.
+[ -f /selinux/enforce ] && echo 0 > /selinux/enforce
+for f in /etc/sysconfig/selinux /etc/selinux/config; do
+ [ -f $f ] && perl -pi -e 's/SELINUX=enforcing/SELINUX=permissive/g' $f
+done
+selinuxenabled 2>/dev/null && setenforce 0 2>/dev/null
}
@@ -181,8 +278,12 @@ case "$OSDISTRIB" in
fi
;;
CentOS) # Postconfiguación personalizada para CentOS.
- # Incluir repositorio de paquetes EPEL.
- DEPENDENCIES=( ${DEPENDENCIES[@]} epel-release )
+ # Incluir repositorio de paquetes EPEL y paquetes específicos.
+ DEPENDENCIES=( ${DEPENDENCIES[@]} epel-release procps )
+ ;;
+ Fedora) # Postconfiguación personalizada para Fedora.
+ # Incluir paquetes específicos.
+ DEPENDENCIES=( ${DEPENDENCIES[@]} libstdc++-static.i686 btrfs-progs procps-ng )
;;
esac
}
@@ -433,9 +534,20 @@ function mysqlTestConnection()
exit 1
fi
- local root_password="${1}"
+ local root_password="$1"
echoAndLog "${FUNCNAME}(): checking connection to mysql..."
- echo "" | mysql -uroot -p"${root_password}"
+ # Componer fichero con credenciales de conexión a MySQL.
+ touch $TMPMYCNF
+ chmod 600 $TMPMYCNF
+ cat << EOT > $TMPMYCNF
+[client]
+user=root
+password=$root_password
+EOT
+ # Borrar el fichero temporal si termina el proceso de instalación.
+ trap "rm -f $TMPMYCNF" 0 1 2 3 6 9 15
+ # Comprobar conexión a MySQL.
+ echo "" | mysql --defaults-extra-file=$TMPMYCNF
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): connection to mysql failed, check root password and if daemon is running!"
return 1
@@ -448,15 +560,14 @@ function mysqlTestConnection()
# comprueba si la base de datos existe
function mysqlDbExists()
{
- if [ $# -ne 2 ]; then
+ if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password="${1}"
- local database=$2
+ local database="$1"
echoAndLog "${FUNCNAME}(): checking if $database exists..."
- echo "show databases" | mysql -uroot -p"${root_password}" | grep "^${database}$"
+ echo "show databases" | mysql --defaults-extra-file=$TMPMYCNF | grep "^${database}$"
if [ $? -ne 0 ]; then
echoAndLog "${FUNCNAME}():database $database doesn't exists"
return 1
@@ -468,15 +579,14 @@ function mysqlDbExists()
function mysqlCheckDbIsEmpty()
{
- if [ $# -ne 2 ]; then
+ if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password="${1}"
- local database=$2
+ local database="$1"
echoAndLog "${FUNCNAME}(): checking if $database is empty..."
- num_tablas=`echo "show tables" | mysql -uroot -p"${root_password}" "${database}" | wc -l`
+ num_tablas=`echo "show tables" | mysql --defaults-extra-file=$TMPMYCNF "${database}" | wc -l`
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error executing query, check database and root password"
exit 1
@@ -495,14 +605,13 @@ function mysqlCheckDbIsEmpty()
function mysqlImportSqlFileToDb()
{
- if [ $# -ne 3 ]; then
+ if [ $# -ne 2 ]; then
errorAndLog "${FNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password="$1"
- local database="$2"
- local sqlfile="$3"
+ local database="$1"
+ local sqlfile="$2"
local tmpfile=$(mktemp)
local i=0
local dev=""
@@ -524,7 +633,7 @@ function mysqlImportSqlFileToDb()
fi
let i++
done
- mysql -uroot -p"${root_password}" --default-character-set=utf8 "${database}" < $tmpfile
+ mysql --defaults-extra-file=$TMPMYCNF --default-character-set=utf8 "${database}" < $tmpfile
status=$?
rm -f $tmpfile
if [ $status -ne 0 ]; then
@@ -538,16 +647,15 @@ function mysqlImportSqlFileToDb()
# Crea la base de datos
function mysqlCreateDb()
{
- if [ $# -ne 2 ]; then
+ if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password="${1}"
- local database=$2
+ local database="$1"
echoAndLog "${FUNCNAME}(): creating database..."
- mysqladmin -u root --password="${root_password}" create $database
+ mysqladmin --defaults-extra-file=$TMPMYCNF create $database
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while creating database $database"
return 1
@@ -559,16 +667,15 @@ function mysqlCreateDb()
function mysqlCheckUserExists()
{
- if [ $# -ne 2 ]; then
+ if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password="${1}"
- local userdb=$2
+ local userdb="$1"
echoAndLog "${FUNCNAME}(): checking if $userdb exists..."
- echo "select user from user where user='${userdb}'\\G" |mysql -uroot -p"${root_password}" mysql | grep user
+ echo "select user from user where user='${userdb}'\\G" |mysql --defaults-extra-file=$TMPMYCNF mysql | grep user
if [ $? -ne 0 ]; then
echoAndLog "${FUNCNAME}(): user doesn't exists"
return 1
@@ -582,15 +689,14 @@ function mysqlCheckUserExists()
# Crea un usuario administrativo para la base de datos
function mysqlCreateAdminUserToDb()
{
- if [ $# -ne 4 ]; then
+ if [ $# -ne 3 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
exit 1
fi
- local root_password=$1
- local database=$2
- local userdb=$3
- local passdb=$4
+ local database="$1"
+ local userdb="$2"
+ local passdb="$3"
echoAndLog "${FUNCNAME}(): creating admin user ${userdb} to database ${database}"
@@ -599,7 +705,7 @@ GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ;
GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ;
FLUSH PRIVILEGES ;
EOF
- mysql -u root --password=${root_password} < $WORKDIR/create_${database}.sql
+ mysql --defaults-extra-file=$TMPMYCNF < $WORKDIR/create_${database}.sql
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while creating user in mysql"
rm -f $WORKDIR/create_${database}.sql
@@ -644,15 +750,22 @@ function svnExportCode()
# Comprobar si existe conexión.
function checkNetworkConnection()
{
- echoAndLog "${FUNCNAME}(): Disabling IPTables."
- if [ -n "$IPTABLESSERV" ]; then
- service=$IPTABLESSERV
+ echoAndLog "${FUNCNAME}(): Disabling Firewall: $FIREWALLSERV."
+ if [ -n "$FIREWALLSERV" ]; then
+ service=$FIREWALLSERV
$STOPSERVICE; $DISABLESERVICE
fi
echoAndLog "${FUNCNAME}(): Checking OpenGnSys server conectivity."
OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
- wget --spider -q $OPENGNSYS_SERVER
+ if which wget &>/dev/null; then
+ wget --spider -q $OPENGNSYS_SERVER
+ elif which curl &>/dev/null; then
+ curl --connect-timeout 10 -s $OPENGNSYS_SERVER -o /dev/null
+ else
+ echoAndLog "${FUNCNAME}(): Cannot execute \"wget\" nor \"curl\"."
+ return 1
+ fi
}
# Obtener los parámetros de red de la interfaz por defecto.
@@ -681,7 +794,9 @@ function getNetworkSettings()
for dev in ${DEVICE[*]}; do
SERVERIP[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
if [ -n "${SERVERIP[i]}" ]; then
- NETMASK[i]=$(LANG=C ifconfig $dev | awk '/Mask/ {sub(/.*:/,"",$4); print $4}')
+ NETMASK[i]=$(LANG=C ifconfig $dev | \
+ awk '/Mask/ {sub(/.*:/,"",$4); print $4}
+ /netmask/ {print $4}')
NETBROAD[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {print ($6)}')
NETIP[i]=$(netstat -nr | awk -v d="$dev" '$1!~/0\.0\.0\.0/&&$8==d {if (n=="") n=$1} END {print n}')
ROUTERIP[i]=$(netstat -nr | awk -v d="$dev" '$1~/0\.0\.0\.0/&&$8==d {print $2}')
@@ -717,8 +832,12 @@ function tftpConfigure()
echoAndLog "${FUNCNAME}(): Configuring TFTP service."
# Habilitar TFTP y reiniciar Inetd.
if [ -n "$TFTPSERV" ]; then
- service=$TFTPSERV
- $ENABLESERVICE
+ if [ -f $INETDCFGDIR/$TFTPSERV ]; then
+ perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/$TFTPSERV
+ else
+ service=$TFTPSERV
+ $ENABLESERVICE
+ fi
fi
service=$INETDSERV
$ENABLESERVICE; $STARTSERVICE
@@ -886,6 +1005,57 @@ function smbConfigure()
########################################################################
+## Configuracion servicio Rsync
+########################################################################
+
+# Configurar servicio Rsync.
+function rsyncConfigure()
+{
+ echoAndLog "${FUNCNAME}(): Configuring Rsync service."
+
+ backupFile $RSYNCCFGDIR/rsyncd.conf
+
+ # Configurar acceso a Rsync.
+ sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
+ $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > $RSYNCCFGDIR/rsyncd.conf
+ sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
+ -e "s/CLIENTPASSWORD/$OPENGNSYS_CLIENT_PASSWD/g" \
+ $WORKDIR/opengnsys/repoman/etc/rsyncd.secrets.tmpl > $RSYNCCFGDIR/rsyncd.secrets
+ chown root.root $RSYNCCFGDIR/rsyncd.secrets
+ chmod 600 $RSYNCCFGDIR/rsyncd.secrets
+
+ # Habilitar Rsync y reiniciar Inetd.
+ if [ -n "$RSYNCSERV" ]; then
+ if [ -f /etc/default/rsync ]; then
+ perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
+ fi
+ if [ -f $INETDCFGDIR/rsync ]; then
+ perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
+ else
+ cat << EOT > $INETDCFGDIR/rsync
+service rsync
+{
+ disable = no
+ socket_type = stream
+ wait = no
+ user = root
+ server = $(which rsync)
+ server_args = --daemon
+ log_on_failure += USERID
+ flags = IPv6
+}
+EOT
+ fi
+ service=$RSYNCSERV $ENABLESERVICE
+ service=$INETDSERV $STARTSERVICE
+ fi
+
+ echoAndLog "${FUNCNAME}(): Added Rsync configuration."
+ return 0
+}
+
+
+########################################################################
## Configuracion servicio DHCP
########################################################################
@@ -931,8 +1101,11 @@ function dhcpConfigure()
# Copiar ficheros del OpenGnSys Web Console.
function installWebFiles()
{
+ local COMPATDIR f
+
echoAndLog "${FUNCNAME}(): Installing web files..."
- cp -a $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www #*/ comentario para doxigen
+ # Copiar ficheros.
+ cp -a $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www #*/ comentario para Doxygen.
if [ $? != 0 ]; then
errorAndLog "${FUNCNAME}(): Error copying web files."
exit 1
@@ -940,8 +1113,16 @@ function installWebFiles()
find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null
# Descomprimir XAJAX.
unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
+ # Compatibilidad con dispositivos móviles.
+ COMPATDIR="$INSTALL_TARGET/www/principal"
+ for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
+ sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
+ done
+ cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
# Cambiar permisos para ficheros especiales.
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
+ chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
+
echoAndLog "${FUNCNAME}(): Web files installed successfully."
}
@@ -953,8 +1134,8 @@ function installWebConsoleApacheConf()
exit 1
fi
- local path_opengnsys_base=$1
- local path_apache2_confd=$2
+ local path_opengnsys_base="$1"
+ local path_apache2_confd="$2"
local CONSOLEDIR=${path_opengnsys_base}/www
if [ ! -d $path_apache2_confd ]; then
@@ -972,10 +1153,15 @@ function installWebConsoleApacheConf()
$APACHEMAKECERT
# Genera configuración de consola web a partir del fichero plantilla.
- sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \
- $WORKDIR/opengnsys/server/etc/apache.conf.tmpl > $path_opengnsys_base/etc/apache.conf
-
- ln -fs $path_opengnsys_base/etc/apache.conf $path_apache2_confd/$APACHESITESDIR/$APACHEOGSITE
+ if [ -n "$(apachectl -v | grep "2\.[0-2]")" ]; then
+ # Configuración para versiones anteriores de Apache.
+ sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \
+ $WORKDIR/opengnsys/server/etc/apache-prev2.4.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE}
+ else
+ # Configuración específica a partir de Apache 2.4
+ sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \
+ $WORKDIR/opengnsys/server/etc/apache.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE}.conf
+ fi
$APACHEENABLEOG
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): config file can't be linked to apache conf, verify your server installation"
@@ -1058,6 +1244,11 @@ function createDirs()
return 1
fi
+ # Mover el fichero de registro de instalación al directorio de logs.
+ echoAndLog "${FUNCNAME}(): moving installation log file"
+ mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
+ chmod 600 $LOG_FILE
+
echoAndLog "${FUNCNAME}(): directory paths created"
return 0
}
@@ -1075,6 +1266,8 @@ function copyServerFiles ()
local SOURCES=( server/tftpboot \
server/bin \
repoman/bin \
+ admin/Sources/Services/ogAdmServerAux
+ admin/Sources/Services/ogAdmRepoAux
installer/opengnsys_uninstall.sh \
installer/opengnsys_update.sh \
installer/install_ticket_wolunicast.sh \
@@ -1082,6 +1275,8 @@ function copyServerFiles ()
local TARGETS=( tftpboot \
bin \
bin \
+ sbin \
+ sbin \
lib \
lib \
lib \
@@ -1199,7 +1394,7 @@ function copyClientFiles()
echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files."
mkdir -p $INSTALL_TARGET/client/lib/engine/bin
- cp -a $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin
+ cp -a $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while copying engine files"
errstatus=1
@@ -1215,11 +1410,12 @@ function copyClientFiles()
}
-# Crear cliente OpenGnSys 1.0.2
+# Crear cliente OpenGnSys 1.0.2 y posteriores.
function clientCreate()
{
local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
local FILENAME=ogLive-precise-3.2.0-23-generic-r3257.iso # 1.0.4-rc2
+ #local FILENAME=ogLive-raring-3.8.0-22-generic-r3836.iso # 1.0.5-rc3
local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
local TMPDIR=/tmp/${FILENAME%.iso}
@@ -1269,13 +1465,13 @@ function openGnsysConfigure()
local CONSOLEURL
echoAndLog "${FUNCNAME}(): Copying init files."
- cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
- cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys
- cp -p $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepoAux $INSTALL_TARGET/sbin
+ cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
+ cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys
echoAndLog "${FUNCNAME}(): Creating cron files."
echo "* * * * * root [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
echo "5 * * * * root [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
+ echo "* * * * * root [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
echoAndLog "${FUNCNAME}(): Creating logrotate configuration file."
sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
@@ -1345,17 +1541,19 @@ function installationSummary()
echo "=============================="
echoAndLog "Project version: $(cat $VERSIONFILE 2>/dev/null)"
echoAndLog "Installation directory: $INSTALL_TARGET"
+ echoAndLog "Installation log file: $LOG_FILE"
echoAndLog "Repository directory: $INSTALL_TARGET/images"
echoAndLog "DHCP configuration directory: $DHCPCFGDIR"
echoAndLog "TFTP configuration directory: $TFTPCFGDIR"
echoAndLog "Samba configuration directory: $SAMBACFGDIR"
echoAndLog "Web Console URL: $OPENGNSYS_CONSOLEURL"
- echoAndLog "Web Console admin user: $OPENGNSYS_DB_USER"
- echoAndLog "Web Console admin password: $OPENGNSYS_DB_PASSWD"
+ echoAndLog "Web Console access data: specified in installer script"
echo
echoAndLog "Post-Installation Instructions:"
echo "==============================="
- echoAndLog "Change IPTables and SELinux system configuration, if needed."
+ echoAndLog "Firewall service has been disabled and SELinux mode set to"
+ echoAndLog " permissive during OpenGnSys installation. Please check"
+ echoAndLog " $FIREWALLSERV and SELinux configuration, if needed."
echoAndLog "Review or edit all configuration files."
echoAndLog "Insert DHCP configuration data and restart service."
echoAndLog "Optional: Log-in as Web Console admin user."
@@ -1450,17 +1648,20 @@ if [ $? -ne 0 ]; then
exit 1
fi
-# Configurando tftp
+# Configuración de TFTP.
tftpConfigure
-# Configuración Samba
+# Configuración de Samba.
smbConfigure
if [ $? -ne 0 ]; then
errorAndLog "Error while configuring Samba server!"
exit 1
fi
-# Configuración ejemplo DHCP
+# Configuración de Rsync.
+rsyncConfigure
+
+# Configuración ejemplo DHCP.
dhcpConfigure
if [ $? -ne 0 ]; then
errorAndLog "Error while copying your dhcp server files!"
@@ -1474,25 +1675,34 @@ if [ $? -ne 0 ]; then
exit 1
fi
-# Instalar Base de datos de OpenGnSys Admin.
+# Instalar base de datos de OpenGnSys Admin.
isInArray notinstalled "mysql-server"
if [ $? -eq 0 ]; then
+ # Habilitar gestor de base de datos (MySQL, si falla, MariaDB).
service=$MYSQLSERV
- $ENABLESERVICE; $STARTSERVICE
- mysqlSetRootPassword ${MYSQL_ROOT_PASSWORD}
+ $ENABLESERVICE
+ if [ $? != 0 ]; then
+ service=$MARIADBSERV
+ $ENABLESERVICE
+ fi
+ # Activar gestor de base de datos.
+ $STARTSERVICE
+ # Asignar clave del usuario "root".
+ mysqlSetRootPassword "${MYSQL_ROOT_PASSWORD}"
else
+ # Si ya está instalado el gestor de bases de datos, obtener clave de "root",
mysqlGetRootPassword
fi
-mysqlTestConnection ${MYSQL_ROOT_PASSWORD}
+mysqlTestConnection "${MYSQL_ROOT_PASSWORD}"
if [ $? -ne 0 ]; then
errorAndLog "Error while connection to mysql"
exit 1
fi
-mysqlDbExists ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
+mysqlDbExists ${OPENGNSYS_DATABASE}
if [ $? -ne 0 ]; then
echoAndLog "Creating Web Console database"
- mysqlCreateDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
+ mysqlCreateDb ${OPENGNSYS_DATABASE}
if [ $? -ne 0 ]; then
errorAndLog "Error while creating Web Console database"
exit 1
@@ -1501,10 +1711,10 @@ else
echoAndLog "Web Console database exists, ommiting creation"
fi
-mysqlCheckUserExists ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DB_USER}
+mysqlCheckUserExists ${OPENGNSYS_DB_USER}
if [ $? -ne 0 ]; then
echoAndLog "Creating user in database"
- mysqlCreateAdminUserToDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}"
+ mysqlCreateAdminUserToDb ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}"
if [ $? -ne 0 ]; then
errorAndLog "Error while creating database user"
exit 1
@@ -1512,11 +1722,11 @@ if [ $? -ne 0 ]; then
fi
-mysqlCheckDbIsEmpty ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
+mysqlCheckDbIsEmpty ${OPENGNSYS_DATABASE}
if [ $? -eq 0 ]; then
echoAndLog "Creating tables..."
if [ -f $WORKDIR/$OPENGNSYS_DB_CREATION_FILE ]; then
- mysqlImportSqlFileToDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE
+ mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE
else
errorAndLog "Unable to locate $WORKDIR/$OPENGNSYS_DB_CREATION_FILE!!"
exit 1
@@ -1528,11 +1738,13 @@ else
OPENGNSYS_DB_UPDATE_FILE="opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
if [ -f $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE ]; then
echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION"
- mysqlImportSqlFileToDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE
+ mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE
else
echoAndLog "Database unchanged."
fi
fi
+# Eliminar fichero temporal con credenciales de acceso a MySQL.
+rm -f $TMPMYCNF
# copiando paqinas web
installWebFiles
@@ -1548,7 +1760,6 @@ fi
popd
-
# Crear la estructura de los accesos al servidor desde el cliente (shared)
copyClientFiles
if [ $? -ne 0 ]; then
diff --git a/installer/opengnsys_makecompress.sh b/installer/opengnsys_makecompress.sh
index 2587343a..99156336 100755
--- a/installer/opengnsys_makecompress.sh
+++ b/installer/opengnsys_makecompress.sh
@@ -17,11 +17,20 @@ SVNREV=$(LANG=C svn info $SVNURL | awk '/Last Changed Rev:/ {print "r"$4}')
cd /tmp
rm -fr opengnsys
svn export $SVNURL opengnsys || exit 1
+
+# Asisgnar propietario de los ficheros descargados.
+chown -R root.root opengnsys
+WARNING=$?
+
# Parchear datos de revisión del código.
perl -pi -e "s/$/ $SVNREV/" opengnsys/doc/VERSION.txt
+
# Generar fichero comprimido.
VERSION=$(awk '{print $2"-"$3}' opengnsys/doc/VERSION.txt)
tar cvzf opengnsys-$VERSION.tar.gz opengnsys
rm -fr opengnsys
+
+# Revisar salida.
+[ $WARNING != 0 ] && echo "*** WARNING: cannot change owner of files to \"root\" user before compressing."
ls -lh $(readlink -e opengnsys-$VERSION.tar.gz)
diff --git a/installer/opengnsys_uninstall.sh b/installer/opengnsys_uninstall.sh
index 2edb6c22..8c206db1 100755
--- a/installer/opengnsys_uninstall.sh
+++ b/installer/opengnsys_uninstall.sh
@@ -15,21 +15,25 @@
#@version 1.0.4 - Compatibilidad con otras distribuciones y auto configuración de acceso a BD
#@author Ramón Gómez - ETSII Univ. Sevilla
#@date 2012/03/28
+#@version 1.0.5 - Usar las mismas variables que el script de instalación.
+#@author Ramón Gómez - ETSII Univ. Sevilla
+#@date 2013/01/09
#### AVISO: Editar configuración de acceso.
#### WARNING: Edit access configuration
-MYSQLROOT="passwordroot" # Clave de root de MySQL
-DATABASE="ogAdmBD" # Base de datos de administración
-DBUSER="usuog" # Usuario de acceso a la base de datos
+MYSQL_ROOT_PASSWORD="passwordroot" # Clave de root de MySQL
+OPENGNSYS_DATABASE="ogAdmBD" # Base de datos de administración
+OPENGNSYS_DB_USER="usuog" # Usuario de acceso a la base de datos
#### AVISO: NO EDITAR variables de configuración.
#### WARNING: DO NOT EDIT configuration variables.
-OPENGNSYS="/opt/opengnsys" # Directorio de OpenGnSys
-OGIMG="images" # Directorio de imágenes del repositorio
-CLIENTUSER="opengnsys" # Usuario Samba
-OLDDATABASE="ogBDAdmin" # Antigua base de datos
+OPENGNSYS="/opt/opengnsys" # Directorio de OpenGnSys
+OGIMG="images" # Directorio de imágenes del repositorio
+OPENGNSYS_CLIENT_USER="opengnsys" # Usuario Samba
+OPENGNSYS_OLDDATABASE="ogBDAdmin" # Antigua base de datos
+MYCNF=/tmp/.my.cnf.$$ # Fichero temporal con credenciales de acceso a la BD.
# Sólo ejecutable por usuario root
@@ -43,33 +47,48 @@ fi
echo "Uninstalling OpenGnSys services."
if [ -x /etc/init.d/opengnsys ]; then
/etc/init.d/opengnsys stop
- if test which update-rc.d 2>/dev/null; then
+ if [ -n "$(which update-rc.d 2>/dev/null)" ]; then
update-rc.d -f opengnsys remove
else
chkconfig --del opengnsys
fi
fi
-# Eliminar bases de datos.
+# Comprobar acceso a la bases de datos.
echo "Erasing OpenGnSys database."
DROP=1
-if ! mysql -u root -p"$MYSQLROOT" <<<"quit" 2>/dev/null; then
+if ! mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then
stty -echo
- read -p "- Please, insert MySQL root password: " MYSQLROOT
+ read -p "- Please, insert MySQL root password: " MYSQL_ROOT_PASSWORD
echo ""
stty echo
- if ! mysql -u root -p"$MYSQLROOT" <<<"quit" 2>/dev/null; then
+ if ! mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then
DROP=0
echo "Warning: database not erased."
fi
fi
if test $DROP; then
- mysql -u root -p"$MYSQLROOT" <<<"DROP DATABASE $OLDDATABASE;" 2>/dev/null
- mysql -u root -p"$MYSQLROOT" <<<"DROP DATABASE $DATABASE;" 2>/dev/null
- mysql -u root -p"$MYSQLROOT" <<<"DROP USER '$DBUSER';" 2>/dev/null
- mysql -u root -p"$MYSQLROOT" <<<"DROP USER '$DBUSER'@'localhost';" 2>/dev/null
+ # Componer fichero temporal con credenciales de conexión a la base de datos.
+ touch $MYCNF
+ chmod 600 $MYCNF
+ cat << EOT > $MYCNF
+[client]
+user=root
+password=$MYSQL_ROOT_PASSWORD
+EOT
+ # Borrar fichero de credenciales si se corta el proceso de acceso a la BD.
+ trap "rm -f $MYCNF" 0 1 2 3 6 9 15
+ # Eliminar bases de datos.
+ mysql --defaults-extra-file=$MYCNF 2> /dev/null << EOT
+DROP DATABASE IF EXISTS $OPENGNSYS_OLDDATABASE;
+DROP DATABASE IF EXISTS $OPENGNSYS_DATABASE;
+DROP USER '$OPENGNSYS_DB_USER';
+DROP USER '$OPENGNSYS_DB_USER'@'localhost';
+EOT
+ # Borrar el fichero temporal de credenciales.
+ rm -f $MYCNF
fi
# Quitar configuración específica de Apache.
-test which a2dissite 2>/dev/null && a2dissite opengnsys
+[ -n "$(which a2dissite 2>/dev/null)" ] && a2dissite opengnsys
rm -f /etc/{apache2/{sites-available,sites-enabled},httpd/conf.d}/opengnsys*
for serv in apache2 httpd; do
[ -x /etc/init.d/$serv ] && /etc/init.d/$serv reload
@@ -90,8 +109,8 @@ for serv in smbd smb ; do
[ -x /etc/init.d/$serv ] && /etc/init.d/$serv reload
done
# Eliminar usuario de OpenGnSys.
-smbpasswd -x $CLIENTUSER
-userdel $CLIENTUSER
+smbpasswd -x $OPENGNSYS_CLIENT_USER
+userdel $OPENGNSYS_CLIENT_USER
# Tareas manuales a realizar después de desinstalar.
echo "Manual tasks:"
echo "- You may stop or uninstall manually all other services"
diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh
index 55e7dc9e..1dff1528 100755
--- a/installer/opengnsys_update.sh
+++ b/installer/opengnsys_update.sh
@@ -21,6 +21,9 @@
#@version 1.0.4 - Detector de distribución y compatibilidad con CentOS.
#@author Ramón Gómez - ETSII Univ. Sevilla
#@date 2012/05/04
+#@version 1.0.5 - Actualizar BD en la misma versión, compatibilidad con Fedora (systemd) y configuración de Rsync.
+#@author Ramón Gómez - ETSII Univ. Sevilla
+#@date 2014/04/03
#*/
@@ -46,7 +49,7 @@ if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then
elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then
source $INSTALL_TARGET/etc/ogAdmAgent.cfg
fi
-OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"} # Base datos
+OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"} # Base de datos
OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"} # Usuario de acceso
OPENGNSYS_DBPASSWORD=${OPENGNSYS_DBPASSWORD:-"$PASSWORD"} # Clave del usuario
if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASSWORD" ]; then
@@ -68,7 +71,9 @@ SVN_URL="http://$OPENGNSYS_SERVER/svn/trunk/"
WORKDIR=/tmp/opengnsys_update
mkdir -p $WORKDIR
-LOG_FILE=/tmp/opengnsys_update.log
+# Registro de incidencias.
+OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
+LOG_FILE=/tmp/$(basename $OGLOGFILE)
@@ -81,7 +86,7 @@ LOG_FILE=/tmp/opengnsys_update.log
# - OSDISTRIB - distribución Linux
# - DEPENDENCIES - array de dependencias que deben estar instaladas
# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKG - comandos para gestión de paquetes
-# - APACHECFGDIR, APACHESERV, DHCPSERV - configuración y servicios
+# - APACHECFGDIR, APACHESERV, DHCPSERV, INETDCFGDIR - configuración y servicios
function autoConfigure()
{
local i
@@ -92,19 +97,38 @@ OSDISTRIB=$(lsb_release -is 2>/dev/null)
# Configuración según la distribución de Linux.
case "$OSDISTRIB" in
Ubuntu|Debian|LinuxMint)
- DEPENDENCIES=
+ DEPENDENCIES=( php5-ldap xinetd rsync btrfs-tools procps)
UPDATEPKGLIST="apt-get update"
INSTALLPKGS="apt-get -y install --force-yes"
CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\""
+ if which service &>/dev/null; then
+ STARTSERVICE="eval service \$service restart"
+ STOPSERVICE="eval service \$service stop"
+ else
+ STARTSERVICE="eval /etc/init.d/\$service restart"
+ STOPSERVICE="eval /etc/init.d/\$service stop"
+ fi
+ ENABLESERVICE="eval update-rc.d \$service defaults"
APACHEUSER="www-data"
APACHEGROUP="www-data"
+ INETDCFGDIR=/etc/xinetd.d
;;
Fedora|CentOS)
- DEPENDENCIES=
+ DEPENDENCIES=( php-ldap xinetd rsync btrfs-progs procps-ng )
INSTALLPKGS="yum install -y"
CHECKPKG="rpm -q --quiet \$package"
+ if which systemctl &>/dev/null; then
+ STARTSERVICE="eval systemctl start \$service.service"
+ STOPSERVICE="eval systemctl stop \$service.service"
+ ENABLESERVICE="eval systemctl enable \$service.service"
+ else
+ STARTSERVICE="eval service \$service start"
+ STOPSERVICE="eval service \$service stop"
+ ENABLESERVICE="eval chkconfig \$service on"
+ fi
APACHEUSER="apache"
APACHEGROUP="apache"
+ INETDCFGDIR=/etc/xinetd.d
;;
*) # Otras distribuciones.
;;
@@ -231,6 +255,7 @@ function importSqlFile()
local database="$3"
local sqlfile="$4"
local tmpfile=$(mktemp)
+ local mycnf=/tmp/.my.cnf.$$
local status
if [ ! -r $sqlfile ]; then
@@ -242,9 +267,18 @@ function importSqlFile()
chmod 600 $tmpfile
sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
-e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" $sqlfile > $tmpfile
- mysql -u$dbuser -p"$dbpassword" --default-character-set=utf8 "$database" < $tmpfile
+ # Componer fichero con credenciales de conexión.
+ touch $mycnf
+ chmod 600 $mycnf
+ cat << EOT > $mycnf
+[client]
+user=$dbuser
+password=$dbpassword
+EOT
+ # Ejecutar actualización y borrar fichero de credenciales.
+ mysql --defaults-extra-file=$mycnf --default-character-set=utf8 -D "$database" < $tmpfile
status=$?
- rm -f $tmpfile
+ rm -f $mycnf $tmpfile
if [ $status -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database"
return 1
@@ -352,7 +386,7 @@ function updateClientFiles()
find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
echoAndLog "${FUNCNAME}(): Updating OpenGnSys Cloning Engine files."
- rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin
+ rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while updating engine files"
exit 1
@@ -385,24 +419,76 @@ function apacheConfiguration ()
APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
}
+# Configurar servicio Rsync.
+function rsyncConfigure()
+{
+ local service
+
+ # Configurar acceso a Rsync.
+ if [ ! -f /etc/rsyncd.conf ]; then
+ echoAndLog "${FUNCNAME}(): Configuring Rsync service."
+ NEWFILES="$NEWFILES /etc/rsyncd.conf"
+ sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENTUSER/g" \
+ $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > /etc/rsyncd.conf
+ # Habilitar Rsync.
+ if [ -f /etc/default/rsync ]; then
+ perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
+ fi
+ if [ -f $INETDCFGDIR/rsync ]; then
+ perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
+ else
+ cat << EOT > $INETDCFGDIR/rsync
+service rsync
+{
+ disable = no
+ socket_type = stream
+ wait = no
+ user = root
+ server = $(which rsync)
+ server_args = --daemon
+ log_on_failure += USERID
+ flags = IPv6
+}
+EOT
+ fi
+ # Activar e iniciar Rsync.
+ service="rsync" $ENABLESERVICE
+ service="xinetd"
+ $ENABLESERVICE; $STARTSERVICE
+ fi
+}
+
# Copiar ficheros del OpenGnSys Web Console.
function updateWebFiles()
{
- local ERRCODE
+ local ERRCODE COMPATDIR f
+
echoAndLog "${FUNCNAME}(): Updating web files..."
- backupFile $INSTALL_TARGET/www/controlacceso.php
- mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
+
+ # Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
+ backupFile $INSTALL_TARGET/www/controlacceso.php
+ mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
- ERRCODE=$?
- mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
+ ERRCODE=$?
+ mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
if [ $ERRCODE != 0 ]; then
errorAndLog "${FUNCNAME}(): Error updating web files."
exit 1
fi
- restoreFile $INSTALL_TARGET/www/controlacceso.php
+ restoreFile $INSTALL_TARGET/www/controlacceso.php
+
+ # Compatibilidad con dispositivos móviles.
+ COMPATDIR="$INSTALL_TARGET/www/principal"
+ for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
+ sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
+ done
+ cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
+
# Cambiar permisos para ficheros especiales.
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
+ chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
+
echoAndLog "${FUNCNAME}(): Web files updated successfully."
}
@@ -410,7 +496,7 @@ function updateWebFiles()
function updateInterfaceAdm()
{
local errcode=0
-
+
# Crear carpeta y copiar Interface
echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
@@ -483,12 +569,19 @@ function createDirs()
# Establecer los permisos básicos.
echoAndLog "${FUNCNAME}(): setting directory permissions"
chmod -R 775 $INSTALL_TARGET/{log/clients,images,tftpboot/pxelinux.cfg,tftpboot/menu.lst}
+ mkdir -p $INSTALL_TARGET/tftpboot/menu.lst/examples
+ ! [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/00unknown ] && mv $INSTALL_TARGET/tftpboot/menu.lst/templates/* $INSTALL_TARGET/tftpboot/menu.lst/examples
chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/{log/clients,images,tftpboot/pxelinux.cfg,tftpboot/menu.lst}
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while setting permissions"
return 1
fi
+ # Mover el fichero de registro al directorio de logs.
+ echoAndLog "${FUNCNAME}(): moving update log file"
+ mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
+ chmod 600 $LOG_FILE
+
echoAndLog "${FUNCNAME}(): directory paths created"
return 0
}
@@ -499,12 +592,16 @@ function updateServerFiles()
# No copiar ficheros del antiguo cliente Initrd
local SOURCES=( repoman/bin \
server/bin \
+ admin/Sources/Services/ogAdmServerAux \
+ admin/Sources/Services/ogAdmRepoAux \
server/tftpboot \
installer/opengnsys_uninstall.sh \
installer/install_ticket_wolunicast.sh \
doc )
local TARGETS=( bin \
bin \
+ sbin/ogAdmServerAux \
+ sbin/ogAdmRepoAux \
tftpboot \
lib/opengnsys_uninstall.sh \
lib/install_ticket_wolunicast.sh \
@@ -549,6 +646,7 @@ function updateServerFiles()
[ ! -f /etc/cron.d/opengnsys ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
[ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
[ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * * root [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
+ [ ! -f /etc/cron.d/imagedelete ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
echoAndLog "${FUNCNAME}(): server files updated successfully."
}
@@ -556,6 +654,27 @@ function updateServerFiles()
### Funciones de compilación de código fuente de servicios
####################################################################
+# Mueve el fichero del nuevo servicio si es distinto al del directorio destino.
+function moveNewService()
+{
+ local service
+
+ # Recibe 2 parámetros: fichero origen y directorio destino.
+ [ $# == 2 ] || return 1
+ [ -f $1 -a -d $2 ] || return 1
+
+ # Comparar los ficheros.
+ if ! diff -q $1 $2/$(basename $1) &>/dev/null; then
+ # Parar los servicios si fuese necesario.
+ [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE
+ # Nuevo servicio.
+ NEWSERVICES="$NEWSERVICES $(basename $1)"
+ # Mover el nuevo fichero de servicio
+ mv $1 $2
+ fi
+}
+
+
# Recompilar y actualiza los serivicios y clientes.
function compileServices()
{
@@ -564,7 +683,7 @@ function compileServices()
# Compilar OpenGnSys Server
echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Admin Server"
pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
- make && mv ogAdmServer $INSTALL_TARGET/sbin
+ make && moveNewService ogAdmServer $INSTALL_TARGET/sbin
if [ $? -ne 0 ]; then
echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Server"
hayErrores=1
@@ -573,7 +692,7 @@ function compileServices()
# Compilar OpenGnSys Repository Manager
echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Repository Manager"
pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
- make && mv ogAdmRepo $INSTALL_TARGET/sbin
+ make && moveNewService ogAdmRepo $INSTALL_TARGET/sbin
if [ $? -ne 0 ]; then
echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Repository Manager"
hayErrores=1
@@ -582,7 +701,7 @@ function compileServices()
# Compilar OpenGnSys Agent
echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Agent"
pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
- make && mv ogAdmAgent $INSTALL_TARGET/sbin
+ make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin
if [ $? -ne 0 ]; then
echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Agent"
hayErrores=1
@@ -612,13 +731,16 @@ function updateClient()
{
local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
local FILENAME=ogLive-precise-3.2.0-23-generic-r3257.iso # 1.0.4-rc2
+ #local FILENAME=ogLive-raring-3.8.0-22-generic-r3836.iso # 1.0.5-rc3
local SOURCEFILE=$DOWNLOADURL/$FILENAME
local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
local SOURCELENGTH
local TARGETLENGTH
local TMPDIR=/tmp/${FILENAME%.iso}
local OGINITRD=$INSTALL_TARGET/tftpboot/ogclient/oginitrd.img
+ local OGVMLINUZ=$INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz
local SAMBAPASS
+ local KERNELVERSION
# Comprobar si debe actualizarse el cliente.
SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}')
@@ -635,7 +757,7 @@ function updateClient()
if [ -f $OGINITRD ]; then
SAMBAPASS=$(gzip -dc $OGINITRD | \
cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
- grep "^[ ]*OPTIONS=" | \
+ grep "^[ ].*OPTIONS=" | \
sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
fi
# Montar la imagen ISO del ogclient, actualizar ficheros y desmontar.
@@ -661,9 +783,36 @@ function updateClient()
cp -av $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz* $INSTALL_TARGET/tftpboot
cp -av $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img* $INSTALL_TARGET/tftpboot
+ # Obtiene versión del Kernel del cliente (con 2 decimales).
+ KERNELVERSION=$(file -bkr $OGVMLINUZ 2>/dev/null | \
+ awk '/Linux/ { for (i=1; i<=NF; i++)
+ if ($i~/version/) {
+ v=$(i+1);
+ printf ("%d",v);
+ sub (/[0-9]*\./,"",v);
+ printf (".%02d",v)
+ } }')
+ # Actaulizar la base de datos adaptada al Kernel del cliente.
+ OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-postinst.sql"
+ if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
+ perl -pi -e "s/KERNELVERSION/$KERNELVERSION/g" $OPENGNSYS_DBUPDATEFILE
+ importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
+ fi
+
echoAndLog "${FUNCNAME}(): Client update successfully"
else
- echoAndLog "${FUNCNAME}(): Client is already updated"
+ # Si no existe, crear el fichero de claves de Rsync.
+ if [ ! -f /etc/rsyncd.secrets ]; then
+ echoAndLog "${FUNCNAME}(): Restoring client access key"
+ SAMBAPASS=$(gzip -dc $OGINITRD | \
+ cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
+ grep "^[ ].*OPTIONS=" | \
+ sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
+ echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | \
+ $INSTALL_TARGET/bin/setsmbpass
+ else
+ echoAndLog "${FUNCNAME}(): Client is already updated"
+ fi
fi
}
@@ -672,7 +821,7 @@ function updateSummary()
{
# Actualizar fichero de versión y revisión.
local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
- local REVISION=$(LANG=C svn info $SVN_URL|awk '/Revision:/ {print "r"$2}')
+ local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
[ -f $VERSIONFILE ] || echo "OpenGnSys" >$VERSIONFILE
perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
@@ -681,9 +830,20 @@ function updateSummary()
echoAndLog "OpenGnSys Update Summary"
echo "========================"
echoAndLog "Project version: $(cat $VERSIONFILE)"
+ echoAndLog "Update log file: $LOG_FILE"
if [ -n "$NEWFILES" ]; then
echoAndLog "Check the new config files: $(echo $NEWFILES)"
fi
+ if [ -n "$NEWSERVICES" ]; then
+ echoAndLog "New compiled services: $(echo $NEWSERVICES)"
+ # Indicar si se debe reiniciar servicios manualmente o usando el Cron.
+ [ -f /etc/default/opengnsys ] && source /etc/default/opengnsys
+ if [ "$RUN_CRONJOB" == "no" ]; then
+ echoAndLog " WARNING: you must restart OpenGnSys services manually."
+ else
+ echoAndLog " New OpenGnSys services will be restarted by the cronjob."
+ fi
+ fi
echo
}
@@ -723,7 +883,7 @@ fi
autoConfigure
# Instalar dependencias.
-installDependencies $DEPENDENCIES
+installDependencies ${DEPENDENCIES[*]}
if [ $? -ne 0 ]; then
errorAndLog "Error: you may install all needed dependencies."
exit 1
@@ -750,9 +910,13 @@ fi
# Si existe fichero de actualización de la base de datos; aplicar cambios.
INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
-OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
+if [ "$INSTVERSION" == "$REPOVERSION" ]; then
+ OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION.sql"
+else
+ OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
+fi
if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
- echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION"
+ echoAndLog "Updating tables from file: $(basename $OPENGNSYS_DBUPDATEFILE)"
importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
else
echoAndLog "Database unchanged."
@@ -765,6 +929,9 @@ if [ $? -ne 0 ]; then
exit 1
fi
+# Configurar Rsync.
+rsyncConfigure
+
# Actualizar ficheros del cliente
updateClientFiles
updateInterfaceAdm