source: server/bin/checkperms @ 2b2311f

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 2b2311f was 663cd905, checked in by ramon <ramongomez@…>, 8 years ago

#730: Actaulizador no cambiar permisos, usa script checkperms.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5232 a21b9725-9963-47de-94b9-378ad31fedc9

  • 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
40chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/{log/clients,images/group}
41find $OPENGNSYS_DIR/log/clients -type f -exec chmod 664 {} \;
42find $OPENGNSYS_DIR/images -maxdepth 1 -exec chown :$OPENGNSYS_USER {} \;
43find $OPENGNSYS_DIR/images -maxdepth 1 -type d -exec chmod 775 {} \;
44find $OPENGNSYS_DIR/images -maxdepth 1 -type f -exec chmod 664 {} \;
45find $OPENGNSYS_DIR/client/{interfaceAdm,scripts} ! -name "*.txt" -exec chmod +x {} \;
46chown $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
47chmod 700 $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
48chown root:root $OPENGNSYS_DIR/etc/{ogAdmServer,ogAdmAgent}*.cfg
49chmod 600 $OPENGNSYS_DIR/etc/{ogAdmServer,ogAdmAgent}*.cfg
50chown root:$APACHE_GROUP $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg}
51chmod 640 $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg}
52chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/images/{fotos,iconos}
53chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/api
54chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/tmp      # ???
55chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/tftpboot/menu.lst
56chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/tftpboot/ogclient
57find -L $OPENGNSYS_DIR/tftpboot -type d -exec chmod 755 {} \;
58find -L $OPENGNSYS_DIR/tftpboot -type f -exec chmod 644 {} \;
59chown $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/log/ogagent.log
60
Note: See TracBrowser for help on using the repository browser.