Compare commits

...

17 Commits

Author SHA1 Message Date
7fa5f9d903 README.md (Update download links) 2022-10-22 17:03:40 +02:00
q3aql
3556d5ddc4 Fix restart samba service on Arch Linux 2022-04-06 22:53:23 +02:00
q3aql
808c25ac51 README.md (v1.6.3) 2021-08-03 13:55:25 +02:00
q3aql
f7bd8348ee Change image for README.md 2021-08-03 13:39:45 +02:00
q3aql
08067a5b07 Bump up version to 1.6.3 2021-08-03 13:26:58 +02:00
q3aql
611eb55fb4 Fixed bug to remove broken link to folder 2021-08-03 13:20:47 +02:00
q3aql
5f1d8d9bd3 Rewrite code for include icons in interface 2021-08-03 04:23:59 +02:00
q3aql
51b170add3 Update Makefile 2021-08-03 03:34:08 +02:00
q3aql
b3b4468e8e Added icons for interface 2021-08-03 03:30:36 +02:00
q3aql
9ccc699036 New icon app 2021-08-03 03:29:58 +02:00
q3aql
862541bbac Fix URL downloads (README.md) 2021-03-28 22:22:24 +02:00
q3aql
bc06dfdc95 README.md (v1.6.2) 2021-03-28 22:19:49 +02:00
q3aql
b71426cda4 Update Makefile 2021-03-28 22:18:14 +02:00
q3aql
0a0ccfa6e6 easy-samba (v1.6.2 - Spanish version) 2021-03-28 22:17:46 +02:00
q3aql
5e8d329fa1 easy-samba (v1.6.2 - English version) 2021-03-28 22:16:51 +02:00
q3aql
8178f1b515 Update easy-samba.desktop 2021-03-28 22:16:14 +02:00
q3aql
a679b18295 Image screenshots 2021-03-28 22:15:45 +02:00
36 changed files with 1610 additions and 292 deletions

View File

@ -1,6 +1,6 @@
################################################# ####################################
# Instalar easy-samba 1.6.2 (q3aql) # # Install easy-samba 1.6.3 (q3aql) #
################################################# ####################################
PREFIX=/usr PREFIX=/usr
@ -9,12 +9,26 @@ install:
mkdir -p $(PREFIX)/share/icons/easy-samba/ mkdir -p $(PREFIX)/share/icons/easy-samba/
cp -rf icon/easy-samba.png $(PREFIX)/share/icons/easy-samba/ cp -rf icon/easy-samba.png $(PREFIX)/share/icons/easy-samba/
cp -rf icon/easy-samba.desktop $(PREFIX)/share/applications/ cp -rf icon/easy-samba.desktop $(PREFIX)/share/applications/
cp -rf img $(PREFIX)/share/icons/easy-samba/
cp -rf src/easy-samba $(PREFIX)/bin cp -rf src/easy-samba $(PREFIX)/bin
cp -rf src/easy-samba-gtk $(PREFIX)/bin cp -rf src/easy-samba-gtk $(PREFIX)/bin
cp -rf src/easy-samba-gtk-admin $(PREFIX)/bin cp -rf src/easy-samba-gtk-admin $(PREFIX)/bin
chmod 755 $(PREFIX)/bin/easy-samba chmod 755 $(PREFIX)/bin/easy-samba
chmod 755 $(PREFIX)/bin/easy-samba-gtk chmod 755 $(PREFIX)/bin/easy-samba-gtk
chmod 755 $(PREFIX)/bin/easy-samba-gtk-admin chmod 755 $(PREFIX)/bin/easy-samba-gtk-admin
install-es:
mkdir -p /opt/easy-samba/
mkdir -p $(PREFIX)/share/icons/easy-samba/
cp -rf icon/easy-samba.png $(PREFIX)/share/icons/easy-samba/
cp -rf icon/easy-samba.desktop $(PREFIX)/share/applications/
cp -rf img $(PREFIX)/share/icons/easy-samba/
cp -rf src-ES/easy-samba $(PREFIX)/bin
cp -rf src-ES/easy-samba-gtk $(PREFIX)/bin
cp -rf src-ES/easy-samba-gtk-admin $(PREFIX)/bin
chmod 755 $(PREFIX)/bin/easy-samba
chmod 755 $(PREFIX)/bin/easy-samba-gtk
chmod 755 $(PREFIX)/bin/easy-samba-gtk-admin
uninstall: uninstall:
rm -rf $(PREFIX)/bin/easy-samba rm -rf $(PREFIX)/bin/easy-samba

View File

@ -1,41 +1,59 @@
easy-samba - Crea carpetas compartidas con Samba de forma facil easy-samba - A basic GTK (zenity) or CLI interface to create, add and remove folders in Samba.
=============================================================== ==============================================================================================
### Paquetes de easy-samba 1.6.2: ### Downloads:
* [easy-samba-1.6.3.tar.gz](https://drive.proton.me/urls/W65QD91EKM#P7rkMa6PEwaY) - Generic package (English + Spanish Languages).
* [easy-samba-1.6.3-en.deb](https://drive.proton.me/urls/W65QD91EKM#P7rkMa6PEwaY) - Debian based package (English version).
* [easy-samba-1.6.3-en.rpm](https://drive.proton.me/urls/W65QD91EKM#P7rkMa6PEwaY) - RedHat/Fedora based package (English version).
* [easy-samba-1.6.3-es.deb](https://drive.proton.me/urls/W65QD91EKM#P7rkMa6PEwaY) - Debian based package (Spanish version).
* [easy-samba-1.6.3-es.rpm](https://drive.proton.me/urls/W65QD91EKM#P7rkMa6PEwaY) - RedHat/Fedora based package (Spanish version).
_Dependencies: samba, bash, coreutils, zenity, xterm, grep, sed_
* **Descargas:** ### Installation (Generic package - English version):
* [easy-samba-1.6.2.deb](https://github.com/q3aql/easy-samba/releases/download/v1.6.2/easy-samba-1.6.2.deb) * Open terminal and run the following commands:
* [easy-samba-1.6.2.rpm](https://github.com/q3aql/easy-samba/releases/download/v1.6.2/easy-samba-1.6.2.rpm)
* [easy-samba-1.6.2.tar.gz](https://github.com/q3aql/easy-samba/releases/download/v1.6.2/easy-samba-1.6.2.tar.gz)
### Dependencias necesarias: ```shell
$ tar zxvf easy-samba-1.6.3.tar.gz
$ cd easy-samba
$ sudo make install
```
* zenity ### Installation (Generic package - Spanish version):
* samba
* xterm
* beesu (en Fedora) (opcional)
* sed
### Como instalarlo: * Open terminal and run the following commands:
* **Ubuntu/Debian:** ```shell
* Descarga el paquete ".deb" y abre la terminal. $ tar zxvf easy-samba-1.6.3.tar.gz
* Desplazate donde se encuentra el paquete y escribe: `sudo gdebi easy-samba-1.6.2.deb` $ cd easy-samba
$ sudo make install-es
```
### How to use:
* **Fedora:** * For `GTK (Zenity) interface`, you should open Menu > Accessories > Easy-Samba or run the following command:
* Descarga el paquete ".rpm" y abre la terminal.
* Instala las dependencias con el comando: `sudo dnf install zenity beesu samba sed`
* Desplazate donde se encuentra el paquete y escribe: `sudo rpm -i --force easy-samba-1.6.2.rpm`
* **Otras distribuciones:** ```shell
* Descarga el paquete ".tar.gz" y abre la terminal. $ sudo easy-samba-gtk
* Instala las dependencias con el gestor de paquetes. ```
* Desplazate donde se encuentra el paquete y descomprimelo: `tar zxvf easy-samba-1.6.2.tar.gz`
* Instalalo con el comando: `cd easy-samba-1.6.2 && sudo make install` * For `CLI interface`, you run the following command:
### Enlaces externos: ```shell
$ sudo easy-samba
```
### Images (Screenshots)
<img src="https://raw.githubusercontent.com/q3aql/easy-samba/master/img/easy-samba-image.png" width="850" />
### External links:
* [Zenity](https://gitlab.gnome.org/GNOME/zenity)
* [Samba](https://www.samba.org/) * [Samba](https://www.samba.org/)
* [Sed](https://www.gnu.org/software/sed/) * [zenity homepage](https://wiki.gnome.org/Projects/Zenity)
* [xterm homepage](https://invisible-island.net/xterm/)
* [Coreutils homepage](https://www.gnu.org/software/coreutils/coreutils.html)
* [Bash homepage](https://www.gnu.org/software/bash/)
* [Grep homepage](https://www.gnu.org/software/grep/)
* [sed homepage](https://www.gnu.org/software/sed/)

View File

@ -1,7 +1,8 @@
[Desktop Entry] [Desktop Entry]
Name=Easy-Samba Name=Easy-Samba
GenericName=Easy-Samba GenericName=Easy-Samba
Comment=Crea carpetas compartidas con Samba de forma facil Comment[es]=Interfaz básica para crear, agregar y eliminar carpetas en Samba
Comment=Basic interface to create, add and remove folders in Samba
TryExec=easy-samba-gtk-admin TryExec=easy-samba-gtk-admin
Exec=easy-samba-gtk-admin Exec=easy-samba-gtk-admin
Icon=/usr/share/icons/easy-samba/easy-samba.png Icon=/usr/share/icons/easy-samba/easy-samba.png

BIN
icon/easy-samba.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
img/about-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/about.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
img/add-folder-samba.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
img/easy-samba-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
img/easy-samba.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
img/exit-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
img/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
img/folder-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
img/restore-smb-conf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/view-shared-folders.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

597
src-ES/easy-samba Executable file
View File

@ -0,0 +1,597 @@
#!/bin/bash
##############################################################
# Crear carpetas compartidas en Linux #
# U. Modificacion: 03-08-2021 #
# Autor: q3aql #
# Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 #
##############################################################
VERSION="1.6.3"
M_DATE="030821"
# Parametros globales
linuxSambaFolder="/opt/easy-samba"
sambaConfig="/etc/samba/smb.conf"
sambaBackup="/etc/samba/smb.conf.orig"
homeUsers="/home"
homeUsersList="/tmp/easy-samba-users.list"
sambaFoldersList="/tmp/easy-samba-folders.list"
sambaSedFolder="/tmp/easy-samba/word/"
# Funcion para comprobar permisos de administrador
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
echo ""
echo "* easy-samba ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Son necesarios permisos de administrador"
echo ""
exit
fi
}
# Funcion para realizar copia del fichero smb.conf original
function backupSmbConf() {
if [ -f ${sambaBackup} ] ; then
echo "OK" > /dev/null
else
echo "" >> ${sambaConfig}
echo "" >> ${sambaConfig}
cp -rf ${sambaConfig} ${sambaBackup} 2> /dev/null
fi
}
# Funcion para eliminar espacios y simbolos
# Sintaxis: convertText "<text>"
function convertText() {
wordToConvert=${1}
sambaSedFile="${sambaSedFolder}/easy-samba-${RANDOM}.txt"
mkdir -p ${sambaSedFolder} && chmod 777 -R ${sambaSedFolder} 2> /dev/null
echo "${wordToConvert}" > ${sambaSedFile}
# Borrar espacios
sed -i 's/ /_/g' "${sambaSedFile}" &> /dev/null
# Borrar simbolos
symbolsList="[ ] @ { } | \ / ~ # $ % & ? ¿ = ( ) < > ! ¡"
for findSymbol in ${symbolsList} ; do
sed -i "s/${findSymbol}//g" "${sambaSedFile}" &> /dev/null
done
# Borrar el resto de simbolos
sed -i 's/*//g' "${sambaSedFile}" &> /dev/null
sed -i 's/"//g' "${sambaSedFile}" &> /dev/null
sed -i "s/^//g" "${sambaSedFile}" &> /dev/null
# Cambiar algunos simbolos
sed -i 's/+/_/g' "${sambaSedFile}" &> /dev/null
sed -i 's/:/-/g' "${sambaSedFile}" &> /dev/null
sed -i 's/;/-/g' "${sambaSedFile}" &> /dev/null
# Mostrar texto convertido
wordToConvert=$(cat ${sambaSedFile})
echo ${wordToConvert}
}
# Funcion para extraer el nombre de la carpeta de una ruta
function extractFolder() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Funcion para crear enlace en el escritorio/home de los usuarios
# Sintaxis: createFolderLink [carpeta]
function createFolderLink() {
echo -n "* Deseas crear un enlace en el escritorio/home para los usuarios locales (s[*]/n): " ; read createLink
if [ "${createLink}" == "n" ] ; then
echo "nule" > /dev/null
else
if [ "$(ls -A ${homeUsers})" ] ; then
cd ${homeUsers}
ls > ${homeUsersList}
for userDetected in $(cat ${homeUsersList}) ; do
if [ -d ${homeUsers}/${userDetected}/Desktop ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Desktop/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escritorio ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Escritorio/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escriptori ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Escriptori/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
else
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
fi
done
if [ ${output} -eq 0 ] ; then
echo "* Enlaces creados correctamente!"
else
echo "* Error: Fallo al crear los enlaces!"
fi
else
echo "* Usuarios no encontrados en ${homeUsers}"
fi
fi
}
# Funcion para borrar los enlaces en el escritorio/home de los usuarios
# Sintaxis: deleteFolderLink [carpeta]
function deleteFolderLink() {
echo -n "* Deseas borrar los enlaces en el escritorio/home de los usuarios locales (s[*]/n): " ; read deleteLink
if [ "${deleteLink}" == "n" ] ; then
echo "nule" > /dev/null
else
if [ "$(ls -A ${homeUsers})" ] ; then
cd ${homeUsers}
ls > ${homeUsersList}
for userDetected in $(cat ${homeUsersList}) ; do
if [ -d ${homeUsers}/${userDetected}/Desktop ] ; then
rm -f ${homeUsers}/${userDetected}/Desktop/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escritorio ] ; then
rm -f ${homeUsers}/${userDetected}/Escritorio/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escriptori ] ; then
rm -f ${homeUsers}/${userDetected}/Escriptori/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
else
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
fi
done
if [ ${output} -eq 0 ] ; then
echo "* Enlaces borrados correctamente!"
else
echo "* Error: Fallo al borrar los enlaces!"
fi
else
echo "* Usuarios no encontrados en ${homeUsers}"
fi
fi
}
# Funcion para corregir los permisos en la home de un usuario
# Sintaxis: fixHomePermissions <directorio>
function fixHomePermissions() {
homeFolder="${1}"
checkHomeFolder=$(echo ${homeFolder} | grep "/home")
if [ -z ${checkHomeFolder} ] ; then
echo "null" > /dev/null
else
userFolder=$(echo ${homeFolder} | cut -d "/" -f 3)
chmod o+rx "/home/${userFolder}"
fi
}
# Funcion para agregar una carpeta a Samba
function addNewFolder() {
echo ""
echo -n "* Introduce la ruta absoluta de la carpeta a agregar: " ; read folder
pathExtracted=$(extractFolder "${folder}")
endFolder=$(convertText "${pathExtracted}")
if [ -z "${folder}" ] ; then
echo "* Debes introducir la ruta absoluta de una carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d "${folder}" ] ; then
if [ -d ${linuxSambaFolder}/${endFolder} ] ; then
echo "* Una carpeta con el mismo nombre ya se encuentra agregada o creada!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
fixHomePermissions "${folder}"
ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al agregar la carpeta '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
echo "[${endFolder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${endFolder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
echo "* Carpeta '${folder}' agregada con exito!"
createFolderLink ${endFolder}
fi
fi
else
echo "* La carpeta introducida no existe!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
}
# Funcion para crear carpeta compartida con acceso para todos
function newFolderEveryone() {
echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Funcion para crear carpeta compartida de solo lectura
function newFolderReadOnly() {
echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = no" >> ${sambaConfig}
echo "read only = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' (solo lectura) creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Crear carpeta compartida para un usuario
function newFolderForUser() {
echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
echo -n "* Introduce el nombre del usuario: " ; read forUser
randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM}
mkdir -p ${randomFolder}
chown ${forUser} ${randomFolder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
rm -rf ${linuxSambaFolder}/${folder}
echo "* No existe el usuario especificado!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
chmod 755 -R ${linuxSambaFolder}/${folder}
chown ${forUser} -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' (para ${forUser}) creada con exito!"
createFolderLink ${folder}
fi
fi
fi
}
# Crear carpeta compartida para imprimir
function newFolderPrintable() {
echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "printable = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' (printable) creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Funcion para reiniciar el servicio de Samba
function restartSamba() {
echo -n "* Deseas reiniciar los servicios de Samba? (s[*]/n): " ; read sambaSN
if [ "${sambaSN}" == "n" ] ; then
echo "nule" > /dev/null
else
echo "* Reiniciando servicios de Samba"
sleep 3
/etc/init.d/samba restart &> /dev/null
/etc/init.d/nmbd restart &> /dev/null
/etc/init.d/smbd restart &> /dev/null
systemctl restart smbd 2> /dev/null
systemctl restart nmbd 2> /dev/null
systemctl restart smb 2> /dev/null
systemctl restart nmb 2> /dev/null
echo "* Servicios de Samba reiniciados"
echo ""
sleep 3
fi
}
# Funcion para todas borrar las carpetas compartidas
function restoreSmb() {
echo ""
echo "* Nota: Se van a eliminar todas las carpetas compartidas y su contenido!"
echo "* Importante: Se volvera al estado inicial del fichero 'smb.conf' antes de"
echo " ejecutar 'easy-samba' por primera vez."
echo ""
echo -n "* Deseas continuar (s/n[*]): " ; read deleteFolder
if [ "${deleteFolder}" == "s" ] ; then
echo "* Borrando carpetas..."
sleep 2
rm -rf ${linuxSambaFolder}/* 2> /dev/null
output=$?
if [ ${output} -eq 0 ] ; then
echo "* Carpetas borradas con exito!"
cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null
#rm -rf ${sambaBackup} 2> /dev/null
restartSamba
else
echo "* Fallo al borrar las carpetas compartidas!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
else
echo "* Se ha anulado el proceso de restauracion"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
}
# Funcion para mostrar carpetas compartidas
function viewFolders() {
if [ "$(ls -A ${linuxSambaFolder})" ] ; then
cd ${linuxSambaFolder}
ls > ${sambaFoldersList}
echo ""
echo "* Lista de carpetas compartidas disponibles:"
echo ""
folderList=""
for folderDetected in $(cat ${sambaFoldersList}) ; do
echo " + ${folderDetected}"
done
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
echo ""
echo "* Actualmente no hay carpetas compartidas!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
}
# Funcion para borrar una carpeta compartida
function removeFolder() {
echo ""
echo -n "* Introduce el nombre de la carpeta que deseas borrar: " ; read folder
if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* Borrando carpeta '${folder}' ..."
rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -eq 0 ] ; then
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then
echo "* La carpeta '${folder}' ha sido borrada pero no se ha encontrado en 'smb.conf'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7)
totalLines=$(cat /etc/samba/smb.conf | wc -l)
count=1
mkdir -p /tmp/easy-samba/
echo > /tmp/easy-samba/smb.conf
while [ ${count} -lt $initLine ] ; do
cat /etc/samba/smb.conf | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
count=$(expr ${endLine} + 1)
while [ ${count} -le ${totalLines} ] ; do
cat ${sambaConfig} | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
echo "* La carpeta '${folder} ha sido borrada con exito!"
deleteFolderLink ${folder}
restartSamba
fi
else
echo "* Error: No se ha podido borrar la carpeta '${folder}'"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
else
echo "* Error: La carpeta '${folder}' no existe!"
echo -n "* Deseas ver un listado con las carpetas disponibles? (s[*]/n): " ; read available
if [ "${available}" == "n" ] ; then
echo "nule" > /dev/null
else
viewFolders
fi
fi
}
# Funcion para mostrar el "acerca" del programa
function mostrarAcerca() {
echo ""
echo "* Acerca:"
echo ""
echo " - Software: easy-samba ${VERSION} (${M_DATE})"
echo " - Autor: q3aql"
echo " - Contacto: q3aql@protonmail.ch"
echo " - Licencia: GPL v2.0"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
}
# Mostrar menu con todas las opciones
mostrarMenu=0
rootMessage
backupSmbConf
while [ ${mostrarMenu} -eq 0 ] ; do
clear
echo ""
echo "* easy-samba ${VERSION} (${M_DATE})"
echo ""
echo " 1 - Agregar carpeta a Samba"
echo " 2 - Crear carpeta compartida"
echo " 3 - Crear carpeta compartida (solo lectura)"
echo " 4 - Crear carpeta compartida (para un usuario)"
echo " 5 - Crear carpeta compartida (printable)"
echo " 6 - Reiniciar servicios de Samba"
echo " 7 - Ver carpetas compartidas disponibles"
echo " 8 - Borrar carpeta compartida"
echo " 9 - Restaurar smb.conf"
echo " 10 - Acerca"
echo ""
echo " 11 - Salir"
echo ""
echo -n " * Elige una opcion: " ; read opcion
if [ "${opcion}" == "1" ] ; then
addNewFolder
restartSamba
elif [ "${opcion}" == "2" ] ; then
newFolderEveryone
restartSamba
elif [ "${opcion}" == "3" ] ; then
newFolderReadOnly
restartSamba
elif [ "${opcion}" == "4" ] ; then
newFolderForUser
restartSamba
elif [ "${opcion}" == "5" ] ; then
newFolderPrintable
restartSamba
elif [ "${opcion}" == "6" ] ; then
restartSamba
elif [ "${opcion}" == "7" ] ; then
viewFolders
elif [ "${opcion}" == "8" ] ; then
removeFolder
elif [ "${opcion}" == "9" ] ; then
restoreSmb
elif [ "${opcion}" == "10" ] ; then
mostrarAcerca
elif [ "${opcion}" == "11" ] ; then
mostrarMenu=1
elif [ -z "${opcion}" ] ; then
echo ""
echo "* Debes elegir alguna opcion"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
else
echo ""
echo "* Opcion no valida!"
echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue
fi
done

567
src-ES/easy-samba-gtk Executable file
View File

@ -0,0 +1,567 @@
#!/bin/bash
##############################################################
# Crear carpetas compartidas en Linux (GTK) #
# U. Modificacion: 03-08-2021 #
# Autor: q3aql #
# Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 #
##############################################################
VERSION="1.6.3 (GTK)"
M_DATE="030821"
# Variables
iconPath="/usr/share/icons/easy-samba/easy-samba.png"
imagesPath="/usr/share/icons/easy-samba/img"
# Parametros globales
linuxSambaFolder="/opt/easy-samba"
sambaConfig="/etc/samba/smb.conf"
sambaBackup="/etc/samba/smb.conf.orig"
homeUsers="/home"
homeUsersList="/tmp/easy-samba-users.list"
sambaFoldersList="/tmp/easy-samba-folders.list"
sambaSedFolder="/tmp/easy-samba/word/"
# Funcion para comprobar permisos de administrador
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
zenity --title "easy-samba-gtk ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 --text "Son necesarios permisos de administrador"
echo ""
echo "* easy-samba-gtk ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Son necesarios permisos de administrador"
echo ""
exit
fi
}
# Funcion para realizar copia del fichero smb.conf original
function backupSmbConf() {
if [ -f ${sambaBackup} ] ; then
echo "OK" > /dev/null
else
echo "" >> ${sambaConfig}
echo "" >> ${sambaConfig}
cp -rf ${sambaConfig} ${sambaBackup} 2> /dev/null
fi
}
# Funcion para eliminar espacios y simbolos
# Sintaxis: convertText "<text>"
function convertText() {
wordToConvert=${1}
sambaSedFile="${sambaSedFolder}/easy-samba-${RANDOM}.txt"
mkdir -p ${sambaSedFolder} && chmod 777 -R ${sambaSedFolder} 2> /dev/null
echo "${wordToConvert}" > ${sambaSedFile}
# Borrar espacios
sed -i 's/ /_/g' "${sambaSedFile}" &> /dev/null
# Borrar simbolos
symbolsList="[ ] @ { } | \ / ~ # $ % & ? ¿ = ( ) < > ! ¡"
for findSymbol in ${symbolsList} ; do
sed -i "s/${findSymbol}//g" "${sambaSedFile}" &> /dev/null
done
# Borrar el resto de simbolos
sed -i 's/*//g' "${sambaSedFile}" &> /dev/null
sed -i 's/"//g' "${sambaSedFile}" &> /dev/null
sed -i "s/^//g" "${sambaSedFile}" &> /dev/null
# Cambiar algunos simbolos
sed -i 's/+/_/g' "${sambaSedFile}" &> /dev/null
sed -i 's/:/-/g' "${sambaSedFile}" &> /dev/null
sed -i 's/;/-/g' "${sambaSedFile}" &> /dev/null
# Mostrar texto convertido
wordToConvert=$(cat ${sambaSedFile})
echo ${wordToConvert}
}
# Funcion para extraer el nombre de la carpeta de una ruta
function extractFolder() {
pathToExtract="${1}/"
findFolder=0
count=1
nameFolder=$(echo ${pathToExtract} | cut -d "/" -f ${count})
count=$(expr $count + 1)
while [ ${findFolder} -eq 0 ] ; do
nameFolderTemp=$(echo ${pathToExtract} | cut -d "/" -f ${count})
if [ -z "${nameFolderTemp}" ] ; then
findFolder=1
else
nameFolder="${nameFolderTemp}"
count=$(expr $count + 1)
fi
done
echo "${nameFolder}"
}
# Funcion para crear enlace en el escritorio/home de los usuarios
# Sintaxis: createFolderLink [carpeta]
function createFolderLink() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Si" --width=530 \
--text "Deseas crear un enlace en el escritorio/home para los usuarios locales?"
createLink=$?
if [ ${createLink} -eq 1 ] ; then
echo "nule" > /dev/null
else
if [ "$(ls -A ${homeUsers})" ] ; then
cd ${homeUsers}
ls > ${homeUsersList}
for userDetected in $(cat ${homeUsersList}) ; do
if [ -d ${homeUsers}/${userDetected}/Desktop ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Desktop/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escritorio ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Escritorio/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escriptori ] ; then
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/Escriptori/ 2> /dev/null
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
else
ln -s ${linuxSambaFolder}/${1} ${homeUsers}/${userDetected}/ 2> /dev/null
output=$?
fi
done
if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=280 --text "Enlaces creados correctamente!"
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=280 --text "Error: Fallo al crear los enlaces!"
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=310 --text "Usuarios no encontrados en ${homeUsers}"
fi
fi
}
# Funcion para borrar los enlaces en el escritorio/home de los usuarios
# Sintaxis: deleteFolderLink [carpeta]
function deleteFolderLink() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Si" --width=530 \
--text "Deseas borrar los enlaces en el escritorio/home de los usuarios locales?"
deleteLink=$?
if [ ${deleteLink} -eq 1 ] ; then
echo "nule" > /dev/null
else
if [ "$(ls -A ${homeUsers})" ] ; then
cd ${homeUsers}
ls > ${homeUsersList}
for userDetected in $(cat ${homeUsersList}) ; do
if [ -d ${homeUsers}/${userDetected}/Desktop ] ; then
rm -f ${homeUsers}/${userDetected}/Desktop/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escritorio ] ; then
rm -f ${homeUsers}/${userDetected}/Escritorio/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
elif [ -d ${homeUsers}/${userDetected}/Escriptori ] ; then
rm -f ${homeUsers}/${userDetected}/Escriptori/${1} 2> /dev/null
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
else
rm -f ${homeUsers}/${userDetected}/${1} 2> /dev/null
output=$?
fi
done
if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=280 --text "Enlaces borrados correctamente!"
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=290 --text "Error: Fallo al borrar los enlaces!"
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=310 --text "Usuarios no encontrados en ${homeUsers}"
fi
fi
}
# Funcion para corregir los permisos en la home de un usuario
# Sintaxis: fixHomePermissions <directorio>
function fixHomePermissions() {
homeFolder="${1}"
checkHomeFolder=$(echo ${homeFolder} | grep "/home")
if [ -z ${checkHomeFolder} ] ; then
echo "null" > /dev/null
else
userFolder=$(echo ${homeFolder} | cut -d "/" -f 3)
chmod o+rx "/home/${userFolder}"
fi
}
# Funcion para agregar una carpeta a Samba
function addNewFolder() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce la ruta absoluta de la carpeta a agregar:")
pathExtracted=$(extractFolder "${folder}")
endFolder=$(convertText "${pathExtracted}")
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=410 --text "Debes introducir la ruta absoluta de una carpeta!"
elif [ -d "${folder}" ] ; then
if [ -d ${linuxSambaFolder}/${endFolder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "Una carpeta con el mismo nombre ya se encuentra agregada o creada!"
else
fixHomePermissions "${folder}"
ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Fallo al agregar la carpeta '${folder}'"
else
echo "[${endFolder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${endFolder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=390 --text "Carpeta '${folder}' agregada con exito!"
createFolderLink ${endFolder}
fi
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=300 --text "La carpeta introducida no existe!"
fi
}
# Funcion para crear carpeta compartida con acceso para todos
function newFolderEveryone() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):")
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "Debes introducir un nombre de carpeta!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre"
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'"
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Carpeta compartida '${folder}' creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Funcion para crear carpeta compartida de solo lectura
function newFolderReadOnly() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):")
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "Debes introducir un nombre de carpeta!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre"
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'"
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = no" >> ${sambaConfig}
echo "read only = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Carpeta compartida '${folder}' (solo lectura) creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Crear carpeta compartida para un usuario
function newFolderForUser() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):")
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "Debes introducir un nombre de carpeta!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre"
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'"
else
forUser=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce el nombre del usuario:")
randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM}
mkdir -p ${randomFolder}
chown ${forUser} ${randomFolder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
rm -rf ${linuxSambaFolder}/${folder}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=330 --text "Error: No existe el usuario especificado!"
else
chmod 755 -R ${linuxSambaFolder}/${folder}
chown ${forUser} -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Carpeta compartida '${folder}' (para ${forUser}) creada con exito!"
createFolderLink ${folder}
fi
fi
fi
}
# Crear carpeta compartida para imprimir
function newFolderPrintable() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):")
formatText=$(convertText "${folder}")
folder=${formatText}
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "Debes introducir un nombre de carpeta!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre"
else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'"
else
chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" >> ${sambaConfig}
echo "path = ${linuxSambaFolder}/${folder}" >> ${sambaConfig}
echo "comment = Folder by easy-samba ${VERSION} (${M_DATE})" >> ${sambaConfig}
echo "browseable = yes" >> ${sambaConfig}
echo "writeable = yes" >> ${sambaConfig}
echo "printable = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Carpeta compartida '${folder}' (printable) creada con exito!"
createFolderLink ${folder}
fi
fi
}
# Funcion de reinicio de samba
function reiniciandoSamba() {
sleep 2
/etc/init.d/samba restart &> /dev/null
/etc/init.d/nmbd restart &> /dev/null
/etc/init.d/smbd restart &> /dev/null
systemctl restart smbd 2> /dev/null
systemctl restart nmbd 2> /dev/null
systemctl restart smb 2> /dev/null
systemctl restart nmb 2> /dev/null
}
# Funcion para reiniciar el servicio de Samba
function restartSamba() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Si" --width=320 --text "Deseas reiniciar los servicios de Samba?"
sambaSN=$?
if [ "${sambaSN}" == "1" ] ; then
echo "nule" > /dev/null
else
reiniciandoSamba | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Reiniciando servicios de Samba"
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=300 --text "Servicios de Samba reiniciados"
fi
}
# Funcion para borrar todas las carpetas compartidas
function restoreSmb() {
echo ""
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Si" --width=530 \
--text "Nota: Se van a eliminar todas las carpetas compartidas y su contenido\n\nImportante: Se volvera al estado inicial del fichero 'smb.conf' antes de\nejecutar 'easy-samba' por primera vez\n\nDeseas continuar?"
deleteFolder=$?
if [ ${deleteFolder} -eq 0 ] ; then
sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Borrando carpetas"
rm -rf ${linuxSambaFolder}/* | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Finalizando proceso de borrado"
output=$?
if [ ${output} -eq 0 ] ; then
cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null
#rm -rf ${sambaBackup} 2> /dev/null
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "Carpetas borradas con exito!"
restartSamba
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=360 --text "Error al borrar las carpetas compartidas"
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=360 --text "Se ha anulado el proceso de restauracion"
fi
}
# Funcion para mostrar carpetas compartidas
function viewFolders() {
if [ "$(ls -A ${linuxSambaFolder})" ] ; then
cd ${linuxSambaFolder}
ls > ${sambaFoldersList}
folderList=""
for folderDetected in $(cat ${sambaFoldersList}) ; do
folderList="${folderList} ${folderDetected}"
done
folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --column "Lista de carpetas compartidas disponibles:" ${folderList})
if [ -z ${folder} ] ; then
echo "nule" > /dev/null
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "Nombre de carpeta: ${folder}\n\nRuta: ${linuxSambaFolder}/${folder}"
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=400 --text "Error: La carpeta '${folder}' no existe!"
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=370 --text "Actualmente no hay carpetas compartidas!"
fi
}
# Funcion para borrar una carpeta compartida
function removeFolder() {
if [ "$(ls -A ${linuxSambaFolder})" ] ; then
cd ${linuxSambaFolder}
ls > ${sambaFoldersList}
folderList=""
for folderDetected in $(cat ${sambaFoldersList}) ; do
folderList="${folderList} ${folderDetected}"
done
folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --column "Selecciona una carpeta para borrar:" ${folderList})
if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "Debes seleccionar una carpeta de la lista"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then
sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Borrando carpeta..."
rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null
output=$?
if [ ${output} -eq 0 ] ; then
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=530 --text "La carpeta '${folder}' ha sido borrada pero no se ha encontrado en 'smb.conf'"
else
initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7)
totalLines=$(cat /etc/samba/smb.conf | wc -l)
count=1
mkdir -p /tmp/easy-samba/
echo > /tmp/easy-samba/smb.conf
while [ ${count} -lt $initLine ] ; do
cat /etc/samba/smb.conf | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
count=$(expr ${endLine} + 1)
while [ ${count} -le ${totalLines} ] ; do
cat ${sambaConfig} | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=460 --text "La carpeta '${folder}' ha sido borrada con exito!"
deleteFolderLink ${folder}
restartSamba
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=450 --text "Error: No se ha podido borrar la carpeta '${folder}'"
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=410 --text "Error: La carpeta '${folder}' no existe o el enlace esta roto!"
rm -rfv ${linuxSambaFolder}/${folder}
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then
echo "disabled" > /dev/null
else
initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7)
totalLines=$(cat /etc/samba/smb.conf | wc -l)
count=1
mkdir -p /tmp/easy-samba/
echo > /tmp/easy-samba/smb.conf
while [ ${count} -lt $initLine ] ; do
cat /etc/samba/smb.conf | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
count=$(expr ${endLine} + 1)
while [ ${count} -le ${totalLines} ] ; do
cat ${sambaConfig} | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=460 --text "La carpeta '${folder}' ha sido borrada del smb.conf!"
deleteFolderLink ${folder}
restartSamba
fi
fi
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "No hay carpetas disponibles para borrar!"
fi
}
# Funcion para mostrar el "acerca" del programa
function mostrarAcerca() {
zenity --title "Acerca" --window-icon=${iconPath} --info --width=330 \
--text "Software: easy-samba ${VERSION} (${M_DATE})\nAutor: q3aql\nContacto: q3aql@protonmail.ch\nLicencia: GPL v2.0"
}
# Mostrar menu con todas las opciones
mostrarMenu=0
rootMessage
backupSmbConf
while [ ${mostrarMenu} -eq 0 ] ; do
clear
opcion=$(zenity --width=380 --height=440 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Icono" --column "Opcion" \
${imagesPath}/add-folder-samba.png "Agregar carpeta a Samba" \
${imagesPath}/create-shared-folder.png "Crear carpeta compartida" \
${imagesPath}/create-shared-folder-read-only.png "Crear carpeta compartida (solo lectura)" \
${imagesPath}/create-shared-folder-user.png "Crear carpeta compartida (para un usuario)" \
${imagesPath}/create-shared-folder-printable.png "Crear carpeta compartida (printable)" \
${imagesPath}/restart-samba-services.png "Reiniciar servicios de Samba" \
${imagesPath}/view-shared-folders.png "Ver carpetas compartidas disponibles" ${imagesPath}/delete-shared-folder.png "Borrar carpeta compartida" \
${imagesPath}/restore-smb-conf.png "Restaurar smb.conf" ${imagesPath}/about.png "Acerca" \
${imagesPath}/exit.png "Salir")
if [ "${opcion}" == "${imagesPath}/add-folder-samba.png" ] ; then
addNewFolder
restartSamba
elif [ "${opcion}" == "${imagesPath}/create-shared-folder.png" ] ; then
newFolderEveryone
restartSamba
elif [ "${opcion}" == "${imagesPath}/create-shared-folder-read-only.png" ] ; then
newFolderReadOnly
restartSamba
elif [ "${opcion}" == "${imagesPath}/create-shared-folder-user.png" ] ; then
newFolderForUser
restartSamba
elif [ "${opcion}" == "${imagesPath}/create-shared-folder-printable.png" ] ; then
newFolderPrintable
restartSamba
elif [ "${opcion}" == "${imagesPath}/restart-samba-services.png" ] ; then
restartSamba
elif [ "${opcion}" == "${imagesPath}/view-shared-folders.png" ] ; then
viewFolders
elif [ "${opcion}" == "${imagesPath}/delete-shared-folder.png" ] ; then
removeFolder
elif [ "${opcion}" == "${imagesPath}/restore-smb-conf.png" ] ; then
restoreSmb
elif [ "${opcion}" == "${imagesPath}/about.png" ] ; then
mostrarAcerca
elif [ "${opcion}" == "${imagesPath}/exit.png" ] ; then
mostrarMenu=1
else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=300 --text "Elige una de las opciones del menu"
fi
done

78
src-ES/easy-samba-gtk-admin Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
##############################################################
# Crear carpetas compartidas en Linux (GTK) #
# U. Modificacion: 03-08-2021 #
# Autor: q3aql #
# Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 #
##############################################################
VERSION="1.6.3 (GTK)"
M_DATE="030821"
# Variables
iconPath="/usr/share/icons/easy-samba/easy-samba.png"
# Enlace con gksudo,gksu o bessu a easy-samba-gtk
function showRootMessage() {
if [ -f /usr/bin/gksudo ] ; then
gksudo /usr/bin/easy-samba-gtk
exit
elif [ -f /bin/gksudo ] ; then
gksudo /usr/bin/easy-samba-gtk
exit
elif [ -f /usr/bin/gksu ] ; then
gksu /usr/bin/easy-samba-gtk
exit
elif [ -f /bin/gksu ] ; then
gksu /usr/bin/easy-samba-gtk
exit
elif [ -f /usr/bin/beesu ] ; then
beesu /usr/bin/easy-samba-gtk
exit
elif [ -f /bin/beesu ] ; then
beesu /usr/bin/easy-samba-gtk
exit
elif [ -f /bin/sudo ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk"
exit
elif [ -f /usr/bin/sudo ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk"
exit
elif [ -f /usr/bin/su ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'"
exit
elif [ -f /bin/su ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'"
exit
else
zenity -h &> /dev/null
output=$?
if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --width 450 --info \
--text "El programa 'easy-samba-gtk' no ha podido ser ejecutado como administrador\n\nPorfavor, ejecuta el comando 'easy-samba-gtk' como usuario root en la terminal"
else
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "easy-samba-gtk-admin --error"
fi
fi
}
# Funcion para mostrar mensaje de error
function errorMessage() {
echo ""
echo "* ATENCION!:"
echo ""
echo "* El programa 'easy-samba-gtk' no ha podido ser ejecutado como administrador"
echo ""
echo "* Por favor, ejecuta el comando 'easy-samba-gtk' como usuario root en la terminal"
echo ""
echo -n "* Pulsa INTRO para salir... " ; read continue
exit
}
# Inicio del script
if [ "${1}" == "--error" ] ; then
errorMessage
else
showRootMessage
fi

View File

@ -2,13 +2,13 @@
############################################################## ##############################################################
# Crear carpetas compartidas en Linux # # Crear carpetas compartidas en Linux #
# U. Modificacion: 27-12-2018 # # U. Modificacion: 03-08-2021 #
# Autor: q3aql # # Autor: q3aql #
# Contacto: q3aql@protonmail.ch # # Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 # # Licencia: GPL v2.0 #
############################################################## ##############################################################
VERSION="1.6.2" VERSION="1.6.3"
M_DATE="271218" M_DATE="030821"
# Parametros globales # Parametros globales
linuxSambaFolder="/opt/easy-samba" linuxSambaFolder="/opt/easy-samba"
@ -29,7 +29,7 @@ function rootMessage() {
echo "" echo ""
echo "* easy-samba ${VERSION} (${M_DATE}) (GPL v2.0)" echo "* easy-samba ${VERSION} (${M_DATE}) (GPL v2.0)"
echo "" echo ""
echo "* Son necesarios permisos de administrador" echo "* Administrator permissions are required"
echo "" echo ""
exit exit
fi fi
@ -95,7 +95,7 @@ function extractFolder() {
# Funcion para crear enlace en el escritorio/home de los usuarios # Funcion para crear enlace en el escritorio/home de los usuarios
# Sintaxis: createFolderLink [carpeta] # Sintaxis: createFolderLink [carpeta]
function createFolderLink() { function createFolderLink() {
echo -n "* Deseas crear un enlace en el escritorio/home para los usuarios locales (s[*]/n): " ; read createLink echo -n "* Do you want to create a link on the desktop/home for local users (y[*]/n): " ; read createLink
if [ "${createLink}" == "n" ] ; then if [ "${createLink}" == "n" ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
else else
@ -121,12 +121,12 @@ function createFolderLink() {
fi fi
done done
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
echo "* Enlaces creados correctamente!" echo "* Links created successfully!"
else else
echo "* Error: Fallo al crear los enlaces!" echo "* Error: Failed to create links!"
fi fi
else else
echo "* Usuarios no encontrados en ${homeUsers}" echo "* Users not found in ${homeUsers}"
fi fi
fi fi
} }
@ -134,7 +134,7 @@ function createFolderLink() {
# Funcion para borrar los enlaces en el escritorio/home de los usuarios # Funcion para borrar los enlaces en el escritorio/home de los usuarios
# Sintaxis: deleteFolderLink [carpeta] # Sintaxis: deleteFolderLink [carpeta]
function deleteFolderLink() { function deleteFolderLink() {
echo -n "* Deseas borrar los enlaces en el escritorio/home de los usuarios locales (s[*]/n): " ; read deleteLink echo -n "* Do you want to delete the links on the desktop/home of local users (y[*]/n): " ; read deleteLink
if [ "${deleteLink}" == "n" ] ; then if [ "${deleteLink}" == "n" ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
else else
@ -160,12 +160,12 @@ function deleteFolderLink() {
fi fi
done done
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
echo "* Enlaces borrados correctamente!" echo "* Links deleted successfully!"
else else
echo "* Error: Fallo al borrar los enlaces!" echo "* Error: Failed to delete links!"
fi fi
else else
echo "* Usuarios no encontrados en ${homeUsers}" echo "* Users not found in ${homeUsers}"
fi fi
fi fi
} }
@ -186,26 +186,26 @@ function fixHomePermissions() {
# Funcion para agregar una carpeta a Samba # Funcion para agregar una carpeta a Samba
function addNewFolder() { function addNewFolder() {
echo "" echo ""
echo -n "* Introduce la ruta absoluta de la carpeta a agregar: " ; read folder echo -n "* Enter the absolute path of the folder to add: " ; read folder
pathExtracted=$(extractFolder "${folder}") pathExtracted=$(extractFolder "${folder}")
endFolder=$(convertText "${pathExtracted}") endFolder=$(convertText "${pathExtracted}")
if [ -z "${folder}" ] ; then if [ -z "${folder}" ] ; then
echo "* Debes introducir la ruta absoluta de una carpeta!" echo "* You must enter the absolute path of a folder!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d "${folder}" ] ; then elif [ -d "${folder}" ] ; then
if [ -d ${linuxSambaFolder}/${endFolder} ] ; then if [ -d ${linuxSambaFolder}/${endFolder} ] ; then
echo "* Una carpeta con el mismo nombre ya se encuentra agregada o creada!" echo "* A folder with the same name is already added or created!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
fixHomePermissions "${folder}" fixHomePermissions "${folder}"
ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al agregar la carpeta '${folder}'" echo "* Error: Failed to add folder '${folder}'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
echo "[${endFolder}]" >> ${sambaConfig} echo "[${endFolder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig} echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig}
@ -216,38 +216,38 @@ function addNewFolder() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
echo "* Carpeta '${folder}' agregada con exito!" echo "* Folder '${folder}' added successfully!"
createFolderLink ${endFolder} createFolderLink ${endFolder}
fi fi
fi fi
else else
echo "* La carpeta introducida no existe!" echo "* The inserted folder does not exist!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
} }
# Funcion para crear carpeta compartida con acceso para todos # Funcion para crear carpeta compartida con acceso para todos
function newFolderEveryone() { function newFolderEveryone() {
echo "" echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder echo -n "* Enter the name of the folder you want to create (without accents): " ; read folder
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!" echo "* You must enter a folder name!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre" echo "* The folder '${folder}' is already created, choose another name"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'" echo "* Error: Failed to create shared folder '${folder}'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -259,7 +259,7 @@ function newFolderEveryone() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' creada con exito!" echo "* Shared folder '${folder}' created successfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
@ -268,24 +268,24 @@ function newFolderEveryone() {
# Funcion para crear carpeta compartida de solo lectura # Funcion para crear carpeta compartida de solo lectura
function newFolderReadOnly() { function newFolderReadOnly() {
echo "" echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder echo -n "* Enter the name of the folder you want to create (without accents): " ; read folder
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!" echo "* You must enter a folder name!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre" echo "* The folder '${folder}' is already created, choose another name"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'" echo "* Error: Failed to create shared folder '${folder}'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -297,7 +297,7 @@ function newFolderReadOnly() {
echo "read only = yes" >> ${sambaConfig} echo "read only = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' (solo lectura) creada con exito!" echo "* Shared folder '${folder}' (read only) created succesfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
@ -306,35 +306,35 @@ function newFolderReadOnly() {
# Crear carpeta compartida para un usuario # Crear carpeta compartida para un usuario
function newFolderForUser() { function newFolderForUser() {
echo "" echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder echo -n "* Enter the name of the folder you want to create (without accents): " ; read folder
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!" echo "* You must enter a folder name!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre" echo "* The folder '${folder}' is already created, choose another name"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'" echo "* Error: Failed to create shared folder '${folder}'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
echo -n "* Introduce el nombre del usuario: " ; read forUser echo -n "* Enter username: " ; read forUser
randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM} randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM}
mkdir -p ${randomFolder} mkdir -p ${randomFolder}
chown ${forUser} ${randomFolder} 2> /dev/null chown ${forUser} ${randomFolder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
rm -rf ${linuxSambaFolder}/${folder} rm -rf ${linuxSambaFolder}/${folder}
echo "* No existe el usuario especificado!" echo "* The specified user does not exist!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
chmod 755 -R ${linuxSambaFolder}/${folder} chmod 755 -R ${linuxSambaFolder}/${folder}
chown ${forUser} -R ${linuxSambaFolder}/${folder} chown ${forUser} -R ${linuxSambaFolder}/${folder}
@ -347,7 +347,7 @@ function newFolderForUser() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
echo "* Carpeta compartida '${folder}' (para ${forUser}) creada con exito!" echo "* Shared folder '${folder}' (for ${forUser}) created successfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
@ -357,24 +357,24 @@ function newFolderForUser() {
# Crear carpeta compartida para imprimir # Crear carpeta compartida para imprimir
function newFolderPrintable() { function newFolderPrintable() {
echo "" echo ""
echo -n "* Introduce el nombre de la carpeta que deseas crear (sin acentos): " ; read folder echo -n "* Enter the name of the folder you want to create (without accents): " ; read folder
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!" echo "* You must enter a folder name!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* La carpeta '${folder}' ya está creada, elige otro nombre" echo "* The folder '${folder}' is already created, choose another name"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
echo "* Error: Fallo al crear la carpeta compartida '${folder}'" echo "* Error: Failed to create shared folder '${folder}'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -394,17 +394,20 @@ function newFolderPrintable() {
# Funcion para reiniciar el servicio de Samba # Funcion para reiniciar el servicio de Samba
function restartSamba() { function restartSamba() {
echo -n "* Deseas reiniciar los servicios de Samba (s[*]/n): " ; read sambaSN echo -n "* Do you want to restart the Samba services? (y[*]/n): " ; read sambaSN
if [ "${sambaSN}" == "n" ] ; then if [ "${sambaSN}" == "n" ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
else else
echo "* Reiniciando servicios de Samba" echo "* Restarting Samba services"
sleep 3 sleep 3
/etc/init.d/samba restart &> /dev/null /etc/init.d/samba restart &> /dev/null
systemctl restart smbd.service 2> /dev/null /etc/init.d/nmbd restart &> /dev/null
systemctl restart nmbd.service 2> /dev/null /etc/init.d/smbd restart &> /dev/null
systemctl restart smb.service 2> /dev/null systemctl restart smbd 2> /dev/null
echo "* Servicios de Samba reiniciados" systemctl restart nmbd 2> /dev/null
systemctl restart smb 2> /dev/null
systemctl restart nmb 2> /dev/null
echo "* Samba services restarted"
echo "" echo ""
sleep 3 sleep 3
fi fi
@ -413,30 +416,30 @@ function restartSamba() {
# Funcion para todas borrar las carpetas compartidas # Funcion para todas borrar las carpetas compartidas
function restoreSmb() { function restoreSmb() {
echo "" echo ""
echo "* Nota: Se van a eliminar todas las carpetas compartidas y su contenido!" echo "* Note: All shared folders and their content will be deleted!"
echo "* Importante: Se volvera al estado inicial del fichero 'smb.conf' antes de" echo "* Important: It will return to the initial state of the file"
echo " de ejecutar 'easy-samba' por primera vez." echo " 'smb.conf' before executing 'easy-samba' for the first time."
echo "" echo ""
echo -n "* Deseas continuar (s/n[*]): " ; read deleteFolder echo -n "* Do you want continue (y/n[*]): " ; read deleteFolder
if [ "${deleteFolder}" == "s" ] ; then if [ "${deleteFolder}" == "y" ] ; then
echo "* Borrando carpetas..." echo "* Deleting folders..."
sleep 2 sleep 2
rm -rf ${linuxSambaFolder}/* 2> /dev/null rm -rf ${linuxSambaFolder}/* 2> /dev/null
output=$? output=$?
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
echo "* Carpetas borradas con exito!" echo "* Folders deleted successfully!"
cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null
#rm -rf ${sambaBackup} 2> /dev/null #rm -rf ${sambaBackup} 2> /dev/null
restartSamba restartSamba
else else
echo "* Fallo al borrar las carpetas compartidas!" echo "* Failed to delete shared folders!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
else else
echo "* Se ha anulado el proceso de restauracion" echo "* The restore process has been aborted"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
} }
@ -446,40 +449,40 @@ function viewFolders() {
cd ${linuxSambaFolder} cd ${linuxSambaFolder}
ls > ${sambaFoldersList} ls > ${sambaFoldersList}
echo "" echo ""
echo "* Lista de carpetas compartidas disponibles:" echo "* List of available shared folders:"
echo "" echo ""
folderList="" folderList=""
for folderDetected in $(cat ${sambaFoldersList}) ; do for folderDetected in $(cat ${sambaFoldersList}) ; do
echo " + ${folderDetected}" echo " + ${folderDetected}"
done done
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
echo "" echo ""
echo "* Actualmente no hay carpetas compartidas!" echo "* There are currently no shared folders!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
} }
# Funcion para borrar una carpeta compartida # Funcion para borrar una carpeta compartida
function removeFolder() { function removeFolder() {
echo "" echo ""
echo -n "* Introduce el nombre de la carpeta que deseas borrar: " ; read folder echo -n "* Enter the name of the folder you want to delete: " ; read folder
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "* Debes introducir un nombre de carpeta!" echo "* You must enter a folder name!"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
echo "* Borrando carpeta '${folder}' ..." echo "* Deleting folder '${folder}' ..."
rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1) readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then if [ -z ${readLine} ] ; then
echo "* La carpeta '${folder}' ha sido borrada pero no se ha encontrado en 'smb.conf'" echo "* The folder '${folder}' has been deleted but not found in 'smb.conf'"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
initLine=$(expr ${readLine} - 1) initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7) endLine=$(expr ${readLine} + 7)
@ -497,18 +500,18 @@ function removeFolder() {
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
done done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig} cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
echo "* La carpeta '${folder} ha sido borrada con exito!" echo "* The folder '${folder} has been deleted successfully!"
deleteFolderLink ${folder} deleteFolderLink ${folder}
restartSamba restartSamba
fi fi
else else
echo "* Error: No se ha podido borrar la carpeta '${folder}'" echo "* Error: The folder '${folder}' could not be deleted"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
else else
echo "* Error: La carpeta '${folder}' no existe!" echo "* Error: The folder '${folder}' does not exist!"
echo -n "* Deseas ver un listado con las carpetas disponibles? (s[*]/n): " ; read available echo -n "* Do you want to see a list of the available folders? (y[*]/n): " ; read available
if [ "${available}" == "n" ] ; then if [ "${available}" == "n" ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
else else
@ -520,14 +523,14 @@ function removeFolder() {
# Funcion para mostrar el "acerca" del programa # Funcion para mostrar el "acerca" del programa
function mostrarAcerca() { function mostrarAcerca() {
echo "" echo ""
echo "* Acerca:" echo "* About:"
echo "" echo ""
echo " - Software: easy-samba ${VERSION} (${M_DATE})" echo " - Software: easy-samba ${VERSION} (${M_DATE})"
echo " - Autor: q3aql" echo " - Author: q3aql"
echo " - Contacto: q3aql@protonmail.ch" echo " - Contact: q3aql@protonmail.ch"
echo " - Licencia: GPL v2.0" echo " - License: GPL v2.0"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
} }
# Mostrar menu con todas las opciones # Mostrar menu con todas las opciones
@ -539,18 +542,18 @@ while [ ${mostrarMenu} -eq 0 ] ; do
echo "" echo ""
echo "* easy-samba ${VERSION} (${M_DATE})" echo "* easy-samba ${VERSION} (${M_DATE})"
echo "" echo ""
echo " 1 - Agregar carpeta a Samba" echo " 1 - Add folder to Samba"
echo " 2 - Crear carpeta compartida" echo " 2 - Create shared folder"
echo " 3 - Crear carpeta compartida (solo lectura)" echo " 3 - Create shared folder (read only)"
echo " 4 - Crear carpeta compartida (para un usuario)" echo " 4 - Create shared folder (for a user)"
echo " 5 - Crear carpeta compartida (printable)" echo " 5 - Create shared folder (printable)"
echo " 6 - Reiniciar servicios de Samba" echo " 6 - Restart Samba services"
echo " 7 - Ver carpetas compartidas disponibles" echo " 7 - View available shared folders"
echo " 8 - Borrar carpeta compartida" echo " 8 - Delete shared folder"
echo " 9 - Restaurar smb.conf" echo " 9 - Restore smb.conf"
echo " 10 - Acerca" echo " 10 - About"
echo "" echo ""
echo " 11 - Salir" echo " 11 - Exit"
echo "" echo ""
echo -n " * Elige una opcion: " ; read opcion echo -n " * Elige una opcion: " ; read opcion
if [ "${opcion}" == "1" ] ; then if [ "${opcion}" == "1" ] ; then
@ -582,13 +585,13 @@ while [ ${mostrarMenu} -eq 0 ] ; do
mostrarMenu=1 mostrarMenu=1
elif [ -z "${opcion}" ] ; then elif [ -z "${opcion}" ] ; then
echo "" echo ""
echo "* Debes elegir alguna opcion" echo "* You must choose an option "
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
else else
echo "" echo ""
echo "* Opcion no valida!" echo "* Invalid option !"
echo "" echo ""
echo -n "* Pulsa INTRO para continuar... " ; read continue echo -n "* Press ENTER to continue... " ; read continue
fi fi
done done

View File

@ -2,13 +2,17 @@
############################################################## ##############################################################
# Crear carpetas compartidas en Linux (GTK) # # Crear carpetas compartidas en Linux (GTK) #
# U. Modificacion: 27-12-2018 # # U. Modificacion: 03-08-2021 #
# Autor: q3aql # # Autor: q3aql #
# Contacto: q3aql@protonmail.ch # # Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 # # Licencia: GPL v2.0 #
############################################################## ##############################################################
VERSION="1.6.2 (GTK)" VERSION="1.6.3 (GTK)"
M_DATE="271218" M_DATE="030821"
# Variables
iconPath="/usr/share/icons/easy-samba/easy-samba.png"
imagesPath="/usr/share/icons/easy-samba/img"
# Parametros globales # Parametros globales
linuxSambaFolder="/opt/easy-samba" linuxSambaFolder="/opt/easy-samba"
@ -26,11 +30,12 @@ function rootMessage() {
if [ ${administrador} -eq 0 ] ; then if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root rm -rf /etc/root
else else
zenity --title "easy-samba-gtk ${VERSION} (${M_DATE})" --warning --width=340 --text "Son necesarios permisos de administrador" zenity --title "easy-samba-gtk ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 \
--text "Administrator permissions are required"
echo "" echo ""
echo "* easy-samba-gtk ${VERSION} (${M_DATE}) (GPL v2.0)" echo "* easy-samba-gtk ${VERSION} (${M_DATE}) (GPL v2.0)"
echo "" echo ""
echo "* Son necesarios permisos de administrador" echo "* Administrator permissions are required"
echo "" echo ""
exit exit
fi fi
@ -74,7 +79,7 @@ function convertText() {
echo ${wordToConvert} echo ${wordToConvert}
} }
# Funcion para extraer el nombre de la carpeta de una ruta # Funcion para extraer el nombre de The folder de una ruta
function extractFolder() { function extractFolder() {
pathToExtract="${1}/" pathToExtract="${1}/"
findFolder=0 findFolder=0
@ -97,8 +102,9 @@ function extractFolder() {
# Sintaxis: createFolderLink [carpeta] # Sintaxis: createFolderLink [carpeta]
function createFolderLink() { function createFolderLink() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --cancel-label="No" --ok-label="Si" --width=530 \ zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
--text "Deseas crear un enlace en el escritorio/home para los usuarios locales?" --ok-label="Yes" --width=530 \
--text "Do you want to create a link on the desktop/home for local users?"
createLink=$? createLink=$?
if [ ${createLink} -eq 1 ] ; then if [ ${createLink} -eq 1 ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
@ -125,12 +131,12 @@ function createFolderLink() {
fi fi
done done
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=280 --text "Enlaces creados correctamente!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=280 --text "Links created successfully!"
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=280 --text "Error: Fallo al crear los enlaces!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=280 --text "Error: Failed to create links!"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=310 --text "Usuarios no encontrados en ${homeUsers}" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=310 --text "Users not found in ${homeUsers}"
fi fi
fi fi
} }
@ -138,8 +144,9 @@ function createFolderLink() {
# Funcion para borrar los enlaces en el escritorio/home de los usuarios # Funcion para borrar los enlaces en el escritorio/home de los usuarios
# Sintaxis: deleteFolderLink [carpeta] # Sintaxis: deleteFolderLink [carpeta]
function deleteFolderLink() { function deleteFolderLink() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --cancel-label="No" --ok-label="Si" --width=530 \ zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" \
--text "Deseas borrar los enlaces en el escritorio/home de los usuarios locales?" --ok-label="Yes" --width=530 \
--text "Do you want to delete the links on the desktop/home of the local users?"
deleteLink=$? deleteLink=$?
if [ ${deleteLink} -eq 1 ] ; then if [ ${deleteLink} -eq 1 ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
@ -166,12 +173,12 @@ function deleteFolderLink() {
fi fi
done done
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=280 --text "Enlaces borrados correctamente!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=280 --text "Links deleted successfully!"
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=290 --text "Error: Fallo al borrar los enlaces!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=290 --text "Error: Failed to delete links!"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=310 --text "Usuarios no encontrados en ${homeUsers}" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=310 --text "Users not found in ${homeUsers}"
fi fi
fi fi
} }
@ -191,20 +198,20 @@ function fixHomePermissions() {
# Funcion para agregar una carpeta a Samba # Funcion para agregar una carpeta a Samba
function addNewFolder() { function addNewFolder() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce la ruta absoluta de la carpeta a agregar:") folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Enter the absolute path of the folder to add:")
pathExtracted=$(extractFolder "${folder}") pathExtracted=$(extractFolder "${folder}")
endFolder=$(convertText "${pathExtracted}") endFolder=$(convertText "${pathExtracted}")
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=410 --text "Debes introducir la ruta absoluta de una carpeta!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=410 --text "You must enter the absolute path of a folder!"
elif [ -d "${folder}" ] ; then elif [ -d "${folder}" ] ; then
if [ -d ${linuxSambaFolder}/${endFolder} ] ; then if [ -d ${linuxSambaFolder}/${endFolder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=530 --text "Una carpeta con el mismo nombre ya se encuentra agregada o creada!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "A folder with the same name is already added or created!"
else else
fixHomePermissions "${folder}" fixHomePermissions "${folder}"
ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null ln -s "${folder}" ${linuxSambaFolder}/${endFolder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=520 --text "Error: Fallo al agregar la carpeta '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Failed to add folder '${folder}'"
else else
echo "[${endFolder}]" >> ${sambaConfig} echo "[${endFolder}]" >> ${sambaConfig}
echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig} echo "# Folder to ${linuxSambaFolder}/${endFolder} # 00bc00" >> ${sambaConfig}
@ -215,29 +222,29 @@ function addNewFolder() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=390 --text "Carpeta '${folder}' agregada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=390 --text "Carpeta '${folder}' agregada con exito!"
createFolderLink ${endFolder} createFolderLink ${endFolder}
fi fi
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=300 --text "La carpeta introducida no existe!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=300 --text "The inserted folder does not exist!"
fi fi
} }
# Funcion para crear carpeta compartida con acceso para todos # Funcion para Create shared folder con acceso para todos
function newFolderEveryone() { function newFolderEveryone() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):") folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Enter the name of the folder you want to create (without accents):")
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=350 --text "Debes introducir un nombre de carpeta!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "You must enter a folder name!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "The folder '${folder}' is already created, choose another name"
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Failed to create shared folder '${folder}'"
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -249,26 +256,26 @@ function newFolderEveryone() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Carpeta compartida '${folder}' creada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Shared folder '${folder}' created sucessfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
} }
# Funcion para crear carpeta compartida de solo lectura # Funcion para Create shared folder de solo lectura
function newFolderReadOnly() { function newFolderReadOnly() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):") folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Enter the name of the folder you want to create (without accents):")
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=350 --text "Debes introducir un nombre de carpeta!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "You must enter a folder name!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "The folder '${folder}' is already created, choose another name"
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Failed to create shared folder '${folder}'"
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -280,35 +287,35 @@ function newFolderReadOnly() {
echo "read only = yes" >> ${sambaConfig} echo "read only = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Carpeta compartida '${folder}' (solo lectura) creada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Shared folder '${folder}' (solo lectura) created sucessfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
} }
# Crear carpeta compartida para un usuario # Create shared folder para un usuario
function newFolderForUser() { function newFolderForUser() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):") folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Enter the name of the folder you want to create (without accents):")
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=350 --text "Debes introducir un nombre de carpeta!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "You must enter a folder name!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "The folder '${folder}' is already created, choose another name"
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Failed to create shared folder '${folder}'"
else else
forUser=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce el nombre del usuario:") forUser=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --text "Enter the username:")
randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM} randomFolder=/tmp/easy-samba/${RANDOM}-${RANDOM}
mkdir -p ${randomFolder} mkdir -p ${randomFolder}
chown ${forUser} ${randomFolder} 2> /dev/null chown ${forUser} ${randomFolder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
rm -rf ${linuxSambaFolder}/${folder} rm -rf ${linuxSambaFolder}/${folder}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=330 --text "Error: No existe el usuario especificado!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=330 --text "Error: The specified user does not exist!"
else else
chmod 755 -R ${linuxSambaFolder}/${folder} chmod 755 -R ${linuxSambaFolder}/${folder}
chown ${forUser} -R ${linuxSambaFolder}/${folder} chown ${forUser} -R ${linuxSambaFolder}/${folder}
@ -321,27 +328,27 @@ function newFolderForUser() {
echo "read only = no" >> ${sambaConfig} echo "read only = no" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Carpeta compartida '${folder}' (para ${forUser}) creada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Shared folder '${folder}' (para ${forUser}) created sucessfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
fi fi
} }
# Crear carpeta compartida para imprimir # Create shared folder para imprimir
function newFolderPrintable() { function newFolderPrintable() {
folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Introduce el nombre de la carpeta que deseas crear (sin acentos):") folder=$(zenity --entry --title "easy-samba ${VERSION} (${M_DATE})" --text "Enter the name of the folder you want to create (without accents):")
formatText=$(convertText "${folder}") formatText=$(convertText "${folder}")
folder=${formatText} folder=${formatText}
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=350 --text "Debes introducir un nombre de carpeta!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "You must enter a folder name!"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=530 --text "La carpeta '${folder}' ya esta creada, elige otro nombre" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=530 --text "The folder '${folder}' is already created, choose another name"
else else
mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null mkdir -p ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -ne 0 ] ; then if [ ${output} -ne 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=520 --text "Error: Fallo al crear la carpeta compartida '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=520 --text "Error: Failed to create shared folder '${folder}'"
else else
chmod 777 -R ${linuxSambaFolder}/${folder} chmod 777 -R ${linuxSambaFolder}/${folder}
echo "[${folder}]" >> ${sambaConfig} echo "[${folder}]" >> ${sambaConfig}
@ -353,7 +360,7 @@ function newFolderPrintable() {
echo "printable = yes" >> ${sambaConfig} echo "printable = yes" >> ${sambaConfig}
echo "guest ok = yes" >> ${sambaConfig} echo "guest ok = yes" >> ${sambaConfig}
echo "" >> ${sambaConfig} echo "" >> ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=530 --text "Carpeta compartida '${folder}' (printable) creada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=530 --text "Shared folder '${folder}' (printable) created sucessfully!"
createFolderLink ${folder} createFolderLink ${folder}
fi fi
fi fi
@ -363,43 +370,46 @@ function newFolderPrintable() {
function reiniciandoSamba() { function reiniciandoSamba() {
sleep 2 sleep 2
/etc/init.d/samba restart &> /dev/null /etc/init.d/samba restart &> /dev/null
systemctl restart smbd.service 2> /dev/null /etc/init.d/nmbd restart &> /dev/null
systemctl restart nmbd.service 2> /dev/null /etc/init.d/smbd restart &> /dev/null
systemctl restart smb.service 2> /dev/null systemctl restart smbd 2> /dev/null
systemctl restart nmbd 2> /dev/null
systemctl restart smb 2> /dev/null
systemctl restart nmb 2> /dev/null
} }
# Funcion para reiniciar el servicio de Samba # Funcion para reiniciar el servicio de Samba
function restartSamba() { function restartSamba() {
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --cancel-label="No" --ok-label="Si" --width=320 --text "Deseas reiniciar los servicios de Samba?" zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Yes" --width=320 --text "Do you want to restart the Samba services?"
sambaSN=$? sambaSN=$?
if [ "${sambaSN}" == "1" ] ; then if [ "${sambaSN}" == "1" ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
else else
reiniciandoSamba | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --auto-close --text "Reiniciando servicios de Samba" reiniciandoSamba | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Restarting Samba services"
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=300 --text "Servicios de Samba reiniciados" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=300 --text "Samba services restarted"
fi fi
} }
# Funcion para borrar todas las carpetas compartidas # Funcion para borrar todas las carpetas compartidas
function restoreSmb() { function restoreSmb() {
echo "" echo ""
zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --cancel-label="No" --ok-label="Si" --width=530 \ zenity --question --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --cancel-label="No" --ok-label="Yes" --width=530 \
--text "Nota: Se van a eliminar todas las carpetas compartidas y su contenido\n\nImportante: Se volvera al estado inicial del fichero 'smb.conf' antes de\nde ejecutar 'easy-samba' por primera vez\n\nDeseas continuar?" --text "Note: All shared folders and their content will be deleted \n\nImportant: It will return to the initial state of the file 'smb.conf' before\nexecuting 'easy-samba' for the first time\n\nDo you want continue?"
deleteFolder=$? deleteFolder=$?
if [ ${deleteFolder} -eq 0 ] ; then if [ ${deleteFolder} -eq 0 ] ; then
sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --auto-close --text "Borrando carpetas" sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Deleting folders"
rm -rf ${linuxSambaFolder}/* | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --auto-close --text "Finalizando proceso de borrado" rm -rf ${linuxSambaFolder}/* | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --auto-close --text "Finalizing the deletion process"
output=$? output=$?
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null cp -rf ${sambaBackup} ${sambaConfig} 2> /dev/null
#rm -rf ${sambaBackup} 2> /dev/null #rm -rf ${sambaBackup} 2> /dev/null
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=350 --text "Carpetas borradas con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "Folders deleted successfully!"
restartSamba restartSamba
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=360 --text "Error al borrar las carpetas compartidas" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=360 --text "Failed to delete shared folders"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=360 --text "Se ha anulado el proceso de restauracion" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=360 --text "The restore process has been aborted"
fi fi
} }
@ -413,20 +423,20 @@ function viewFolders() {
folderList="${folderList} ${folderDetected}" folderList="${folderList} ${folderDetected}"
done done
folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \ folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--column "Lista de carpetas compartidas disponibles:" ${folderList}) --window-icon=${iconPath} --column "List of available shared folders:" ${folderList})
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
echo "nule" > /dev/null echo "nule" > /dev/null
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=350 --text "Nombre de carpeta: ${folder}\n\nRuta: ${linuxSambaFolder}/${folder}" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "Folder name: ${folder}\n\nPath: ${linuxSambaFolder}/${folder}"
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=400 --text "Error: La carpeta '${folder}' no existe!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=400 --text "Error: The folder '${folder}' does not exist!"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=370 --text "Actualmente no hay carpetas compartidas!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=370 --text "There are currently no shared folders!"
fi fi
} }
# Funcion para borrar una carpeta compartida # Funcion para borrar una Shared folder
function removeFolder() { function removeFolder() {
if [ "$(ls -A ${linuxSambaFolder})" ] ; then if [ "$(ls -A ${linuxSambaFolder})" ] ; then
cd ${linuxSambaFolder} cd ${linuxSambaFolder}
@ -436,17 +446,17 @@ function removeFolder() {
folderList="${folderList} ${folderDetected}" folderList="${folderList} ${folderDetected}"
done done
folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \ folder=$(zenity --width=390 --height=300 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--column "Selecciona una carpeta para borrar:" ${folderList}) --window-icon=${iconPath} --column "Select folder to delete:" ${folderList})
if [ -z ${folder} ] ; then if [ -z ${folder} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=350 --text "Debes seleccionar una carpeta de la lista" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=350 --text "You must select a folder from the list"
elif [ -d ${linuxSambaFolder}/${folder} ] ; then elif [ -d ${linuxSambaFolder}/${folder} ] ; then
sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --auto-close --text "Borrando carpeta..." sleep 2 | zenity --progress --pulsate --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --auto-close --text "Deleting folder..."
rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null rm -rf ${linuxSambaFolder}/${folder} 2> /dev/null
output=$? output=$?
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1) readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then if [ -z ${readLine} ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=530 --text "La carpeta '${folder}' ha sido borrada pero no se ha encontrado en 'smb.conf'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=530 --text "The folder '${folder}' has been deleted but not found in 'smb.conf'"
else else
initLine=$(expr ${readLine} - 1) initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7) endLine=$(expr ${readLine} + 7)
@ -464,25 +474,50 @@ function removeFolder() {
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
done done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig} cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=460 --text "La carpeta '${folder}' ha sido borrada con exito!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=460 --text "The folder '${folder}' has been deleted successfully!"
deleteFolderLink ${folder} deleteFolderLink ${folder}
restartSamba restartSamba
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=450 --text "Error: No se ha podido borrar la carpeta '${folder}'" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=450 --text "Error: Could not delete folder '${folder}'"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --error --width=400 --text "Error: La carpeta '${folder}' no existe!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=410 --text "Error: The folder '${folder}' does not exist or the link is broken!"
rm -rfv ${linuxSambaFolder}/${folder}
readLine=$(cat ${sambaConfig} | grep "# Folder to ${linuxSambaFolder}/${folder} # 00bc00" -n | cut -d ":" -f 1)
if [ -z ${readLine} ] ; then
echo "disabled" > /dev/null
else
initLine=$(expr ${readLine} - 1)
endLine=$(expr ${readLine} + 7)
totalLines=$(cat /etc/samba/smb.conf | wc -l)
count=1
mkdir -p /tmp/easy-samba/
echo > /tmp/easy-samba/smb.conf
while [ ${count} -lt $initLine ] ; do
cat /etc/samba/smb.conf | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
count=$(expr ${endLine} + 1)
while [ ${count} -le ${totalLines} ] ; do
cat ${sambaConfig} | head -${count} | tail -1 >> /tmp/easy-samba/smb.conf
count=$(expr ${count} + 1)
done
cp -rf /tmp/easy-samba/smb.conf ${sambaConfig}
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=460 --text "The folder '${folder}' has been deleted from smb.conf!"
deleteFolderLink ${folder}
restartSamba
fi
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info --width=350 --text "No hay carpetas disponibles para borrar!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "There are no folders available to delete!"
fi fi
} }
# Funcion para mostrar el "acerca" del programa # Funcion para mostrar el "About" del programa
function mostrarAcerca() { function mostrarAbout() {
zenity --title "Acerca" --info --width=330 \ zenity --title "About" --window-icon=${iconPath} --info --width=330 \
--text "Software: easy-samba ${VERSION} (${M_DATE})\nAutor: q3aql\nContacto: q3aql@protonmail.ch\nLicencia: GPL v2.0" --text "Software: easy-samba ${VERSION} (${M_DATE})\nAuthor: q3aql\nContact: q3aql@protonmail.ch\nLicense: GPL v2.0"
} }
# Mostrar menu con todas las opciones # Mostrar menu con todas las opciones
@ -491,40 +526,42 @@ rootMessage
backupSmbConf backupSmbConf
while [ ${mostrarMenu} -eq 0 ] ; do while [ ${mostrarMenu} -eq 0 ] ; do
clear clear
opcion=$(zenity --width=390 --height=400 --list --title "easy-samba ${VERSION} ($M_DATE)" \ opcion=$(zenity --width=350 --height=440 --list --title "easy-samba ${VERSION} ($M_DATE)" \
--column "Selecciona una opcion:" "Agregar carpeta a Samba" "Crear carpeta compartida" \ --window-icon=${iconPath} --imagelist --column "Icon" --column "Option" ${imagesPath}/add-folder-samba.png "Add folder to Samba" \
"Crear carpeta compartida (solo lectura)" "Crear carpeta compartida (para un usuario)" \ ${imagesPath}/create-shared-folder.png "Create shared folder" ${imagesPath}/create-shared-folder-read-only.png "Create shared folder (read only)" \
"Crear carpeta compartida (printable)" "Reiniciar servicios de Samba" \ ${imagesPath}/create-shared-folder-user.png "Create shared folder (for a user)" \
"Ver carpetas compartidas disponibles" "Borrar carpeta compartida" "Restaurar smb.conf" \ ${imagesPath}/create-shared-folder-printable.png "Create shared folder (printable)" \
"Acerca" "Salir") ${imagesPath}/restart-samba-services.png "Restart Samba services" \
if [ "${opcion}" == "Agregar carpeta a Samba" ] ; then ${imagesPath}/view-shared-folders.png "View available shared folders" ${imagesPath}/delete-shared-folder.png "Delete shared folder" ${imagesPath}/restore-smb-conf.png "Restore smb.conf" \
${imagesPath}/about.png "About" ${imagesPath}/exit.png "Exit")
if [ "${opcion}" == "${imagesPath}/add-folder-samba.png" ] ; then
addNewFolder addNewFolder
restartSamba restartSamba
elif [ "${opcion}" == "Crear carpeta compartida" ] ; then elif [ "${opcion}" == "${imagesPath}/create-shared-folder.png" ] ; then
newFolderEveryone newFolderEveryone
restartSamba restartSamba
elif [ "${opcion}" == "Crear carpeta compartida (solo lectura)" ] ; then elif [ "${opcion}" == "${imagesPath}/create-shared-folder-read-only.png" ] ; then
newFolderReadOnly newFolderReadOnly
restartSamba restartSamba
elif [ "${opcion}" == "Crear carpeta compartida (para un usuario)" ] ; then elif [ "${opcion}" == "${imagesPath}/create-shared-folder-user.png" ] ; then
newFolderForUser newFolderForUser
restartSamba restartSamba
elif [ "${opcion}" == "Crear carpeta compartida (printable)" ] ; then elif [ "${opcion}" == "${imagesPath}/create-shared-folder-printable.png" ] ; then
newFolderPrintable newFolderPrintable
restartSamba restartSamba
elif [ "${opcion}" == "Reiniciar servicios de Samba" ] ; then elif [ "${opcion}" == "${imagesPath}/restart-samba-services.png" ] ; then
restartSamba restartSamba
elif [ "${opcion}" == "Ver carpetas compartidas disponibles" ] ; then elif [ "${opcion}" == "${imagesPath}/view-shared-folders.png" ] ; then
viewFolders viewFolders
elif [ "${opcion}" == "Borrar carpeta compartida" ] ; then elif [ "${opcion}" == "${imagesPath}/delete-shared-folder.png" ] ; then
removeFolder removeFolder
elif [ "${opcion}" == "Restaurar smb.conf" ] ; then elif [ "${opcion}" == "${imagesPath}/restore-smb-conf.png" ] ; then
restoreSmb restoreSmb
elif [ "${opcion}" == "Acerca" ] ; then elif [ "${opcion}" == "${imagesPath}/about.png" ] ; then
mostrarAcerca mostrarAbout
elif [ "${opcion}" == "Salir" ] ; then elif [ "${opcion}" == "${imagesPath}/exit.png" ] ; then
mostrarMenu=1 mostrarMenu=1
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --warning --width=300 --text "Elige una de las opciones del menu" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=300 --text "Choose one of the menu options"
fi fi
done done

View File

@ -2,74 +2,77 @@
############################################################## ##############################################################
# Crear carpetas compartidas en Linux (GTK) # # Crear carpetas compartidas en Linux (GTK) #
# U. Modificacion: 27-12-2018 # # U. Modificacion: 03-08-2021 #
# Autor: q3aql # # Autor: q3aql #
# Contacto: q3aql@protonmail.ch # # Contacto: q3aql@protonmail.ch #
# Licencia: GPL v2.0 # # Licencia: GPL v2.0 #
############################################################## ##############################################################
VERSION="1.6.2 (GTK)" VERSION="1.6.3 (GTK)"
M_DATE="271218" M_DATE="030821"
# Variables
iconPath="/usr/share/icons/easy-samba/easy-samba.png"
# Enlace con gksudo,gksu o bessu a easy-samba-gtk # Enlace con gksudo,gksu o bessu a easy-samba-gtk
function showRootMessage() { function showRootMessage() {
if [ -f /usr/bin/gksudo ] ; then if [ -f /usr/bin/gksudo ] ; then
gksudo /usr/bin/easy-samba-gtk gksudo /usr/bin/easy-samba-gtk
exit exit
elif [ -f /bin/gksudo ] ; then elif [ -f /bin/gksudo ] ; then
gksudo /usr/bin/easy-samba-gtk gksudo /usr/bin/easy-samba-gtk
exit exit
elif [ -f /usr/bin/gksu ] ; then elif [ -f /usr/bin/gksu ] ; then
gksu /usr/bin/easy-samba-gtk gksu /usr/bin/easy-samba-gtk
exit exit
elif [ -f /bin/gksu ] ; then elif [ -f /bin/gksu ] ; then
gksu /usr/bin/easy-samba-gtk gksu /usr/bin/easy-samba-gtk
exit exit
elif [ -f /usr/bin/beesu ] ; then elif [ -f /usr/bin/beesu ] ; then
beesu /usr/bin/easy-samba-gtk beesu /usr/bin/easy-samba-gtk
exit exit
elif [ -f /bin/beesu ] ; then elif [ -f /bin/beesu ] ; then
beesu /usr/bin/easy-samba-gtk beesu /usr/bin/easy-samba-gtk
exit exit
elif [ -f /bin/sudo ] ; then elif [ -f /bin/sudo ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk" xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk"
exit exit
elif [ -f /usr/bin/sudo ] ; then elif [ -f /usr/bin/sudo ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk" xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo easy-samba-gtk"
exit exit
elif [ -f /usr/bin/su ] ; then elif [ -f /usr/bin/su ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'" xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'"
exit exit
elif [ -f /bin/su ] ; then elif [ -f /bin/su ] ; then
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'" xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'easy-samba-gtk'"
exit exit
else else
zenity -h &> /dev/null zenity -h &> /dev/null
output=$? output=$?
if [ ${output} -eq 0 ] ; then if [ ${output} -eq 0 ] ; then
zenity --title "easy-samba ${VERSION} (${M_DATE})" --info \ zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --width 450 --info \
--text "El programa 'easy-samba-gtk' no ha podido ser ejecutado como administrador\n\nPorfavor, ejecuta el comando 'easy-samba-gtk' como usuario root en la terminal" --text "The 'easy-samba-gtk' program could not be run as administrator\n\nPlease run the command 'easy-samba-gtk' as root user in terminal"
else else
xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "easy-samba-gtk-admin --error" xterm -T "easy-samba ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "easy-samba-gtk-admin --error"
fi fi
fi fi
} }
# Funcion para mostrar mensaje de error # Funcion para mostrar mensaje de error
function errorMessage() { function errorMessage() {
echo "" echo ""
echo "* ATENCION!:" echo "* ATTENTION!:"
echo "" echo ""
echo "* El programa 'easy-samba-gtk' no ha podido ser ejecutado como administrador" echo "* The 'easy-samba-gtk' program could not be run as administrator"
echo "" echo ""
echo "* Porfavor, ejecuta el comando 'easy-samba-gtk' como usuario root en la terminal" echo "* Please run the command 'easy-samba-gtk' as root user in terminal"
echo "" echo ""
echo -n "* Pulsa INTRO para salir... " ; read continue echo -n "* Press ENTER to exit... " ; read continue
exit exit
} }
# Inicio del script # Inicio del script
if [ "${1}" == "--error" ] ; then if [ "${1}" == "--error" ] ; then
errorMessage errorMessage
else else
showRootMessage showRootMessage
fi fi