diff options
-rwxr-xr-x | perl-install/standalone/draksambashare | 98 |
1 files changed, 62 insertions, 36 deletions
diff --git a/perl-install/standalone/draksambashare b/perl-install/standalone/draksambashare index 9e8d35b63..365b5c491 100755 --- a/perl-install/standalone/draksambashare +++ b/perl-install/standalone/draksambashare @@ -37,30 +37,30 @@ $in->do_pkgs->ensure_is_installed('samba-server', '/usr/sbin/smbd') or return; use constant FALSE => 0; use constant TRUE => 1; -use constant COLUMN_PATH => 0; -use constant COLUMN_COMMENT => 1; -use constant COLUMN_BROWSEABLE => 2; -use constant COLUMN_PUBLIC => 3; -use constant COLUMN_WRITABLE => 4; -use constant COLUMN_CREATE_MASK => 5; -use constant COLUMN_DIRECTORY_MASK => 6; -use constant COLUMN_READ_LIST => 7; -use constant COLUMN_WRITE_LIST => 8; -use constant COLUMN_ADMIN_USERS => 9; -use constant COLUMN_VALID_USERS => 10; -use constant COLUMN_HIDE_DOT_FILES => 11; -use constant COLUMN_HIDE_FILES => 12; -use constant COLUMN_PRESERVE_CASE => 13; -use constant COLUMN_FORCE_CREATE_MODE => 14; -use constant COLUMN_FORCE_GROUP => 15; -use constant COLUMN_DEFAULT_CASE => 16; -use constant COLUMN_INHERIT_PERMISSIONS => 17; -use constant NUM_COLUMNS => 18; +use constant COLUMN_SHARE_NAME => 0; +use constant COLUMN_PATH => 1; +use constant COLUMN_COMMENT => 2; +use constant COLUMN_BROWSEABLE => 3; +use constant COLUMN_PUBLIC => 4; +use constant COLUMN_WRITABLE => 5; +use constant COLUMN_CREATE_MASK => 6; +use constant COLUMN_DIRECTORY_MASK => 7; +use constant COLUMN_READ_LIST => 8; +use constant COLUMN_WRITE_LIST => 9; +use constant COLUMN_ADMIN_USERS => 10; +use constant COLUMN_VALID_USERS => 11; +use constant COLUMN_HIDE_DOT_FILES => 12; +use constant COLUMN_HIDE_FILES => 13; +use constant COLUMN_PRESERVE_CASE => 14; +use constant COLUMN_FORCE_CREATE_MODE => 15; +use constant COLUMN_FORCE_GROUP => 16; +use constant COLUMN_DEFAULT_CASE => 17; +use constant COLUMN_INHERIT_PERMISSIONS => 18; my $samba = new Libconf::Glueconf::Samba::Smb_conf({ filename => '/etc/samba/smb.conf', show_commented_info => 1 }); my (@listshare); -my @yesno = qw(yes no); -my @default_case = qw(upper lower); +my @yesno = qw(yes no); push @yesno, ""; +my @default_case = qw(upper lower); push @default_case, ""; my %adv_options = ( read_list => N("Read List"), @@ -138,12 +138,13 @@ my $fdwidget = sub { sub get_samba_share() { undef @listshare; foreach my $clef (keys %$samba) { - if ($samba->{$clef}{printable} =~ /yes/i) { + if ($samba->{$clef}{printable} =~ /yes/i or $clef =~ /print\$/) { print "$clef is a printer\n"; - } elsif ($clef =~ /global/ or $clef =~ /print\$/ or $clef =~ /cdrom/ or $clef eq "homes" or $clef eq "profiles") { + } elsif ($clef =~ /global/ or $clef =~ /cdrom$/ or $clef eq "homes" or $clef eq "profiles") { print "unwanted (special shares)\n"; } else { push @listshare, { + share_name => $clef, path => $samba->{$clef}{path}, comment => $samba->{$clef}{comment}, browseable => $samba->{$clef}{browseable}, @@ -179,6 +180,27 @@ sub create_smbuser { } sub write_conf { + foreach my $clef (@listshare) { + $samba->{$clef}; + $samba->{$clef}{path}; + $samba->{$clef}{comment}; + $samba->{$clef}{browseable}; + $samba->{$clef}{public}; + $samba->{$clef}{writable}; + $samba->{$clef}{'create mask'}; + $samba->{$clef}{'directory mask'}; + $samba->{$clef}{'read list'}; + $samba->{$clef}{'write list'}; + $samba->{$clef}{'admin users'}; + $samba->{$clef}{'valid users'}; + $samba->{$clef}{'hide dot files'}; + $samba->{$clef}{'hide files'}; + $samba->{$clef}{'preserve case'}; + $samba->{$clef}{'force create mode'}; + $samba->{$clef}{'force group'}; + $samba->{$clef}{'default case'}; + $samba->{$clef}{'inherit permissions'}; + } $samba->write_conf("/etc/samba/smb.conf"); } @@ -258,9 +280,9 @@ sub modify_entry { my $selection = $treeview->get_selection; my $iter; - my ($dir, $i, $path, $comment, $create_mask, $directory_mask, $read_list, $write_list, $admin_users, $valid_users, $force_group, $browseable, $public, $writable, $hide_files, $hide_dot_files, $force_create_mode, $preserve_case, $default_case, $inherit_permissions); + my ($dir, $i, $path, $comment, $create_mask, $directory_mask, $read_list, $write_list, $admin_users, $valid_users, $force_group, $browseable, $public, $writable, $hide_files, $hide_dot_files, $force_create_mode, $preserve_case, $default_case, $inherit_permissions, $share_name); - $_ = Gtk2::Entry->new foreach $dir, $path, $comment, $create_mask, $directory_mask; + $_ = Gtk2::Entry->new foreach $share_name, $dir, $path, $comment, $create_mask, $directory_mask; $_ = Gtk2::Entry->new foreach $read_list, $write_list, $admin_users, $valid_users, $force_group, $force_create_mode; $_ = Gtk2::OptionMenu->new foreach $browseable, $public, $writable, $default_case, $preserve_case, $hide_files, $hide_dot_files, $inherit_permissions; @@ -279,6 +301,7 @@ sub modify_entry { my $path = $model->get_path($iter); $i = ($path->get_indices)[0]; + $share_name->set_text($listshare[$i]{share_name}); $dir->set_text($listshare[$i]{path}); $comment->set_text($listshare[$i]{comment}); $browseable->set_text($listshare[$i]{browseable}); @@ -322,7 +345,6 @@ sub modify_entry { ), ); - my $expander_file = Gtk2::Expander->new('File options'); $expander_file->add(gtkpack_(Gtk2::VBox->new, 0, gtkadd(Gtk2::Frame->new(N("Display options")), @@ -349,18 +371,17 @@ sub modify_entry { gtkadd($w->{window}, gtknew('VBox', spacing => 0, children_loose => [ gtkadd(Gtk2::Frame->new(N("Samba share directory")), - gtkpack_(gtkset_border_width(Gtk2::VBox->new, 1), - 0, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0), + gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0), + 0, gtkpack_(gtkset_border_width(Gtk2::VBox->new, 0), + 0, $label_and_widgets->(N("Share name:"), $share_name), 0, $label_and_widgets->(N("Directory:"), $dir, $button), 0, $label_and_widgets->(N("Comment:"), $comment, ""), ), - 0, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0), - 0, $label_and_widgets->(N("Browseable:"), $browseable, ""), + 0, gtkpack_(gtkset_border_width(Gtk2::VBox->new, 0), 0, $label_and_widgets->(N("Public:"), $public, ""), - ), - 0, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0), 0, $label_and_widgets->(N("Writable:"), $writable, ""), - ), + 0, $label_and_widgets->(N("Browseable:"), $browseable, ""), + ), ), ), gtkadd(Gtk2::Frame->new("Advanced options"), @@ -372,7 +393,9 @@ sub modify_entry { create_okcancel({ cancel_clicked => sub { $w->destroy }, ok_clicked => sub { - $model->set($iter, + # update gui treeview + $model->set($iter, + COLUMN_SHARE_NAME, $share_name->get_text, COLUMN_PATH, $dir->get_text, COLUMN_COMMENT, $comment->get_text, COLUMN_BROWSEABLE, $browseable->get_text, @@ -392,6 +415,8 @@ sub modify_entry { COLUMN_DEFAULT_CASE, $default_case->get_text, COLUMN_INHERIT_PERMISSIONS, $inherit_permissions->get_text, ); + # update $samba with the new value + $w->destroy; }, }, @@ -418,10 +443,11 @@ sub remove_entry { sub create_model() { get_samba_share(); - my $model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String"); + my $model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String"); foreach my $a (@listshare) { my $iter = $model->append; $model->set($iter, + COLUMN_SHARE_NAME, $a->{share_name}, COLUMN_PATH, $a->{path}, COLUMN_COMMENT, $a->{comment}, COLUMN_BROWSEABLE, $a->{browseable}, @@ -455,7 +481,7 @@ sub add_columns { $renderer->signal_connect(edited => \&cell_edited, $model); $renderer->set_data(column => $::i); $treeview->insert_column_with_attributes(-1, $_, $renderer, 'text' => $::i); - } N("Share directory"), N("Comment"), N("Browseable"), N("Public"), N("Writable"), N("Create mask"), N("Directory mask"), N("Read list"), N("Write list"), N("Admin users"), N("Valid users"), N("Hide dot files"), N("Hide files"), N("Preserve case"), N("Force create mode"), N("Force group"), N("Default case"),; + } N("Share name"), N("Share directory"), N("Comment"), N("Browseable"), N("Public"), N("Writable"), N("Create mask"), N("Directory mask"), N("Read list"), N("Write list"), N("Admin users"), N("Valid users"), N("Hide dot files"), N("Hide files"), N("Preserve case"), N("Force create mode"), N("Force group"), N("Default case"), N("Inherit Permissions"); } ############### |