Koozali.org: home of the SME Server

SharedFolders contrib - Changing Recycle Bin name

Offline nicolatiana

  • *
  • 721
  • +0/-0
SharedFolders contrib - Changing Recycle Bin name
« on: May 07, 2019, 11:31:12 PM »
I'd like to modify "Recycle Bin" name into ".Recycle Bin" to have the directory hidden in the same way I did/do with standard iBays.
The template fragment to be duplicated in template-custom and then expanded should be:
/etc/e-smith/templates/etc/smb.conf/shares/10recyclebin
The line to modify should be:
my $recycle = $share->prop('RecycleBinDir') || "Recycle Bin";
my $recycle = $share->prop('RecycleBinDir') || ".Recycle Bin";
purge-shares-recycle in cron.daily should be modified too:
my $dir = $share->prop('RecycleBinDir') || 'Recycle Bin';
my $dir = $share->prop('RecycleBinDir') || '.Recycle Bin';
Just to be confirmed if this is enough or other settings are stored in other places.
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia.

Offline john56

  • ***
  • 143
  • +0/-0
Re: SharedFolders contrib - Changing Recycle Bin name
« Reply #1 on: May 22, 2019, 04:06:51 PM »
Hi, i'm also interested in the subject. (in fact change their names) for recycle bin's users too.

Offline nicolatiana

  • *
  • 721
  • +0/-0
Re: SharedFolders contrib - Changing Recycle Bin name
« Reply #2 on: May 22, 2019, 05:44:00 PM »
I did it and it's working fine.

You need also to change manually (it's not templated) purge script located in /etc/cron.daily

purge-shares-recycle

#!/usr/bin/perl -w

#----------------------------------------------------------------------
# copyright (C) 2010 Firewall Services
# daniel@firewall-services.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#----------------------------------------------------------------------

use esmith::AccountsDB;
use File::Find;
use File::stat;

my $a = esmith::AccountsDB->open_ro or die "Error opening accounts DB\n";

foreach my $share ($a->get_all_by_prop(type=>'share')){
    my $key = $share->key;
    my $recycle = $share->prop('RecycleBin') || 'disabled';
    our $retention = $share->prop('RecycleBinRetention') || 'unlimited';
    # Skip the share if recycle bin is disabled or if retention is not limited
    next if (($recycle eq 'disabled') || ($retention eq 'unlimited'));
    # Convert retention in seconds
    $retention = 60*60*24*$retention;
    my $dir = $share->prop('RecycleBinDir') || '.Recycle Bin';
    # Skip if dir contains ./
    next if $dir =~ m#(\./)#;
    finddepth(\&remove, "/home/e-smith/files/shares/$key/files/$dir/");
}


sub remove{
    # Remove files with last modification older than $retention
    if ( -f ){
        my $mtime = stat($_)->mtime;
        (time() - $mtime > $retention) && unlink($_);
    }
    # Remove empty directories
    elsif ( -d ){
        (scalar <"$_/*">) || rmdir("$_");
    }
}
« Last Edit: May 22, 2019, 06:02:00 PM by nicolatiana »
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia.

Offline john56

  • ***
  • 143
  • +0/-0
Re: SharedFolders contrib - Changing Recycle Bin name
« Reply #3 on: May 22, 2019, 08:25:16 PM »
It seems ok to rename witch "corbeille" and purge sharefolders with cron
But if i modify the share with the server-manager, it creates again a new recycle bin called recycled bin or .recycled bin ...

Offline nicolatiana

  • *
  • 721
  • +0/-0
Re: SharedFolders contrib - Changing Recycle Bin name
« Reply #4 on: June 26, 2019, 10:43:21 AM »
What kind of modifications did you: specifically concerning Trash ?


It seems template-custom is not considered.
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia.