[de87b1a] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file mountrepo.sh |
---|
| 4 | #@brief Script para montar el repositorio de datos remoto. |
---|
| 5 | #@warning License: GNU GPLv3+ |
---|
| 6 | #@version 1.0 |
---|
| 7 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 8 | #@date 2011-03-17 |
---|
| 9 | #*/ |
---|
| 10 | |
---|
| 11 | OGIMG=${OGIMG:-/opt/opengnsys/images} |
---|
[33100f8] | 12 | ROOTREPO=${ROOTREPO:-"$ROOTSERVER"} |
---|
[de87b1a] | 13 | |
---|
| 14 | # TODO Revisar proceso de arranque para no montar 2 veces el repositorio. |
---|
[5acde60] | 15 | if [ "$ogactiveadmin" == "true" ]; then |
---|
[c39fac3] | 16 | export boot=admin # ATENCIÓN: siempre en modo "admin". |
---|
[de87b1a] | 17 | umount $OGIMG 2>/dev/null |
---|
| 18 | |
---|
[522c19d] | 19 | protocol=${ogprotocol:-"smb"} |
---|
[7cf3d39] | 20 | [ "$ogunit" != "" ] && OGUNIT="/$ogunit" |
---|
[de87b1a] | 21 | printf "$MSG_MOUNTREPO\n" "$protocol" "$boot" |
---|
[cca95a3] | 22 | case "$ogprotocol" in |
---|
[7cf3d39] | 23 | nfs) mount.nfs ${ROOTREPO}:$OGIMG$OGUNIT $OGIMG -o rw,nolock ;; |
---|
[300fbd9] | 24 | smb) PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \ |
---|
[1895428] | 25 | sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') |
---|
| 26 | PASS=${PASS:-"og"} |
---|
[7cf3d39] | 27 | mount.cifs //${ROOTREPO}/ogimages$OGUNIT $OGIMG -o rw,serverino,acl,username=opengnsys,password=$PASS |
---|
[1895428] | 28 | ;; |
---|
[1a2fa9d8] | 29 | local) # TODO: hacer funcion dentro de este script que monte smb |
---|
| 30 | # Comprobamos que estatus sea online. |
---|
| 31 | if [ "$ogstatus" == "offline" -o "$SERVER" == "" ]; then |
---|
| 32 | # Si estatus es offline buscamos un dispositivo con etiqueta repo |
---|
| 33 | # y si no existe montamos la cache como repo (si existe). |
---|
| 34 | TYPE=$(blkid | grep REPO | awk -F"TYPE=" '{print $2}' | tr -d \") |
---|
| 35 | if [ "$TYPE" == "" ]; then |
---|
| 36 | [ -d $OGCAC/$OGIMG ] && mount --bind $OGCAC/$OGIMG $OGIMG |
---|
| 37 | else |
---|
| 38 | mount -t $TYPE LABEL=REPO $OGIMG &>/dev/null |
---|
| 39 | fi |
---|
| 40 | else |
---|
| 41 | # Comprobamos que existe un servicio de samba. |
---|
| 42 | smbclient -L $SERVER -N &>/dev/null |
---|
| 43 | if [ $? -eq 0 ]; then |
---|
| 44 | PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \ |
---|
| 45 | sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') |
---|
| 46 | PASS=${PASS:-"og"} |
---|
| 47 | mount.cifs //${ROOTREPO}/ogimages $OGIMG -o rw,serverino,acl,username=opengnsys,password=$PASS |
---|
| 48 | fi |
---|
| 49 | # TODO: buscar condicion para NFS |
---|
| 50 | fi |
---|
| 51 | ;; |
---|
[de87b1a] | 52 | esac |
---|
| 53 | fi |
---|
| 54 | |
---|