|
|
|
#!/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
|
|
|
|
#
|
|
|
|
# Technical support for this program is available from Mitel Networks
|
|
|
|
# Please visit our web site www.mitel.com/sme/ for details.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
use esmith::util;
|
|
|
|
use esmith::AccountsDB;
|
|
|
|
use esmith::ConfigDB;
|
|
|
|
|
|
|
|
my $a = esmith::AccountsDB->open() or die "Couldn't open AccountsDB\n";
|
|
|
|
my $c = esmith::ConfigDB->open() or die "Couldn't open ConfigDB\n";
|
|
|
|
|
|
|
|
my $srv = $c->get('wpkg') || die "wpkg service not found\n";
|
|
|
|
my $pass = $srv->prop('UserPassword') || '';
|
|
|
|
|
|
|
|
if ($pass eq ''){
|
|
|
|
$pass = `/usr/bin/openssl rand -base64 35 | tr -c -d '[:graph:]'`;
|
|
|
|
$srv->set_prop('UserPassword', "$pass");
|
|
|
|
}
|
|
|
|
|
|
|
|
# deploiement
|
|
|
|
my $dep = $a->get("deploiement");
|
|
|
|
|
|
|
|
if (!$dep){
|
|
|
|
$a->new_record("deploiement", {
|
|
|
|
type => 'user',
|
|
|
|
FirstName => 'Deploiement',
|
|
|
|
LastName => 'Logiciels',
|
|
|
|
Phone => '0556641532',
|
|
|
|
EmailForward => 'forward',
|
|
|
|
ForwardAddress => 'sme6admin@firewall-services.com',
|
|
|
|
Company => 'Firewall-Services',
|
|
|
|
City => 'Martillac',
|
|
|
|
Dept => 'Administration',
|
|
|
|
Removable => 'no',
|
|
|
|
PasswordSet => 'no',
|
|
|
|
});
|
|
|
|
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "user-create", "deploiement") == 0 ){
|
|
|
|
die "Failed to create user account deploiement\n";
|
|
|
|
}
|
|
|
|
esmith::util::setUserPassword ("deploiement", "$pass");
|
|
|
|
$a->set_prop('deploiement', 'PasswordSet', 'yes');
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "password-modify", "deploiement") == 0 ){
|
|
|
|
die "Failed to set password for user deploiement\n";
|
|
|
|
}
|
|
|
|
$a->set_prop('deploiement', 'Password', "$pass");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
my $wpkg = $c->get('wpkg') || die "Couldn't find wpkg service\n";
|
|
|
|
my $new = $wpkg->prop('UserPassword') || '';
|
|
|
|
my $old = $dep->prop('Password') || '';
|
|
|
|
my $set = $dep->prop('PasswordSet') || 'no';
|
|
|
|
if (($old ne $new) || ($set ne 'yes')){
|
|
|
|
esmith::util::setUserPassword ("deploiement", "$new");
|
|
|
|
$a->set_prop('deploiement', 'PasswordSet', 'yes');
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "password-modify", "deploiement") == 0 ){
|
|
|
|
die "Failed to set password for user deploiement\n";
|
|
|
|
}
|
|
|
|
$a->set_prop('deploiement', 'Password', "$new");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# sharedfolder wpkg
|
|
|
|
my $wpkg = $a->get("wpkg");
|
|
|
|
|
|
|
|
if (!$wpkg){
|
|
|
|
$a->new_record("wpkg", {
|
|
|
|
type => 'share',
|
|
|
|
Name => 'Deploiement WPKG',
|
|
|
|
WriteGroups => 'admins',
|
|
|
|
ReadUsers => 'deploiement',
|
|
|
|
smbAccess => 'non-browseable',
|
|
|
|
httpAccess => 'none',
|
|
|
|
RecycleBin => 'disabled'
|
|
|
|
});
|
|
|
|
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "share-create", "wpkg") == 0 ){
|
|
|
|
die "Failed to create share wpkg\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# sharedfolder wpkglogs
|
|
|
|
my $wpkglogs = $a->get("wpkglogs");
|
|
|
|
|
|
|
|
if (!$wpkglogs){
|
|
|
|
$a->new_record("wpkglogs", {
|
|
|
|
type => 'share',
|
|
|
|
Name => 'Journaux WPKG',
|
|
|
|
WriteGroups => 'admins',
|
|
|
|
WriteUsers => 'deploiement',
|
|
|
|
smbAccess => 'non-browseable',
|
|
|
|
httpAccess => 'none',
|
|
|
|
RecycleBin => 'disabled'
|
|
|
|
});
|
|
|
|
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "share-create", "wpkglogs") == 0 ){
|
|
|
|
die "Failed to create share wpkglogs\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach my $share (qw/wpkg wpkglogs tools/) {
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "share-modify-files", "$share") == 0 ){
|
|
|
|
die "Failed to create share $share\n";
|
|
|
|
}
|
|
|
|
}
|