panel logonscript

tags/0.1.3
Daniel Berteaud 13 years ago
parent 3f22bb9f23
commit aa66ac3f39
  1. 2
      createlinks
  2. 67
      root/etc/e-smith/web/functions/logonscript
  3. 68
      root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/logonscript.pm

@ -9,3 +9,5 @@ event_link("initialize-default-databases", "wpkg-update", "02");
templates2events("/home/e-smith/files/shares/tools/files/scripts/wpkg/conf.bat", qw(wpkg-update bootstrap-console-save));
templates2events("/home/e-smith/files/shares/wpkg/files/config.xml", qw(wpkg-update bootstrap-console-save));
templates2events("/home/e-smith/files/shares/wpkg/files/profiles/variables.xml", qw(wpkg-update bootstrap-console-save));
panel_link('logonscript','manager');

@ -0,0 +1,67 @@
#!/usr/bin/perl -wT
# vim: ft=xml ts=4 sw=4 et:
#----------------------------------------------------------------------
# heading : Collaboration
# description : Logon Script
# navigation : 2000 2100
#----------------------------------------------------------------------
#----------------------------------------------------------------------
# copyright (C) 2012 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 strict;
use esmith::TestUtils;
use esmith::FormMagick::Panel::logonscript;
my $fm = esmith::FormMagick::Panel::logonscript->new();
use CGI;
my $q = new CGI;
$fm->display();
__DATA__
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
<page name="First" pre-event="print_status_message()" post-event="save_change()" >
<description>FIRSTPAGE_DESC</description>
<field type="select"
id="homedrive"
options="'a' => 'A:', 'b' => 'B:', 'c' => 'C:', 'd' => 'D:',
'e' => 'E:', 'f' => 'F:', 'g' => 'G:', 'h' => 'H:',
'i' => 'I:', 'j' => 'J:', 'k' => 'K:', 'l' => 'L:',
'm' => 'M:', 'n' => 'N:', 'o' => 'O:', 'p' => 'P:',
'q' => 'Q:', 'r' => 'R:', 's' => 'S:', 't' => 'T:',
'u' => 'U:', 'v' => 'V:', 'w' => 'W:', 'x' => 'X:',
'y' => 'Y:', 'z' => 'Z:'"
value="get_prop('smb', 'HomeDrive')">
<label>LABEL_HOME_DRIVE</label>
<description>DESC_HOME_DRIVE</description>
</field>
<field type="textarea"
id="logonscript"
rows="25"
cols="70"
value="read_logonscript()">
<label>LABEL_LOGON_SCRIPT</label>
<description>DESC_LOGON_SCRIPT</description>
</field>
<subroutine src="print_button('SAVE')" />
</page>
</form>

@ -0,0 +1,68 @@
#!/usr/bin/perl -w
package esmith::FormMagick::Panel::logonscript;
use strict;
use esmith::FormMagick;
use esmith::ConfigDB;
use esmith::cgi;
use File::Basename;
use Exporter;
use Carp;
our @ISA = qw(esmith::FormMagick Exporter);
our @EXPORT = qw(
read_logon
save_change
);
our $c = esmith::ConfigDB->open() || die "Couldn't open config db";
sub new {
shift;
my $self = esmith::FormMagick->new();
$self->{calling_package} = (caller)[0];
bless $self;
return $self;
}
sub get_prop {
my $self = shift;
my $item = shift;
my $prop = shift;
return ($c->get($item)->prop($prop));
}
sub read_logonscript {
my $self = shift;
my $ret = '';
if (! open (LOGON, "</home/e-smith/files/samba/netlogon/netlogon.template")){
$self->error('ERROR_OPEN_FILE','First');
return;
}
while (<LOGON>){
$ret .= $_;
}
close LOGON;
return $ret;
}
sub save_change {
my $self = shift;
my $q = $self->{cgi};
my $logon = $q->param('logonscript');
my $drive = $q->param('homedrive');
if (! open (LOGON, ">/home/e-smith/files/samba/netlogon/netlogon.template")){
$self->error('ERROR_OPEN_FILE','First');
return;
}
print LOGON $logon;
close LOGON;
$c->set_prop('smb', 'HomeDrive', $drive);
unless ( system ("/sbin/e-smith/signal-event", "workgroup-update") == 0 ){
return $self->error('ERROR_OCCURED');;
}
return $self->success('SUCCESS');
}
Loading…
Cancel
Save