source: server/bin/checkperms

lgromero-new-oglive
Last change on this file was c28eefa, checked in by Natalia Serrano <natalia.serrano@…>, 19 months ago

Log to syslog in a number of shell scripts

  • Property mode set to 100755
File size: 3.2 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
22source $OPENGNSYS_DIR/lib/ogfunctions.sh
23
24# Control de errores.
25if [ "$USER" != "root" ]; then
26        echo "$PROG: Error: solo ejecutable por root" >&2
27        exit 1
28fi
29if [ "$OPENGNSYS_USER" == "root" -o -z "$(getent passwd "$OPENGNSYS_USER" 2>/dev/null)" ]; then
30        echo "$PROG: Error: el usuario de OpenGnsys debe existir y no ser root (OPENGNSYS_USER=\"$OPENGNSYS_USER\")" >&2
31        exit 1
32fi
33if [ ! -d "$OPENGNSYS_DIR" ]; then
34        echo "$PROG: Error: sin acceso al directorio de OpenGnsys (OPENGNSYS_DIR=\"$OPENGNSYS_DIR\")". >&2
35        exit 1
36fi
37if [ -z "$(getent passwd "$APACHE_USER" 2>/dev/null)" -o -z "$(getent group "$APACHE_GROUP" 2>/dev/null)" ]; then
38        echo "$PROG: Error: no se detectan el usuario o el grupo de Apache (APACHE_USER=\"$APACHE_USER\", APACHE_GROUP=\"$APACHE_GROUP\")" >&2
39        exit 1
40fi
41
42echolog "Fixing filesystem permissions"
43mkdir -p $OPENGNSYS_DIR/{log/clients,images/groups}
44chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/{log/clients,images/groups}
45find $OPENGNSYS_DIR/log/clients -type f -exec chmod 664 {} \;
46find $OPENGNSYS_DIR/images -maxdepth 1 -exec chown :$OPENGNSYS_USER {} \;
47find $OPENGNSYS_DIR/images -maxdepth 1 -type d -exec chmod 775 {} \;
48find $OPENGNSYS_DIR/images -maxdepth 1 -type f -exec chmod 664 {} \;
49find $OPENGNSYS_DIR/client/{interfaceAdm,scripts} ! -name "*.txt" -exec chmod +x {} \;
50chown -R $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/etc/ssl/private
51chmod -R go-rwx $OPENGNSYS_DIR/client/etc/ssl/private
52chown $OPENGNSYS_USER:$OPENGNSYS_USER $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
53chmod 700 $OPENGNSYS_DIR/client/interfaceAdm/CambiarAcceso
54chown root:root $OPENGNSYS_DIR/etc/ogAdmAgent*.cfg
55chmod 600 $OPENGNSYS_DIR/etc/ogAdmAgent*.cfg
56chown root:$APACHE_GROUP $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg,etc/ogAdmServer*.cfg}
57chmod 640 $OPENGNSYS_DIR/{www/controlacceso*.php,etc/ogAdmRepo*.cfg,etc/ogAdmServer*.cfg}
58chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/images/{fotos,iconos}
59mkdir -p $OPENGNSYS_DIR/www/{api,tmp}
60chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/www/{api,tmp}
61chown -R $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/tftpboot/{menu.lst,grub}
62chown -R :$OPENGNSYS_USER $OPENGNSYS_DIR/tftpboot/ogLive*
63find -L $OPENGNSYS_DIR/tftpboot -type d -exec chmod 755 {} \;
64find -L $OPENGNSYS_DIR/tftpboot -type f -exec chmod 644 {} \;
65chown $APACHE_USER:$APACHE_GROUP $OPENGNSYS_DIR/log/{ogagent,remotepc,rest}.log
66
Note: See TracBrowser for help on using the repository browser.