source: server/bin/checkperms @ b50031b

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since b50031b was a3a1ff2, checked in by Ramón M. Gómez <ramongomez@…>, 7 years ago

#840: Checking permissions and directories after Git downloads.

  • Property mode set to 100755
File size: 2.9 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 $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
48chmod 700 $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
49chown root:root $OPENGNSYS_DIR/etc/{ogAdmServer,ogAdmAgent}*.cfg
50chmod 600 $OPENGNSYS_DIR/etc/{ogAdmServer,ogAdmAgent}*.cfg
51chown root:$APACHE_GROUP $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg}
52chmod 640 $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg}
53chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/images/{fotos,iconos}
54mkdir -p $OPENGNSYS_DIR/www/{api,tmp}
55chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/{api,tmp}
56chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/tftpboot/menu.lst
57chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/tftpboot/ogLive*
58find -L $OPENGNSYS_DIR/tftpboot -type d -exec chmod 755 {} \;
59find -L $OPENGNSYS_DIR/tftpboot -type f -exec chmod 644 {} \;
60chown $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/log/ogagent.log
61
Note: See TracBrowser for help on using the repository browser.