Database Logging Daemon for samba on SME Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
991 B

12 years ago
#!/usr/bin/perl -w
use esmith::ConfigDB;
my $c = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB\n";
my $rec = $c->get('samba-db-logd');
my $dbname = $rec->prop('DbName') || 'samba_log';
my $dbuser = $rec->prop('DbUser') || 'samba';
my $dbpass = $rec->prop('DbPassword') || 'samba';
my $dbhost = $rec->prop('DbHost') || 'localhost';
my $log = '/var/log/messages';
if (-e '/var/log/smb_audit.log') {
$log = '/var/log/smb_audit.log';
}
elsif ($rec->prop('LogFile')){
$log = $rec->prop('LogFile');
}
12 years ago
open(STDERR, ">&STDOUT");
my @args = ("--debug=1", "--dbname=$dbname", "--dbuser=$dbuser",
"--dbpass=$dbpass", "--exclude=opendir",
"--log=$log");
12 years ago
push @args, "--dbhost=$dbhost" if ($dbhost ne 'localhost');
my $smbd = $c->get('smbd')->prop('status');
12 years ago
if ($smbd ne 'enabled'){
exec("sv", "d", "/service/samba-db-logd");
exit(0);
}
exec("/usr/bin/samba-db-logd", @args)
12 years ago
or die "Cannot run the Samba Database Loggind Daemon";
exit(1);