source: server/bin/checkperms

qndtest
Last change on this file was 436abc7, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#915 Change WebConsole? to read API token from ogAdmServer.cfg

This commit changes restfunctions.php to read the API token of
ogAmdServer from ogAdmRepo.cfg to ogAdmServer.cfg. This way it avoids
possible communication errors if ogAdmRepo.cfg and ogAdmServer.cfg are
desynced.

In order to restfuntions.php can read ogAdmServer.cfg this commit
also changes the permissions of the file.

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#!/bin/bash
2# checkperms: Comprueba que los permisos de los ficheros sean correctos.
3# Nota: Las siguientes variables de entorno pueden usarse para retocar los
4#       valores por defecto:
5#       - OPENGNSYS_USER - usuario de OpenGnsys.
6#       - OPENGNSYS_DIR  - directorio de instalación.
7#       - APACHE_USER    - usuario de Apache.
8#       - APACHE_GROUP   - grupo de Apache.
9# Uso:  checkperms
10#       variable1=valor1 ... checkperms
11# Autor: Ramon Gomez - Univ. Sevilla, noviembre 2010
12# Fecha: 2012/07/13
13
14
15# Variables.
16OPENGNSYS_USER=${OPENGNSYS_USER:-"opengnsys"}   # Usuario del cliente para acceso remoto
17OPENGNSYS_DIR=${OPENGNSYS_DIR:-/opt/opengnsys}  # Directorio de instalación de OpenGnsys
18APACHE_USER=${APACHE_USER:-"www-data"}          # Usuario de ejecución de Apache
19APACHE_GROUP=${APACHE_GROUP:-"www-data"}        # Grupo de ejecución de Apache
20PROG=$(basename "$0")
21
22# Control de errores.
23if [ "$USER" != "root" ]; then
24        echo "$PROG: Error: solo ejecutable por root" >&2
25        exit 1
26fi
27if [ "$OPENGNSYS_USER" == "root" -o -z "$(getent passwd "$OPENGNSYS_USER" 2>/dev/null)" ]; then
28        echo "$PROG: Error: el usuario de OpenGnsys debe existir y no ser root (OPENGNSYS_USER=\"$OPENGNSYS_USER\")" >&2
29        exit 1
30fi
31if [ ! -d "$OPENGNSYS_DIR" ]; then
32        echo "$PROG: Error: sin acceso al directorio de OpenGnsys (OPENGNSYS_DIR=\"$OPENGNSYS_DIR\")". >&2
33        exit 1
34fi
35if [ -z "$(getent passwd "$APACHE_USER" 2>/dev/null)" -o -z "$(getent group "$APACHE_GROUP" 2>/dev/null)" ]; then
36        echo "$PROG: Error: no se detectan el usuario o el grupo de Apache (APACHE_USER=\"$APACHE_USER\", APACHE_GROUP=\"$APACHE_GROUP\")" >&2
37        exit 1
38fi
39
40mkdir -p $OPENGNSYS_DIR/{log/clients,images/groups}
41chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/{log/clients,images/groups}
42find $OPENGNSYS_DIR/log/clients -type f -exec chmod 664 {} \;
43find $OPENGNSYS_DIR/images -maxdepth 1 -exec chown :$OPENGNSYS_USER {} \;
44find $OPENGNSYS_DIR/images -maxdepth 1 -type d -exec chmod 775 {} \;
45find $OPENGNSYS_DIR/images -maxdepth 1 -type f -exec chmod 664 {} \;
46find $OPENGNSYS_DIR/client/{interfaceAdm,scripts} ! -name "*.txt" -exec chmod +x {} \;
47chown -R $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/etc/ssl/private
48chmod -R go-rwx $OPENGNSYS_DIR/client/etc/ssl/private
49chown $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
50chmod 700 $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
51chown root:root $OPENGNSYS_DIR/etc/ogAdmAgent*.cfg
52chmod 600 $OPENGNSYS_DIR/etc/ogAdmAgent*.cfg
53chown root:$APACHE_GROUP $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg,etc/ogAdmServer*.cfg}
54chmod 640 $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg,etc/ogAdmServer*.cfg}
55chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/images/{fotos,iconos}
56mkdir -p $OPENGNSYS_DIR/www/{api,tmp}
57chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/{api,tmp}
58chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/tftpboot/{menu.lst,grub}
59chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/tftpboot/ogLive*
60find -L $OPENGNSYS_DIR/tftpboot -type d -exec chmod 755 {} \;
61find -L $OPENGNSYS_DIR/tftpboot -type f -exec chmod 644 {} \;
62chown $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/log/{ogagent,remotepc,rest}.log
63
Note: See TracBrowser for help on using the repository browser.