Fixed bug to remove broken link to folder

This commit is contained in:
q3aql 2021-08-03 13:20:47 +02:00
parent 5f1d8d9bd3
commit 611eb55fb4
2 changed files with 52 additions and 2 deletions

View File

@ -476,7 +476,32 @@ function removeFolder() {
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --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: No se ha podido borrar la carpeta '${folder}'"
fi fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --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: 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 fi
else else
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "No hay carpetas disponibles para borrar!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "No hay carpetas disponibles para borrar!"

View File

@ -479,7 +479,32 @@ function removeFolder() {
zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --error --width=450 --text "Error: Could not delete folder '${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})" --window-icon=${iconPath} --error --width=400 --text "Error: The folder '${folder}' does not exist!" 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})" --window-icon=${iconPath} --info --width=350 --text "There are no folders available to delete!" zenity --title "easy-samba ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=350 --text "There are no folders available to delete!"