[a01156a] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | ##################################################################### |
---|
[6ef01d9] | 4 | ####### Script instalador OpenGnSys |
---|
[a01156a] | 5 | ####### autor: Luis Guillén <lguillen@unizar.es> |
---|
| 6 | ##################################################################### |
---|
| 7 | |
---|
| 8 | |
---|
[9672640] | 9 | #### AVISO: Puede editar configuración de acceso por defecto. |
---|
| 10 | #### WARNING: Edit default access configuration if you wish. |
---|
| 11 | DEFAULT_MYSQL_ROOT_PASSWORD="passwordroot" # Clave por defecto root de MySQL |
---|
| 12 | DEFAULT_OPENGNSYS_DB_USER="usuog" # Usuario por defecto de acceso a la base de datos |
---|
| 13 | DEFAULT_OPENGNSYS_DB_PASSWD="passusuog" # Clave por defecto de acceso a la base de datos |
---|
| 14 | DEFAULT_OPENGNSYS_CLIENT_PASSWD="og" # Clave por defecto de acceso del cliente |
---|
[4a3cd1f] | 15 | |
---|
[1e7eaab] | 16 | # Sólo ejecutable por usuario root |
---|
[6ef01d9] | 17 | if [ "$(whoami)" != 'root' ]; then |
---|
[1e7eaab] | 18 | echo "ERROR: this program must run under root privileges!!" |
---|
| 19 | exit 1 |
---|
| 20 | fi |
---|
[9672640] | 21 | |
---|
| 22 | echo -e "\\nOpenGnSys Installation" |
---|
| 23 | echo "==============================" |
---|
| 24 | |
---|
| 25 | # Clave root de MySQL |
---|
| 26 | while : ; do |
---|
| 27 | echo -n -e "\\nEnter root password for MySQL (${DEFAULT_MYSQL_ROOT_PASSWORD}): "; |
---|
| 28 | read MYSQL_ROOT_PASSWORD |
---|
| 29 | if [ -n "${MYSQL_ROOT_PASSWORD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico |
---|
| 30 | echo -e "\\aERROR: Must be alphanumeric, try again..." |
---|
| 31 | else |
---|
| 32 | if [ -z $MYSQL_ROOT_PASSWORD ]; then # Si esta vacio ponemos el valor por defecto |
---|
| 33 | MYSQL_ROOT_PASSWORD=$DEFAULT_MYSQL_ROOT_PASSWORD |
---|
| 34 | fi |
---|
| 35 | break |
---|
| 36 | fi |
---|
| 37 | done |
---|
| 38 | |
---|
| 39 | # Usuario de acceso a la base de datos |
---|
| 40 | while : ; do |
---|
| 41 | echo -n -e "\\nEnter username for OpenGnSys console (${DEFAULT_OPENGNSYS_DB_USER}): " |
---|
| 42 | read OPENGNSYS_DB_USER |
---|
| 43 | if [ -n "${OPENGNSYS_DB_USER//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico |
---|
| 44 | echo -e "\\aERROR: Must be alphanumeric, try again..." |
---|
| 45 | else |
---|
| 46 | if [ -z $OPENGNSYS_DB_USER ]; then # Si esta vacio ponemos el valor por defecto |
---|
| 47 | OPENGNSYS_DB_USER=$DEFAULT_OPENGNSYS_DB_USER |
---|
| 48 | fi |
---|
| 49 | break |
---|
| 50 | fi |
---|
| 51 | done |
---|
| 52 | |
---|
| 53 | # Clave de acceso a la base de datos |
---|
| 54 | while : ; do |
---|
| 55 | echo -n -e "\\nEnter password for OpenGnSys console (${DEFAULT_OPENGNSYS_DB_PASSWD}): " |
---|
| 56 | read OPENGNSYS_DB_PASSWD |
---|
| 57 | if [ -n "${OPENGNSYS_DB_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico |
---|
| 58 | echo -e "\\aERROR: Must be alphanumeric, try again..." |
---|
| 59 | else |
---|
| 60 | if [ -z $OPENGNSYS_DB_PASSWD ]; then # Si esta vacio ponemos el valor por defecto |
---|
| 61 | OPENGNSYS_DB_PASSWD=$DEFAULT_OPENGNSYS_DB_PASSWD |
---|
| 62 | fi |
---|
| 63 | break |
---|
| 64 | fi |
---|
| 65 | done |
---|
| 66 | |
---|
| 67 | # Clave de acceso del cliente |
---|
| 68 | while : ; do |
---|
| 69 | echo -n -e "\\nEnter root password for OpenGnSys client (${DEFAULT_OPENGNSYS_CLIENT_PASSWD}): " |
---|
| 70 | read OPENGNSYS_CLIENT_PASSWD |
---|
| 71 | if [ -n "${OPENGNSYS_CLIENT_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico |
---|
| 72 | echo -e "\\aERROR: Must be alphanumeric, try again..." |
---|
| 73 | else |
---|
| 74 | if [ -z $OPENGNSYS_CLIENT_PASSWD ]; then # Si esta vacio ponemos el valor por defecto |
---|
| 75 | OPENGNSYS_CLIENT_PASSWD=$DEFAULT_OPENGNSYS_CLIENT_PASSWD |
---|
| 76 | fi |
---|
| 77 | break |
---|
| 78 | fi |
---|
| 79 | done |
---|
| 80 | |
---|
| 81 | echo -e "\\n==============================" |
---|
[1e7eaab] | 82 | |
---|
| 83 | # Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1). |
---|
[49c6891] | 84 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
[35b0ef1] | 85 | PROGRAMNAME=$(basename "$0") |
---|
[07c3a59] | 86 | OPENGNSYS_SERVER="www.opengnsys.es" |
---|
[1e7eaab] | 87 | if [ -d "$PROGRAMDIR/../installer" ]; then |
---|
[6ef01d9] | 88 | USESVN=0 |
---|
[1e7eaab] | 89 | else |
---|
[6ef01d9] | 90 | USESVN=1 |
---|
[1e7eaab] | 91 | fi |
---|
[eb9424f] | 92 | SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.0/" |
---|
[1e7eaab] | 93 | |
---|
[a01156a] | 94 | WORKDIR=/tmp/opengnsys_installer |
---|
[1e7eaab] | 95 | mkdir -p $WORKDIR |
---|
| 96 | |
---|
[42a0e41] | 97 | # Directorio destino de OpenGnSys. |
---|
[1e7eaab] | 98 | INSTALL_TARGET=/opt/opengnsys |
---|
[42a0e41] | 99 | |
---|
| 100 | # Registro de incidencias. |
---|
| 101 | OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log |
---|
[acfb07d] | 102 | LOG_FILE=/tmp/$(basename $OGLOGFILE) |
---|
[a01156a] | 103 | |
---|
[fd021b0] | 104 | # Usuario del cliente para acceso remoto. |
---|
| 105 | OPENGNSYS_CLIENT_USER="opengnsys" |
---|
| 106 | |
---|
| 107 | # Nombre de la base datos y fichero SQL para su creación. |
---|
| 108 | OPENGNSYS_DATABASE="ogAdmBD" |
---|
| 109 | OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/${OPENGNSYS_DATABASE}.sql |
---|
[3aaf91d] | 110 | |
---|
[a01156a] | 111 | |
---|
| 112 | ##################################################################### |
---|
[d168a46] | 113 | ####### Funciones de configuración |
---|
| 114 | ##################################################################### |
---|
| 115 | |
---|
| 116 | # Generar variables de configuración del instalador |
---|
| 117 | # Variables globales: |
---|
[44f6582] | 118 | # - OSDISTRIB - tipo de distribución GNU/Linux |
---|
[d168a46] | 119 | # - DEPENDENCIES - array de dependencias que deben estar instaladas |
---|
| 120 | # - UPDATEPKGLIST, INSTALLPKGS, CHECKPKGS - comandos para gestión de paquetes |
---|
[109e8b2] | 121 | # - INSTALLEXTRADEPS - instalar dependencias no incluidas en la distribución |
---|
[53fba30] | 122 | # - STARTSERVICE, ENABLESERVICE - iniciar y habilitar un servicio |
---|
[109e8b2] | 123 | # - STOPSERVICE, DISABLESERVICE - parar y deshabilitar un servicio |
---|
[53fba30] | 124 | # - APACHESERV, APACHECFGDIR, APACHESITESDIR, APACHEUSER, APACHEGROUP - servicio y configuración de Apache |
---|
[7825e9e] | 125 | # - APACHESSLMOD, APACHEENABLESSL, APACHEMAKECERT - habilitar módulo Apache y certificado SSL |
---|
[53fba30] | 126 | # - APACHEENABLEOG, APACHEOGSITE, - habilitar sitio web de OpenGnSys |
---|
| 127 | # - INETDSERV - servicio Inetd |
---|
[09ac3b8] | 128 | # - FIREWALLSERV - servicio de cortabuegos IPTables/FirewallD |
---|
[53fba30] | 129 | # - DHCPSERV, DHCPCFGDIR - servicio y configuración de DHCP |
---|
[0f8100d] | 130 | # - MYSQLSERV, TMPMYCNF - servicio MySQL y fichero temporal con credenciales de acceso |
---|
| 131 | # - MARIADBSERV - servicio MariaDB (sustituto de MySQL en algunas distribuciones) |
---|
[e70925a] | 132 | # - RSYNCSERV, RSYNCCFGDIR - servicio y configuración de Rsync |
---|
[53fba30] | 133 | # - SAMBASERV, SAMBACFGDIR - servicio y configuración de Samba |
---|
[297df16] | 134 | # - TFTPSERV, TFTPCFGDIR, SYSLINUXDIR - servicio y configuración de TFTP/PXE |
---|
[d168a46] | 135 | function autoConfigure() |
---|
| 136 | { |
---|
[44f6582] | 137 | # Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB). |
---|
| 138 | if [ -f /etc/os-release ]; then |
---|
| 139 | source /etc/os-release |
---|
[eb7b39d] | 140 | OSDISTRIB="$ID" |
---|
[44f6582] | 141 | else |
---|
| 142 | OSDISTRIB=$(lsb_release -is 2>/dev/null) |
---|
| 143 | fi |
---|
[eb7b39d] | 144 | # Convertir a minúsculas para evitar errores. |
---|
| 145 | OSDISTRIB="${OSDISTRIB,,}" |
---|
[d168a46] | 146 | |
---|
[eb7b39d] | 147 | # Configuración según la distribución GNU/Linux (usar minúsculas). |
---|
[d168a46] | 148 | case "$OSDISTRIB" in |
---|
[eb7b39d] | 149 | ubuntu|debian|linuxmint) |
---|
[c49ef02] | 150 | 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 arp-scan ) |
---|
[d168a46] | 151 | UPDATEPKGLIST="apt-get update" |
---|
| 152 | INSTALLPKG="apt-get -y install --force-yes" |
---|
| 153 | CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install" |
---|
[53fba30] | 154 | if which service &>/dev/null; then |
---|
[7ba85a4] | 155 | STARTSERVICE="eval service \$service restart" |
---|
[109e8b2] | 156 | STOPSERVICE="eval service \$service stop" |
---|
[53fba30] | 157 | else |
---|
[7ba85a4] | 158 | STARTSERVICE="eval /etc/init.d/\$service restart" |
---|
[109e8b2] | 159 | STOPSERVICE="eval /etc/init.d/\$service stop" |
---|
[53fba30] | 160 | fi |
---|
[7ba85a4] | 161 | ENABLESERVICE="eval update-rc.d \$service defaults" |
---|
[109e8b2] | 162 | DISABLESERVICE="eval update-rc.d \$service disable" |
---|
[53fba30] | 163 | APACHESERV=apache2 |
---|
[d168a46] | 164 | APACHECFGDIR=/etc/apache2 |
---|
[643ca8c] | 165 | APACHESITESDIR=sites-available |
---|
[53fba30] | 166 | APACHEOGSITE=opengnsys |
---|
[d168a46] | 167 | APACHEUSER="www-data" |
---|
| 168 | APACHEGROUP="www-data" |
---|
[7ba85a4] | 169 | APACHESSLMOD="a2enmod ssl" |
---|
| 170 | APACHEENABLESSL="a2ensite default-ssl" |
---|
[53fba30] | 171 | APACHEENABLEOG="a2ensite $APACHEOGSITE" |
---|
[643ca8c] | 172 | APACHEMAKECERT="make-ssl-cert generate-default-snakeoil --force-overwrite" |
---|
[53fba30] | 173 | DHCPSERV=isc-dhcp-server |
---|
[83518d5] | 174 | DHCPCFGDIR=/etc/dhcp |
---|
[f243a47] | 175 | INETDSERV=xinetd |
---|
| 176 | INETDCFGDIR=/etc/xinetd.d |
---|
[53fba30] | 177 | MYSQLSERV=mysql |
---|
[0f8100d] | 178 | MARIADBSERV=mariadb |
---|
[e70925a] | 179 | RSYNCSERV=rsync |
---|
| 180 | RSYNCCFGDIR=/etc |
---|
[53fba30] | 181 | SAMBASERV=smbd |
---|
[d168a46] | 182 | SAMBACFGDIR=/etc/samba |
---|
[297df16] | 183 | SYSLINUXDIR=/usr/lib/syslinux |
---|
[d168a46] | 184 | TFTPCFGDIR=/var/lib/tftpboot |
---|
| 185 | ;; |
---|
[eb7b39d] | 186 | fedora|centos) |
---|
| 187 | 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 samba-client rsync unzip debootstrap schroot squashfs-tools python-crypto arp-scan ) |
---|
[109e8b2] | 188 | INSTALLEXTRADEPS=( 'rpm -Uv ftp://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/files/i586/RPMS/netpipes-4.2-alt1.i586.rpm' |
---|
[03cfd6e] | 189 | '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' ) |
---|
[eb7b39d] | 190 | if [ "$OSDISTRIB" == "centos" ]; then |
---|
[03cfd6e] | 191 | 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' |
---|
| 192 | fi |
---|
[d168a46] | 193 | INSTALLPKG="yum install -y" |
---|
[c79a2b3] | 194 | CHECKPKG="rpm -q --quiet \$package" |
---|
[03cfd6e] | 195 | SYSTEMD=$(which systemctl 2>/dev/null) |
---|
| 196 | if [ -n "$SYSTEMD" ]; then |
---|
| 197 | STARTSERVICE="eval systemctl start \$service.service" |
---|
| 198 | STOPSERVICE="eval systemctl stop \$service.service" |
---|
| 199 | ENABLESERVICE="eval systemctl enable \$service.service" |
---|
| 200 | DISABLESERVICE="eval systemctl disable \$service.service" |
---|
| 201 | else |
---|
| 202 | STARTSERVICE="eval service \$service start" |
---|
| 203 | STOPSERVICE="eval service \$service stop" |
---|
| 204 | ENABLESERVICE="eval chkconfig \$service on" |
---|
| 205 | DISABLESERVICE="eval chkconfig \$service off" |
---|
| 206 | fi |
---|
[53fba30] | 207 | APACHESERV=httpd |
---|
[d168a46] | 208 | APACHECFGDIR=/etc/httpd/conf.d |
---|
[53fba30] | 209 | APACHEOGSITE=opengnsys.conf |
---|
[d168a46] | 210 | APACHEUSER="apache" |
---|
| 211 | APACHEGROUP="apache" |
---|
[53fba30] | 212 | DHCPSERV=dhcpd |
---|
[d168a46] | 213 | DHCPCFGDIR=/etc/dhcp |
---|
[09ac3b8] | 214 | if firewall-cmd --state &>/dev/null; then |
---|
| 215 | FIREWALLSERV=firewalld |
---|
| 216 | else |
---|
| 217 | FIREWALLSERV=iptables |
---|
| 218 | fi |
---|
[53fba30] | 219 | INETDSERV=xinetd |
---|
[f243a47] | 220 | INETDCFGDIR=/etc/xinetd.d |
---|
[53fba30] | 221 | MYSQLSERV=mysqld |
---|
[0f8100d] | 222 | MARIADBSERV=mariadb |
---|
[e70925a] | 223 | RSYNCSERV=rsync |
---|
| 224 | RSYNCCFGDIR=/etc |
---|
[53fba30] | 225 | SAMBASERV=smb |
---|
[d168a46] | 226 | SAMBACFGDIR=/etc/samba |
---|
[297df16] | 227 | SYSLINUXDIR=/usr/share/syslinux |
---|
[53fba30] | 228 | TFTPSERV=tftp |
---|
[d168a46] | 229 | TFTPCFGDIR=/var/lib/tftpboot |
---|
| 230 | ;; |
---|
| 231 | "") echo "ERROR: Unknown Linux distribution, please install \"lsb_release\" command." |
---|
| 232 | exit 1 ;; |
---|
| 233 | *) echo "ERROR: Distribution not supported by OpenGnSys." |
---|
| 234 | exit 1 ;; |
---|
| 235 | esac |
---|
[09bf701] | 236 | |
---|
| 237 | # Fichero de credenciales de acceso a MySQL. |
---|
| 238 | TMPMYCNF=/tmp/.my.cnf.$$ |
---|
[d168a46] | 239 | } |
---|
| 240 | |
---|
[09ac3b8] | 241 | |
---|
[ff6c349] | 242 | # Modificar variables de configuración tras instalar paquetes del sistema. |
---|
| 243 | function autoConfigurePost() |
---|
| 244 | { |
---|
[09ac3b8] | 245 | local f |
---|
| 246 | |
---|
[44f6582] | 247 | # Configuraciones específicas para Samba y TFTP en Debian 6. |
---|
| 248 | [ -z "$SYSTEMD" -a ! -e /etc/init.d/$SAMBASERV ] && SAMBASERV=samba |
---|
| 249 | [ ! -e $TFTPCFGDIR ] && TFTPCFGDIR=/srv/tftp |
---|
| 250 | |
---|
[09ac3b8] | 251 | # Configuraciones específicas para SELinux permisivo en distintas versiones. |
---|
[44f6582] | 252 | [ -f /selinux/enforce ] && echo 0 > /selinux/enforce |
---|
[e5f9c147] | 253 | for f in /etc/sysconfig/selinux /etc/selinux/config; do |
---|
[4fdf2b1] | 254 | [ -f $f ] && perl -pi -e 's/SELINUX=enforcing/SELINUX=permissive/g' $f |
---|
[09ac3b8] | 255 | done |
---|
| 256 | selinuxenabled 2>/dev/null && setenforce 0 2>/dev/null |
---|
[ff6c349] | 257 | } |
---|
| 258 | |
---|
| 259 | |
---|
[83518d5] | 260 | # Cargar lista de paquetes del sistema y actualizar algunas variables de configuración |
---|
| 261 | # dependiendo de la versión instalada. |
---|
| 262 | function updatePackageList() |
---|
| 263 | { |
---|
| 264 | local DHCPVERSION |
---|
| 265 | |
---|
| 266 | # Si es necesario, actualizar la lista de paquetes disponibles. |
---|
| 267 | [ -n "$UPDATEPKGLIST" ] && eval $UPDATEPKGLIST |
---|
| 268 | |
---|
| 269 | # Configuración personallizada de algunos paquetes. |
---|
| 270 | case "$OSDISTRIB" in |
---|
[eb7b39d] | 271 | ubuntu|linuxmint) # Postconfiguación personalizada para Ubuntu. |
---|
[83518d5] | 272 | # Configuración para DHCP v3. |
---|
[e4b1572] | 273 | DHCPVERSION=$(apt-cache show $(apt-cache pkgnames|egrep "dhcp.?-server$") | \ |
---|
[83518d5] | 274 | awk '/Version/ {print substr($2,1,1);}' | \ |
---|
| 275 | sort -n | tail -1) |
---|
| 276 | if [ $DHCPVERSION = 3 ]; then |
---|
[e4b1572] | 277 | DEPENDENCIES=( ${DEPENDENCIES[@]/isc-dhcp-server/dhcp3-server} ) |
---|
[53fba30] | 278 | DHCPSERV=dhcp3-server |
---|
[83518d5] | 279 | DHCPCFGDIR=/etc/dhcp3 |
---|
| 280 | fi |
---|
| 281 | ;; |
---|
[eb7b39d] | 282 | centos) # Postconfiguación personalizada para CentOS. |
---|
[c525453] | 283 | # Incluir repositorio de paquetes EPEL y paquetes específicos. |
---|
| 284 | DEPENDENCIES=( ${DEPENDENCIES[@]} epel-release procps ) |
---|
| 285 | ;; |
---|
[eb7b39d] | 286 | fedora) # Postconfiguación personalizada para Fedora. |
---|
[c525453] | 287 | # Incluir paquetes específicos. |
---|
| 288 | DEPENDENCIES=( ${DEPENDENCIES[@]} libstdc++-static.i686 btrfs-progs procps-ng ) |
---|
[c79a2b3] | 289 | ;; |
---|
[83518d5] | 290 | esac |
---|
| 291 | } |
---|
| 292 | |
---|
[d168a46] | 293 | |
---|
| 294 | ##################################################################### |
---|
[a01156a] | 295 | ####### Algunas funciones útiles de propósito general: |
---|
| 296 | ##################################################################### |
---|
[d168a46] | 297 | |
---|
[13a01a7] | 298 | function getDateTime() |
---|
[a01156a] | 299 | { |
---|
[d168a46] | 300 | date "+%Y%m%d-%H%M%S" |
---|
[a01156a] | 301 | } |
---|
| 302 | |
---|
| 303 | # Escribe a fichero y muestra por pantalla |
---|
[13a01a7] | 304 | function echoAndLog() |
---|
[a01156a] | 305 | { |
---|
[d168a46] | 306 | local DATETIME=`getDateTime` |
---|
[87c7b02] | 307 | echo "$1" |
---|
[d168a46] | 308 | echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE |
---|
[a01156a] | 309 | } |
---|
| 310 | |
---|
[87c7b02] | 311 | # Escribe a fichero y muestra mensaje de error |
---|
[13a01a7] | 312 | function errorAndLog() |
---|
[a01156a] | 313 | { |
---|
[d168a46] | 314 | local DATETIME=`getDateTime` |
---|
[87c7b02] | 315 | echo "ERROR: $1" |
---|
[d168a46] | 316 | echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE |
---|
[a01156a] | 317 | } |
---|
| 318 | |
---|
[346eaee] | 319 | # Escribe a fichero y muestra mensaje de aviso |
---|
| 320 | function warningAndLog() |
---|
| 321 | { |
---|
| 322 | local DATETIME=`getDateTime` |
---|
| 323 | echo "ERROR: $1" |
---|
| 324 | echo "$DATETIME;$SSH_CLIENT;Warning: $1" >> $LOG_FILE |
---|
| 325 | } |
---|
| 326 | |
---|
[87c7b02] | 327 | # Comprueba si el elemento pasado en $2 está en el array $1 |
---|
[13a01a7] | 328 | function isInArray() |
---|
[a01156a] | 329 | { |
---|
| 330 | if [ $# -ne 2 ]; then |
---|
[13a01a7] | 331 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 332 | exit 1 |
---|
| 333 | fi |
---|
| 334 | |
---|
| 335 | local deps |
---|
[87c7b02] | 336 | local is_in_array=1 |
---|
| 337 | local element="$2" |
---|
| 338 | |
---|
| 339 | echoAndLog "${FUNCNAME}(): checking if $2 is in $1" |
---|
[5c33840] | 340 | eval "deps=( \"\${$1[@]}\" )" |
---|
[a01156a] | 341 | |
---|
[87c7b02] | 342 | # Copia local del array del parámetro 1. |
---|
| 343 | for (( i = 0 ; i < ${#deps[@]} ; i++ )); do |
---|
| 344 | if [ "${deps[$i]}" = "${element}" ]; then |
---|
| 345 | echoAndLog "isInArray(): $element found in array" |
---|
[a01156a] | 346 | is_in_array=0 |
---|
| 347 | fi |
---|
| 348 | done |
---|
| 349 | |
---|
| 350 | if [ $is_in_array -ne 0 ]; then |
---|
[87c7b02] | 351 | echoAndLog "${FUNCNAME}(): $element NOT found in array" |
---|
[a01156a] | 352 | fi |
---|
| 353 | |
---|
| 354 | return $is_in_array |
---|
| 355 | } |
---|
| 356 | |
---|
[87c7b02] | 357 | |
---|
[a01156a] | 358 | ##################################################################### |
---|
| 359 | ####### Funciones de manejo de paquetes Debian |
---|
| 360 | ##################################################################### |
---|
| 361 | |
---|
[13a01a7] | 362 | function checkPackage() |
---|
[a01156a] | 363 | { |
---|
| 364 | package=$1 |
---|
| 365 | if [ -z $package ]; then |
---|
[73cfa0a] | 366 | errorAndLog "${FUNCNAME}(): parameter required" |
---|
[a01156a] | 367 | exit 1 |
---|
| 368 | fi |
---|
[73cfa0a] | 369 | echoAndLog "${FUNCNAME}(): checking if package $package exists" |
---|
[d168a46] | 370 | eval $CHECKPKG |
---|
[a01156a] | 371 | if [ $? -eq 0 ]; then |
---|
[73cfa0a] | 372 | echoAndLog "${FUNCNAME}(): package $package exists" |
---|
[a01156a] | 373 | return 0 |
---|
| 374 | else |
---|
[73cfa0a] | 375 | echoAndLog "${FUNCNAME}(): package $package doesn't exists" |
---|
[a01156a] | 376 | return 1 |
---|
| 377 | fi |
---|
| 378 | } |
---|
| 379 | |
---|
[87c7b02] | 380 | # Recibe array con dependencias |
---|
[a01156a] | 381 | # por referencia deja un array con las dependencias no resueltas |
---|
| 382 | # devuelve 1 si hay alguna dependencia no resuelta |
---|
[13a01a7] | 383 | function checkDependencies() |
---|
[a01156a] | 384 | { |
---|
| 385 | if [ $# -ne 2 ]; then |
---|
[73cfa0a] | 386 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 387 | exit 1 |
---|
| 388 | fi |
---|
| 389 | |
---|
[73cfa0a] | 390 | echoAndLog "${FUNCNAME}(): checking dependences" |
---|
[a01156a] | 391 | uncompletedeps=0 |
---|
| 392 | |
---|
| 393 | # copia local del array del parametro 1 |
---|
| 394 | local deps |
---|
[5c33840] | 395 | eval "deps=( \"\${$1[@]}\" )" |
---|
[a01156a] | 396 | |
---|
| 397 | declare -a local_notinstalled |
---|
[5c33840] | 398 | |
---|
[a01156a] | 399 | for (( i = 0 ; i < ${#deps[@]} ; i++ )) |
---|
| 400 | do |
---|
| 401 | checkPackage ${deps[$i]} |
---|
| 402 | if [ $? -ne 0 ]; then |
---|
| 403 | local_notinstalled[$uncompletedeps]=$package |
---|
| 404 | let uncompletedeps=uncompletedeps+1 |
---|
| 405 | fi |
---|
| 406 | done |
---|
| 407 | |
---|
| 408 | # relleno el array especificado en $2 por referencia |
---|
| 409 | for (( i = 0 ; i < ${#local_notinstalled[@]} ; i++ )) |
---|
| 410 | do |
---|
| 411 | eval "${2}[$i]=${local_notinstalled[$i]}" |
---|
| 412 | done |
---|
| 413 | |
---|
| 414 | # retorna el numero de paquetes no resueltos |
---|
[73cfa0a] | 415 | echoAndLog "${FUNCNAME}(): dependencies uncompleted: $uncompletedeps" |
---|
[a01156a] | 416 | return $uncompletedeps |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | # Recibe un array con las dependencias y lo instala |
---|
[13a01a7] | 420 | function installDependencies() |
---|
[a01156a] | 421 | { |
---|
| 422 | if [ $# -ne 1 ]; then |
---|
[813f617] | 423 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 424 | exit 1 |
---|
| 425 | fi |
---|
[813f617] | 426 | echoAndLog "${FUNCNAME}(): installing uncompleted dependencies" |
---|
[a01156a] | 427 | |
---|
| 428 | # copia local del array del parametro 1 |
---|
| 429 | local deps |
---|
[5c33840] | 430 | eval "deps=( \"\${$1[@]}\" )" |
---|
[a01156a] | 431 | |
---|
| 432 | local string_deps="" |
---|
| 433 | for (( i = 0 ; i < ${#deps[@]} ; i++ )) |
---|
| 434 | do |
---|
| 435 | string_deps="$string_deps ${deps[$i]}" |
---|
| 436 | done |
---|
| 437 | |
---|
| 438 | if [ -z "${string_deps}" ]; then |
---|
[813f617] | 439 | errorAndLog "${FUNCNAME}(): array of dependeces is empty" |
---|
[a01156a] | 440 | exit 1 |
---|
| 441 | fi |
---|
| 442 | |
---|
[c79a2b3] | 443 | OLD_DEBIAN_FRONTEND=$DEBIAN_FRONTEND # Debian/Ubuntu |
---|
[a01156a] | 444 | export DEBIAN_FRONTEND=noninteractive |
---|
| 445 | |
---|
[d168a46] | 446 | echoAndLog "${FUNCNAME}(): now $string_deps will be installed" |
---|
| 447 | eval $INSTALLPKG $string_deps |
---|
[a01156a] | 448 | if [ $? -ne 0 ]; then |
---|
[813f617] | 449 | errorAndLog "${FUNCNAME}(): error installing dependencies" |
---|
[a01156a] | 450 | return 1 |
---|
| 451 | fi |
---|
| 452 | |
---|
[c79a2b3] | 453 | DEBIAN_FRONTEND=$OLD_DEBIAN_FRONTEND # Debian/Ubuntu |
---|
[8244351] | 454 | test grep -q "EPEL temporal" /etc/yum.repos.d/epel.repo 2>/dev/null ] || mv -f /etc/yum.repos.d/epel.repo.rpmnew /etc/yum.repos.d/epel.repo 2>/dev/null # CentOS/RedHat EPEL |
---|
[c79a2b3] | 455 | |
---|
[813f617] | 456 | echoAndLog "${FUNCNAME}(): dependencies installed" |
---|
[a01156a] | 457 | } |
---|
| 458 | |
---|
[13a01a7] | 459 | # Hace un backup del fichero pasado por parámetro |
---|
| 460 | # deja un -last y uno para el día |
---|
| 461 | function backupFile() |
---|
| 462 | { |
---|
| 463 | if [ $# -ne 1 ]; then |
---|
| 464 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 465 | exit 1 |
---|
| 466 | fi |
---|
| 467 | |
---|
[d168a46] | 468 | local file="$1" |
---|
| 469 | local dateymd=`date +%Y%m%d` |
---|
[13a01a7] | 470 | |
---|
[d168a46] | 471 | if [ ! -f "$file" ]; then |
---|
[346eaee] | 472 | warningAndLog "${FUNCNAME}(): file $file doesn't exists" |
---|
[13a01a7] | 473 | return 1 |
---|
| 474 | fi |
---|
| 475 | |
---|
[d168a46] | 476 | echoAndLog "${FUNCNAME}(): making $file backup" |
---|
[13a01a7] | 477 | |
---|
| 478 | # realiza una copia de la última configuración como last |
---|
[d168a46] | 479 | cp -a "$file" "${file}-LAST" |
---|
[13a01a7] | 480 | |
---|
| 481 | # si para el día no hay backup lo hace, sino no |
---|
[d168a46] | 482 | if [ ! -f "${file}-${dateymd}" ]; then |
---|
| 483 | cp -a "$file" "${file}-${dateymd}" |
---|
[13a01a7] | 484 | fi |
---|
| 485 | |
---|
[d168a46] | 486 | echoAndLog "${FUNCNAME}(): $file backup success" |
---|
[13a01a7] | 487 | } |
---|
| 488 | |
---|
[a01156a] | 489 | ##################################################################### |
---|
| 490 | ####### Funciones para el manejo de bases de datos |
---|
| 491 | ##################################################################### |
---|
| 492 | |
---|
| 493 | # This function set password to root |
---|
[13a01a7] | 494 | function mysqlSetRootPassword() |
---|
[a01156a] | 495 | { |
---|
| 496 | if [ $# -ne 1 ]; then |
---|
[813f617] | 497 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 498 | exit 1 |
---|
| 499 | fi |
---|
| 500 | |
---|
[e0edc14] | 501 | local root_mysql="$1" |
---|
[813f617] | 502 | echoAndLog "${FUNCNAME}(): setting root password in MySQL server" |
---|
[e0edc14] | 503 | mysqladmin -u root password "$root_mysql" |
---|
[a01156a] | 504 | if [ $? -ne 0 ]; then |
---|
[813f617] | 505 | errorAndLog "${FUNCNAME}(): error while setting root password in MySQL server" |
---|
[a01156a] | 506 | return 1 |
---|
| 507 | fi |
---|
[813f617] | 508 | echoAndLog "${FUNCNAME}(): root password saved!" |
---|
[a01156a] | 509 | return 0 |
---|
| 510 | } |
---|
| 511 | |
---|
[892606b9] | 512 | # Si el servicio mysql esta ya instalado cambia la variable de la clave del root por la ya existente |
---|
[e0edc14] | 513 | function mysqlGetRootPassword() |
---|
| 514 | { |
---|
[892606b9] | 515 | local pass_mysql |
---|
| 516 | local pass_mysql2 |
---|
[7c54b49] | 517 | # Comprobar si MySQL está instalado con la clave de root por defecto. |
---|
| 518 | if mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then |
---|
| 519 | echoAndLog "${FUNCNAME}(): Using default mysql root password." |
---|
| 520 | else |
---|
| 521 | stty -echo |
---|
[e0edc14] | 522 | echo "There is a MySQL service already installed." |
---|
| 523 | read -p "Enter MySQL root password: " pass_mysql |
---|
[7c54b49] | 524 | echo "" |
---|
[e0edc14] | 525 | read -p "Confrim password:" pass_mysql2 |
---|
[7c54b49] | 526 | echo "" |
---|
| 527 | stty echo |
---|
| 528 | if [ "$pass_mysql" == "$pass_mysql2" ] ;then |
---|
[e0edc14] | 529 | MYSQL_ROOT_PASSWORD="$pass_mysql" |
---|
[7c54b49] | 530 | return 0 |
---|
| 531 | else |
---|
[e0edc14] | 532 | echo "The keys don't match. Do not configure the server's key," |
---|
| 533 | echo "transactions in the database will give error." |
---|
[7c54b49] | 534 | return 1 |
---|
| 535 | fi |
---|
[892606b9] | 536 | fi |
---|
| 537 | } |
---|
| 538 | |
---|
[a01156a] | 539 | # comprueba si puede conectar con mysql con el usuario root |
---|
| 540 | function mysqlTestConnection() |
---|
| 541 | { |
---|
| 542 | if [ $# -ne 1 ]; then |
---|
[e0edc14] | 543 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 544 | exit 1 |
---|
| 545 | fi |
---|
| 546 | |
---|
[09bf701] | 547 | local root_password="$1" |
---|
[e0edc14] | 548 | echoAndLog "${FUNCNAME}(): checking connection to mysql..." |
---|
[09bf701] | 549 | # Componer fichero con credenciales de conexión a MySQL. |
---|
| 550 | touch $TMPMYCNF |
---|
| 551 | chmod 600 $TMPMYCNF |
---|
| 552 | cat << EOT > $TMPMYCNF |
---|
[c073224] | 553 | [client] |
---|
[09bf701] | 554 | user=root |
---|
| 555 | password=$root_password |
---|
| 556 | EOT |
---|
| 557 | # Borrar el fichero temporal si termina el proceso de instalación. |
---|
| 558 | trap "rm -f $TMPMYCNF" 0 1 2 3 6 9 15 |
---|
| 559 | # Comprobar conexión a MySQL. |
---|
| 560 | echo "" | mysql --defaults-extra-file=$TMPMYCNF |
---|
[a01156a] | 561 | if [ $? -ne 0 ]; then |
---|
[e0edc14] | 562 | errorAndLog "${FUNCNAME}(): connection to mysql failed, check root password and if daemon is running!" |
---|
[a01156a] | 563 | return 1 |
---|
| 564 | else |
---|
[e0edc14] | 565 | echoAndLog "${FUNCNAME}(): connection success" |
---|
[a01156a] | 566 | return 0 |
---|
| 567 | fi |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | # comprueba si la base de datos existe |
---|
| 571 | function mysqlDbExists() |
---|
| 572 | { |
---|
[09bf701] | 573 | if [ $# -ne 1 ]; then |
---|
[e0edc14] | 574 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 575 | exit 1 |
---|
| 576 | fi |
---|
| 577 | |
---|
[09bf701] | 578 | local database="$1" |
---|
[e0edc14] | 579 | echoAndLog "${FUNCNAME}(): checking if $database exists..." |
---|
[09bf701] | 580 | echo "show databases" | mysql --defaults-extra-file=$TMPMYCNF | grep "^${database}$" |
---|
[a01156a] | 581 | if [ $? -ne 0 ]; then |
---|
[e0edc14] | 582 | echoAndLog "${FUNCNAME}():database $database doesn't exists" |
---|
[a01156a] | 583 | return 1 |
---|
| 584 | else |
---|
[e0edc14] | 585 | echoAndLog "${FUNCNAME}():database $database exists" |
---|
[a01156a] | 586 | return 0 |
---|
| 587 | fi |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | function mysqlCheckDbIsEmpty() |
---|
| 591 | { |
---|
[09bf701] | 592 | if [ $# -ne 1 ]; then |
---|
[e0edc14] | 593 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 594 | exit 1 |
---|
| 595 | fi |
---|
| 596 | |
---|
[09bf701] | 597 | local database="$1" |
---|
[e0edc14] | 598 | echoAndLog "${FUNCNAME}(): checking if $database is empty..." |
---|
[09bf701] | 599 | num_tablas=`echo "show tables" | mysql --defaults-extra-file=$TMPMYCNF "${database}" | wc -l` |
---|
[a01156a] | 600 | if [ $? -ne 0 ]; then |
---|
[e0edc14] | 601 | errorAndLog "${FUNCNAME}(): error executing query, check database and root password" |
---|
[a01156a] | 602 | exit 1 |
---|
| 603 | fi |
---|
| 604 | |
---|
| 605 | if [ $num_tablas -eq 0 ]; then |
---|
[e0edc14] | 606 | echoAndLog "${FUNCNAME}():database $database is empty" |
---|
[a01156a] | 607 | return 0 |
---|
| 608 | else |
---|
[e0edc14] | 609 | echoAndLog "${FUNCNAME}():database $database has tables" |
---|
[a01156a] | 610 | return 1 |
---|
| 611 | fi |
---|
| 612 | |
---|
| 613 | } |
---|
| 614 | |
---|
| 615 | |
---|
| 616 | function mysqlImportSqlFileToDb() |
---|
| 617 | { |
---|
[09bf701] | 618 | if [ $# -ne 2 ]; then |
---|
[c5ce04c] | 619 | errorAndLog "${FNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 620 | exit 1 |
---|
| 621 | fi |
---|
| 622 | |
---|
[09bf701] | 623 | local database="$1" |
---|
| 624 | local sqlfile="$2" |
---|
[c4321ae] | 625 | local tmpfile=$(mktemp) |
---|
[d168a46] | 626 | local i=0 |
---|
| 627 | local dev="" |
---|
[c4321ae] | 628 | local status |
---|
[a01156a] | 629 | |
---|
| 630 | if [ ! -f $sqlfile ]; then |
---|
[c5ce04c] | 631 | errorAndLog "${FUNCNAME}(): Unable to locate $sqlfile!!" |
---|
[a01156a] | 632 | return 1 |
---|
| 633 | fi |
---|
| 634 | |
---|
[d168a46] | 635 | echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..." |
---|
[c4321ae] | 636 | chmod 600 $tmpfile |
---|
[d168a46] | 637 | for dev in ${DEVICE[*]}; do |
---|
[73a1bd6] | 638 | if [ "${DEVICE[i]}" == "$DEFAULTDEV" ]; then |
---|
[d168a46] | 639 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 640 | -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \ |
---|
| 641 | -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \ |
---|
| 642 | $sqlfile > $tmpfile |
---|
| 643 | fi |
---|
| 644 | let i++ |
---|
| 645 | done |
---|
[09bf701] | 646 | mysql --defaults-extra-file=$TMPMYCNF --default-character-set=utf8 "${database}" < $tmpfile |
---|
[c4321ae] | 647 | status=$? |
---|
| 648 | rm -f $tmpfile |
---|
| 649 | if [ $status -ne 0 ]; then |
---|
[c5ce04c] | 650 | errorAndLog "${FUNCNAME}(): error while importing $sqlfile in database $database" |
---|
[a01156a] | 651 | return 1 |
---|
| 652 | fi |
---|
[c5ce04c] | 653 | echoAndLog "${FUNCNAME}(): file imported to database $database" |
---|
[a01156a] | 654 | return 0 |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | # Crea la base de datos |
---|
| 658 | function mysqlCreateDb() |
---|
| 659 | { |
---|
[09bf701] | 660 | if [ $# -ne 1 ]; then |
---|
[a555f49] | 661 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 662 | exit 1 |
---|
| 663 | fi |
---|
| 664 | |
---|
[09bf701] | 665 | local database="$1" |
---|
[a01156a] | 666 | |
---|
[a555f49] | 667 | echoAndLog "${FUNCNAME}(): creating database..." |
---|
[09bf701] | 668 | mysqladmin --defaults-extra-file=$TMPMYCNF create $database |
---|
[a01156a] | 669 | if [ $? -ne 0 ]; then |
---|
[a555f49] | 670 | errorAndLog "${FUNCNAME}(): error while creating database $database" |
---|
[a01156a] | 671 | return 1 |
---|
| 672 | fi |
---|
[a555f49] | 673 | echoAndLog "${FUNCNAME}(): database $database created" |
---|
[a01156a] | 674 | return 0 |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | |
---|
| 678 | function mysqlCheckUserExists() |
---|
| 679 | { |
---|
[09bf701] | 680 | if [ $# -ne 1 ]; then |
---|
[e0edc14] | 681 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 682 | exit 1 |
---|
| 683 | fi |
---|
| 684 | |
---|
[09bf701] | 685 | local userdb="$1" |
---|
[a01156a] | 686 | |
---|
[e0edc14] | 687 | echoAndLog "${FUNCNAME}(): checking if $userdb exists..." |
---|
[09bf701] | 688 | echo "select user from user where user='${userdb}'\\G" |mysql --defaults-extra-file=$TMPMYCNF mysql | grep user |
---|
[a01156a] | 689 | if [ $? -ne 0 ]; then |
---|
[e0edc14] | 690 | echoAndLog "${FUNCNAME}(): user doesn't exists" |
---|
[a01156a] | 691 | return 1 |
---|
| 692 | else |
---|
[e0edc14] | 693 | echoAndLog "${FUNCNAME}(): user already exists" |
---|
[a01156a] | 694 | return 0 |
---|
| 695 | fi |
---|
| 696 | |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | # Crea un usuario administrativo para la base de datos |
---|
| 700 | function mysqlCreateAdminUserToDb() |
---|
| 701 | { |
---|
[09bf701] | 702 | if [ $# -ne 3 ]; then |
---|
[e0edc14] | 703 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 704 | exit 1 |
---|
| 705 | fi |
---|
| 706 | |
---|
[09bf701] | 707 | local database="$1" |
---|
| 708 | local userdb="$2" |
---|
| 709 | local passdb="$3" |
---|
[a01156a] | 710 | |
---|
[e0edc14] | 711 | echoAndLog "${FUNCNAME}(): creating admin user ${userdb} to database ${database}" |
---|
[a01156a] | 712 | |
---|
| 713 | cat > $WORKDIR/create_${database}.sql <<EOF |
---|
| 714 | GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ; |
---|
| 715 | GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ; |
---|
| 716 | FLUSH PRIVILEGES ; |
---|
| 717 | EOF |
---|
[09bf701] | 718 | mysql --defaults-extra-file=$TMPMYCNF < $WORKDIR/create_${database}.sql |
---|
[a01156a] | 719 | if [ $? -ne 0 ]; then |
---|
[e0edc14] | 720 | errorAndLog "${FUNCNAME}(): error while creating user in mysql" |
---|
[a01156a] | 721 | rm -f $WORKDIR/create_${database}.sql |
---|
| 722 | return 1 |
---|
| 723 | else |
---|
[e0edc14] | 724 | echoAndLog "${FUNCNAME}(): user created ok" |
---|
[a01156a] | 725 | rm -f $WORKDIR/create_${database}.sql |
---|
| 726 | return 0 |
---|
| 727 | fi |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | |
---|
| 731 | ##################################################################### |
---|
| 732 | ####### Funciones para el manejo de Subversion |
---|
| 733 | ##################################################################### |
---|
| 734 | |
---|
[13a01a7] | 735 | function svnExportCode() |
---|
| 736 | { |
---|
| 737 | if [ $# -ne 1 ]; then |
---|
| 738 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 739 | exit 1 |
---|
| 740 | fi |
---|
| 741 | |
---|
[6090a2d] | 742 | local url="$1" |
---|
[13a01a7] | 743 | |
---|
| 744 | echoAndLog "${FUNCNAME}(): downloading subversion code..." |
---|
| 745 | |
---|
[6090a2d] | 746 | svn export --force "$url" opengnsys |
---|
[13a01a7] | 747 | if [ $? -ne 0 ]; then |
---|
[6090a2d] | 748 | errorAndLog "${FUNCNAME}(): error getting OpenGnSys code from $url" |
---|
[13a01a7] | 749 | return 1 |
---|
| 750 | fi |
---|
| 751 | echoAndLog "${FUNCNAME}(): subversion code downloaded" |
---|
| 752 | return 0 |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | |
---|
[892606b9] | 756 | ############################################################ |
---|
[7586ca3] | 757 | ### Detectar red |
---|
| 758 | ############################################################ |
---|
| 759 | |
---|
[07c3a59] | 760 | # Comprobar si existe conexión. |
---|
| 761 | function checkNetworkConnection() |
---|
| 762 | { |
---|
[09ac3b8] | 763 | echoAndLog "${FUNCNAME}(): Disabling Firewall: $FIREWALLSERV." |
---|
| 764 | if [ -n "$FIREWALLSERV" ]; then |
---|
| 765 | service=$FIREWALLSERV |
---|
[b83843c] | 766 | $STOPSERVICE; $DISABLESERVICE |
---|
| 767 | fi |
---|
[109e8b2] | 768 | |
---|
| 769 | echoAndLog "${FUNCNAME}(): Checking OpenGnSys server conectivity." |
---|
[07c3a59] | 770 | OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"} |
---|
[225e859] | 771 | if which wget &>/dev/null; then |
---|
| 772 | wget --spider -q $OPENGNSYS_SERVER |
---|
| 773 | elif which curl &>/dev/null; then |
---|
| 774 | curl --connect-timeout 10 -s $OPENGNSYS_SERVER -o /dev/null |
---|
| 775 | else |
---|
| 776 | echoAndLog "${FUNCNAME}(): Cannot execute \"wget\" nor \"curl\"." |
---|
| 777 | return 1 |
---|
| 778 | fi |
---|
[07c3a59] | 779 | } |
---|
| 780 | |
---|
| 781 | # Obtener los parámetros de red de la interfaz por defecto. |
---|
[7586ca3] | 782 | function getNetworkSettings() |
---|
| 783 | { |
---|
[d168a46] | 784 | # Arrays globales definidas: |
---|
| 785 | # - DEVICE: nombres de dispositivos de red activos. |
---|
| 786 | # - SERVERIP: IPs locales del servidor. |
---|
| 787 | # - NETIP: IPs de redes. |
---|
| 788 | # - NETMASK: máscaras de red. |
---|
| 789 | # - NETBROAD: IPs de difusión de redes. |
---|
| 790 | # - ROUTERIP: IPs de routers. |
---|
| 791 | # Otras variables globales: |
---|
| 792 | # - DEFAULTDEV: dispositivo de red por defecto. |
---|
| 793 | # - DNSIP: IP del servidor DNS principal. |
---|
| 794 | |
---|
| 795 | local i=0 |
---|
| 796 | local dev="" |
---|
| 797 | |
---|
[109e8b2] | 798 | echoAndLog "${FUNCNAME}(): Detecting network parameters." |
---|
[d168a46] | 799 | DEVICE=( $(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}') ) |
---|
| 800 | if [ -z "$DEVICE" ]; then |
---|
| 801 | errorAndLog "${FUNCNAME}(): Network devices not detected." |
---|
[62e3bcf] | 802 | exit 1 |
---|
| 803 | fi |
---|
[d168a46] | 804 | for dev in ${DEVICE[*]}; do |
---|
| 805 | SERVERIP[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}') |
---|
| 806 | if [ -n "${SERVERIP[i]}" ]; then |
---|
[03cfd6e] | 807 | NETMASK[i]=$(LANG=C ifconfig $dev | \ |
---|
| 808 | awk '/Mask/ {sub(/.*:/,"",$4); print $4} |
---|
| 809 | /netmask/ {print $4}') |
---|
[d168a46] | 810 | NETBROAD[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {print ($6)}') |
---|
[eb7b39d] | 811 | NETIP[i]=$(ip route | awk -v d="$dev" '{ if ($3==d) {sub (/\/.*/,""); print $1} }') |
---|
| 812 | ROUTERIP[i]=$(ip route | awk -v d="$dev" '$1~/default/ { if ($5==d) print $3 }') |
---|
[d168a46] | 813 | DEFAULTDEV=${DEFAULTDEV:-"$dev"} |
---|
| 814 | fi |
---|
[ce85ae8] | 815 | let i++ |
---|
[d168a46] | 816 | done |
---|
[a555f49] | 817 | DNSIP=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n1) |
---|
[03cfd6e] | 818 | if [ -z "${NETIP[*]}" -o -z "${NETMASK[*]}" ]; then |
---|
[62e3bcf] | 819 | errorAndLog "${FUNCNAME}(): Network not detected." |
---|
[7586ca3] | 820 | exit 1 |
---|
| 821 | fi |
---|
[cc7eab7] | 822 | |
---|
| 823 | # Variables de ejecución de Apache |
---|
| 824 | # - APACHE_RUN_USER |
---|
| 825 | # - APACHE_RUN_GROUP |
---|
[d168a46] | 826 | if [ -f $APACHECFGDIR/envvars ]; then |
---|
| 827 | source $APACHECFGDIR/envvars |
---|
[cc7eab7] | 828 | fi |
---|
[d168a46] | 829 | APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"} |
---|
| 830 | APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"} |
---|
[73a1bd6] | 831 | |
---|
| 832 | echoAndLog "${FUNCNAME}(): Default network device: $DEFAULTDEV." |
---|
[7586ca3] | 833 | } |
---|
| 834 | |
---|
| 835 | |
---|
| 836 | ############################################################ |
---|
[892606b9] | 837 | ### Esqueleto para el Servicio pxe y contenedor tftpboot ### |
---|
| 838 | ############################################################ |
---|
| 839 | |
---|
[e0edc14] | 840 | function tftpConfigure() |
---|
| 841 | { |
---|
[109e8b2] | 842 | echoAndLog "${FUNCNAME}(): Configuring TFTP service." |
---|
| 843 | # Habilitar TFTP y reiniciar Inetd. |
---|
[8244351] | 844 | if [ -n "$TFTPSERV" ]; then |
---|
[584b103] | 845 | if [ -f $INETDCFGDIR/$TFTPSERV ]; then |
---|
| 846 | perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/$TFTPSERV |
---|
| 847 | else |
---|
| 848 | service=$TFTPSERV |
---|
| 849 | $ENABLESERVICE |
---|
| 850 | fi |
---|
[8244351] | 851 | fi |
---|
[53fba30] | 852 | service=$INETDSERV |
---|
| 853 | $ENABLESERVICE; $STARTSERVICE |
---|
[892606b9] | 854 | |
---|
[297df16] | 855 | # preparacion contenedor tftpboot |
---|
| 856 | cp -a $SYSLINUXDIR $TFTPCFGDIR/syslinux |
---|
| 857 | cp -a $SYSLINUXDIR/pxelinux.0 $TFTPCFGDIR |
---|
| 858 | # prepamos el directorio de la configuracion de pxe |
---|
| 859 | mkdir -p $TFTPCFGDIR/pxelinux.cfg |
---|
| 860 | cat > $TFTPCFGDIR/pxelinux.cfg/default <<EOF |
---|
[8fc9552] | 861 | DEFAULT syslinux/vesamenu.c32 |
---|
| 862 | MENU TITLE Aplicacion GNSYS |
---|
| 863 | |
---|
| 864 | LABEL 1 |
---|
| 865 | MENU LABEL 1 |
---|
| 866 | KERNEL syslinux/chain.c32 |
---|
| 867 | APPEND hd0 |
---|
| 868 | |
---|
| 869 | PROMPT 0 |
---|
| 870 | TIMEOUT 10 |
---|
[892606b9] | 871 | EOF |
---|
[297df16] | 872 | # comprobamos el servicio tftp |
---|
| 873 | sleep 1 |
---|
| 874 | testPxe |
---|
[892606b9] | 875 | } |
---|
| 876 | |
---|
[e0edc14] | 877 | function testPxe () |
---|
| 878 | { |
---|
[297df16] | 879 | echoAndLog "${FUNCNAME}(): Checking TFTP service... please wait." |
---|
| 880 | pushd /tmp |
---|
[eb7b39d] | 881 | tftp -v 127.0.0.1 -c get pxelinux.0 /tmp/pxelinux.0 && echoAndLog "TFTP service is OK." || errorAndLog "TFTP service is down." |
---|
[297df16] | 882 | popd |
---|
[892606b9] | 883 | } |
---|
| 884 | |
---|
[8fc9552] | 885 | |
---|
[892606b9] | 886 | ######################################################################## |
---|
[e4b1572] | 887 | ## Configuracion servicio NFS |
---|
| 888 | ######################################################################## |
---|
| 889 | |
---|
| 890 | # Configurar servicio NFS. |
---|
| 891 | # ADVERTENCIA: usa variables globales NETIP y NETMASK! |
---|
| 892 | function nfsConfigure() |
---|
| 893 | { |
---|
| 894 | echoAndLog "${FUNCNAME}(): Config nfs server." |
---|
| 895 | backupFile /etc/exports |
---|
| 896 | |
---|
| 897 | nfsAddExport $INSTALL_TARGET/client ${NETIP}/${NETMASK}:ro,no_subtree_check,no_root_squash,sync |
---|
| 898 | if [ $? -ne 0 ]; then |
---|
| 899 | errorAndLog "${FUNCNAME}(): error while adding NFS client config" |
---|
| 900 | return 1 |
---|
| 901 | fi |
---|
| 902 | |
---|
| 903 | nfsAddExport $INSTALL_TARGET/images ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync,crossmnt |
---|
| 904 | if [ $? -ne 0 ]; then |
---|
| 905 | errorAndLog "${FUNCNAME}(): error while adding NFS images config" |
---|
| 906 | return 1 |
---|
| 907 | fi |
---|
| 908 | |
---|
| 909 | nfsAddExport $INSTALL_TARGET/log/clients ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync |
---|
| 910 | if [ $? -ne 0 ]; then |
---|
| 911 | errorAndLog "${FUNCNAME}(): error while adding logging client config" |
---|
| 912 | return 1 |
---|
| 913 | fi |
---|
| 914 | |
---|
| 915 | nfsAddExport $INSTALL_TARGET/tftpboot ${NETIP}/${NETMASK}:ro,no_subtree_check,no_root_squash,sync |
---|
| 916 | if [ $? -ne 0 ]; then |
---|
| 917 | errorAndLog "${FUNCNAME}(): error while adding second filesystem for the PXE ogclient" |
---|
| 918 | return 1 |
---|
| 919 | fi |
---|
| 920 | |
---|
| 921 | /etc/init.d/nfs-kernel-server restart |
---|
| 922 | exportfs -va |
---|
| 923 | if [ $? -ne 0 ]; then |
---|
| 924 | errorAndLog "${FUNCNAME}(): error while configure exports" |
---|
| 925 | return 1 |
---|
| 926 | fi |
---|
| 927 | |
---|
| 928 | echoAndLog "${FUNCNAME}(): Added NFS configuration to file \"/etc/exports\"." |
---|
| 929 | return 0 |
---|
| 930 | } |
---|
| 931 | |
---|
| 932 | |
---|
| 933 | # Añadir entrada en fichero de configuración del servidor NFS. |
---|
| 934 | # Ejemplos: |
---|
| 935 | #nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0:ro,no_subtree_check,no_root_squash,sync |
---|
| 936 | #nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0 |
---|
| 937 | #nfsAddExport /opt/opengnsys 80.20.2.1:ro 192.123.32.2:rw |
---|
| 938 | function nfsAddExport() |
---|
| 939 | { |
---|
| 940 | if [ $# -lt 2 ]; then |
---|
| 941 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 942 | exit 1 |
---|
| 943 | fi |
---|
| 944 | if [ ! -f /etc/exports ]; then |
---|
| 945 | errorAndLog "${FUNCNAME}(): /etc/exports don't exists" |
---|
| 946 | return 1 |
---|
| 947 | fi |
---|
| 948 | |
---|
| 949 | local export="$1" |
---|
| 950 | local contador=0 |
---|
| 951 | local cadenaexport |
---|
| 952 | |
---|
| 953 | grep "^$export" /etc/exports > /dev/null |
---|
| 954 | if [ $? -eq 0 ]; then |
---|
| 955 | echoAndLog "${FUNCNAME}(): $export exists in /etc/exports, omiting" |
---|
| 956 | return 0 |
---|
| 957 | fi |
---|
| 958 | |
---|
| 959 | cadenaexport="${export}" |
---|
| 960 | for parametro in $*; do |
---|
| 961 | if [ $contador -gt 0 ]; then |
---|
| 962 | host=`echo $parametro | awk -F: '{print $1}'` |
---|
| 963 | options=`echo $parametro | awk -F: '{print $2}'` |
---|
| 964 | if [ "${host}" == "" ]; then |
---|
| 965 | errorAndLog "${FUNCNAME}(): host can't be empty" |
---|
| 966 | return 1 |
---|
| 967 | fi |
---|
| 968 | cadenaexport="${cadenaexport}\t${host}" |
---|
| 969 | |
---|
| 970 | if [ "${options}" != "" ]; then |
---|
| 971 | cadenaexport="${cadenaexport}(${options})" |
---|
| 972 | fi |
---|
| 973 | fi |
---|
| 974 | let contador=contador+1 |
---|
| 975 | done |
---|
| 976 | |
---|
| 977 | echo -en "$cadenaexport\n" >> /etc/exports |
---|
| 978 | |
---|
| 979 | echoAndLog "${FUNCNAME}(): add $export to /etc/exports" |
---|
| 980 | return 0 |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | |
---|
| 984 | ######################################################################## |
---|
[813f617] | 985 | ## Configuracion servicio Samba |
---|
[8fc9552] | 986 | ######################################################################## |
---|
[e4b1572] | 987 | |
---|
| 988 | # Configurar servicios Samba. |
---|
[8fc9552] | 989 | function smbConfigure() |
---|
| 990 | { |
---|
[e0edc14] | 991 | echoAndLog "${FUNCNAME}(): Configuring Samba service." |
---|
[8fc9552] | 992 | |
---|
[d168a46] | 993 | backupFile $SAMBACFGDIR/smb.conf |
---|
[8fc9552] | 994 | |
---|
[813f617] | 995 | # Copiar plantailla de recursos para OpenGnSys |
---|
[c1e00e4] | 996 | sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \ |
---|
[d168a46] | 997 | $WORKDIR/opengnsys/server/etc/smb-og.conf.tmpl > $SAMBACFGDIR/smb-og.conf |
---|
[813f617] | 998 | # Configurar y recargar Samba" |
---|
[6addf73] | 999 | perl -pi -e "s/WORKGROUP/OPENGNSYS/; s/server string \=.*/server string \= OpenGnSys Samba Server/" $SAMBACFGDIR/smb.conf |
---|
[03cfd6e] | 1000 | if ! grep -q "smb-og" $SAMBACFGDIR/smb.conf; then |
---|
| 1001 | echo "include = $SAMBACFGDIR/smb-og.conf" >> $SAMBACFGDIR/smb.conf |
---|
| 1002 | fi |
---|
[53fba30] | 1003 | service=$SAMBASERV |
---|
| 1004 | $ENABLESERVICE; $STARTSERVICE |
---|
[8fc9552] | 1005 | if [ $? -ne 0 ]; then |
---|
[813f617] | 1006 | errorAndLog "${FUNCNAME}(): error while configure Samba" |
---|
[8fc9552] | 1007 | return 1 |
---|
| 1008 | fi |
---|
[eb9424f] | 1009 | # Crear clave para usuario de acceso a los recursos. |
---|
[813f617] | 1010 | echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | smbpasswd -a -s $OPENGNSYS_CLIENT_USER |
---|
[8fc9552] | 1011 | |
---|
[813f617] | 1012 | echoAndLog "${FUNCNAME}(): Added Samba configuration." |
---|
[8fc9552] | 1013 | return 0 |
---|
| 1014 | } |
---|
| 1015 | |
---|
| 1016 | |
---|
[b6906f7] | 1017 | ######################################################################## |
---|
[e70925a] | 1018 | ## Configuracion servicio Rsync |
---|
| 1019 | ######################################################################## |
---|
| 1020 | |
---|
| 1021 | # Configurar servicio Rsync. |
---|
| 1022 | function rsyncConfigure() |
---|
| 1023 | { |
---|
| 1024 | echoAndLog "${FUNCNAME}(): Configuring Rsync service." |
---|
| 1025 | |
---|
| 1026 | backupFile $RSYNCCFGDIR/rsyncd.conf |
---|
| 1027 | |
---|
| 1028 | # Configurar acceso a Rsync. |
---|
| 1029 | sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \ |
---|
| 1030 | $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > $RSYNCCFGDIR/rsyncd.conf |
---|
| 1031 | sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \ |
---|
| 1032 | -e "s/CLIENTPASSWORD/$OPENGNSYS_CLIENT_PASSWD/g" \ |
---|
| 1033 | $WORKDIR/opengnsys/repoman/etc/rsyncd.secrets.tmpl > $RSYNCCFGDIR/rsyncd.secrets |
---|
| 1034 | chown root.root $RSYNCCFGDIR/rsyncd.secrets |
---|
| 1035 | chmod 600 $RSYNCCFGDIR/rsyncd.secrets |
---|
| 1036 | |
---|
| 1037 | # Habilitar Rsync y reiniciar Inetd. |
---|
| 1038 | if [ -n "$RSYNCSERV" ]; then |
---|
[4666588] | 1039 | if [ -f /etc/default/rsync ]; then |
---|
| 1040 | perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync |
---|
| 1041 | fi |
---|
[f243a47] | 1042 | if [ -f $INETDCFGDIR/rsync ]; then |
---|
| 1043 | perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync |
---|
| 1044 | else |
---|
| 1045 | cat << EOT > $INETDCFGDIR/rsync |
---|
| 1046 | service rsync |
---|
| 1047 | { |
---|
| 1048 | disable = no |
---|
| 1049 | socket_type = stream |
---|
| 1050 | wait = no |
---|
| 1051 | user = root |
---|
| 1052 | server = $(which rsync) |
---|
| 1053 | server_args = --daemon |
---|
| 1054 | log_on_failure += USERID |
---|
| 1055 | flags = IPv6 |
---|
| 1056 | } |
---|
| 1057 | EOT |
---|
| 1058 | fi |
---|
[e70925a] | 1059 | service=$RSYNCSERV $ENABLESERVICE |
---|
| 1060 | service=$INETDSERV $STARTSERVICE |
---|
| 1061 | fi |
---|
| 1062 | |
---|
| 1063 | echoAndLog "${FUNCNAME}(): Added Rsync configuration." |
---|
| 1064 | return 0 |
---|
| 1065 | } |
---|
| 1066 | |
---|
| 1067 | |
---|
| 1068 | ######################################################################## |
---|
[b6906f7] | 1069 | ## Configuracion servicio DHCP |
---|
| 1070 | ######################################################################## |
---|
| 1071 | |
---|
[e4b1572] | 1072 | # Configurar servicios DHCP. |
---|
[7586ca3] | 1073 | function dhcpConfigure() |
---|
| 1074 | { |
---|
[836a7597] | 1075 | echoAndLog "${FUNCNAME}(): Sample DHCP configuration." |
---|
[a555f49] | 1076 | |
---|
[d168a46] | 1077 | local errcode=0 |
---|
| 1078 | local i=0 |
---|
| 1079 | local dev="" |
---|
| 1080 | |
---|
| 1081 | backupFile $DHCPCFGDIR/dhcpd.conf |
---|
| 1082 | for dev in ${DEVICE[*]}; do |
---|
[01a9904] | 1083 | if [ -n "${SERVERIP[i]}" ]; then |
---|
[d168a46] | 1084 | backupFile $DHCPCFGDIR/dhcpd-$dev.conf |
---|
[e4b1572] | 1085 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 1086 | -e "s/NETIP/${NETIP[i]}/g" \ |
---|
| 1087 | -e "s/NETMASK/${NETMASK[i]}/g" \ |
---|
| 1088 | -e "s/NETBROAD/${NETBROAD[i]}/g" \ |
---|
| 1089 | -e "s/ROUTERIP/${ROUTERIP[i]}/g" \ |
---|
[d168a46] | 1090 | -e "s/DNSIP/$DNSIP/g" \ |
---|
| 1091 | $WORKDIR/opengnsys/server/etc/dhcpd.conf.tmpl > $DHCPCFGDIR/dhcpd-$dev.conf || errcode=1 |
---|
| 1092 | fi |
---|
| 1093 | let i++ |
---|
| 1094 | done |
---|
| 1095 | if [ $errcode -ne 0 ]; then |
---|
[b25fc47] | 1096 | errorAndLog "${FUNCNAME}(): error while configuring DHCP server" |
---|
[a555f49] | 1097 | return 1 |
---|
| 1098 | fi |
---|
[d168a46] | 1099 | ln -f $DHCPCFGDIR/dhcpd-$DEFAULTDEV.conf $DHCPCFGDIR/dhcpd.conf |
---|
[53fba30] | 1100 | service=$DHCPSERV |
---|
| 1101 | $ENABLESERVICE; $STARTSERVICE |
---|
[d168a46] | 1102 | echoAndLog "${FUNCNAME}(): Sample DHCP configured in \"$DHCPCFGDIR\"." |
---|
[a555f49] | 1103 | return 0 |
---|
[892606b9] | 1104 | } |
---|
| 1105 | |
---|
| 1106 | |
---|
[a01156a] | 1107 | ##################################################################### |
---|
| 1108 | ####### Funciones específicas de la instalación de Opengnsys |
---|
| 1109 | ##################################################################### |
---|
| 1110 | |
---|
[49c6891] | 1111 | # Copiar ficheros del OpenGnSys Web Console. |
---|
[7586ca3] | 1112 | function installWebFiles() |
---|
| 1113 | { |
---|
[2b793a8] | 1114 | local COMPATDIR f |
---|
| 1115 | |
---|
[dce072b] | 1116 | echoAndLog "${FUNCNAME}(): Installing web files..." |
---|
[2b793a8] | 1117 | # Copiar ficheros. |
---|
| 1118 | cp -a $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www #*/ comentario para Doxygen. |
---|
[7586ca3] | 1119 | if [ $? != 0 ]; then |
---|
[dce072b] | 1120 | errorAndLog "${FUNCNAME}(): Error copying web files." |
---|
[7586ca3] | 1121 | exit 1 |
---|
| 1122 | fi |
---|
| 1123 | find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null |
---|
[813f617] | 1124 | # Descomprimir XAJAX. |
---|
[b83843c] | 1125 | unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax |
---|
[2b793a8] | 1126 | # Compatibilidad con dispositivos móviles. |
---|
| 1127 | COMPATDIR="$INSTALL_TARGET/www/principal" |
---|
| 1128 | for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do |
---|
| 1129 | sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php |
---|
| 1130 | done |
---|
| 1131 | cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php |
---|
[7586ca3] | 1132 | # Cambiar permisos para ficheros especiales. |
---|
[e6d22c6] | 1133 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos} |
---|
[b7bd0df] | 1134 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/ |
---|
[2b793a8] | 1135 | |
---|
[dce072b] | 1136 | echoAndLog "${FUNCNAME}(): Web files installed successfully." |
---|
[7586ca3] | 1137 | } |
---|
| 1138 | |
---|
| 1139 | # Configuración específica de Apache. |
---|
[73a1bd6] | 1140 | function installWebConsoleApacheConf() |
---|
[a01156a] | 1141 | { |
---|
| 1142 | if [ $# -ne 2 ]; then |
---|
[dce072b] | 1143 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 1144 | exit 1 |
---|
| 1145 | fi |
---|
| 1146 | |
---|
[f9e3393] | 1147 | local path_opengnsys_base="$1" |
---|
| 1148 | local path_apache2_confd="$2" |
---|
[30837bb] | 1149 | local CONSOLEDIR=${path_opengnsys_base}/www |
---|
[a01156a] | 1150 | |
---|
[892606b9] | 1151 | if [ ! -d $path_apache2_confd ]; then |
---|
[dce072b] | 1152 | errorAndLog "${FUNCNAME}(): path to apache2 conf.d can not found, verify your server installation" |
---|
[892606b9] | 1153 | return 1 |
---|
| 1154 | fi |
---|
| 1155 | |
---|
[7586ca3] | 1156 | mkdir -p $path_apache2_confd/{sites-available,sites-enabled} |
---|
[892606b9] | 1157 | |
---|
[dce072b] | 1158 | echoAndLog "${FUNCNAME}(): creating apache2 config file.." |
---|
[a01156a] | 1159 | |
---|
[3ce53a7] | 1160 | # Activar HTTPS. |
---|
[7825e9e] | 1161 | $APACHESSLMOD |
---|
[643ca8c] | 1162 | $APACHEENABLESSL |
---|
| 1163 | $APACHEMAKECERT |
---|
[d725a41] | 1164 | |
---|
[30837bb] | 1165 | # Genera configuración de consola web a partir del fichero plantilla. |
---|
[f9e3393] | 1166 | if [ -n "$(apachectl -v | grep "2\.[0-2]")" ]; then |
---|
| 1167 | # Configuración para versiones anteriores de Apache. |
---|
| 1168 | sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \ |
---|
[f3dde7e] | 1169 | $WORKDIR/opengnsys/server/etc/apache-prev2.4.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE} |
---|
[f9e3393] | 1170 | else |
---|
| 1171 | # Configuración específica a partir de Apache 2.4 |
---|
| 1172 | sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \ |
---|
[f3dde7e] | 1173 | $WORKDIR/opengnsys/server/etc/apache.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE}.conf |
---|
[f9e3393] | 1174 | fi |
---|
[643ca8c] | 1175 | $APACHEENABLEOG |
---|
[a01156a] | 1176 | if [ $? -ne 0 ]; then |
---|
[dce072b] | 1177 | errorAndLog "${FUNCNAME}(): config file can't be linked to apache conf, verify your server installation" |
---|
[a01156a] | 1178 | return 1 |
---|
| 1179 | else |
---|
[dce072b] | 1180 | echoAndLog "${FUNCNAME}(): config file created and linked, restarting apache daemon" |
---|
[53fba30] | 1181 | service=$APACHESERV |
---|
| 1182 | $ENABLESERVICE; $STARTSERVICE |
---|
[a01156a] | 1183 | return 0 |
---|
| 1184 | fi |
---|
| 1185 | } |
---|
| 1186 | |
---|
[8fc9552] | 1187 | |
---|
[5d6bf97] | 1188 | # Crear documentación Doxygen para la consola web. |
---|
| 1189 | function makeDoxygenFiles() |
---|
| 1190 | { |
---|
| 1191 | echoAndLog "${FUNCNAME}(): Making Doxygen web files..." |
---|
| 1192 | $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \ |
---|
| 1193 | $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www |
---|
| 1194 | if [ ! -d "$INSTALL_TARGET/www/html" ]; then |
---|
| 1195 | errorAndLog "${FUNCNAME}(): unable to create Doxygen web files." |
---|
[ead38fb] | 1196 | return 1 |
---|
[5d6bf97] | 1197 | fi |
---|
| 1198 | mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api" |
---|
| 1199 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api |
---|
| 1200 | echoAndLog "${FUNCNAME}(): Doxygen web files created successfully." |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | |
---|
[a01156a] | 1204 | # Crea la estructura base de la instalación de opengnsys |
---|
[eb9424f] | 1205 | function createDirs() |
---|
[a01156a] | 1206 | { |
---|
| 1207 | if [ $# -ne 1 ]; then |
---|
[dce072b] | 1208 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[a01156a] | 1209 | exit 1 |
---|
| 1210 | fi |
---|
| 1211 | |
---|
[eb9424f] | 1212 | local path_opengnsys_base="$1" |
---|
[a01156a] | 1213 | |
---|
[eb9424f] | 1214 | # Crear estructura de directorios. |
---|
[dce072b] | 1215 | echoAndLog "${FUNCNAME}(): creating directory paths in $path_opengnsys_base" |
---|
[a01156a] | 1216 | mkdir -p $path_opengnsys_base |
---|
| 1217 | mkdir -p $path_opengnsys_base/bin |
---|
[5c33840] | 1218 | mkdir -p $path_opengnsys_base/client |
---|
[49c6891] | 1219 | mkdir -p $path_opengnsys_base/doc |
---|
[5c33840] | 1220 | mkdir -p $path_opengnsys_base/etc |
---|
[a01156a] | 1221 | mkdir -p $path_opengnsys_base/lib |
---|
[1cc5697] | 1222 | mkdir -p $path_opengnsys_base/log/clients |
---|
[eb9424f] | 1223 | ln -fs $path_opengnsys_base/log /var/log/opengnsys |
---|
[7586ca3] | 1224 | mkdir -p $path_opengnsys_base/sbin |
---|
[a01156a] | 1225 | mkdir -p $path_opengnsys_base/www |
---|
[5c33840] | 1226 | mkdir -p $path_opengnsys_base/images |
---|
[87c7b02] | 1227 | mkdir -p $TFTPCFGDIR |
---|
[63fd1ba] | 1228 | ln -fs $TFTPCFGDIR $path_opengnsys_base/tftpboot |
---|
[eb9424f] | 1229 | mkdir -p $path_opengnsys_base/tftpboot/pxelinux.cfg |
---|
[cfad47b] | 1230 | mkdir -p $path_opengnsys_base/tftpboot/menu.lst |
---|
[a01156a] | 1231 | if [ $? -ne 0 ]; then |
---|
[dce072b] | 1232 | errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?" |
---|
[a01156a] | 1233 | return 1 |
---|
| 1234 | fi |
---|
| 1235 | |
---|
[eb9424f] | 1236 | # Crear usuario ficticio. |
---|
| 1237 | if id -u $OPENGNSYS_CLIENT_USER &>/dev/null; then |
---|
| 1238 | echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENT_USER\" is already created" |
---|
| 1239 | else |
---|
| 1240 | echoAndLog "${FUNCNAME}(): creating OpenGnSys user" |
---|
| 1241 | useradd $OPENGNSYS_CLIENT_USER 2>/dev/null |
---|
| 1242 | if [ $? -ne 0 ]; then |
---|
| 1243 | errorAndLog "${FUNCNAME}(): error creating OpenGnSys user" |
---|
| 1244 | return 1 |
---|
| 1245 | fi |
---|
| 1246 | fi |
---|
| 1247 | |
---|
| 1248 | # Establecer los permisos básicos. |
---|
| 1249 | echoAndLog "${FUNCNAME}(): setting directory permissions" |
---|
[5eb61a6] | 1250 | chmod -R 775 $path_opengnsys_base/{log/clients,images} |
---|
| 1251 | chown -R :$OPENGNSYS_CLIENT_USER $path_opengnsys_base/{log/clients,images} |
---|
[eb9424f] | 1252 | if [ $? -ne 0 ]; then |
---|
| 1253 | errorAndLog "${FUNCNAME}(): error while setting permissions" |
---|
| 1254 | return 1 |
---|
| 1255 | fi |
---|
| 1256 | |
---|
[7669bca] | 1257 | # Mover el fichero de registro de instalación al directorio de logs. |
---|
[acfb07d] | 1258 | echoAndLog "${FUNCNAME}(): moving installation log file" |
---|
| 1259 | mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE |
---|
[7669bca] | 1260 | chmod 600 $LOG_FILE |
---|
[acfb07d] | 1261 | |
---|
[dce072b] | 1262 | echoAndLog "${FUNCNAME}(): directory paths created" |
---|
[a01156a] | 1263 | return 0 |
---|
| 1264 | } |
---|
| 1265 | |
---|
[463a1d49] | 1266 | # Copia ficheros de configuración y ejecutables genéricos del servidor. |
---|
[73a1bd6] | 1267 | function copyServerFiles () |
---|
[e0edc14] | 1268 | { |
---|
[463a1d49] | 1269 | if [ $# -ne 1 ]; then |
---|
[879689f] | 1270 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
[463a1d49] | 1271 | exit 1 |
---|
| 1272 | fi |
---|
| 1273 | |
---|
[7caf5a7c] | 1274 | local path_opengnsys_base="$1" |
---|
[463a1d49] | 1275 | |
---|
[cfad47b] | 1276 | local SOURCES=( server/tftpboot \ |
---|
[7caf5a7c] | 1277 | server/bin \ |
---|
| 1278 | repoman/bin \ |
---|
[42a0e41] | 1279 | admin/Sources/Services/ogAdmServerAux |
---|
| 1280 | admin/Sources/Services/ogAdmRepoAux |
---|
[7caf5a7c] | 1281 | installer/opengnsys_uninstall.sh \ |
---|
| 1282 | installer/opengnsys_update.sh \ |
---|
| 1283 | doc ) |
---|
[cfad47b] | 1284 | local TARGETS=( tftpboot \ |
---|
[7caf5a7c] | 1285 | bin \ |
---|
| 1286 | bin \ |
---|
[42a0e41] | 1287 | sbin \ |
---|
| 1288 | sbin \ |
---|
[7caf5a7c] | 1289 | lib \ |
---|
| 1290 | lib \ |
---|
| 1291 | doc ) |
---|
[463a1d49] | 1292 | |
---|
| 1293 | if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then |
---|
[879689f] | 1294 | errorAndLog "${FUNCNAME}(): inconsistent number of array items" |
---|
[463a1d49] | 1295 | exit 1 |
---|
| 1296 | fi |
---|
| 1297 | |
---|
[879689f] | 1298 | echoAndLog "${FUNCNAME}(): copying files to server directories" |
---|
[f2bb433] | 1299 | |
---|
[8457092] | 1300 | pushd $WORKDIR/opengnsys |
---|
[463a1d49] | 1301 | local i |
---|
| 1302 | for (( i = 0; i < ${#SOURCES[@]}; i++ )); do |
---|
| 1303 | if [ -f "${SOURCES[$i]}" ]; then |
---|
[879689f] | 1304 | echoAndLog "Copying ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" |
---|
[b5aae72] | 1305 | cp -a "${SOURCES[$i]}" "${path_opengnsys_base}/${TARGETS[$i]}" |
---|
[8457092] | 1306 | elif [ -d "${SOURCES[$i]}" ]; then |
---|
[879689f] | 1307 | echoAndLog "Copying content of ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" |
---|
[8457092] | 1308 | cp -a "${SOURCES[$i]}"/* "${path_opengnsys_base}/${TARGETS[$i]}" |
---|
| 1309 | else |
---|
[346eaee] | 1310 | warningAndLog "Unable to copy ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" |
---|
[463a1d49] | 1311 | fi |
---|
| 1312 | done |
---|
[7586ca3] | 1313 | popd |
---|
[892606b9] | 1314 | } |
---|
| 1315 | |
---|
[7586ca3] | 1316 | #################################################################### |
---|
[5eb61a6] | 1317 | ### Funciones de compilación de código fuente de servicios |
---|
[7586ca3] | 1318 | #################################################################### |
---|
| 1319 | |
---|
[5eb61a6] | 1320 | # Compilar los servicios de OpenGnSys |
---|
[7586ca3] | 1321 | function servicesCompilation () |
---|
| 1322 | { |
---|
[13a01a7] | 1323 | local hayErrores=0 |
---|
[0795938] | 1324 | |
---|
[49c6891] | 1325 | # Compilar OpenGnSys Server |
---|
| 1326 | echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Server" |
---|
[7b61735] | 1327 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer |
---|
[d168a46] | 1328 | make && mv ogAdmServer $INSTALL_TARGET/sbin |
---|
[13a01a7] | 1329 | if [ $? -ne 0 ]; then |
---|
[49c6891] | 1330 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Server" |
---|
[13a01a7] | 1331 | hayErrores=1 |
---|
| 1332 | fi |
---|
[7586ca3] | 1333 | popd |
---|
[49c6891] | 1334 | # Compilar OpenGnSys Repository Manager |
---|
| 1335 | echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Repository Manager" |
---|
[7b61735] | 1336 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo |
---|
[d168a46] | 1337 | make && mv ogAdmRepo $INSTALL_TARGET/sbin |
---|
[13a01a7] | 1338 | if [ $? -ne 0 ]; then |
---|
[49c6891] | 1339 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Repository Manager" |
---|
[13a01a7] | 1340 | hayErrores=1 |
---|
| 1341 | fi |
---|
[8125e7c] | 1342 | popd |
---|
[4984660] | 1343 | # Compilar OpenGnSys Agent |
---|
| 1344 | echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Agent" |
---|
[7b61735] | 1345 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent |
---|
[d168a46] | 1346 | make && mv ogAdmAgent $INSTALL_TARGET/sbin |
---|
[4984660] | 1347 | if [ $? -ne 0 ]; then |
---|
| 1348 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Agent" |
---|
| 1349 | hayErrores=1 |
---|
| 1350 | fi |
---|
| 1351 | popd |
---|
[49c6891] | 1352 | # Compilar OpenGnSys Client |
---|
| 1353 | echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Client" |
---|
[7b61735] | 1354 | pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient |
---|
[2338c95f] | 1355 | make && mv ogAdmClient ../../../../client/shared/bin |
---|
[13a01a7] | 1356 | if [ $? -ne 0 ]; then |
---|
[49c6891] | 1357 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Client" |
---|
[13a01a7] | 1358 | hayErrores=1 |
---|
| 1359 | fi |
---|
[318efac] | 1360 | popd |
---|
[13a01a7] | 1361 | |
---|
| 1362 | return $hayErrores |
---|
[b6906f7] | 1363 | } |
---|
| 1364 | |
---|
[7b61735] | 1365 | #################################################################### |
---|
| 1366 | ### Funciones de copia de la Interface de administración |
---|
| 1367 | #################################################################### |
---|
| 1368 | |
---|
| 1369 | # Copiar carpeta de Interface |
---|
[c1e00e4] | 1370 | function copyInterfaceAdm () |
---|
[7b61735] | 1371 | { |
---|
| 1372 | local hayErrores=0 |
---|
| 1373 | |
---|
[fbd9bcc] | 1374 | # Crear carpeta y copiar Interface |
---|
[7b61735] | 1375 | echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder" |
---|
[fbd9bcc] | 1376 | cp -ar $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client/interfaceAdm |
---|
[7b61735] | 1377 | if [ $? -ne 0 ]; then |
---|
| 1378 | echoAndLog "${FUNCNAME}(): error while copying Administration Interface Folder" |
---|
| 1379 | hayErrores=1 |
---|
| 1380 | fi |
---|
[b6f1726] | 1381 | chown $OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso |
---|
[f6c1d2b] | 1382 | chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso |
---|
[7b61735] | 1383 | |
---|
| 1384 | return $hayErrores |
---|
| 1385 | } |
---|
[b6906f7] | 1386 | |
---|
[892606b9] | 1387 | #################################################################### |
---|
| 1388 | ### Funciones instalacion cliente opengnsys |
---|
| 1389 | #################################################################### |
---|
| 1390 | |
---|
[73a1bd6] | 1391 | function copyClientFiles() |
---|
[7586ca3] | 1392 | { |
---|
[d168a46] | 1393 | local errstatus=0 |
---|
[a555f49] | 1394 | |
---|
[49c6891] | 1395 | echoAndLog "${FUNCNAME}(): Copying OpenGnSys Client files." |
---|
[73a1bd6] | 1396 | cp -a $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client |
---|
[d47d38d] | 1397 | if [ $? -ne 0 ]; then |
---|
[9ef8920] | 1398 | errorAndLog "${FUNCNAME}(): error while copying client estructure" |
---|
[d168a46] | 1399 | errstatus=1 |
---|
[9ef8920] | 1400 | fi |
---|
[d47d38d] | 1401 | find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null |
---|
[9ef8920] | 1402 | |
---|
[49c6891] | 1403 | echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files." |
---|
[d47d38d] | 1404 | mkdir -p $INSTALL_TARGET/client/lib/engine/bin |
---|
[73a1bd6] | 1405 | cp -a $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin |
---|
[a555f49] | 1406 | if [ $? -ne 0 ]; then |
---|
| 1407 | errorAndLog "${FUNCNAME}(): error while copying engine files" |
---|
[d168a46] | 1408 | errstatus=1 |
---|
[a555f49] | 1409 | fi |
---|
[9ef8920] | 1410 | |
---|
[d168a46] | 1411 | if [ $errstatus -eq 0 ]; then |
---|
[9ef8920] | 1412 | echoAndLog "${FUNCNAME}(): client copy files success." |
---|
| 1413 | else |
---|
| 1414 | errorAndLog "${FUNCNAME}(): client copy files with errors" |
---|
| 1415 | fi |
---|
| 1416 | |
---|
[d168a46] | 1417 | return $errstatus |
---|
[463a1d49] | 1418 | } |
---|
| 1419 | |
---|
| 1420 | |
---|
[e70925a] | 1421 | # Crear cliente OpenGnSys 1.0.2 y posteriores. |
---|
[5ad5dcc] | 1422 | function clientCreate() |
---|
[813f617] | 1423 | { |
---|
[89179ff] | 1424 | local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads" |
---|
[de1220c] | 1425 | local FILENAME=ogLive-precise-3.2.0-23-generic-r3257.iso # 1.0.4-rc2 |
---|
| 1426 | #local FILENAME=ogLive-raring-3.8.0-22-generic-r3836.iso # 1.0.5-rc3 |
---|
[0b85cc93] | 1427 | local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME |
---|
| 1428 | local TMPDIR=/tmp/${FILENAME%.iso} |
---|
[d168a46] | 1429 | |
---|
[79c26a8] | 1430 | # Descargar cliente, si es necesario. |
---|
| 1431 | if [ -s $PROGRAMDIR/$FILENAME ]; then |
---|
| 1432 | echoAndLog "${FUNCNAME}(): Moving $PROGRAMDIR/$FILENAME file to $(dirname $TARGETFILE)" |
---|
| 1433 | mv $PROGRAMDIR/$FILENAME $TARGETFILE |
---|
| 1434 | else |
---|
| 1435 | echoAndLog "${FUNCNAME}(): Loading Client" |
---|
| 1436 | wget $DOWNLOADURL/$FILENAME -O $TARGETFILE |
---|
| 1437 | fi |
---|
[0b85cc93] | 1438 | if [ ! -s $TARGETFILE ]; then |
---|
[6ef9f23] | 1439 | errorAndLog "${FUNCNAME}(): Error loading OpenGnSys Client" |
---|
[813f617] | 1440 | return 1 |
---|
| 1441 | fi |
---|
[79c26a8] | 1442 | # Montar imagen, copiar cliente ogclient y desmontar. |
---|
[5ad5dcc] | 1443 | echoAndLog "${FUNCNAME}(): Copying Client files" |
---|
[d168a46] | 1444 | mkdir -p $TMPDIR |
---|
[0b85cc93] | 1445 | mount -o loop,ro $TARGETFILE $TMPDIR |
---|
[73a1bd6] | 1446 | cp -av $TMPDIR/ogclient $INSTALL_TARGET/tftpboot |
---|
[5ad5dcc] | 1447 | umount $TMPDIR |
---|
| 1448 | rmdir $TMPDIR |
---|
[6ef01d9] | 1449 | # Asignar la clave cliente para acceso a Samba. |
---|
| 1450 | echoAndLog "${FUNCNAME}(): Set client access key" |
---|
| 1451 | echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | \ |
---|
| 1452 | $INSTALL_TARGET/bin/setsmbpass |
---|
[0b85cc93] | 1453 | |
---|
[813f617] | 1454 | # Establecer los permisos. |
---|
[19fdf38] | 1455 | find -L $INSTALL_TARGET/tftpboot -type d -exec chmod 755 {} \; |
---|
| 1456 | find -L $INSTALL_TARGET/tftpboot -type f -exec chmod 644 {} \; |
---|
[813f617] | 1457 | chown -R :$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/tftpboot/ogclient |
---|
[5eb61a6] | 1458 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/tftpboot/{menu.lst,pxelinux.cfg} |
---|
[6ef01d9] | 1459 | |
---|
[e8963d0] | 1460 | # Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache |
---|
[73a1bd6] | 1461 | cp -av $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz* $INSTALL_TARGET/tftpboot |
---|
| 1462 | cp -av $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img* $INSTALL_TARGET/tftpboot |
---|
[6ef01d9] | 1463 | |
---|
[813f617] | 1464 | echoAndLog "${FUNCNAME}(): Client generation success" |
---|
| 1465 | } |
---|
| 1466 | |
---|
| 1467 | |
---|
[49c6891] | 1468 | # Configuración básica de servicios de OpenGnSys |
---|
[cc7eab7] | 1469 | function openGnsysConfigure() |
---|
| 1470 | { |
---|
[d168a46] | 1471 | local i=0 |
---|
| 1472 | local dev="" |
---|
[7d4ce64] | 1473 | local CONSOLEURL |
---|
[d168a46] | 1474 | |
---|
[9ee62ad] | 1475 | echoAndLog "${FUNCNAME}(): Copying init files." |
---|
[42a0e41] | 1476 | cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys |
---|
| 1477 | cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys |
---|
[9ee62ad] | 1478 | echoAndLog "${FUNCNAME}(): Creating cron files." |
---|
[57cf15b] | 1479 | echo "* * * * * root [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys |
---|
[9ee62ad] | 1480 | echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator |
---|
[8fc9552] | 1481 | echo "5 * * * * root [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker |
---|
[dc762088] | 1482 | echo "* * * * * root [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete |
---|
[d168a46] | 1483 | |
---|
[700299b] | 1484 | echoAndLog "${FUNCNAME}(): Creating logrotate configuration file." |
---|
| 1485 | sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \ |
---|
| 1486 | $WORKDIR/opengnsys/server/etc/logrotate.tmpl > /etc/logrotate.d/opengnsys |
---|
| 1487 | |
---|
[d168a46] | 1488 | echoAndLog "${FUNCNAME}(): Creating OpenGnSys config files." |
---|
| 1489 | for dev in ${DEVICE[*]}; do |
---|
| 1490 | if [ -n "${SERVERIP[i]}" ]; then |
---|
| 1491 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 1492 | -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \ |
---|
| 1493 | -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \ |
---|
| 1494 | -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \ |
---|
| 1495 | $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer/ogAdmServer.cfg > $INSTALL_TARGET/etc/ogAdmServer-$dev.cfg |
---|
| 1496 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 1497 | $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo/ogAdmRepo.cfg > $INSTALL_TARGET/etc/ogAdmRepo-$dev.cfg |
---|
| 1498 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 1499 | -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \ |
---|
| 1500 | -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \ |
---|
| 1501 | -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \ |
---|
| 1502 | $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent/ogAdmAgent.cfg > $INSTALL_TARGET/etc/ogAdmAgent-$dev.cfg |
---|
[7d4ce64] | 1503 | CONSOLEURL="http://${SERVERIP[i]}/opengnsys" |
---|
[d168a46] | 1504 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
| 1505 | -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \ |
---|
| 1506 | -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \ |
---|
| 1507 | -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \ |
---|
[b22305e] | 1508 | -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \ |
---|
[d168a46] | 1509 | $INSTALL_TARGET/www/controlacceso.php > $INSTALL_TARGET/www/controlacceso-$dev.php |
---|
| 1510 | sed -e "s/SERVERIP/${SERVERIP[i]}/g" \ |
---|
[d7f8305] | 1511 | -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \ |
---|
[d168a46] | 1512 | $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient/ogAdmClient.cfg > $INSTALL_TARGET/client/etc/ogAdmClient-$dev.cfg |
---|
[7d4ce64] | 1513 | if [ "$dev" == "$DEFAULTDEV" ]; then |
---|
[03cfd6e] | 1514 | OPENGNSYS_CONSOLEURL="${CONSOLEURL/http:/https:}" |
---|
[7d4ce64] | 1515 | fi |
---|
[d168a46] | 1516 | fi |
---|
| 1517 | let i++ |
---|
| 1518 | done |
---|
| 1519 | ln -f $INSTALL_TARGET/etc/ogAdmServer-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmServer.cfg |
---|
| 1520 | ln -f $INSTALL_TARGET/etc/ogAdmRepo-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmRepo.cfg |
---|
| 1521 | ln -f $INSTALL_TARGET/etc/ogAdmAgent-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmAgent.cfg |
---|
| 1522 | ln -f $INSTALL_TARGET/client/etc/ogAdmClient-$DEFAULTDEV.cfg $INSTALL_TARGET/client/etc/ogAdmClient.cfg |
---|
| 1523 | ln -f $INSTALL_TARGET/www/controlacceso-$DEFAULTDEV.php $INSTALL_TARGET/www/controlacceso.php |
---|
| 1524 | chown root:root $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg |
---|
| 1525 | chmod 600 $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg |
---|
| 1526 | chown $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/controlacceso*.php |
---|
| 1527 | chmod 600 $INSTALL_TARGET/www/controlacceso*.php |
---|
[1f7b2d0] | 1528 | |
---|
| 1529 | # Revisar permisos generales. |
---|
| 1530 | if [ -x $INSTALL_TARGET/bin/checkperms ]; then |
---|
| 1531 | echoAndLog "${FUNCNAME}(): Checking permissions." |
---|
| 1532 | OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENT_USER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms |
---|
| 1533 | fi |
---|
| 1534 | |
---|
[9ee62ad] | 1535 | echoAndLog "${FUNCNAME}(): Starting OpenGnSys services." |
---|
[53fba30] | 1536 | service="opengnsys" |
---|
| 1537 | $ENABLESERVICE; $STARTSERVICE |
---|
[cc7eab7] | 1538 | } |
---|
| 1539 | |
---|
[b6906f7] | 1540 | |
---|
[a01156a] | 1541 | ##################################################################### |
---|
[180a07dd] | 1542 | ####### Función de resumen informativo de la instalación |
---|
| 1543 | ##################################################################### |
---|
| 1544 | |
---|
[813f617] | 1545 | function installationSummary() |
---|
| 1546 | { |
---|
[eb9424f] | 1547 | # Crear fichero de versión y revisión, si no existe. |
---|
| 1548 | local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt" |
---|
[0b85cc93] | 1549 | local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}') |
---|
[eb9424f] | 1550 | [ -f $VERSIONFILE ] || echo "OpenGnSys" >$VERSIONFILE |
---|
| 1551 | perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE |
---|
| 1552 | |
---|
| 1553 | # Mostrar información. |
---|
[180a07dd] | 1554 | echo |
---|
[49c6891] | 1555 | echoAndLog "OpenGnSys Installation Summary" |
---|
[180a07dd] | 1556 | echo "==============================" |
---|
[eb9424f] | 1557 | echoAndLog "Project version: $(cat $VERSIONFILE 2>/dev/null)" |
---|
[49c6891] | 1558 | echoAndLog "Installation directory: $INSTALL_TARGET" |
---|
[acfb07d] | 1559 | echoAndLog "Installation log file: $LOG_FILE" |
---|
[49c6891] | 1560 | echoAndLog "Repository directory: $INSTALL_TARGET/images" |
---|
[d168a46] | 1561 | echoAndLog "DHCP configuration directory: $DHCPCFGDIR" |
---|
[87c7b02] | 1562 | echoAndLog "TFTP configuration directory: $TFTPCFGDIR" |
---|
| 1563 | echoAndLog "Samba configuration directory: $SAMBACFGDIR" |
---|
[49c6891] | 1564 | echoAndLog "Web Console URL: $OPENGNSYS_CONSOLEURL" |
---|
[35b0ef1] | 1565 | echoAndLog "Web Console access data: specified in installer script" |
---|
[180a07dd] | 1566 | echo |
---|
| 1567 | echoAndLog "Post-Installation Instructions:" |
---|
| 1568 | echo "===============================" |
---|
[663c6625] | 1569 | echoAndLog "Firewall service has been disabled and SELinux mode set to" |
---|
| 1570 | echoAndLog " permissive during OpenGnSys installation. Please check" |
---|
[09ac3b8] | 1571 | echoAndLog " $FIREWALLSERV and SELinux configuration, if needed." |
---|
[180a07dd] | 1572 | echoAndLog "Review or edit all configuration files." |
---|
[c5ce04c] | 1573 | echoAndLog "Insert DHCP configuration data and restart service." |
---|
[af5efd6] | 1574 | echoAndLog "Optional: Log-in as Web Console admin user." |
---|
| 1575 | echoAndLog " - Review default Organization data and assign access to users." |
---|
[180a07dd] | 1576 | echoAndLog "Log-in as Web Console organization user." |
---|
[e4b1572] | 1577 | echoAndLog " - Insert OpenGnSys data (labs, computers, menus, etc)." |
---|
[180a07dd] | 1578 | echo |
---|
| 1579 | } |
---|
| 1580 | |
---|
| 1581 | |
---|
| 1582 | |
---|
| 1583 | ##################################################################### |
---|
[49c6891] | 1584 | ####### Proceso de instalación de OpenGnSys |
---|
[a01156a] | 1585 | ##################################################################### |
---|
| 1586 | |
---|
[49c6891] | 1587 | echoAndLog "OpenGnSys installation begins at $(date)" |
---|
[6090a2d] | 1588 | pushd $WORKDIR |
---|
[cc7eab7] | 1589 | |
---|
[af5efd6] | 1590 | # Detectar datos iniciales de auto-configuración del instalador. |
---|
[d168a46] | 1591 | autoConfigure |
---|
| 1592 | |
---|
| 1593 | # Detectar parámetros de red y comprobar si hay conexión. |
---|
| 1594 | getNetworkSettings |
---|
| 1595 | if [ $? -ne 0 ]; then |
---|
| 1596 | errorAndLog "Error reading default network settings." |
---|
| 1597 | exit 1 |
---|
| 1598 | fi |
---|
[07c3a59] | 1599 | checkNetworkConnection |
---|
| 1600 | if [ $? -ne 0 ]; then |
---|
| 1601 | errorAndLog "Error connecting to server. Causes:" |
---|
| 1602 | errorAndLog " - Network is unreachable, review devices parameters." |
---|
| 1603 | errorAndLog " - You are inside a private network, configure the proxy service." |
---|
| 1604 | errorAndLog " - Server is temporally down, try agian later." |
---|
| 1605 | exit 1 |
---|
| 1606 | fi |
---|
[7586ca3] | 1607 | |
---|
[e0edc14] | 1608 | # Detener servicios de OpenGnSys, si están activos previamente. |
---|
| 1609 | [ -f /etc/init.d/opengnsys ] && /etc/init.d/opengnsys stop |
---|
| 1610 | |
---|
[318efac] | 1611 | # Actualizar repositorios |
---|
[83518d5] | 1612 | updatePackageList |
---|
[318efac] | 1613 | |
---|
[b6906f7] | 1614 | # Instalación de dependencias (paquetes de sistema operativo). |
---|
[a01156a] | 1615 | declare -a notinstalled |
---|
| 1616 | checkDependencies DEPENDENCIES notinstalled |
---|
| 1617 | if [ $? -ne 0 ]; then |
---|
| 1618 | installDependencies notinstalled |
---|
| 1619 | if [ $? -ne 0 ]; then |
---|
| 1620 | echoAndLog "Error while installing some dependeces, please verify your server installation before continue" |
---|
| 1621 | exit 1 |
---|
| 1622 | fi |
---|
| 1623 | fi |
---|
[109e8b2] | 1624 | if [ -n "$INSTALLEXTRADEPS" ]; then |
---|
| 1625 | echoAndLog "Installing extra dependencies" |
---|
| 1626 | for (( i=0; i<${#INSTALLEXTRADEPS[*]}; i++ )); do |
---|
| 1627 | eval ${INSTALLEXTRADEPS[i]} |
---|
| 1628 | done |
---|
| 1629 | fi |
---|
[a01156a] | 1630 | |
---|
[ff6c349] | 1631 | # Detectar datos de auto-configuración después de instalar paquetes. |
---|
| 1632 | autoConfigurePost |
---|
| 1633 | |
---|
[49c6891] | 1634 | # Arbol de directorios de OpenGnSys. |
---|
[eb9424f] | 1635 | createDirs ${INSTALL_TARGET} |
---|
[a01156a] | 1636 | if [ $? -ne 0 ]; then |
---|
| 1637 | errorAndLog "Error while creating directory paths!" |
---|
| 1638 | exit 1 |
---|
| 1639 | fi |
---|
[b6906f7] | 1640 | |
---|
[1e7eaab] | 1641 | # Si es necesario, descarga el repositorio de código en directorio temporal |
---|
[49c6891] | 1642 | if [ $USESVN -eq 1 ]; then |
---|
[1e7eaab] | 1643 | svnExportCode $SVN_URL |
---|
| 1644 | if [ $? -ne 0 ]; then |
---|
| 1645 | errorAndLog "Error while getting code from svn" |
---|
| 1646 | exit 1 |
---|
| 1647 | fi |
---|
| 1648 | else |
---|
| 1649 | ln -fs "$(dirname $PROGRAMDIR)" opengnsys |
---|
[a01156a] | 1650 | fi |
---|
| 1651 | |
---|
[49c6891] | 1652 | # Compilar código fuente de los servicios de OpenGnSys. |
---|
[b6906f7] | 1653 | servicesCompilation |
---|
[13a01a7] | 1654 | if [ $? -ne 0 ]; then |
---|
| 1655 | errorAndLog "Error while compiling OpenGnsys services" |
---|
| 1656 | exit 1 |
---|
| 1657 | fi |
---|
[b6906f7] | 1658 | |
---|
[7b61735] | 1659 | # Copiar carpeta Interface entre administración y motor de clonación. |
---|
[c1e00e4] | 1660 | copyInterfaceAdm |
---|
[7b61735] | 1661 | if [ $? -ne 0 ]; then |
---|
[c1e00e4] | 1662 | errorAndLog "Error while copying Administration Interface" |
---|
[7b61735] | 1663 | exit 1 |
---|
| 1664 | fi |
---|
| 1665 | |
---|
[e70925a] | 1666 | # Configuración de TFTP. |
---|
[318efac] | 1667 | tftpConfigure |
---|
[b6906f7] | 1668 | |
---|
[e70925a] | 1669 | # Configuración de Samba. |
---|
[8fc9552] | 1670 | smbConfigure |
---|
| 1671 | if [ $? -ne 0 ]; then |
---|
[c1e00e4] | 1672 | errorAndLog "Error while configuring Samba server!" |
---|
[8fc9552] | 1673 | exit 1 |
---|
| 1674 | fi |
---|
| 1675 | |
---|
[e70925a] | 1676 | # Configuración de Rsync. |
---|
| 1677 | rsyncConfigure |
---|
| 1678 | |
---|
| 1679 | # Configuración ejemplo DHCP. |
---|
[b6906f7] | 1680 | dhcpConfigure |
---|
[a555f49] | 1681 | if [ $? -ne 0 ]; then |
---|
| 1682 | errorAndLog "Error while copying your dhcp server files!" |
---|
| 1683 | exit 1 |
---|
| 1684 | fi |
---|
[b6906f7] | 1685 | |
---|
[49c6891] | 1686 | # Copiar ficheros de servicios OpenGnSys Server. |
---|
[73a1bd6] | 1687 | copyServerFiles ${INSTALL_TARGET} |
---|
[463a1d49] | 1688 | if [ $? -ne 0 ]; then |
---|
| 1689 | errorAndLog "Error while copying the server files!" |
---|
| 1690 | exit 1 |
---|
| 1691 | fi |
---|
| 1692 | |
---|
[094ac0d] | 1693 | # Instalar base de datos de OpenGnSys Admin. |
---|
[b6906f7] | 1694 | isInArray notinstalled "mysql-server" |
---|
| 1695 | if [ $? -eq 0 ]; then |
---|
[094ac0d] | 1696 | # Habilitar gestor de base de datos (MySQL, si falla, MariaDB). |
---|
| 1697 | service=$MYSQLSERV |
---|
| 1698 | $ENABLESERVICE |
---|
| 1699 | if [ $? != 0 ]; then |
---|
| 1700 | service=$MARIADBSERV |
---|
| 1701 | $ENABLESERVICE |
---|
| 1702 | fi |
---|
| 1703 | # Activar gestor de base de datos. |
---|
[0f8100d] | 1704 | $STARTSERVICE |
---|
[094ac0d] | 1705 | # Asignar clave del usuario "root". |
---|
[09bf701] | 1706 | mysqlSetRootPassword "${MYSQL_ROOT_PASSWORD}" |
---|
[b6906f7] | 1707 | else |
---|
[094ac0d] | 1708 | # Si ya está instalado el gestor de bases de datos, obtener clave de "root", |
---|
[b6906f7] | 1709 | mysqlGetRootPassword |
---|
| 1710 | fi |
---|
[463a1d49] | 1711 | |
---|
[09bf701] | 1712 | mysqlTestConnection "${MYSQL_ROOT_PASSWORD}" |
---|
[a01156a] | 1713 | if [ $? -ne 0 ]; then |
---|
| 1714 | errorAndLog "Error while connection to mysql" |
---|
| 1715 | exit 1 |
---|
| 1716 | fi |
---|
[09bf701] | 1717 | mysqlDbExists ${OPENGNSYS_DATABASE} |
---|
[a01156a] | 1718 | if [ $? -ne 0 ]; then |
---|
[cc7eab7] | 1719 | echoAndLog "Creating Web Console database" |
---|
[09bf701] | 1720 | mysqlCreateDb ${OPENGNSYS_DATABASE} |
---|
[a01156a] | 1721 | if [ $? -ne 0 ]; then |
---|
[cc7eab7] | 1722 | errorAndLog "Error while creating Web Console database" |
---|
[a01156a] | 1723 | exit 1 |
---|
| 1724 | fi |
---|
| 1725 | else |
---|
[cc7eab7] | 1726 | echoAndLog "Web Console database exists, ommiting creation" |
---|
[a01156a] | 1727 | fi |
---|
| 1728 | |
---|
[09bf701] | 1729 | mysqlCheckUserExists ${OPENGNSYS_DB_USER} |
---|
[a01156a] | 1730 | if [ $? -ne 0 ]; then |
---|
| 1731 | echoAndLog "Creating user in database" |
---|
[09bf701] | 1732 | mysqlCreateAdminUserToDb ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}" |
---|
[a01156a] | 1733 | if [ $? -ne 0 ]; then |
---|
[cc7eab7] | 1734 | errorAndLog "Error while creating database user" |
---|
[a01156a] | 1735 | exit 1 |
---|
| 1736 | fi |
---|
| 1737 | |
---|
| 1738 | fi |
---|
| 1739 | |
---|
[09bf701] | 1740 | mysqlCheckDbIsEmpty ${OPENGNSYS_DATABASE} |
---|
[a01156a] | 1741 | if [ $? -eq 0 ]; then |
---|
| 1742 | echoAndLog "Creating tables..." |
---|
[892606b9] | 1743 | if [ -f $WORKDIR/$OPENGNSYS_DB_CREATION_FILE ]; then |
---|
[09bf701] | 1744 | mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE |
---|
[a01156a] | 1745 | else |
---|
[892606b9] | 1746 | errorAndLog "Unable to locate $WORKDIR/$OPENGNSYS_DB_CREATION_FILE!!" |
---|
[a01156a] | 1747 | exit 1 |
---|
| 1748 | fi |
---|
[bc7dfe7] | 1749 | else |
---|
| 1750 | # Si existe fichero ogBDAdmin-VersLocal-VersRepo.sql; aplicar cambios. |
---|
| 1751 | INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt) |
---|
| 1752 | REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt) |
---|
[295b4ab] | 1753 | OPENGNSYS_DB_UPDATE_FILE="opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql" |
---|
| 1754 | if [ -f $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE ]; then |
---|
[bc7dfe7] | 1755 | echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION" |
---|
[09bf701] | 1756 | mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE |
---|
[bc7dfe7] | 1757 | else |
---|
| 1758 | echoAndLog "Database unchanged." |
---|
| 1759 | fi |
---|
[a01156a] | 1760 | fi |
---|
[09bf701] | 1761 | # Eliminar fichero temporal con credenciales de acceso a MySQL. |
---|
| 1762 | rm -f $TMPMYCNF |
---|
[a01156a] | 1763 | |
---|
| 1764 | # copiando paqinas web |
---|
[7586ca3] | 1765 | installWebFiles |
---|
[5d6bf97] | 1766 | # Generar páqinas web de documentación de la API |
---|
| 1767 | makeDoxygenFiles |
---|
[a01156a] | 1768 | |
---|
| 1769 | # creando configuracion de apache2 |
---|
[5fcf180] | 1770 | installWebConsoleApacheConf $INSTALL_TARGET $APACHECFGDIR |
---|
[a01156a] | 1771 | if [ $? -ne 0 ]; then |
---|
[87c7b02] | 1772 | errorAndLog "Error configuring Apache for OpenGnSys Admin" |
---|
[a01156a] | 1773 | exit 1 |
---|
| 1774 | fi |
---|
| 1775 | |
---|
| 1776 | popd |
---|
[892606b9] | 1777 | |
---|
[9ef8920] | 1778 | # Crear la estructura de los accesos al servidor desde el cliente (shared) |
---|
[73a1bd6] | 1779 | copyClientFiles |
---|
[9ef8920] | 1780 | if [ $? -ne 0 ]; then |
---|
| 1781 | errorAndLog "Error creating client structure" |
---|
| 1782 | fi |
---|
| 1783 | |
---|
[d168a46] | 1784 | # Crear la estructura del cliente de OpenGnSys |
---|
[5ad5dcc] | 1785 | clientCreate |
---|
[a555f49] | 1786 | if [ $? -ne 0 ]; then |
---|
[813f617] | 1787 | errorAndLog "Error creating client" |
---|
[a555f49] | 1788 | exit 1 |
---|
| 1789 | fi |
---|
[892606b9] | 1790 | |
---|
[65245d1] | 1791 | # Configuración de servicios de OpenGnSys |
---|
| 1792 | openGnsysConfigure |
---|
| 1793 | |
---|
[180a07dd] | 1794 | # Mostrar sumario de la instalación e instrucciones de post-instalación. |
---|
| 1795 | installationSummary |
---|
| 1796 | |
---|
[077dd7c5] | 1797 | #rm -rf $WORKDIR |
---|
[49c6891] | 1798 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|
[05d2e03] | 1799 | exit 0 |
---|
[2308fc7] | 1800 | |
---|