Update aclset.sh

This commit is contained in:
deflax 2020-04-07 23:14:32 +03:00 committed by GitHub
parent 06b93b2352
commit add84bc08a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,33 +1,33 @@
#!/bin/bash
# afx acl setup
# acl setup
### vars
watchdir="/srv/test"
domainadmin="afx"
password="CHANGEME"
watchdir="/srv/share"
domainadmin="admin"
password="bangovasil"
###
#init
controlfile="control.txt"
passfile="password.txt"
passfile="delete.txt"
aclset="";
acldel="";
old_IFS=$IFS # save the field separator
IFS=$'\n' # new field separator, the end of line
exec > /tmp/afxacl.log 2>&1
exec >> /var/log/afxacl.log 2>&1
mlocate --database=/tmp/afxacl.db $controlfile > /tmp/afxacl.set.1.tmp
mlocate --database=/tmp/afxacl.db $passfile > /tmp/afxacl.del.1.tmp
updatedb --database-root=$watchdir --output /tmp/afxacl.db -l 0
mlocate --database=/tmp/afxacl.db $controlfile > /tmp/afxacl.set.2.tmp
mlocate --database=/tmp/afxacl.db $passfile > /tmp/afxacl.del.2.tmp
mlocate --database=/var/tmp/afxacl.db $controlfile > /var/tmp/afxacl.set.1.tmp
mlocate --database=/var/tmp/afxacl.db $passfile > /var/tmp/afxacl.del.1.tmp
updatedb --database-root=$watchdir --output /var/tmp/afxacl.db -l 0
mlocate --database=/var/tmp/afxacl.db $controlfile > /var/tmp/afxacl.set.2.tmp
mlocate --database=/var/tmp/afxacl.db $passfile > /var/tmp/afxacl.del.2.tmp
setlist=`diff /tmp/afxacl.set.1.tmp /tmp/afxacl.set.2.tmp`
setlist=`diff /var/tmp/afxacl.set.1.tmp /var/tmp/afxacl.set.2.tmp`
aclset=`echo "$setlist" | grep '>'`
dellist=`diff /tmp/afxacl.del.1.tmp /tmp/afxacl.del.2.tmp`
dellist=`diff /var/tmp/afxacl.del.1.tmp /var/tmp/afxacl.del.2.tmp`
acldel=`echo "$dellist" | grep '>'`
#del
@ -61,6 +61,7 @@ then
echo "warning: whole dir was deleted"
fi
echo ""
updatedb --database-root=$watchdir --output /var/tmp/afxacl.db -l 0
echo ""
done < <(echo "$acldel")
fi
@ -105,12 +106,11 @@ fi
IFS=$old_IFS # restore default field separator
if [ -s /tmp/afxacl.log ];
then
mutt -s "setacl.sh notice" mailbox@server.com < /tmp/afxacl.log
fi
#if [ -s /var/log/afxacl.log ];
#then
# mutt -s "ACL" user@mail.com < /var/tmp/afxacl.log
#fi
#cleantmp
rm /tmp/afxacl.set*
rm /tmp/afxacl.del*
rm /var/tmp/afxacl.set*
rm /var/tmp/afxacl.del*