diff options
Diffstat (limited to 'samba_wizard/Samba.pm')
-rwxr-xr-x | samba_wizard/Samba.pm | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm index 2407bf9a..7b7e76b4 100755 --- a/samba_wizard/Samba.pm +++ b/samba_wizard/Samba.pm @@ -50,6 +50,9 @@ my $o = { wiz_do_homes => '', wiz_workgroup => '', wiz_dir => '', + wiz_share_comment => '', + wiz_share_browseable => '', + wiz_share_writable => '', wiz_banner => '', wiz_write_list => '', wiz_read_list => '', @@ -66,16 +69,17 @@ my $o = { # we ask glueconf to give us the structure representing /etc/samba/smb.conf my $samba = new Libconf::Glueconf::Samba::Smb_conf({ filename => '/etc/samba/smb.conf', }); -$samba->read_conf(); #debug -#print Dumper($samba); +print Dumper($samba); my %level = ( 1 => N('All - No access restriction'), 2 => N('My rules - Ask me allowed and denied hosts') ); +my @yesorno = qw(yes no); push @yesorno, ""; + $o->{pages} = { welcome => { name => N('Samba Configuration Wizard') . "\n\n" . N('Samba allows your server to behave as a file and print server for workstations running non-Linux systems.') . "\n\n" . N('This wizard will help you configuring the Samba services of your server.'), @@ -177,10 +181,16 @@ $o->{pages} = { ask_dir => { name => N('Shared directory:') . "\n\n" . N('Type the path of the directory you want being shared.'), pre => sub { - $o->{var}{wiz_dir} ||= $samba->{public}{path} + $o->{var}{wiz_dir} ||= $samba->{public}{path}; + $o->{var}{wiz_share_comment} ||= $samba->{public}{comment}; + $o->{var}{wiz_share_browseable} ||= $samba->{public}{browseable}; + $o->{var}{wiz_share_writable} ||= $samba->{public}{writable}; }, data => [ + { label => N('Comment:'), val => \$o->{var}{wiz_share_comment} }, { label => N('Shared directory:'), val => \$o->{var}{wiz_dir} }, + { label => N('Browseable:'), val => \$o->{var}{wiz_share_browseable}, fixed_list => \@yesorno }, + { label => N('Writable:'), val => \$o->{var}{wiz_share_writable}, fixed_list => \@yesorno }, { text => N("Create shared directory if it doesn't exist"), type => 'bool', val => \$o->{var}{create_missing_directory} }, ], post => sub { @@ -208,7 +218,7 @@ $o->{pages} = { name => N('Select which printers you want to be accessible from known users'), pre => sub { $o->{var}{list_printers} ||= [ list_printers() ]; - $o->{var}{wiz_box_list} ||= [] + $o->{var}{wiz_box_list} ||= []; }, data => [ { text => N('Enable all printers'), type => 'bool', val => \$o->{var}{wiz_all_printers} }, @@ -348,8 +358,10 @@ sub ask_dir { # remember one variable cannot be commented and not in the same file. sub do_it { $::testing and return; + # display a wait dialog box my $in = 'interactive'->vnew('su', 'Samba'); my $w = $in->wait_message(N("Samba server"), N("Configuring your Samba server...")); + # global section $samba->{global}{workgroup} = $o->{var}{wiz_workgroup}; $samba->{global}{'server string'} = $o->{var}{wiz_banner}; @@ -358,7 +370,7 @@ sub do_it { $samba->{global}{netbios} = $o->{var}{wiz_netbios}; } - # log level + # log level in global section $samba->{global}{'log file'} = $o->{var}{wiz_log_file}; if ($o->{var}{wiz_log_level}) { $samba->{global}{'log level'} = $o->{var}{wiz_log_level}; @@ -366,17 +378,26 @@ sub do_it { $samba->{global}{'max log size'} = $o->{var}{wiz_max_log_size}; - # user access - $samba->{public}{'write list'} = $o->{var}{wiz_write_list} if $o->{var}{wiz_do_file_sharing}; - $samba->{public}{'read list'} = $o->{var}{wiz_read_list} if $o->{var}{wiz_do_file_sharing}; - + # public share if ($o->{var}{wiz_do_file_sharing}) { - standalone->explanations("Enabling $o->{var}{wiz_dir} samba file sharing"); - $samba->{public}{path} = $o->{var}{wiz_dir}; + if ($o->{var}{wiz_write_list}) { + $samba->{public}{'write list'} = $o->{var}{wiz_write_list}; + } + if ($o->{var}{wiz_read_list}) { + $samba->{public}{'read list'} = $o->{var}{wiz_read_list}; + } + # enable options if exist + $o->{var}{wiz_share_comment} and $samba->{public}{comment} = $o->{var}{wiz_share_comment}; + $o->{var}{wiz_share_browseable} and $samba->{public}{browseable} = $o->{var}{wiz_share_browseable}; + $o->{var}{wiz_share_writable} and $samba->{public}{writable} = $o->{var}{wiz_share_writable}; + standalone->explanations("Enabling $o->{var}{wiz_dir} samba file sharing"); + $samba->{public}{path} = $o->{var}{wiz_dir}; } else { - standalone->explanations("Disabling samba file sharing"); - $samba->set_comment('{public}', 1); + standalone->explanations("Disabling samba file sharing"); + $samba->set_comment('{public}', 1); } + + # share home dir if ($o->{var}{wiz_do_homes}) { standalone->explanations("Enabling samba homes sharing"); $samba->{homes}; @@ -387,6 +408,7 @@ sub do_it { standalone->explanations("Samba deny $o->{var}{wiz_hosts_deny}"); standalone->explanations("Samba allow $o->{var}{wiz_hosts_allow}"); + # share printers if ($o->{var}{wiz_do_printer_sharing}) { standalone->explanations("Enabling printer sharing"); printer_sharing(); |