-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconexionsamba
More file actions
52 lines (43 loc) · 2.16 KB
/
conexionsamba
File metadata and controls
52 lines (43 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#Actualizacion de repositorio 2111
DIRECTORIO="$HOME/mntsamba"
#Ruta de conexion con el servidor samba
CONNECT2="RUTA_A_CONECTAR"
select option in "Conectar" "Desconectar" "Salir"; do
case $option in
Conectar )
if ! [ -d $DIRECTORIO ]; then
echo "Se crea el directirio $DIRECTORIO"
mkdir $DIRECTORIO
fi
echo "Inicio de conexion"
read -p "Usuario:" uservar
echo $CONNECT2
sudo mount $CONNECT2 $DIRECTORIO -t cifs -o username=$uservar,file_mode=0766,dir_mode=0755
break
;;
Desconectar )
if [ -d $DIRECTORIO ]; then
TipoDirectorio=$( df -P -T $DIRECTORIO | tail -1 | awk '{print $2}' )
if [ $TipoDirectorio == "cifs" ]; then
sudo umount $DIRECTORIO
echo "Se desconecta del servidor."
fi
fi
if [ -d $DIRECTORIO ]; then
if [ -z $( ls -A $DIRECTORIO ) ]; then
rm -Rf $DIRECTORIO
echo "Se ha Eliminado el Directorio $DIRECTORIO vacio"
else
echo "No se puede eliminar el Directorio, por que no esta vacio"
fi
else
echo " EL directorio no Existe $DIRECTORIO"
fi
break
;;
Salir )
exit
;;
esac
done