I realized LinuxHotFolder for give Linux folders where you can put files, whithout could after read or modify them.
Whith LinuxHotFolder and Netatalk you have an effect like Apple's systems hotfolders.
This example olnly copy files in a different directory, implementing it you could associate other actions to files, printing them with lpr, transform format from pdf to postscript whith ghostscript, ecc..
LinuxHotfolder not need Netatalk for work, anc could create hotfolder directly on Linux's filesystems, wich could be condivided with Samba, Nfs, ecc..
LinuxHotFolder is a bash script that use commands that you can found in any Linux system.
Program:
#!/bin/bash
export IFS=$'\n'
#Directory in cui mettere i files / Direcctory where put files
export ORIGINE="/home/condivisa/HotFolder"
#Directory in cui vengono spostati i files / Directory where te files will goes
export DESTINAZIONE="/home/condivisa/Destinazione"
if [ ! -d ${ORIGINE} ]
then
echo "La directory di origine ${ORIGINE} non esiste!"
exit 6
fi
if [ ! -d ${DESTINAZIONE} ]
then
echo "La directory di destinazione ${DESTINAZIONE} non esiste!"
exit 6
fi
if [ ! -d ${DESTINAZIONE}/.AppleDouble ]
then
echo "La directory ${DESTINAZIONE}/.AppleDouble non esiste!"
exit 6
fi
while true
do
# sposta i files nella directori fatti
for NOMEFILE in `ls -1 ${ORIGINE}`
do
# Non sposta le informazioni delle directory di MacOSX / Do not move MacOSX directory informations
if ! [ `echo ${NOMEFILE} | fgrep DS_Store` ] ;
then
if [ -s "${ORIGINE}/${NOMEFILE}" ];
then
if ! fuser -s "${ORIGINE}/${NOMEFILE}" ;
then
if [ -s "${ORIGINE}/.AppleDouble/${NOMEFILE}" ] ;
then
if ! fuser -s "${ORIGINE}/.AppleDouble/${NOMEFILE}" ;
then
export STATO="OK"
else
export STATO="RISORSA_UTILIZZATA"
fi
else
export STATO="NON_ESISTE_RISORSA_O_DIMENSIONE_0"
fi
else
export STATO="UTILIZZATO"
fi
else
export STATO="NON_ESISTE_O_DIMESIONE_0"
fi
else
export STATO="DS_Store"
fi
# Rimuovere il commento alla linea seguente per avere un log delle operazioni / Remove the comment to the next line for logging
# echo ${NOMEFILE} ${STATO}
if [ ${STATO} = "OK" ] ;
then
#Se il file esiste si sposta quello vecchio in una versione diversa / If the file exists rename the old file
if [ -f ${DESTINAZIONE}/${NOMEFILE} ] ;
then
export AGGIUNTA=`date +%H%M%S`_
if mv "${DESTINAZIONE}/${NOMEFILE}" "${DESTINAZIONE}/${AGGIUNTA}${NOMEFILE}"
then
logger -t linuxhotfolder "moved file ${DESTINAZIONE}/${NOMEFILE} to ${DESTINAZIONE}/${AGGIUNTA}${NOMEFILE}"
fi
if [ -f ${DESTINAZIONE}/.AppleDouble/$NOMEFILE ] ;
then
mv "${DESTINAZIONE}/.AppleDouble/${NOMEFILE}" "${DESTINAZIONE}/.AppleDouble/${AGGIUNTA}${NOMEFILE}"
fi
fi
#Sposta il file in un'altra cartella
if mv "${ORIGINE}/${NOMEFILE}" "${DESTINAZIONE}/${NOMEFILE}"
then
logger -t linuxhotfolder "moved file ${ORIGINE}/${NOMEFILE} to ${DESTINAZIONE}/${NOMEFILE}"
fi
#Sposta la risorsa Mac
if [ -f ${ORIGINE}/.AppleDouble/${NOMEFILE} ] ;
then
mv "${ORIGINE}/.AppleDouble/${NOMEFILE}" "${DESTINAZIONE}/.AppleDouble/${NOMEFILE}"
fi
fi
done
done
This script must be runned demonized with a & at the command's name end and must run with root privileges for guarantee fuser command correct functionement.
If you copy on the target folder a file that exist before the old file is renamed prepending actual hhmmss_ , be aware that netatalk 1 not work with files longer than 31 characters.