summaryrefslogtreecommitdiffstats
path: root/samba_wizard/Samba.pm
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-05-30 10:04:34 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-05-30 10:04:34 +0000
commitc21aa28a2cb02a125d0481af214f3e1cf3b7a5f4 (patch)
treecf3488f455e3d52b22420bd9a050fcb627952b0d /samba_wizard/Samba.pm
parentcac1a787bcc97f3af620928eaf9a8cc16f36e22a (diff)
downloaddrakwizard-c21aa28a2cb02a125d0481af214f3e1cf3b7a5f4.tar
drakwizard-c21aa28a2cb02a125d0481af214f3e1cf3b7a5f4.tar.gz
drakwizard-c21aa28a2cb02a125d0481af214f3e1cf3b7a5f4.tar.bz2
drakwizard-c21aa28a2cb02a125d0481af214f3e1cf3b7a5f4.tar.xz
drakwizard-c21aa28a2cb02a125d0481af214f3e1cf3b7a5f4.zip
add add/remove/modify a share
Diffstat (limited to 'samba_wizard/Samba.pm')
-rwxr-xr-xsamba_wizard/Samba.pm93
1 files changed, 89 insertions, 4 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm
index e0253cca..61dbe434 100755
--- a/samba_wizard/Samba.pm
+++ b/samba_wizard/Samba.pm
@@ -36,6 +36,7 @@ my $wiz = new MDK::Wizard::Wizcommon;
my $DOMAINNAME = chomp_(`dnsdomainname`);
my $SHORTHOSTNAME = chomp_(`hostname -s`);
my $wiz_samba_etc = "/etc/sysconfig/wizard_samba";
+my @listshare;
my $o = {
name => 'Samba wizard',
@@ -83,6 +84,11 @@ my $o = {
wiz_ldap_suffix => '',
wiz_ldap_root_pw => '',
wiz_ldap_root_pw_2 => '',
+ wiz_addshare_comment => '',
+ wiz_addshare_browseable => '',
+ wiz_addshare_writable => '',
+ wiz_addshare_createmode => '',
+ wiz_selected_share => '',
test => '',
},
init => sub {
@@ -111,8 +117,15 @@ my %type = (
2 => N('PDC - primary domain controller'),
3 => N('Standalone - standalone server'),
4 => N('Member - member of a domain'),
+ 5 => N('Share - modify a share'),
);
+my %share = (
+ 1 => N('Add - add a share'),
+ 2 => N('Remove - remove a share'),
+ 3 => N('Modify - modify a share'),
+ );
+
my @yesorno = qw(yes no); #push @yesorno, "";
my @loglevel = qw(0 1 2 3 4 5 6 7 8 9 10);
@@ -138,6 +151,9 @@ $o->{pages} = {
return 'ask_workgroup' }
elsif ($o->{var}{wiz_type} == 4) {
return 'member' }
+ elsif ($o->{var}{wiz_type} == 5 and -f $wiz_samba_etc) {
+ return 'share_menu';
+ }
},
data => [
{ label => N("Wich type of Samba server do you you want:"), val => \$o->{var}{wiz_type}, list => [ keys %type ], format => sub { $type{$_[0]} } },
@@ -223,6 +239,68 @@ $o->{pages} = {
},
next => 'ask_workgroup',
},
+ share_menu => {
+ name => N('What do you want todo with your share ?') . "\n\n" . N('add/remove/modify a share'),
+ data => [
+ { label => N("what do you want:"), val => \$o->{var}{wiz_share}, list => [ keys %share ], format => sub { $share{$_[0]} } },
+ ],
+ post => sub {
+ if ($o->{var}{wiz_share} == 1) {
+ return 'add_share' }
+ elsif ($o->{var}{wiz_share} == 2) {
+ return 'choose_share' }
+ elsif ($o->{var}{wiz_share} == 3) {
+ return 'choose_share' }
+ }
+ },
+ choose_share => {
+ name => N('Modify a share'),
+ pre => \&list_all_shares,
+ post => sub {
+ if ($o->{var}{wiz_share} == 2) {
+ return 'delete_share';
+ } else {
+ return 'modify_share';
+ }
+ },
+ data => [
+ { label => N('Choose share you want to modifie:'), val => \$o->{var}{wiz_selected_share}, fixed_list => \@listshare },
+ ],
+ },
+ delete_share => {
+ name => N('Delete a share'),
+ # pre => sub {
+ # $samba->{$o->{var}{wiz_selected_share}};
+ # },
+ data => [
+ { label => N('Delete this share:'), fixed_val => \$o->{var}{wiz_selected_share} },
+ ],
+ complete => sub {
+ remove_share($o->{var}{wiz_selected_share});
+ },
+ next => 'summary',
+ },
+ modify_share => {
+ name => N('Modify a share'),
+ # pre => sub {
+ # $samba->{$o->{var}{wiz_selected_share}};
+ # },
+ next => 'summary',
+ },
+ add_share => {
+ name => N('Add a share') . "\n" . N('You have selected to add a share.') . "\n" . N('Comment: description of the share') . "\n" . N('Browseable: view share') . "\n" . N('Writable: user can write in the share') . "\n" . N('Create mode: man chmod for more info'),
+ data => [
+ { label => N('Name of the share:'), val => \$o->{var}{wiz_addshare_name} },
+ { label => N('Comment:'), val => \$o->{var}{wiz_addshare_comment} },
+ { label => N('Browseable:'), val => \$o->{var}{wiz_addshare_browseable}, fixed_list => \@yesorno },
+ { label => N('Writable:'), val => \$o->{var}{wiz_add_share_writable}, fixed_list => \@yesorno },
+ { label => N('Create mode:'), val => \$o->{var}{wiz_addshare_createmode} },
+ ],
+ complete => sub {
+ chack_share_doesnt_exist($o->{var}{wiz_addshare_name});
+ },
+ next => 'summary_addshare',
+ },
ldap_conf => {
name => N('LDAP configuration for Domain Controlling') . "\n\n" . N('The account (dn) that samba uses to access the LDAP server. This account needs to have write access to the LDAP tree. You will need to give samba the password for this dn.'),
pre => sub {
@@ -549,6 +627,11 @@ sub add_printer {
$samba->{$printer}{printable} = 'yes';
}
+sub remove_share {
+ my ($share) = @_;
+ delete $samba->{$share};
+}
+
sub remove_printer {
my ($printer) = @_;
delete $samba->{$printer};
@@ -565,17 +648,19 @@ sub list_printers() {
} else { () }
}
-sub list_share() {
- my @listshare;
+sub list_all_shares() {
foreach my $clef (keys %$samba) {
if ($samba->{$clef}{printable} =~ /yes/i) {
print "$clef est une imprimante\n";
+ } elsif ($clef =~ /global/ or $clef =~ /print\$/) {
+ print "unwanted\n";
} else {
push @listshare, $clef;
}
- print "------------- \n";
- foreach (@listshare) { print "$_\n"; }
}
+ print "------------- \n";
+ foreach (@listshare) { print "$_\n"; }
+ return @listshare;
}
sub printer_sharing() {