source: admin/Interface/CambiarAcceso @ 2d40ba26

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 2d40ba26 was eb9424f, checked in by ramon <ramongomez@…>, 14 years ago

branches/version1.0: aplicar cambios de la rama trunk para desarrollar version 1.0.1

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

  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[6905c2a7]1#!/bin/bash
2
3#_______________________________________________________________________________________________________________________________
4#
5# PARAMETROS RECIBIDOS DESDE EL CLIENTE
6# $1 modo  (admin, user)
7#_______________________________________________________________________________________________________________________________
[eb9424f]8### codigos de error
9#$OG_ERR_NOTEXEC = 7      La llamada no se ha realizado desde OGclient.
10#$OG_ERR_NOTFOUND = 2       Repositorio no montado.
11#$OG_ERR_LOCKED =       4          Repositorio bloqueado.
12#$OG_ERR_NOTWRITE = 14    No Se ha realizado el montaje RW correctamente.
13
[6905c2a7]14
15# Error si llamada no se realliza desde OpenGnSys Client.
16PROG=$(basename $0)
17CALLER=$(ogGetCaller)
18if [ "$CALLER" != "CrearImagen" -a "$CALLER" != "ConsolaRemota" ]; then
19    ogRaiseError $OG_ERR_NOTEXEC "$CALLER -> $PROG"
20    exit $?
21fi
22
[eb9424f]23# Salir si el repositorio est� bloquedo (tiene ficheros abiertos).
[6905c2a7]24REPOIP=$(ogGetRepoIp)
25if [ -z "$REPOIP" ]; then
26        ogRaiseError $OG_ERR_NOTFOUND "repo no montado"
27        exit $?
28fi
29if ogIsRepoLocked; then
30        ogRaiseError $OG_ERR_LOCKED "repo $REPOIP"
31        exit $?
32fi
33
34# Comprobar protocolo y modo de acceso.
[16919ef]35PROTO=${ogprotocol:-"smb"}
36case "$PROTO" in
[6905c2a7]37        nfs|smb) ;;
[16919ef]38        *)      ogRaiseError $OG_ERR_FORMAT "protocolo desconocido $PROTO"
[6905c2a7]39                exit $? ;;
40esac
41case "$1" in
42        admin)  MODE="rw,nolock" ;;
43        user)   MODE="ro,nolock" ;;
44        *)      ogRaiseError $OG_ERR_FORMAT "modo desconocido $1"
45                exit $? ;;
46esac
47
48# Desmontar repositorio y volver a montarlo con el modo adecuado.
49umount $OGIMG
[1222e988]50ogEcho info "$PROG: Montar repositorio $REPO por $PROTO en modo $1"
[16919ef]51case "$PROTO" in
52        nfs)    mount -t nfs $REPOIP:$OGIMG $OGIMG -o $MODE ;;
53        smb)    mount -t cifs //$REPOIP/ogimages $OGIMG -o $MODE,serverino,acl,username=opengnsys,password=og ;;
[6905c2a7]54esac
55
[eb9424f]56#Comprobamos que el tipo de acceso (escritura/lectura) se ha realizado correctamente.
57FILETEST="${OGIMG}/testWrite.txt"
58touch $FILETEST
59VALUE=$?
60
61case "$1" in
62        admin)
63                if [ "$VALUE" == 0 ]
64                then
65                        rm $FILETEST
66                else
67                        ogRaiseError $OG_ERR_NOTWRITE "sin acceso de escritura en modo admin"
68                        exit $?                 
69                fi
70        ;;
71        user)
72                if [ "$VALUE" == 0 ]
73                then
74                        rm $FILETEST
75                        ogRaiseError $OG_ERR_NOTWRITE "Warning: con acceso de escritura en modo user"
76                        exit $?
77                fi
78        ;;
79esac
80
Note: See TracBrowser for help on using the repository browser.