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