Advertisement
adanbazan

Montar particion remota

Nov 26th, 2022
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.23 KB | None | 0 0
  1. #!/bin/bash -x
  2. #Script que monitorea que la partici�n /STORAGE/C1 del equipo Cerebro1 esté montada
  3. #en este servidor de manera local.
  4. #VARIABLES
  5.  
  6. #IP del servidor sshfs
  7. IPSSHFS="10.12.102.60"
  8. IPGOOG="8.8.8.8"
  9. #Revisi�n de que la partici�n estémontada
  10. /usr/bin/df -h | /usr/bin/grep "/STORAGE/C1"
  11. #Variable que contiene el dato validador de la particion montada
  12. VAL=$(echo $?)
  13.  
  14. if [ $VAL -ne 0 ]
  15. then
  16.         /usr/bin/ping -c2 $IPSSHFS
  17.         #Variable que contiene el dato validador del ping al servidor remoto
  18.         VFS=$(echo $?)
  19.         echo "Empieza el segundo condicional"
  20.         #Inicia el condicional para montar la particion
  21.         if [ $VFS -eq 0 ]
  22.         then
  23.                 #Montamos todas las particiones
  24.                 /usr/bin/mount -a
  25.                 sleep 10
  26.                 #Revisamos que este montada la particion
  27.                 /usr/bin/df -h | /usr/bin/grep "/STORAGE/C1"
  28.                 VAL2=$(echo $?)
  29.                 if [ $VAL2 -eq 0 ]
  30.                 then
  31.                         #Enviar correo de aviso que se monto
  32.                 else
  33.                         #Enviar correo de aviso que no se pudo montar
  34.                 fi
  35.         else
  36.                 #Hacer ping a google para ver que haya internet y corroborar que el
  37.                 #Switch no este apagado
  38.                 /usr/bin/ping -c2 $IPGOOG
  39.                 VAL3=$(echo $?)
  40.                 #Condicional para la revision de internet
  41.                 if [ $VAL3 -eq 0 ]
  42.                 then
  43.                         #Enviar mensaje que si hay internet y no se pudo montar
  44.                 else
  45.                         #Enviar mensaje que no hay internet
  46.                 fi
  47.         fi
  48. else
  49.         echo "La particion esta montada"
  50. fi
  51.  
  52. -------------------------------------------------
  53. Error que muestra es:
  54.  
  55. [sysadmin@cerebro2:~/.SCRIPTS/cerebros/cer2]$ ./monitoreo_sshfs.sh
  56. + IPSSHFS=10.12.102.60
  57. + IPGOOG=8.8.8.8
  58. + /usr/bin/df -h
  59. + /usr/bin/grep /STORAGE/C1
  60. root@10.12.102.60:/STORAGE/C1  3.6T  614G  2.9T  18% /STORAGE/C1
  61. ++ echo 0
  62. + VAL=0
  63. ./monitoreo_sshfs.sh: line 32: syntax error near unexpected token `else'
  64. ./monitoreo_sshfs.sh: line 32: `                else'
  65. [sysadmin@cerebro2:~/.SCRIPTS/cerebros/cer2]$
  66.  
  67.  
  68.  
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement