commit 5f6c937b6495143e272d3e66b8dd1802b81d7f35 Author: Christoph Date: Tue Feb 21 02:35:05 2017 +0100 Initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a149b6f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/BAK/* diff --git a/check_samba_rights.sh b/check_samba_rights.sh new file mode 100755 index 0000000..b1d537d --- /dev/null +++ b/check_samba_rights.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +(/root/bin/cleanup_samba_rights.sh ) +.. + +exit 0 diff --git a/clean_trash.sh b/clean_trash.sh new file mode 100755 index 0000000..cb1aab8 --- /dev/null +++ b/clean_trash.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +trash_dirs="/data/buero/.Trash /data/ajur/.Trash /data/scan/.Trash /data/datev/.Trash" +days=31 + +traverse() { + + for file in `ls -a $1` ; do + if [ -d $1/$file ] ; then + [ "$1/$file" = "$1/.." ] && continue + [ "$1/$file" = "$1/." ] && continue + traverse $1/$file + fi + done + + find $1 -type f -mtime +${days} -exec rm -f "{}" \; + + ## - leere Unterverzeichnisse löschen + #find $1 -depth -mindepth 1 -type d -empty -exec rmdir "{}" \; + +} + +for dir in $trash_dirs ; do + traverse "$dir" +done + +## - lösche leere (Unter-)Verzeichnisse +## - +for dir in $trash_dirs ; do + #find $dir -depth -mindepth 2 -type d -empty -exec rmdir "{}" \; + find $dir -depth -mindepth 2 -type d -empty -delete +done + +exit diff --git a/cleanup_samba_rights.sh b/cleanup_samba_rights.sh new file mode 100755 index 0000000..2bec6e9 --- /dev/null +++ b/cleanup_samba_rights.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +base_dir=$1 +group=$2 +dir_perm=2775 +#dir_perm="u=rwx,g=rwx,o=rx,g+s" +file_perm=664 + +chmod $dir_perm $base_dir +chgrp $group $base_dir + +while IFS='' read -r -d '' filename ; do + + [ -f "$filename" ] && ( chmod $file_perm "$filename"; chgrp $group $"$filename") + [ ! -d "$filename" ] && continue + + [ "$filename" = "lost+found" ] && continue + + chmod $dir_perm "$filename" ; chgrp $group "$filename" + + find "$filename" -exec chgrp -R $group {} \; + find "$filename" -type d -exec chmod -R $dir_perm {} \; + find "$filename" -type f -exec chmod -R $file_perm {} \; + + +done < <(find $base_dir -mindepth 1 -maxdepth 1 -print0) + +exit 0