configNFS.bash

d
Nombre:configNFS.bash
Autor: Soal
Correo: garcia.robertogarcia@gmail.com
Descripción: Script que permite la instalación del servicio NFS en sistemas tipo Debian
#!/bin/bash
#Copyright (C)2012  soal

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

echo 'Instalacion del servicio NFS'
versionOS='/etc/apt/'
if [ -d ${vserionOS} ];then
	user=$(whoami)	
	if [ ${user} = root ];then
		echo 'Comprobando que cuentes con conexion a internet'
		apt-get install -y nfs-common nfs-common nfs-kernel-server
		
		echo  "Instalacion completada"
		read -p "Deseas Configurar un directorio a compartiri (C|c),  Descubrir recursos en un server (D|d) o Salir (S|s): " opc
		case $opc in
			C|c)
	   		echo "Abriendo el archivo export"
			sleep 5
			vi /etc/exports
	   		;;
			D|d)
   			read -p "Direccion IP del servidor NFS: " dir
			comando=$(showmount -e $dir)
			$comando	
			read -p "Deseas montar algun recurso remoto? (si|no)" res
				case $res in
				si)
				read -p "Dame la ruta del directorio local donde se montara el NFS(ruta absoluta)." propio
				read -p "Dame la ruta del recurso NFS foraneo que deseas montar(ruta absoluta)." foraneo 
				comando1=$(mount -t nfs ${dir}:$propio $foraneo)
				exit 0
				;;
				no)
				echo "Hasta luego"
				exit 0
				;;
				*)
				echo "Opcion no valida"
				exit 1
				;;
				esac	
   			;;
			S|s)
			echo "Hasta Luego"
			;;
			*)
			echo "Opcion no valida, saliendo"
			exit 1
			;;
			esac
		exit 0
	else
		echo 'No tienes suficientes privilegios'
		exit 1
	fi
else
	echo 'Tu sistema no es tipo DEBIAN'
	exit 1
fi
exit 

0 comentarios: