From aa66ac3f396bc2be461e7bb7999d2f6729185895 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 24 Jun 2012 22:36:00 +0200 Subject: [PATCH] panel logonscript --- createlinks | 2 + root/etc/e-smith/web/functions/logonscript | 67 +++++++++++++++++++++ .../esmith/FormMagick/Panel/logonscript.pm | 68 ++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 root/etc/e-smith/web/functions/logonscript create mode 100644 root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/logonscript.pm diff --git a/createlinks b/createlinks index c7cc19d..88c9dcf 100644 --- a/createlinks +++ b/createlinks @@ -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'); diff --git a/root/etc/e-smith/web/functions/logonscript b/root/etc/e-smith/web/functions/logonscript new file mode 100644 index 0000000..40e8715 --- /dev/null +++ b/root/etc/e-smith/web/functions/logonscript @@ -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__ +
+ + FIRSTPAGE_DESC + + + DESC_HOME_DRIVE + + + + DESC_LOGON_SCRIPT + + + +
+ diff --git a/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/logonscript.pm b/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/logonscript.pm new file mode 100644 index 0000000..8786606 --- /dev/null +++ b/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/logonscript.pm @@ -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, "error('ERROR_OPEN_FILE','First'); + return; + } + while (){ + $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'); +}