summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-xperl-install/standalone/drakTermServ157
-rwxr-xr-xperl-install/standalone/drakauth4
-rwxr-xr-xperl-install/standalone/drakbackup137
-rwxr-xr-xperl-install/standalone/drakfont2
-rwxr-xr-xperl-install/standalone/draksplash52
-rwxr-xr-xperl-install/standalone/drakupdate_fstab6
-rwxr-xr-xperl-install/standalone/drakups99
-rwxr-xr-xperl-install/standalone/harddrake214
-rwxr-xr-xperl-install/standalone/net_monitor10
-rwxr-xr-xperl-install/standalone/printerdrake288
-rwxr-xr-xperl-install/standalone/service_harddrake29
11 files changed, 464 insertions, 334 deletions
diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ
index 9f3b5bfcc..ba850e5cc 100755
--- a/perl-install/standalone/drakTermServ
+++ b/perl-install/standalone/drakTermServ
@@ -47,10 +47,11 @@ my $in_wizard = 0;
my $config_written = 0;
my $clients_set = 0;
my @nothing = (0..10);
+my %conf;
+$conf{ALLOW_THIN} = 0;
my $nfs_subnet;
my $nfs_mask;
-my $thin_clients = 0;
my $cfg_dir = "/etc/drakxtools/draktermserv/";
my $cfg_file = $cfg_dir . "draktermserv.conf";
my $interface = get_net_interface();
@@ -150,24 +151,13 @@ interactive_mode() if $#ARGV < 1;
sub read_conf_file() {
if (-e $cfg_file) {
- local *CONF_FILE;
- open(CONF_FILE, "<" . $cfg_file) || print N("You must be root to read configuration file. \n");
- local $_;
- while (<CONF_FILE>) {
- if (/^\bALLOW_THIN\b/) {
- $thin_clients = 1;
- last;
- }
- }
+ substInFile { s/ALLOW_THIN$/ALLOW_THIN=1/ } $cfg_file;
+ %conf = getVarsFromSh($cfg_file);
}
}
sub write_conf_file() {
- my @cfg_list;
- if ($thin_clients == 1) {
- @cfg_list = "ALLOW_THIN\n";
- }
- output_p($cfg_file, @cfg_list);
+ setVarsInSh($cfg_file, \%conf);
chmod(0600, $cfg_file);
}
@@ -210,10 +200,7 @@ ca::ctrlaltdel:/sbin/reboot -f
x:5:respawn:/usr/X11R6/bin/X -ac -query $server_ip\n";
my $inittab_file = "/etc/inittab$suffix";
- local *INITTAB;
- open(INITTAB, "> $inittab_file") or warn("Can't open $inittab_file!");
- print INITTAB $inittab;
- close INITTAB
+ output_p($inittab_file, $inittab);
}
sub cursor_wait() {
@@ -443,7 +430,7 @@ sub clear_buttons() {
sub client_type() {
my $check_allow_thin = new Gtk2::CheckButton(N("Use thin clients."));
- $check_allow_thin->set_active($thin_clients);
+ $check_allow_thin->set_active($conf{ALLOW_THIN});
text_view(N("Please select default client type.
'Thin' clients run everything off the server's CPU/RAM, using the client display.
'Fat' clients use their own CPU/RAM but the server's filesystem."), "wizard");
@@ -451,7 +438,7 @@ sub client_type() {
0, gtkpack_(new Gtk2::HBox(1,0),
1, Gtk2::VBox->new,
0, gtksignal_connect($check_allow_thin, clicked => sub {
- invbool \$thin_clients;
+ invbool \$conf{ALLOW_THIN};
client_set("all");
}),
0, Gtk2::VBox->new,
@@ -477,17 +464,17 @@ sub sync_users {
my $buff = N("Syncing server user list with client list, including root.");
my @active_users = cat_("/etc/shadow");
- local *SHADOW;
- open(SHADOW, '> /etc/shadow$$CLIENT$$');
-
+ my $shadow = '/etc/shadow$$CLIENT$$';
+ my @userlist;
+
#- only users with home dirs, and root
foreach my $user (@active_users) {
my @fields = split(/:/, $user);
if (-d "/home/" . $fields[0] || $fields[0] eq "root") {
- print SHADOW $user;
+ push @userlist, $user;
}
}
- close SHADOW;
+ output_p($shadow, @userlist);
$buff .= "\n\n\t" . N("Done!");
text_view($buff, "wizard") if !$cmd_line;
}
@@ -1075,11 +1062,11 @@ sub maintain_clients() {
),
);
- $check_allow_thin->set_active($thin_clients);
- $check_thin->set_sensitive($thin_clients);
+ $check_allow_thin->set_active($conf{ALLOW_THIN});
+ $check_thin->set_sensitive($conf{ALLOW_THIN});
gtksignal_connect($check_allow_thin, clicked =>
- sub { invbool \$thin_clients;
- $check_thin->set_sensitive($thin_clients);
+ sub { invbool \$conf{ALLOW_THIN};
+ $check_thin->set_sensitive($conf{ALLOW_THIN});
client_set("single");
$in->ask_warn(N("Warning"), N("Need to restart the Display Manager for full changes to take effect. \n(service dm restart - at the console)"));
}
@@ -1119,7 +1106,7 @@ sub client_set {
# we need to change some system files to allow the thin clients
# to access the server - enabling xdmcp and modify hosts.deny/hosts.allow for some security
# we also need to set runlevel to 5 and restart the display manager
- if ($thin_clients == 1) {
+ if ($conf{ALLOW_THIN} == 1) {
if (-f "/etc/sysconfig/autologin") {
my $answer = $in->ask_yesorno('', N("Thin clients won't work with autologin. Disable autologin?"));
if ($answer == 1) {
@@ -1385,15 +1372,14 @@ sub get_ip_from_sys() {
sub write_dhcpd_config {
my ($mode, $subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_;
+ my @dhcpd_config;
if ($mode eq "append") {
append_to_file("/etc/dhcpd.conf", qq(include "/etc/dhcpd.conf.terminal-server";\n));
- local *FHANDLE;
- open(FHANDLE, "> /etc/dhcpd.conf.terminal-server");
- print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
- print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n);
- print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- close FHANDLE;
+ push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
+ push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n);
+ push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
+ output_p("/etc/dhcpd.conf.terminal-server", @dhcpd_config);
$config_written = 1;
return;
}
@@ -1401,34 +1387,32 @@ sub write_dhcpd_config {
$nfs_subnet = $subnet;
$nfs_mask = $subnet_mask;
- local *FHANDLE;
- open(FHANDLE, "> /etc/dhcpd.conf");
- print FHANDLE "#dhcpd.conf - generated by drakTermServ\n\n";
- print FHANDLE "ddns-update-style none;\n\n";
- print FHANDLE "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n";
- print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
- print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n);
- print FHANDLE "# Network-specific section\n\n";
+ push @dhcpd_config, "#dhcpd.conf - generated by drakTermServ\n\n";
+ push @dhcpd_config, "ddns-update-style none;\n\n";
+ push @dhcpd_config, "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n";
+ push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
+ push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n);
+ push @dhcpd_config, "# Network-specific section\n\n";
- print FHANDLE "subnet $subnet netmask $netmask {\n";
- print FHANDLE "\toption routers $routers;\n" if $routers;
- print FHANDLE "\toption subnet-mask $subnet_mask;\n" if $subnet_mask;
- print FHANDLE "\toption broadcast-address $broadcast;\n" if $broadcast;
- print FHANDLE qq(\toption domain-name "$domain";\n) if $domain;
+ push @dhcpd_config, "subnet $subnet netmask $netmask {\n";
+ push @dhcpd_config, "\toption routers $routers;\n" if $routers;
+ push @dhcpd_config, "\toption subnet-mask $subnet_mask;\n" if $subnet_mask;
+ push @dhcpd_config, "\toption broadcast-address $broadcast;\n" if $broadcast;
+ push @dhcpd_config, qq(\toption domain-name "$domain";\n) if $domain;
my $pool_string = "\trange dynamic-bootp " . $pool_start . " " . $pool_end . ";\n" if $pool_start && $pool_end;
- print FHANDLE $pool_string if $pool_string;
+ push @dhcpd_config, $pool_string if $pool_string;
my $ns_string = "\toption domain-name-servers " . $ns1 if $ns1;
$ns_string = $ns_string . ", " . $ns2 if $ns2;
$ns_string = $ns_string . ", " . $ns3 if $ns3;
$ns_string = $ns_string . ";\n" if $ns_string;
- print FHANDLE $ns_string if $ns_string;
+ push @dhcpd_config, $ns_string if $ns_string;
- print FHANDLE "}\n\n";
+ push @dhcpd_config, "}\n\n";
- print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- close FHANDLE;
+ push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
+ output_p("/etc/dhcpd.conf", @dhcpd_config);
$config_written = 1;
}
@@ -1564,14 +1548,11 @@ sub toggle_chkconfig {
sub service_change {
my ($service, $command, $buff_index) = @_;
system("BOOTUP=serial /sbin/service $service $command > /tmp/drakTSservice.status 2>&1");
- local *STATUS;
- open(STATUS, "/tmp/drakTSservice.status");
- local $_;
- while (<STATUS>) {
+ my @result = cat_("/tmp/drakTSservice.status");
+ foreach (@result) {
$buff[$buff_index] = "\t$_";
- $buff_index++;
+ $buff_index++;
}
- close STATUS;
unlink "/tmp/drakTSservice.status";
$buff_index;
}
@@ -1655,13 +1636,8 @@ sub adduser {
}
} else {
# new ts user
- local *FHANDLE;
- open(FHANDLE, '>> /etc/shadow$$CLIENT$$');
- print FHANDLE $shadow_entry[0] or $add_fail = 1;
- close FHANDLE;
- open(FHANDLE, '>> /etc/passwd$$CLIENT$$');
- print FHANDLE $passwd_entry[0] or $add_fail = 1;
- close FHANDLE;
+ append_to_file('/etc/shadow$$CLIENT$$', $shadow_entry[0]) or $add_fail = 1;
+ append_to_file('/etc/passwd$$CLIENT$$', $passwd_entry[0]) or $add_fail = 1;
$in_already = 0;
}
}
@@ -1700,10 +1676,7 @@ sub deluser {
}
$i++;
}
- local *FHANDLE;
- open(FHANDLE, '> /etc/shadow$$CLIENT$$');
- print FHANDLE $_ foreach @ts_users;
- close FHANDLE;
+ output_p('/etc/shadow$$CLIENT$$', @ts_users);
}
if ($is_passwd_user) {
@@ -1716,10 +1689,7 @@ sub deluser {
}
$i++;
}
- local *FHANDLE;
- open(FHANDLE, '> /etc/passwd$$CLIENT$$');
- print FHANDLE $_ foreach @passwd_users;
- close FHANDLE;
+ output_p('/etc/passwd$$CLIENT$$', @passwd_users);
}
if ($cmd_line == 1) {
@@ -1772,12 +1742,8 @@ sub addclient {
$ts_clients{$hostname}{hdw_config} = "false";
client_hdw_config($ip, 0);
}
- my $clients = $client_cfg;
- local *CLIENT;
- open(CLIENT, ">> $clients") or warn(N("Can't open %s!", $clients));
my $client_entry = format_client_entry($hostname, %ts_clients);
- print CLIENT $client_entry;
- close CLIENT;
+ append_to_file($client_cfg, $client_entry);
$changes_made = 1;
create_client_sysnetwork($hostname, $ip);
0;
@@ -1898,15 +1864,12 @@ qq(\tfilename\t\t"$ts_clients{$client}{filename}";),
sub write_dhcpd_conf {
my %ts_clients = @_;
- my $clients = $client_cfg;
-
- local *CLIENT;
- open(CLIENT, "> $clients") or warn("Can't open $clients!");
+ my @client_data;
foreach my $key (keys(%ts_clients)) {
my $client_entry = format_client_entry($key, %ts_clients);
- print CLIENT $client_entry;
+ push @client_data, $client_entry;
}
- close CLIENT
+ output_p($client_cfg, @client_data);
}
sub read_dhcpd_conf() {
@@ -1915,9 +1878,8 @@ sub read_dhcpd_conf() {
my $hostname;
#- read and parse current client entries
- local *CLIENTS;
- open(CLIENTS, $clients) or warn("Can't open $clients\n");
- while (<CLIENTS>) {
+ my @client_data = cat_($clients);
+ foreach (@client_data) {
my ($name, $val, $val2) = split ' ';
$val = $val2 if $name =~ /hardware/;
$val =~ s/[;"]//g;
@@ -1932,7 +1894,6 @@ sub read_dhcpd_conf() {
}
}
}
- close CLIENTS;
%ts_clients;
}
@@ -1960,11 +1921,15 @@ sub client_hdw_config {
cp_af('/etc/X11/XF86Config-4$$CLIENT$$', "/etc/X11/XF86Config-4$suffix") if -f '/etc/X11/XF86Config-4$$CLIENT$$';
cp_af("/dev/null", "/etc/modules.conf$suffix");
cp_af("/dev/null", "/etc/modules$suffix");
+ cp_af("/dev/null", "/etc/modprobe.conf$suffix");
+ cp_af("/dev/null", "/etc/modprobe.preload$suffix");
# create mount points so they can be edited by the client
my $mnt_access = "$client_ip(rw,no_root_squash)";
append_to_file("/etc/exports", "/etc/sysconfig/mouse$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/modules.conf$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/modules$suffix\t$mnt_access\n");
+ append_to_file("/etc/exports", "/etc/modprobe.conf$suffix\t$mnt_access\n");
+ append_to_file("/etc/exports", "/etc/modprobe.preload$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/X11/XF86Config$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/X11/XF86Config-4$suffix\t$mnt_access\n");
} else {
@@ -1979,12 +1944,8 @@ sub create_client_sysnetwork {
my ($hostname, $ip) = @_;
log::explanations("Adding /etc/sysconfig/network for $ip");
my $network_file = "/etc/sysconfig/network\$\$IP=$ip\$\$";
- local *NETWORK;
- open(NETWORK, "> $network_file") or warn("Can't open $network_file!");
- print NETWORK "HOSTNAME=$hostname\n";
- print NETWORK "NETWORKING=yes\n";
- print NETWORK "FORWARD_IPV4=false\n";
- close NETWORK;
+ my @net_data = ("HOSTNAME=$hostname\n", "NETWORKING=yes\n", "FORWARD_IPV4=false\n");
+ output_p($network_file, @net_data);
}
sub restart_server() {
@@ -2005,6 +1966,8 @@ sub clean_client_config {
eval { rm_rf("/etc/sysconfig/mouse$suffix") };
eval { rm_rf("/etc/modules.conf$suffix") };
eval { rm_rf("/etc/modules$suffix") };
+ eval { rm_rf("/etc/modprobe.conf$suffix") };
+ eval { rm_rf("/etc/modprobe.preload$suffix") };
eval { rm_rf("/etc/X11/XF86Config$suffix") };
eval { rm_rf("/etc/X11/XF86Config-4$suffix") };
eval { rm_rf("/etc/sysconfig/network$suffix") };
diff --git a/perl-install/standalone/drakauth b/perl-install/standalone/drakauth
index f091a3000..8fdb40896 100755
--- a/perl-install/standalone/drakauth
+++ b/perl-install/standalone/drakauth
@@ -21,9 +21,9 @@ my $authentication = {}; # TODO
my $kind = authentication::to_kind($authentication);
main:
-$in->ask_from('', '',
+$in->ask_from(N("Authentication"), authentication::kind2description(),
[
- { label => N("Authentication"), val => \$kind, list => [ authentication::kinds() ], format => \&authentication::kind2description },
+ { label => N("Authentication"), val => \$kind, type => 'list' , list => [ authentication::kinds() ], format => \&authentication::kind2name },
]) or $in->exit;
authentication::ask_parameters($in, $netc, $authentication, $kind) or goto main;
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
index 351f363f3..dbce62c84 100755
--- a/perl-install/standalone/drakbackup
+++ b/perl-install/standalone/drakbackup
@@ -119,7 +119,7 @@ my @list_of_rpm_to_install;
my @other_files;
my @sys_files = "/etc";
my $host_passwd;
-my $untar_prefix;
+my $untar_prefix = "tar -C $restore_path -x";
# allow not-root user with own config
if ($ENV{USER} ne 'root' && $ENV{HOME} ne '/root') {
@@ -147,6 +147,20 @@ foreach (@ARGV) {
/--debug/ and $DEBUG = 1, next;
}
+sub getVarsFromSh {
+ my %l;
+ open(my $F, $_[0]) or return;
+ local $_;
+ while (<$F>) {
+ s/#.*//; # remove comments
+ s/^\s*//; # leading space
+ my ($v, $val) = /^(\w+)=(.*)/ or next;
+ $val = $1 if $val =~ /^"(.*)"$/ || $val =~ /^'(.*)'$/;
+ $l{$v} = $val;
+ }
+ %l;
+}
+
sub setup_tooltips() {
%help = (
'use_expect' => N("Expect is an extension to the Tcl scripting language that allows interactive sessions without user intervention."),
@@ -223,16 +237,13 @@ sub get_tape_info() {
my @line_data;
my $info = "$ENV{HOME}/tmp/dmesg";
@tape_devices = ();
- system("dmesg | grep 'st[0-9] at' > $info");
+ system("dmesg -s 100000 | grep 'st[0-9] at' > $info");
- local *INFO;
- open INFO, $info or warn("Can't open $info\n");
- local $_;
- while (<INFO>) {
+ my @info = cat_($info);
+ foreach (@info) {
@line_data = split(/[ \t,]+/, $_);
push @tape_devices, "/dev/" . $line_data[3];
}
- close INFO;
unlink($info);
}
@@ -246,8 +257,8 @@ sub get_free_space {
sub check_storage_quota {
my ($dir) = @_;
- my $used = `du $dir`;
- my $used_space = $used / 1024;
+ my $used = `du -b $dir`;
+ my $used_space = $used / 1024 / 1024;
if ($used_space > $conf{MAX_SPACE}) {
return $used_space;
} else {
@@ -310,7 +321,7 @@ sub get_cd_info() {
print "{$key}->{dvdr} = $cd_devices{$key}{dvdr}\n";
print "{$key}->{dvdram} = $cd_devices{$key}{dvdram}\n";
} else {
- delete $cd_devices{$key} if $cd_devices{$key}{rec_dev} eq ''
+ delete $cd_devices{$key} if $cd_devices{$key}{rec_dev} eq '';
}
}
}
@@ -392,7 +403,7 @@ sub save_cron_files() {
system("chmod +x /etc/cron.$conf{DAEMON_TIME_SPACE}/drakbackup");
}
if ($conf{DAEMON_TIME_SPACE} eq "custom" || !$backup_daemon) {
- my $newdetail = join(" ", $time_string, $exec_string, "\n") if $backup_daemon;
+ my $newdetail = $backup_daemon && join(" ", $time_string, $exec_string, "\n");
system("crontab -l | tail +4 > $tmpcron");
my @cronlines = cat_($tmpcron);
my $index = 0;
@@ -400,7 +411,7 @@ sub save_cron_files() {
if (/$exec_string/) {
splice(@cronlines, $index, 1);
}
- $index++
+ $index++;
}
push(@cronlines, $newdetail) if $backup_daemon;
output($tmpcron, @cronlines);
@@ -547,6 +558,7 @@ sub ftp_client() {
$ftp = 0;
}
return 1 if !$ftp;
+ $ftp->binary();
$ftp->cwd($conf{HOST_PATH});
foreach (@file_list_to_send_by_ftp) {
$interactive and $pbar->set_fraction(0);
@@ -728,9 +740,11 @@ sub check_for_cd() {
show_warning("f", N("Does not appear to be recordable media!"));
return 1;
}
- if ($log_buff =~ /Is not erasable/ && $conf{MEDIA_ERASE}) {
- show_warning("f", N("Not erasable media!"));
- return 1;
+ #- non-fatal, just disable erase
+ if (($log_buff =~ /Is not erasable/ || $log_buff =~ /Found DVD media/) && $conf{MEDIA_ERASE}) {
+ show_warning("w", N("Not erasable media!"));
+ $conf{MEDIA_ERASE} = 0;
+ save_conf_file();
}
if ($conf{MULTI_SESSION}) {
@@ -755,8 +769,8 @@ sub check_for_cd() {
sub write_on_cd() {
my $command = "cdrecord -v dev=$conf{CD_DEVICE} -data ";
- # DVD+RW use -dao
- $command .= "-dao " if $conf{DVDRW};
+ # DVD+RW use -sao
+ $command .= "-sao " if $conf{DVDRW};
#- only blank if it's the first session
$command .= "blank=fast " if $conf{MEDIA_ERASE} && $session_offset eq '';
#- multi-session mode
@@ -1029,7 +1043,7 @@ sub build_backup_files() {
my $list_file = name_list_file($incr . $user);
do_find($more_recent, $find_args_user, $list_file, $path_name);
if (check_rm_list($list_file)) {
- do_tar($tar_cmd_user, "backup_$incr$user", $list_file, undef);
+ do_tar($tar_cmd_cuser, "backup_$incr$user", $list_file, undef);
}
$first_done = 1;
} else {
@@ -1042,13 +1056,13 @@ sub build_backup_files() {
if (!$first_done) {
my $list_file = name_list_file($incr . $user);
do_find(undef, $find_args_user, $list_file, $path_name);
- do_tar($tar_cmd_user, "backup_$incr$user", undef, $path_name);
+ do_tar($tar_cmd_cuser, "backup_$incr$user", undef, $path_name);
}
- push_list("$incr$user") if $incr =~ /_user/;
+ push_list("list_$incr$user") if $incr =~ /_user/;
files_to_results("$incr$user");
}
}
- $interactive and progress($pbar2, $plabel1, 1, N("Backup User files..."));
+ $interactive and progress($pbar1, $plabel1, 1, N("Backup User files..."));
$interactive and progress($pbar3, $plabel3, 0.4, N("Hard Disk Backup files..."));
if ($conf{OTHER_FILES}) {
@@ -1078,12 +1092,12 @@ sub build_backup_files() {
if (!$first_done) {
my $list_file = name_list_file($incr);
do_find(undef, $find_args_other, $list_file, @other_files);
- do_tar($tar_cmd_user, "backup_$incr", undef, @other_files);
+ do_tar($tar_cmd_other, "backup_$incr", undef, @other_files);
}
push_list("list_$incr") if $incr =~ /_other/;
files_to_results($incr);
}
- $interactive and progress($pbar1, $plabel2, 1, N("Backup Other files..."));
+ $interactive and progress($pbar2, $plabel2, 1, N("Backup Other files..."));
$interactive and progress($pbar3, $plabel3, 0.3, N("Hard Disk Backup Progress..."));
}
@@ -1172,7 +1186,7 @@ sub build_backup_files() {
$catalog .= ":Users=(@user_list)" unless $conf{NO_USER_FILES};
$catalog .= ":I" if $conf{USER_INCREMENTAL_BACKUPS} && !$conf{NO_USER_FILES} && !$conf{USER_DIFFERENTIAL_BACKUPS};
$catalog .= ":D" if $conf{USER_INCREMENTAL_BACKUPS} && !$conf{NO_USER_FILES} && $conf{USER_DIFFERENTIAL_BACKUPS};
- $catalog .= ":F" if !$conf{USER_INCREMENTAL_BACKUPS} && !$conf{NO_USER_FILES};;
+ $catalog .= ":F" if !$conf{USER_INCREMENTAL_BACKUPS} && !$conf{NO_USER_FILES};
$catalog .= ":Other=(@other_files)" if $conf{OTHER_FILES};
$catalog .= ":I" if $conf{OTHER_INCREMENTAL_BACKUPS} && $conf{OTHER_FILES} && !$conf{OTHER_DIFFERENTIAL_BACKUPS};
$catalog .= ":D" if $conf{OTHER_INCREMENTAL_BACKUPS} && $conf{OTHER_FILES} && $conf{OTHER_DIFFERENTIAL_BACKUPS};
@@ -1239,6 +1253,8 @@ sub do_find {
#- $newer may be undef - if it's defined then "-cnewer $newer"
$newer = $conf{PATH_TO_SAVE} . "/" . $newer if defined($newer);
defined($newer) ? system("find @where -cnewer $newer $more_args > $into") : system("find @where $more_args > $into");
+ #- someone on club complained about perms being too open
+ chmod(0600, $into) if -e $into;
}
sub do_tar {
@@ -1246,6 +1262,8 @@ sub do_tar {
my $full_dest_file = $conf{PATH_TO_SAVE} . "/" . $dest_file . $the_time . "." . $conf{OPTION_COMP};
#- if $list_file is undefined, then use the @files list
defined($list_file) ? system("$tar_cmd -f $full_dest_file -T $list_file") : system("$tar_cmd -f $full_dest_file @files");
+ #- someone on club complained about perms being too open
+ chmod(0600, $full_dest_file) if -e $full_dest_file;
push_list($dest_file);
}
@@ -1254,7 +1272,7 @@ sub push_list {
my $filename = $conf{PATH_TO_SAVE} . "/" . $prefix . $the_time . ".";
$filename .= $conf{OPTION_COMP} if $prefix =~ /^backup/;
$filename .= "txt" if $prefix =~ /^list/;
- push @file_list_to_send_by_ftp, $filename;
+ push @file_list_to_send_by_ftp, $filename if -e $filename;
}
sub files_to_results {
@@ -1262,6 +1280,7 @@ sub files_to_results {
$results .= "\nfile: " . $conf{PATH_TO_SAVE} . "/backup_" . $basename . $the_time . "." . $conf{OPTION_COMP} . "\n\n";
$results .= cat_("$conf{PATH_TO_SAVE}/list_" . $basename . $the_time . ".txt");
$results .= "\nignored:\n" . $ignore_files_list . "\n" if $ignore_files_list;
+
}
sub handle_ignores {
@@ -1358,6 +1377,8 @@ sub filedialog_generic {
$$widget->set_text($file_dialog->get_filename);
} else {
my $file_name = $file_dialog->get_filename;
+ #- catch files and dirs with spaces
+ $file_name = '"' . $file_name . '"' if $file_name =~ / /;
if (!member($file_name, @other_files)) {
push(@other_files, $file_name);
$list_model->append_set(undef, $file_name);
@@ -1783,7 +1804,7 @@ sub advanced_where_cd {
foreach ([$check_cdrw_erase, \$conf{MEDIA_ERASE}], [$check_dvdrw, \$conf{DVDRW}], [$check_dvdr, \$conf{DVDR}], [$check_dvdram, \$conf{DVDRAM}], [$check_multisession, \$conf{MULTI_SESSION}]) {
my $ref = $_->[1];
- gtksignal_connect(gtkset_active($_->[0], $$ref), toggled => sub { $$ref = $$ref ? 0 : 1 })
+ gtksignal_connect(gtkset_active($_->[0], $$ref), toggled => sub { $$ref = $$ref ? 0 : 1 });
}
gtksignal_connect(gtkset_active($check_where_cd, $conf{USE_CD}), toggled => sub {
$conf{USE_CD} = $conf{USE_CD} ? 0 : 1;
@@ -1945,7 +1966,7 @@ sub advanced_where_hd {
1, new Gtk2::VBox(0, 6),
0, gtkset_size_request(gtkset_sensitive($save_path_entry = new Gtk2::Entry(), $conf{USE_HD}), 152, 20),
0, gtkset_sensitive($button = gtksignal_connect(Gtk2::Button->new, clicked => sub {
- filedialog_generic(N("Directory to save to"), \$save_path_entry)
+ filedialog_generic(N("Directory to save to"), \$save_path_entry);
}), $conf{USE_HD}),
),
0, new Gtk2::VBox(0, 6),
@@ -2156,7 +2177,7 @@ sub advanced_when() {
advanced_when();
});
if ($custom_cron) {
- $entry_crontab->set_text("$time_string $exec_string")
+ $entry_crontab->set_text("$time_string $exec_string");
}
$combo_minute_when->entry->signal_connect('changed', sub { combo_to_cron_string($combo_minute_when->get_history - 1, 0) });
@@ -2272,7 +2293,7 @@ sub advanced_box() {
sub wizard_step3() {
destroy_widget();
- my $no_device = 1 if $conf{USE_CD} && $conf{CD_DEVICE} eq '' || $conf{USE_TAPE} && $conf{TAPE_DEVICE} eq '' || $conf{USE_NET} && $conf{NET_PROTO} eq '';
+ my $no_device = $conf{USE_CD} && $conf{CD_DEVICE} eq '' || $conf{USE_TAPE} && $conf{TAPE_DEVICE} eq '' || $conf{USE_NET} && $conf{NET_PROTO} eq '' && 1;
if ($no_device) {
show_warning("f", N("Backup destination not configured..."));
wizard_step2();
@@ -2413,7 +2434,7 @@ sub wizard() {
} else {
@user_list = ();
}
- })
+ });
}
if (!$conf{NO_SYS_FILES} || !$conf{NO_USER_FILES} && @user_list) {
fonction_env(\$box2, \&wizard, \&interactive_mode_box, \&wizard_step2);
@@ -2580,7 +2601,7 @@ sub select_user_data_to_restore() {
@user_list_to_restore = ();
local $_;
- -d $path_to_find_restore and my @list_backup_tmp2 = grep { /^backup/ } all($path_to_find_restore);
+ my @list_backup_tmp2 = -d $path_to_find_restore && grep { /^backup/ } all($path_to_find_restore);
@list_tmp2 = @list_backup_tmp2;
foreach (@list_backup_tmp2) {
s/_base//gi;
@@ -2776,22 +2797,18 @@ sub restore_aff_result() {
button_box_ok_only();
$central_widget = \$do_restore;
$up_box->show_all;
-
}
sub return_path {
my ($username) = @_;
my $usr;
my $home_dir;
- my $passwdfile = "/etc/passwd";
- local *PASSWD;
- open(PASSWD, $passwdfile) or exit 1;
- while (defined(my $line = <PASSWD>)) {
+ my @passwords = cat_("/etc/passwd");
+ foreach my $line (@passwords) {
chomp($line);
($usr, $home_dir) = (split(/:/, $line))[0,5];
last if $usr eq $username;
}
- close(PASSWD);
return $home_dir;
}
@@ -2884,6 +2901,7 @@ sub restore_do() {
}
sub restore_do2() {
+ destroy_widget();
my $do_restore;
my $text = new Gtk2::TextView;
restore_state();
@@ -2964,7 +2982,7 @@ sub restore_step_user() {
if (!$check_user_to_restore{$name_complet}[1]) {
$check_user_to_restore{$name_complet}[1] = 1;
if (!any { /$name/ } @user_list_to_restore2) {
- push @user_list_to_restore2, $name_complet
+ push @user_list_to_restore2, $name_complet;
}
} else {
$check_user_to_restore{$name_complet}[1] = 0;
@@ -3071,7 +3089,8 @@ sub restore_step2() {
my $sys_exist;
my $user_exist;
local $_;
-
+ destroy_widget();
+
my $restore_info_path = $conf{PATH_TO_SAVE};
$restore_info_path = $path_to_find_restore if $conf{USE_HD} || $conf{USE_CD};
my $info_prefix = "backup";
@@ -3088,7 +3107,7 @@ sub restore_step2() {
$sys_exist = 0; $restore_sys = 0;
}
if (any { /_user_/ } grep { /^$info_prefix/ } all("$restore_info_path/")) {
- $user_exist = 1
+ $user_exist = 1;
} else {
$user_exist = 0; $restore_user = 0;
}
@@ -3143,7 +3162,7 @@ sub restore_step2() {
} else {
$next_widget = \&restore_do;
}
- })
+ });
}
gtksignal_connect(gtkset_active($check_restore_other_path, $restore_other_path), toggled => sub {
$restore_other_path = $restore_other_path ? 0 : 1;
@@ -3187,7 +3206,8 @@ sub find_files_to_restore() {
my @files_to_restore;
my $cat_entry;
my @catalog = cat_("$cfg_dir/drakbackup_catalog");
-
+ destroy_widget();
+
#- file info in tree view
my $model = Gtk2::TreeStore->new("Glib::String", "Gtk2::Gdk::Pixbuf", "Glib::Int");
my $file_list = Gtk2::TreeView->new_with_model($model);
@@ -3222,7 +3242,7 @@ sub find_files_to_restore() {
chop;
$model->append_set($list_entry, [ 0 => $_, 1 => $unselected, 2 => 0 ]);
}
- $match = 1
+ $match = 1;
}
}
show_warning("i", N("No matches found...")) if $match == 0;
@@ -3281,7 +3301,8 @@ sub catalog_restore {
my $cat_entry;
my @restore_files;
my $restore_path_entry;
-
+ destroy_widget();
+
#- catalog info in tree view
my $model = Gtk2::TreeStore->new("Glib::String");
my $tree_catalog = Gtk2::TreeView->new_with_model($model);
@@ -3411,7 +3432,7 @@ sub catalog_restore {
});
$button->add(gtkpack(new Gtk2::HBox(0,10), gtkcreate_img("ic82-dossier-32")));
button_box_restore();
- fonction_env(\$catalog_box, \&catalog_restore, \&restore_find_media_box, \&catalog_restore) if $call_method eq "need media";;
+ fonction_env(\$catalog_box, \&catalog_restore, \&restore_find_media_box, \&catalog_restore) if $call_method eq "need media";
fonction_env(\$catalog_box, \&catalog_restore, \&restore_box, \&catalog_restore) if $call_method eq "button";
$central_widget = \$catalog_box;
$up_box->show_all;
@@ -3612,6 +3633,7 @@ sub restore_ftp {
else { $ftp = Net::FTP->new($hostname, Debug => 0) or return 1 }
$ftp->login($username, $userpass);
$ftp->cwd($hostpath);
+ $ftp->binary();
my $wild_card = catalog_to_wildcard($cat_entry);
@@ -3693,9 +3715,12 @@ sub wildcard_to_tarfile {
sub file_to_tarfile {
my ($restore_file, $wildcard) = @_;
+ #- remove leading "/"
+ $restore_file = substr($restore_file, 1);
+ #- filename with spaces
+ $restore_file = "'" . $restore_file . "'" if $restore_file =~ / /;
my $tarfile = `grep -l $restore_file $conf{PATH_TO_SAVE}/*$wildcard.txt`;
chop $tarfile;
- $restore_file = substr($restore_file, 1);
$tarfile = basename($tarfile);
$tarfile =~ s/txt/$conf{OPTION_COMP}/;
$tarfile =~ s/list/backup/;
@@ -3727,7 +3752,7 @@ sub get_file_from_tape {
my $offset = find_tape_offset($cat_entry);
spawn_progress("mt -f $dev_path rewind", "Rewinding tape on $dev_path.");
spawn_progress("mt -f $dev_path fsf $offset", "Moving forward $offset file records.");
- spawn_progress("tar -C cfg_dir/restores -xf $dev_path", "Untarring from $dev_path to work directory.");
+ spawn_progress("tar -C $cfg_dir/restores -xf $dev_path", "Untarring from $dev_path to work directory.");
}
sub restore_box() {
@@ -3750,7 +3775,7 @@ sub restore_box() {
1, new Gtk2::VBox(0,10),
1, gtksignal_connect(Gtk2::Button->new(N("Search for files to restore")), clicked => sub {
button_box_file_restore();
- find_files_to_restore()
+ find_files_to_restore();
}),
1, gtksignal_connect(Gtk2::Button->new(N("Restore all backups")), clicked => sub {
button_box_restore();
@@ -3758,7 +3783,7 @@ sub restore_box() {
$restore_sys = 1;
$restore_other = 1;
$restore_user = 1;
- restore_do()
+ restore_do();
}),
1, gtksignal_connect(Gtk2::Button->new(N("Custom Restore")), clicked => sub {
button_box_restore();
@@ -3775,7 +3800,7 @@ sub restore_box() {
);
} else {
destroy_widget();
- restore_find_media_box(),
+ restore_find_media_box();
}
fonction_env(\$box2, \&restore_box, \&interactive_mode_box);
$central_widget = \$box2;
@@ -3820,7 +3845,7 @@ sub restore_find_media_box() {
gtksignal_connect(Gtk2::Button->new(N("Search for files to restore")), clicked => sub {
$box2->destroy;
button_box_file_restore();
- find_files_to_restore()
+ find_files_to_restore();
}),
),
new Gtk2::VBox(0, 5),
@@ -3874,6 +3899,10 @@ sub cbutton() {
0, gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&interactive_mode_box);
}
+sub cbuttonr() {
+ 0, gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&restore_box);
+}
+
sub ibutton {
my ($msg) = @_;
0, gtksignal_connect(Gtk2::Button->new($msg), clicked => \&interactive_mode_box);
@@ -3983,7 +4012,7 @@ sub button_box_restore_end() {
$button_box_tmp->destroy;
gtkpack($button_box,
$button_box_tmp = gtkpack_(new Gtk2::HButtonBox,
- cbutton(),
+ cbuttonr(),
hbutton(),
hspace(),
pbutton(),
@@ -4010,7 +4039,7 @@ sub button_box_restore() {
$button_box_tmp->destroy;
gtkpack($button_box,
$button_box_tmp = gtkpack_(new Gtk2::HButtonBox,
- cbutton(),
+ cbuttonr(),
hbutton(),
hspace(),
pbutton(),
@@ -4179,7 +4208,7 @@ sub build_backup_ftp_status() {
$table = gtkpack_(new Gtk2::VBox(0, 15),
1, N("Sending files by FTP"),
1, new Gtk2::VBox(0, 15),
- 1, create_packtable ({ col_spacings => 10, row_spacings => 5 },
+ 1, create_packtable({ col_spacings => 10, row_spacings => 5 },
[N("Sending files...")],
[""],
[ $plabel = new Gtk2::Label(' ') ],
diff --git a/perl-install/standalone/drakfont b/perl-install/standalone/drakfont
index 3b232919b..e5876d3ce 100755
--- a/perl-install/standalone/drakfont
+++ b/perl-install/standalone/drakfont
@@ -457,7 +457,7 @@ sub backend_mod() {
print "\nUninstall Specifics Fonts.........\n";
search_installed_fonts_full_path();
if ($interactive) { search_dir_font_uninstall_gi() }
- else { search_dir_font_uninstall() foreach @uninstall }
+ else { search_dir_font_uninstall($_) foreach @uninstall }
remove_fonts();
print "\nThe End............................\n";
}
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash
index 3101128fd..91cc3664b 100755
--- a/perl-install/standalone/draksplash
+++ b/perl-install/standalone/draksplash
@@ -126,18 +126,18 @@ my %boot_conf_frame = ('frame' => Gtk2::Frame->new(N("Configure bootsplash pictu
'quiet' => N("Make kernel message quiet by default"),
},
},
- 'pos' => [ 'tx 1',
- 'ty 1',
- 'tw 1',
- 'th 1',
- 'px 1',
- 'py 1',
- 'pw 1',
- 'ph 1',
+ 'pos' => [ 'tx',
+ 'ty',
+ 'tw',
+ 'th',
+ 'px',
+ 'py',
+ 'pw',
+ 'ph',
'pc',
'logo',
'quiet',
- 'annul',
+ # 'annul',
'prev',
'save',
'kill',
@@ -370,47 +370,49 @@ sub mk_frame {
my $u = create_packtable({ col_spacings => 10, row_spacings => 5 },
map {
my @widgets;
+ my $pos = $_;
#- look for label
- if ($ref->{widget}{label}{$1}) {
- my $w = $ref->{widgets}{label}{$1} = Gtk2::Label->new($ref->{widget}{label}{$1});
+ if ($ref->{widget}{label}{$pos}) {
+ my $w = $ref->{widgets}{label}{$pos} = Gtk2::Label->new($ref->{widget}{label}{$pos});
push @widgets, $w;
}
#- look for scale
- if ($ref->{widget}{scale}{$1}) {
- my $w = $ref->{widgets}{scale}{$1} = Gtk2::HScale->new($adj{$1} = Gtk2::Adjustment->new(0, 0, $scale_size{$1}, 1, 10, 0));
- $ref->{widgets}{scale}{$1}->set_digits(0);
+ if ($ref->{widget}{scale}{$pos}) {
+ my $w = $ref->{widgets}{scale}{$pos} = Gtk2::HScale->new($adj{$pos} = Gtk2::Adjustment->new(0, 0, $scale_size{$pos}, 1, 10, 0));
+ $ref->{widgets}{scale}{$pos}->set_digits(0);
push @widgets, $w;
}
- $adj{$1} and $adj{$1}->set_value($theme{boot_conf}{$1});
+ $adj{$pos} and $adj{$pos}->set_value($theme{boot_conf}{$pos});
#- look for combo
my @popdown;
- if ($ref->{widget}{combo}{$1}) {
- @popdown = @{$ref->{widget}{combo}{$1}};
- my $w = $ref->{widgets}{combo}{$1} = $ref->{widget}{extras}{$1}{noneditable} ? Gtk2::OptionMenu->new : Gtk2::Combo->new;
- $ref->{widgets}{combo}{$1}->set_popdown_strings(@popdown);
+ if ($ref->{widget}{combo}{$pos}) {
+ @popdown = @{$ref->{widget}{combo}{$pos}};
+ my $w = $ref->{widgets}{combo}{$pos} = $ref->{widget}{extras}{$pos}{noneditable} ? Gtk2::ComboBox->new_text : Gtk2::Combo->new;
+ $w->set_popdown_strings(@popdown);
+ $w->set_active(0) if $w->isa('Gtk2::ComboBox');
push @widgets, $w;
}
#- look for checkbox
- if ($ref->{widget}{check}{$1}) {
- my $w = $ref->{widgets}{check}{$1} = Gtk2::CheckButton->new($ref->{widget}{check}{$1});
- $ref->{widgets}{check}{$1}->set_active(1);
+ if ($ref->{widget}{check}{$pos}) {
+ my $w = $ref->{widgets}{check}{$pos} = Gtk2::CheckButton->new($ref->{widget}{check}{$pos});
+ $ref->{widgets}{check}{$pos}->set_active(1);
push @widgets, $w;
}
#- look for button
- if ($ref->{widget}{button}{$1}) {
- my $w = $ref->{widgets}{button}{$1} = Gtk2::Button->new($ref->{widget}{button}{$1});
+ if ($ref->{widget}{button}{$pos}) {
+ my $w = $ref->{widgets}{button}{$pos} = Gtk2::Button->new($ref->{widget}{button}{$pos});
@widgets ?
push @widgets, $w
: push @buttons, $w;
}
#- look for tooltips
- $ref->{widget}{tooltip}{$1} and tool_tip($1, \%$ref);
+ $ref->{widget}{tooltip}{$pos} and tool_tip($pos, \%$ref);
if_(@widgets, \@widgets);
} @{$ref->{pos}}
);
diff --git a/perl-install/standalone/drakupdate_fstab b/perl-install/standalone/drakupdate_fstab
index ab7878adc..c911f7055 100755
--- a/perl-install/standalone/drakupdate_fstab
+++ b/perl-install/standalone/drakupdate_fstab
@@ -83,6 +83,7 @@ sub device_name_to_entry {
} else {
$e->{device} = $name; #- keeping the exact name given (often is the devfs name)
}
+ $e->{media_type} = 'fd' if $name =~ /fd[01]/;
$e;
}
@@ -143,7 +144,10 @@ sub main {
set_mount_point($part, $fstab) or return;
my ($line) = fs::prepare_write_fstab([$part]);
- append_to_file($fstab_file, $line) if $line;
+ if ($line) {
+ append_to_file($fstab_file, $line);
+ system("mount $part->{mntpoint}") if !$::testing && $device_name =~ /^fd\d+/;
+ }
if ($::auto) {
print $part->{mntpoint}, " ", $useSupermount ? 'supermount' : 'user', "\n";
diff --git a/perl-install/standalone/drakups b/perl-install/standalone/drakups
index 9f55af292..ee6aeedb1 100755
--- a/perl-install/standalone/drakups
+++ b/perl-install/standalone/drakups
@@ -23,16 +23,25 @@ my ($w, $in); # GUI
my %indexes;
-sub writeconf {
+sub writeconf() {
info_dialog(N("Warning"), "Write support for users is incomplete\n\nIt lacks some support for some extra fields that would be lost else");
log::explanations("Updating NUT configuration accordingly");
$struct->writeConf($files{devices});
- log::explanations("Updating NUT users configuration accordingly");
- $users->writeConf($files{users});
+ if ($users) {
+ log::explanations("Updating NUT users configuration accordingly");
+ $users->writeConf($files{users});
+ }
+
+ require services;
+ services::restart("upsd");
}
-sub readDriversList {
+sub read_nut_config() {
+ $struct = Libconf::Glueconf::NUT::Ups_conf->new($files{devices})
+}
+
+sub readDriversList() {
my (%ups, @ups);
local $_;
foreach (cat_(first(glob("/usr/share/doc/nut-*/docs/driver.list")))) {
@@ -42,12 +51,14 @@ sub readDriversList {
driver => $driver,
extra => $extra,
};
- push @ups, "$vendor|$model";
+ push @ups, "$vendor|$model ($extra)";
}
}
\%ups, \@ups;
}
+my %models;
+
sub add_device_wizard {
my ($in, $config) = @_;
my ($ups_models, $model_list) = readDriversList();
@@ -63,7 +74,7 @@ sub add_device_wizard {
auto => N("Connected through a serial port or an usb cable"),
manual => N("Manual configuration"),
);
- my $method = $methods{manual};
+ my $method = $methods{auto};
$wiz = {
#defaultimage => "logdrake.png", # FIXME
name => N("Add an UPS device"),
@@ -71,14 +82,14 @@ sub add_device_wizard {
welcome => {
name => N("Welcome to the UPS configuration utility.
-Here, you'll be add a new UPS to your system.\n"),
+Here, you'll add a new UPS to your system.\n"),
no_back => 1,
next => 'method'
},
method => {
name => N("We're going to add an UPS device.
-Do you prefer autodetect UPS devices connected to this machine or ?"),
+Do you want to autodetect UPS devices connected to this machine or to manually select them?"),
data => [ { label => N("Autodetection"), val => \$method, type => "list",
list => [ values %methods ] } ],
post => sub { +{ reverse %methods }->{$method} },
@@ -87,7 +98,7 @@ Do you prefer autodetect UPS devices connected to this machine or ?"),
end => 1,
pre => sub {
local $::isWizard;
- my $wait = $in->wait_message(N("Please wait"), N("Detection in progress"));
+ my $_wait = $in->wait_message(N("Please wait"), N("Detection in progress"));
# UPS autoconfig:
detect_devices::probeSerialDevices() if !$::testing;
@new_devices = ();
@@ -95,10 +106,11 @@ Do you prefer autodetect UPS devices connected to this machine or ?"),
foreach my $ups_device (detect_devices::getUPS()) {
my $str = $ups_device->{name} || $ups_device->{DESCRIPTION};
$str =~ s/ /_/g;
+ $name = $str;
if (!exists $struct->{$str}) {
- $struct->{$str}{port} = $ups_device->{port} || $ups_device->{DEVICE};
- $struct->{$str}{driver} = $ups_device->{driver};
+ $port = $struct->{$str}{port} = $ups_device->{port} || $ups_device->{DEVICE};
+ $driver = $struct->{$str}{driver} = $ups_device->{driver};
push @new_devices, $str;
}
}
@@ -106,7 +118,7 @@ Do you prefer autodetect UPS devices connected to this machine or ?"),
name => sub {
if (@new_devices) {
N("Congratulations") . "\n\n" .
- N("The wizard successfully added the following UPS devices:", join("\n\n-", @new_devices))
+ N("The wizard successfully added the following UPS devices:") . join("\n\n-", @new_devices)
} else {
N("No new UPS devices was found");
}
@@ -117,9 +129,9 @@ Do you prefer autodetect UPS devices connected to this machine or ?"),
data => [ { label => N("Manufacturer / Model:"), val => \$ups, list => $model_list,
type => 'combo', sort => 1, separator => '|' }, ],
post => sub {
- ($vendor, $model) = split(/\|/, $ups);
+ ($vendor, $model) = ($1, $2) if $ups =~ /(.*)\|(.*) \(/;
($name, $driver, $port) = ("myups", $ups_models->{$vendor}{$model}{driver}, "");
- ($driver) = split(/\s*/, $driver);
+ ($driver) = split(/\s+/, $driver);
"driver";
},
},
@@ -131,7 +143,7 @@ Please fill in its name, its driver and its port.", $model, $vendor);
data => sub {
[
{ label => N("Name:"), val => \$name, help => N("The name of your ups") },
- { label => N("Driver:"), val => \$driver, help => N("The driver that manage your ups") },
+ { label => N("Driver:"), val => \$driver, help => N("The driver that manages your ups") },
{ label => N("Port:"), val => \$port, format => \&mouse::serial_port2text, type => "combo",
list => [ &mouse::serial_ports() ], not_edit => 0,
help => N("The port on which is connected your ups") },
@@ -154,6 +166,8 @@ Please fill in its name, its driver and its port.", $model, $vendor);
$config->{$name}{driver} = $driver;
$config->{$name}{port} = $port;
+ # refresh the GUI when needed:
+ $models{ups}->append_set(1 => $name, 2 => $driver, 3 => $port) if $models{ups};
log::explanations(qq(Configuring "$name" UPS));
}
@@ -206,19 +220,19 @@ sub edit_row {
}
-sub add_callback() {
- my ($model, $list, $getindex) = @_;
+sub add_callback {
+ my ($model, $_list, $_getindex) = @_;
edit_row($model);
}
-sub edit_callback() {
+sub edit_callback {
my ($model, $list) = @_;
my ($iter) = $list->get_selection->get_selected;
return unless $iter;
edit_row($model, $iter);
}
-sub del_callback() {
+sub del_callback {
my ($model, $list) = @_;
my (undef, $iter) = $list->get_selection->get_selected;
my $removed_idx = $list->get($iter, 0); # 1st column is index
@@ -239,13 +253,14 @@ my @pages = (
$::WizardWindow->destroy if defined $::WizardWindow;
undef $::WizardWindow;
},
- edit => sub { },
- remove => sub { },
+ edit => sub {},
+ remove => sub {},
},
load => sub {
- $struct = Libconf::Glueconf::NUT::Ups_conf->new($files{devices});
+ read_nut_config();
map { [ $_, @{$struct->{$_}}{qw(driver port)} ] } keys %$struct;
},
+ id => "ups",
},
{ name => N("UPS users"),
columns => [ N("Name") ],
@@ -254,35 +269,38 @@ my @pages = (
my ($name) = @_;
$users->{$name} = {};
},
- edit => sub { },
- remove => sub { },
+ edit => sub {},
+ remove => sub {},
},
load => sub {
$users = Libconf::Glueconf::NUT::Ups_conf->new($files{users});
map { [ $_ ] } keys %$users;
},
+ id => "users",
},
{ name => N("Access Control Lists"),
columns => [ N("Name"), N("IP address"), N("IP mask") ],
callbacks => {
- add => sub { },
- edit => sub { },
- remove => sub { },
+ add => sub {},
+ edit => sub {},
+ remove => sub {},
},
load => sub {
load_access_conf();
@acls;
},
+ id => "acls",
},
{ name => N("Rules"),
columns => [ N("Action"), N("Level"), N("ACL name"), N("Password") ],
callbacks => {
- N("Add") => sub { },
- N("Edit") => sub { },
- N("Remove") => sub { },
+ N("Add") => sub {},
+ N("Edit") => sub {},
+ N("Remove") => sub {},
},
load => sub { @rules }, # already loaded when we loaded acls
+ id => "rules",
},
);
@@ -294,6 +312,16 @@ my @pages = (
$in = 'interactive'->vnew;
$ugtk2::wm_icon = "drakups";
+
+$in->do_pkgs->ensure_is_installed('nut-server', '/etc/rc.d/init.d/upsd') if !$::testing;
+
+if (member('--wizard', @ARGV)) {
+ read_nut_config();
+ add_device_wizard($in, $struct);
+ writeconf();
+ $in->exit($@ ? 1 : 0);
+}
+
$w = ugtk2->new(N("DrakUPS"));
if (!$::isEmbedded) {
$::main_window = $w->{rwindow};
@@ -307,9 +335,9 @@ if (!$::isEmbedded) {
my $_msg = N("Welcome to the UPS configuration tools");
$w->{window}->add(gtkpack_(Gtk2::VBox->new,
- 0, Gtk2::Banner->new('drakups', N("DrakUPS")),
+ if_(!$::isEmbedded, 0, Gtk2::Banner->new('drakups', N("DrakUPS"))),
1, my $nb = Gtk2::Notebook->new,
- 0, create_okcancel( my $oc =
+ 0, create_okcancel(my $oc =
{
ok_clicked => sub {
#$_->{save}->() foreach @pages;
@@ -332,11 +360,11 @@ my %labels = (
);
foreach my $i (@pages) {
- my $model = Gtk2::ListStore->new("Glib::Int", ("Glib::String") x listlength(@{$i->{columns}}));
+ my $model = $models{$i->{id}} = Gtk2::ListStore->new("Glib::Int", ("Glib::String") x listlength(@{$i->{columns}}));
my (%buttons, $list);
$indexes{$i->{name}} = 0;
my $idx = \$indexes{$i->{name}};
- my $getindex = sub { ${$idx}++ };
+ my $getindex = sub { $$idx++ };
$nb->append_page(gtkpack_(Gtk2::VBox->new,
1, create_scrolled_window($list = Gtk2::TreeView->new_with_model($model),
[ 'automatic', 'automatic' ]),
@@ -348,7 +376,7 @@ foreach my $i (@pages) {
})
} ([ 'add', N("Add"), $i->{callbacks}{add} || \&add_callback ],
[ 'edit', N("Edit"), \&edit_callback ],
- [ 'remove', N("Remove"), \&del_callback],
+ [ 'remove', N("Remove"), \&del_callback ],
)
)
#(map {
@@ -380,6 +408,5 @@ foreach my $i (@pages) {
#------------------------------------------------------------------
# let's start the show:
-$in->do_pkgs->ensure_is_installed('nut-server', '/usr/sbin/upsd') if !$::testing;
$w->{rwindow}->show_all;
$w->main;
diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2
index 9afdcf78a..be8b2bbd2 100755
--- a/perl-install/standalone/harddrake2
+++ b/perl-install/standalone/harddrake2
@@ -78,6 +78,8 @@ my $conffile = "/etc/sysconfig/harddrake2/ui.conf";
my ($current_device, $current_configurator);
+my %sysh = distrib();
+my $distro_name = $sysh{system};
#-PO Translators, please keep all "/" charaters !!!
my %menus = (
@@ -103,7 +105,9 @@ my @menu_items =
[ join('', @{$menu_options{JAZZ_DETECTION}}), undef,
sub { $options{JAZZ_DETECTION} = $check_boxes{JAZZ_DETECTION}->get_active }, undef, '<CheckItem>' ],
[ $menus{help}, undef, undef, undef, '<Branch>' ],
- [ $menus{help}.N("/_Help"), undef, sub { unless (fork()) { exec("drakhelp --id harddrake") } }, undef, '<Item>' ],
+ if_(-x "/usr/sbin/drakhelp_inst",
+ [ $menus{help}.N("/_Help"), undef, sub { unless (fork()) { exec("drakhelp --id harddrake") } }, undef, '<Item>' ],
+ ),
[ $menus{help}.N("/_Fields description"), undef, sub {
if ($current_device) {
create_dialog(N("Harddrake help"),
@@ -117,12 +121,14 @@ my @menu_items =
},
undef, '<Item>'
],
- [ $menus{help}.N("/_Report Bug"), undef, sub { unless (fork()) { exec("drakbug --report harddrake2 &") } }, undef, '<Item>' ],
+ if_(!-e "/etc/sysconfig/oem",
+ [ $menus{help}.N("/_Report Bug"), undef, sub { unless (fork()) { exec("drakbug --report harddrake2 &") } }, undef, '<Item>' ],
+ ),
[ $menus{help}.N("/_About..."), undef, sub {
create_dialog(N("About Harddrake"),
#-PO Do not alter the <span ..> and </span> tags
- N("This is HardDrake, a Mandrake hardware configuration tool.\n<span foreground=\"royalblue3\">Version:</span> %s
-<span foreground=\"royalblue3\">Author:</span> Thierry Vignaud &lt;tvignaud\@mandrakesoft.com&gt;\n\n", $harddrake::data::version) . "\n" .
+ N("This is HardDrake, a %s hardware configuration tool.\n<span foreground=\"royalblue3\">Version:</span> %s
+<span foreground=\"royalblue3\">Author:</span> Thierry Vignaud &lt;tvignaud\@mandrakesoft.com&gt;\n\n", $distro_name, $harddrake::data::version) . "\n" .
formatAlaTeX($::license), { use_markup => 1, if_(!$::isEmbedded, transient => $w->{window}) });
}, undef, '<Item>'
]
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 7e323fb19..3863e0197 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -25,6 +25,7 @@ use lib qw(/usr/lib/libDrakX);
use strict;
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+use c;
use interactive;
use ugtk2 qw(:helpers :wrappers :create);
use common;
@@ -281,12 +282,15 @@ sub get_val() {
$a =~ s/^.*?\n.*?\n//;
$a =~ s/^\s*lo:.*?\n//;
my @line = split(/\n/, $a);
+ my @interfaces = c::get_netdevices();
map {
s/\s*(\w*)://;
my $intf = $1;
- $monitor->{$intf}{val} = [split()];
- $monitor->{$intf}{intf} = $intf;
- $intf;
+ if (member($intf, @interfaces)) {
+ $monitor->{$intf}{val} = [ split() ];
+ $monitor->{$intf}{intf} = $intf;
+ $intf;
+ } else { () }
} @line;
}
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index 42694f065..bb01d456f 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -1,9 +1,9 @@
#!/usr/bin/perl
#
-# Copyright (C) 2003-2004 MandrakeSoft
+# Copyright (C) 2003-2005 Mandriva
#
-# Till Kamppeter <till@mandrakesoft.com>
-# Daouda Lo <daouda@mandrakesoft.com>
+# Till Kamppeter <till at mandriva.com>
+# Daouda Lo <daouda at mandriva.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -20,6 +20,11 @@
#
use strict;
+
+# i18n: IMPORTANT: to get correct namespace (printerdrake instead of
+# libDrakX)
+BEGIN { unshift @::textdomains, 'drakconf' }
+
use lib qw(/usr/lib/libDrakX);
use standalone;
@@ -37,64 +42,55 @@ use Gtk2::Gdk::Keysyms;
use modules;
use c;
-my $companyname = "Mandrakesoft";
-my $distroname = "Mandrakelinux";
-my $domainname = "mandrakesoft.com";
+my %sysh = distrib();
+my $distroname = $sysh{system};
+
+my $domainname = "mandriva.com";
my $pixdir = '/usr/share/libDrakX/pixmaps/';
+my $refreshinterval = 5;
+
local $_ = join '', @ARGV;
my $printer;
+$ugtk2::wm_icon = "printerdrake";
my $in = 'interactive'->vnew('su', if_(!$::isEmbedded, 'printer-mdk'));
my $commandline = $_;
-exit 0 unless printer::printerdrake::first_time_dialog($printer, $in);
+# Suppress some wait messages to avoid windows popping up if no new print
+# queue has to be set up
+$commandline =~ /-onlyautoqueue/ and $::autoqueue = 1;
# Data structure for GTK2 main window
my $us = {};
-$us->{VERSION} = '0.1';
-
-# GTK2 splash screen
-my $window_splash;
-if (0 && !$::isInstall && !$::isEmbedded) {
- $window_splash = Gtk2::Window->new('popup');
-#BUG $window_splash->signal_connect(delete_event => \&quit_global);
- $window_splash->set_title(N("Printerdrake") . $us->{VERSION});
- $window_splash->set_position('center_always');
- $window_splash->add(gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'etched_out'),
- gtkpack(Gtk2::VBox->new(0, 0),
- gtkcreate_img("$pixdir/about.png"),
- Gtk2::Label->new(N("Loading printer configuration... Please wait"))
- )
- )
- );
- $window_splash->show_all;
- gtkflush();
-}
-
-#my $wait = $in->wait_message(N("Please wait"),
-# N("Loading printer configuration... "));
-#gtkflush();
+$us->{VERSION} = '2006';
# Check whether Foomatic is installed and install it if necessary
#printer::printerdrake::install_foomatic($in);
-my $w = $in->wait_message(N("Printerdrake"),
- N("Reading data of installed printers..."));
+my $w = $::autoqueue ||
+ $in->wait_message(N("Printerdrake"),
+ N("Reading data of installed printers..."));
# Get what was installed before
eval { $printer = printer::main::getinfo('') };
+undef $w;
+
+exit 0 unless printer::printerdrake::first_time_dialog($printer, $in, undef);
+
# Were we in expert mode last time?
$printer->{expert} = printer::main::get_usermode();
# Choose the spooler by command line options
-$commandline =~ /-expert/ and $printer->{expert} = 1;
+$::expert and $printer->{expert} = 1;
$commandline =~ /-cups/ and
$printer->{SPOOLER} = 'cups' and printer::main::read_configured_queues($printer);
+$commandline =~ /-rcups/ and
+ $printer->{SPOOLER} = 'rcups' and printer::main::read_configured_queues($printer);
$commandline =~ /-lpr/ and
$printer->{SPOOLER} = 'lpd' and printer::main::read_configured_queues($printer);
$commandline =~ /-lpd/ and
@@ -103,29 +99,32 @@ $commandline =~ /-lprng/ and
$printer->{SPOOLER} = 'lprng' and printer::main::read_configured_queues($printer);
$commandline =~ /-pdq/ and
$printer->{SPOOLER} = 'pdq' and printer::main::read_configured_queues($printer);
--r '/etc/modules.conf' and modules::mergein_conf('/etc/modules.conf');
-
-undef $w;
if ($::isInstall) {
# Interactive main window for installation
- printer::printerdrake::main($printer, $in, 1);
+ printer::printerdrake::main($printer, $::o->{security}, $in, 1, undef);
exit();
}
+require security::level;
+my $security = security::level::get();
+
# Do not let printerdrake ask for the spooler
$printer->{SPOOLER} ||= 'cups';
# Initialization
-printer::printerdrake::init($printer, $in);
+printer::printerdrake::init($printer, $security, $in, undef);
+
+# Stop here when we are supposed to only automatically set up print queues
+$commandline =~ /-onlyautoqueue/ and exit 0;
# GTK2 main window
-my $error = 0;
my $stringsearch = '';
-sub HelpSystem() { exec("drakhelp --id printerdrake") unless fork() };
+sub HelpSystem() { exec("drakhelp --id printerdrake") unless fork() }
+$::noborderWhenEmbedded = 1;
$us->{wnd} = ugtk2->new(N("%s Printer Management Tool", $distroname) . " " . $us->{VERSION});
gtkset_size_request($us->{wnd}{rwindow}, 660, 460);
@@ -133,13 +132,14 @@ if (!$::isEmbedded) {
$us->{wnd}{rwindow}->set_position('center');
}
$us->{wnd}{window}->signal_connect(delete_event => \&QuitGlobal);
-my $ltree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
-my $rtree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
+my $ltree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
+my $rtree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
my ($localtree, $remotetree);
$localtree = CreateTree($ltree_model);
$remotetree = CreateTree($rtree_model);
# slightly verbatimed from control-center
my %options = (
+ 'add' => [ N("/_Actions"), N("/_Add Printer") ],
'default' => [ N("/_Actions"), N("/Set as _Default") ],
'edit' => [ N("/_Actions"), N("/_Edit") ],
'delete' => [ N("/_Actions"), N("/_Delete") ],
@@ -168,15 +168,18 @@ my ($menu, $factory) = create_factory_menu($::isEmbedded ? $::Plug : $us->{wnd}{
%printer::main::thedb =
();
}, undef, '<CheckItem>' ],
+ [ N("/_Options") . N("/Configure _Auto Administration"), undef, \&ConfigAutoAdmin, undef, '<StockItem>', 'gtk-autoadmin' ],
[ N("/_Help"), undef, undef, undef, '<Branch>' ],
- [ N("/_Help").N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ],
- [ N("/_Help").N("/_Report Bug"), undef, sub { system("$ENV{BROWSER} https://qa.$domainname &") }, undef, '<StockItem>', 'gtk-stop' ],
- [ N("/_Help").N("/_About..."), undef, \&About, undef, '<StockItem>', 'gtk-preferences' ]
+ if_(-x "/usr/sbin/drakhelp_inst",
+ [ N("/_Help") . N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ],
+ ),
+ if_(!-e "/etc/sysconfig/oem",
+ [ N("/_Help") . N("/_Report Bug"), undef, sub { system("$ENV{BROWSER} https://qa.$domainname &") }, undef, '<StockItem>', 'gtk-stop' ],
+ ),
+ [ N("/_Help") . N("/_About..."), undef, \&About, undef, '<StockItem>', 'gtk-preferences' ]
)
);
-%buttorcheck = map {
- $_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}})
-}('default', 'edit', 'delete', 'expert');
+%buttorcheck = map { $_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}}) } ('add', 'default', 'edit', 'delete', 'expert');
if (defined $buttorcheck{expert}) {
$buttorcheck{expert}->set_active($printer->{expert});
@@ -190,80 +193,100 @@ my $searchBox = gtkpack_(Gtk2::HBox->new(0,5),
1, Gtk2::Label->new(""),
0, Gtk2::Label->new(N("Search:")),
0, gtksignal_connect($filter = Gtk2::Entry->new,
- key_press_event => sub { $_[1]->keyval == $Gtk2::Gdk::Keysyms{Return} and Refresh($filter->get_text) }),
+ key_press_event => sub { $_[1]->keyval == $Gtk2::Gdk::Keysyms{Return} and do { $stringsearch = $filter->get_text; Refresh($stringsearch) };}),
0, my $fbut = Gtk2::Button->new(N("Apply filter")),
);
gtkappend_page(my $nb = Gtk2::Notebook->new, gtkpack(create_scrolled_window($localtree)), gtkshow(Gtk2::Label->new(N("Configured on this machine"))));
gtkappend_page($nb, gtkpack(create_scrolled_window($remotetree)), gtkshow(Gtk2::Label->new(N("Configured on other machines"))));
$nb->set_show_border(0);
+
+my @extra_widgets;
+if ($::isEmbedded) {
+ push @extra_widgets, 0, Gtk2::Banner->new("/usr/share/mcc/themes/default/printer-mcc-mdk.png",
+ #-PO: do not translate, this is already translated in mcc
+ translate("Printers"));
+}
+
$us->{wnd}{window}->add(gtkpack_(Gtk2::VBox->new(0, 0),
0, $menu,
+ @extra_widgets,
0, $toolb,
0, $searchBox,
0, Gtk2::HSeparator->new,
1, $nb));
-my @lcolsize = (1, 1, 1, 1, 1, 1, -1);
-my @rcolsize = (1, 1, 1, 1, 1, -1);
+my @lcolsize = (1, 1, 1, 1, 1, 1, 1, -1);
+my @rcolsize = (1, 1, 1, 1, 1, 1, -1);
each_index {
my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i);
$col->set_sort_column_id($::i);
$col->set_min_width($lcolsize[$::i]);
$localtree->append_column($col);
-} (N("Def."), N("Printer Name"), N("Model"), N("Connection Type"), N("Description"), N("Location"));
+} (N("Def."), N("Printer Name"), N("State"), N("Model"), N("Connection Type"), N("Description"), N("Location"));
each_index {
my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i);
$col->set_sort_column_id($::i);
$col->set_min_width($rcolsize[$::i]);
$remotetree->append_column($col);
-} (N("Def."), N("Printer Name"), N("Server Name"), N("Description"), N("Location"));
+} (N("Def."), N("Printer Name"), N("State"), N("Server Name"), N("Description"), N("Location"));
my @toolbwg = map {
$toolb->append_item($_->[0], $_->[1], $_->[2],
Gtk2::Image->new_from_file($pixdir . $_->[2] . '.png'), $_->[3], $toolb);
# $toolb->append_space;
-#-PO "Add Printer" is a button text and the translation has to be AS SHORT AS POSSIBLE
-} ( [ N("Add Printer"), N("Add a new printer to the system"), 'printer_add', \&AddPrinter ],
-#-PO "Set as default" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Set as default"), N("Set selected printer as the default printer"), 'printer_default', \&SetAsDefault ],
-#-PO "Edit" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Edit"), N("Edit selected printer"), 'printer_conf', \&Edit ],
-#-PO "Delete" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Delete"), N("Delete selected printer"), 'printer_del', \&Delete ],
-#-PO "Refresh" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Refresh"), N("Refresh the list"), 'refresh', sub { Refresh($stringsearch) } ],
-#-PO "Configure CUPS" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Configure CUPS"), N("Configure CUPS printing system"), 'cups_config', \&ConfigCUPS ]
+} ([
+ # FIXME: then "add printer" should be a simple verb as suggested in Human Guidelines!!!
+ #-PO: "Add Printer" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Add Printer"), N("Add a new printer to the system"), 'printer_add', \&AddPrinter ],
+ [
+ #-PO: "Set as default" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Set as default"), N("Set selected printer as the default printer"), 'printer_default', \&SetAsDefault ],
+ [
+ #-PO: "Edit" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Edit"), N("Edit selected printer"), 'printer_conf', \&Edit ],
+ [
+ #-PO: "Delete" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Delete"), N("Delete selected printer"), 'printer_del', \&Delete ],
+ [
+ #-PO: "Refresh" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Refresh"), N("Refresh the list"), 'refresh', sub { Refresh($stringsearch) } ],
+ [
+ #-PO: "Configure CUPS" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Configure CUPS"), N("Configure CUPS printing system"), 'cups_config', \&ConfigCUPS ]
);
-my ($_tbadd, $tbdefault, $tbedit, $tbdel, $_tbref, $_tbconfig) = @toolbwg;
+my ($tbadd, $tbdefault, $tbedit, $tbdel, $_tbref, $_tbconfig) = @toolbwg;
GrayDelEdit();
+foreach ($tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups") }
+$localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups");
+$nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups";
$fbut->signal_connect('clicked', sub { $stringsearch = $filter->get_text; Refresh($stringsearch) });
Refresh($stringsearch);
$nb->signal_connect('switch-page' => sub { NotebookSwitch() });
$us->{wnd}{rwindow}->show_all;
set_selection($printer->{DEFAULT});
-#undef $wait;
-if (0 && !$::isInstall && !$::isEmbedded) {
- $window_splash->destroy;
- undef $window_splash;
-}
gtkset_mousecursor_normal();
# Prevent subwindows to embed themselves in the mcc which has already the
# main window embedded
+my $isEmbedded = $::isEmbedded;
local $::isEmbedded = 0;
-Gtk2->main;
+# Auto refresh
+my $refreshing = 0;
+Glib::Timeout->add($refreshinterval * 1000,
+ sub { Refresh($stringsearch); 1 });
+
+$us->{wnd}->main;
ugtk2->exit;
sub GrayDelEdit() {
- foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { defined $_ and $_->set_sensitive(0) };
+ foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { defined $_ and $_->set_sensitive(0) }
}
sub TreeUnselect {
my $treev = shift;
$treev->get_selection->unselect_all;
- GrayDelEdit()
+ GrayDelEdit();
}
sub NotebookSwitch() {
TreeUnselect($localtree);
@@ -272,38 +295,48 @@ sub NotebookSwitch() {
}
sub RefreshLocalPrintersFull {
- my ($strfilt) = @_;
+ my ($strfilt, @allprinters) = @_;
my @printers;
defined $printer and @printers = keys %{$printer->{configured}};
$ltree_model->clear;
+ return if $printer->{SPOOLER} eq "rcups";
my @LocalReal;
- LOOP: foreach my $p (@printers) {
+ foreach my $p (@printers) {
# Apply string search to all fields, not only the printer name
+ my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") :
+ ((any {
+ ($_->{queuename} eq $p) &&
+ ($_->{state} eq "enabled");
+ } @allprinters) ? N("Enabled") : N("Disabled")));
my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect});
my $model = $printer->{configured}{$p}{queuedata}{make} . ' ' .
$printer->{configured}{$p}{queuedata}{model};
my $description = $printer->{configured}{$p}{queuedata}{desc};
my $location = $printer->{configured}{$p}{queuedata}{loc};
- my $searchstr = "$p|$model|$connect|$description|$location";
- push(@LocalReal, $p) if $searchstr =~ /\Q$strfilt/i;
- };
+ my $searchstr = "$p|$state|$model|$connect|$description|$location";
+ push(@LocalReal, $p) if !$strfilt || ($searchstr =~ /\Q$strfilt/i);
+ }
foreach my $p (sort { lc($a) cmp lc($b) } @LocalReal) {
+ my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") :
+ ((any {
+ ($_->{queuename} eq $p) &&
+ ($_->{state} eq "enabled");
+ } @allprinters) ? N("Enabled") : N("Disabled")));
my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect});
my $description = $printer->{configured}{$p}{queuedata}{desc};
my $location = $printer->{configured}{$p}{queuedata}{loc};
my $model = $printer->{configured}{$p}{queuedata}{make} . ' ' .
$printer->{configured}{$p}{queuedata}{model};
my $default = ($p eq $printer->{DEFAULT} ? "X" : "");
- $ltree_model->append_set([ 0 => $default, 1 => $p, 2 => $model,
- 3 => $connect, 4 => $description,
- 5 => $location ]);
+ $ltree_model->append_set([ 0 => $default, 1 => $p, 2 => $state,
+ 3 => $model,
+ 4 => $connect, 5 => $description,
+ 6 => $location ]);
}
}
sub RefreshRemotePrintersFull {
- my ($strfilt) = @_;
- my @printers;
- defined $printer and @printers = printer::cups::lpstat_lpv();
+ my ($strfilt, @printers) = @_;
$rtree_model->clear;
my @RemoteReal;
LOOP: foreach my $p (@printers) {
@@ -311,38 +344,50 @@ sub RefreshRemotePrintersFull {
next LOOP if defined($printer->{configured}{$p->{queuename}});
# Apply string search to all fields, not only the printer name
my $queue = $p->{queuename};
- my $server = $p->{ipp};
+ my $state = ($p->{state} eq "enabled" ?
+ N("Enabled") : N("Disabled"));
+ my $server = $p->{ipp} || $printer->{remote_cups_server};
my $description = $p->{description};
my $location = $p->{location};
- my $searchstr = "$queue|$server|$description|$location";
+ my $searchstr = "$queue|$state|$server|$description|$location";
# All remaining to which the search term applies
- push(@RemoteReal, $p) if $searchstr =~ /\Q$strfilt/i;
- };
+ push(@RemoteReal, $p) if !$strfilt || ($searchstr =~ /\Q$strfilt/i);
+ }
foreach my $p (sort { lc($a->{queuename}) cmp lc($b->{queuename}) }
@RemoteReal) {
my $queue = $p->{queuename};
- my $server = $p->{ipp};
+ my $state = ($p->{state} eq "enabled" ?
+ N("Enabled") : N("Disabled"));
+ my $server = $p->{ipp} || $printer->{remote_cups_server};
my $description = $p->{description};
my $location = $p->{location};
my $default = ($queue eq $printer->{DEFAULT} ? "X" : "");
$rtree_model->append_set([ 0 => $default, 1 => $queue,
- 2 => $server, 3 => $description,
- 4 => $location ]);
+ 2 => $state, 3 => $server,
+ 4 => $description,
+ 5 => $location ]);
}
}
sub Refresh {
+ # Do not have ourselves recalled if we are already running
+ return if $refreshing;
+ $refreshing = 1;
my ($strfilt) = @_;
my $selection = get_selection();
- RefreshLocalPrintersFull($strfilt);
- RefreshRemotePrintersFull($strfilt);
+ printer::services::wait_for_cups() if ($printer->{SPOOLER} eq "cups");
+ my @printers;
+ defined $printer and @printers = printer::cups::lpstat_lpv();
+ RefreshLocalPrintersFull($strfilt, @printers);
+ RefreshRemotePrintersFull($strfilt, @printers);
GrayDelEdit();
set_selection($selection);
+ $refreshing = 0;
}
sub AddPrinter() {
deactivate_mainwindow();
- if (printer::printerdrake::add_printer($printer, $in)) {
+ if (printer::printerdrake::add_printer($printer, $in, undef)) {
Refresh($stringsearch);
set_selection($printer->{QUEUE});
} else {
@@ -386,7 +431,17 @@ sub Delete() {
sub ConfigCUPS() {
deactivate_mainwindow();
- printer::printerdrake::config_cups($printer, $in);
+ printer::printerdrake::config_cups($printer, $security, $in, undef);
+ foreach ($tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups") }
+ $localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups");
+ $nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups";
+ Refresh($stringsearch);
+ activate_mainwindow();
+}
+
+sub ConfigAutoAdmin() {
+ deactivate_mainwindow();
+ printer::printerdrake::config_auto_admin($printer, $in);
Refresh($stringsearch);
activate_mainwindow();
}
@@ -394,7 +449,6 @@ sub ConfigCUPS() {
sub deactivate_mainwindow() {
$us->{wnd}{rwindow}->set_sensitive(0);
gtkset_mousecursor_wait();
- $error = 0;
}
sub activate_mainwindow() {
@@ -466,7 +520,7 @@ sub GetNameEntFromIter {
my (undef, $iter) = $tree->get_selection->get_selected;
return undef if !defined($iter);
my $name = $model->get($iter, $rank);
- $name
+ $name;
}
sub CreateTree {
@@ -475,18 +529,39 @@ sub CreateTree {
$tree->get_selection->set_mode('browse');
$tree->set_headers_visible(1);
$tree->set_rules_hint(1);
- $tree->get_selection->signal_connect('changed' => sub { foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) } });
+ $tree->get_selection->signal_connect('changed' => sub {
+ my (undef, $_event) = @_;
+ my (undef, $iter) = $tree->get_selection->get_selected;
+ return unless $iter;
+ foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) }
+ my $queue = $tree_model->get($iter, 1);
+ if (!defined($printer->{configured}{$queue})) {
+ foreach ($tbdel, $buttorcheck{delete}) {
+ $_->set_sensitive(0);
+ }
+ }
+ if ($queue eq $printer->{DEFAULT}) {
+ foreach ($tbdefault, $buttorcheck{default}) {
+ $_->set_sensitive(0);
+ }
+ }
+ });
$tree->signal_connect(button_press_event => sub {
my (undef, $event) = @_;
my (undef, $iter) = $tree->get_selection->get_selected;
return unless $iter;
- foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) };
+ foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) }
my $queue = $tree_model->get($iter, 1);
if (!defined($printer->{configured}{$queue})) {
foreach ($tbdel, $buttorcheck{delete}) {
$_->set_sensitive(0);
}
}
+ if ($queue eq $printer->{DEFAULT}) {
+ foreach ($tbdefault, $buttorcheck{default}) {
+ $_->set_sensitive(0);
+ }
+ }
Edit() if $event->type eq '2button-press';
});
$tree->signal_connect(key_press_event => sub {
@@ -495,13 +570,13 @@ sub CreateTree {
return unless $iter;
Edit() if $event->keyval == $Gtk2::Gdk::Keysyms{Return};
});
- $tree
+ $tree;
}
sub NewDialog {
my ($title, $o_no_button) = @_;
my $dialog = gtkset_border_width(Gtk2::Dialog->new, 10);
- $dialog->set_transient_for($us->{wnd}{rwindow});
+ $dialog->set_transient_for($us->{wnd}{real_window});
$dialog->set_position('center-on-parent');
$dialog->set_title($title);
$dialog->action_area->pack_start(gtkadd(Gtk2::HButtonBox->new,
@@ -518,13 +593,18 @@ sub About() {
$list->can_focus(0);
each_index { $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => $::i)) } 0..2;
$list->set_headers_visible(0);
- foreach my $row ([ '', '', ''], [ N("Authors: "), 'Till Kamppeter', "<till\@$domainname>" ], ['', '', '']) {
+ foreach my $row ([ '', '', '' ], [ N("Authors: "), 'Till Kamppeter', "<till\@$domainname>" ], [ '', '', '' ]) {
$tree_model->append_set(undef, [ map_index { $::i => $_ } @$row ]);
}
$list->get_selection->set_mode('none');
gtkpack_($window_about->vbox,
-r "$pixdir/about-printerdrake.png" ?
- (0, Gtk2::Image->new_from_file("$pixdir/about-printerdrake.png")) : (1, gtkmodify_font(Gtk2::Label->new(N("Printer Management \n") . $us->{VERSION}), 'Bold 18'),),
+ (0, Gtk2::Image->new_from_file("$pixdir/about-printerdrake.png")) :
+ (1, gtkset_markup(Gtk2::Label->new,
+ qq(<span weight="bold" size="x-large">) .
+ #-PO: here %s is the version number
+ N("Printer Management %s", $us->{VERSION}) . "</span>"),
+ ),
1, $list,
);
$window_about->show_all;
diff --git a/perl-install/standalone/service_harddrake b/perl-install/standalone/service_harddrake
index 5c4ac6811..b12c5d3f3 100755
--- a/perl-install/standalone/service_harddrake
+++ b/perl-install/standalone/service_harddrake
@@ -5,6 +5,7 @@ use lib qw(/usr/lib/libDrakX);
use strict;
use diagnostics;
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+use c;
use common;
use interactive;
use detect_devices;
@@ -21,16 +22,25 @@ $last_boot_config .= '_X11' if $invert_do_it;
modules::mergein_conf('/etc/modules.conf');
+# autoreconfigure the mouse on major kernel change:
+my $prev_kernel = { getVarsFromSh("$hw_sysconfdir/kernel") }->{KERNEL};
+my $curr_kernel = c::kernel_version();
+$curr_kernel =~ s/(^\d+\.\d+).*/\1/;
+setVarsInSh("$hw_sysconfdir/kernel", { KERNEL => $curr_kernel });
+system("mousedrake --auto") if $curr_kernel ne $prev_kernel;
+
if (find { $_->{driver} =~ /Card:NVIDIA/ } detect_devices::probeall()) {
- if (find { -e join('', "/lib/modules/", c::kernel_version(), "/kernel/drivers/$_") } map { ("video/$_", "char/$_") } qw(NVdriver nvidia.o nvidia.o.gz nvidia.ko nvidia.ko.gz)) {
- log::explanations("switch XFree86 driver from nv to nvidia");
- substInFile { s!Driver "nv.*"!Driver "nvidia"!g; s!#*( Load.*glx)!\1!g } $_ foreach "/etc/X11/XF86Config-4", "/etc/X11/XF86Config";
+ if (find { -e join('', "/lib/modules/", c::kernel_version(), "/kernel/drivers/$_") } map { ("video/$_", "char/$_", "char/drm/$_") } qw(NVdriver nvidia.o nvidia.o.gz nvidia.ko nvidia.ko.gz)) {
+ # log::explanations("switch XFree86 driver from nv to nvidia");
+ # substInFile { s!Driver "nv.*"!Driver "nvidia"!g; s!#*( Load.*glx)!\1!g } $_ foreach "/etc/X11/XF86Config-4", "/etc/X11/XF86Config";
} else {
log::explanations("switch XFree86 driver from nvidia to nv");
substInFile { s!Driver "nv.*"!Driver "nv"!g; s!([^#]Load.*glx)!#\1!g } $_ foreach "/etc/X11/XF86Config-4", "/etc/X11/XF86Config";
}
}
+my $is_globetrotter = -f '/usr/sbin/mdkmove';
+
# first run ? if not read old hw config
my $previous_config = -f $last_boot_config && -s $last_boot_config ? Storable::retrieve($last_boot_config) : {};
$previous_config = $$previous_config if ref($previous_config) !~ /HASH/;
@@ -52,7 +62,7 @@ foreach my $hw_class (@harddrake::data::tree) {
$id => $i;
} eval { &$detector };
$config{$Ident} = \%ID;
- next if is_empty_hash_ref $previous_config; # don't fsck on first run
+ next if !$is_globetrotter && is_empty_hash_ref $previous_config; # don't fsck on first run
my $oldconfig = $previous_config->{$Ident};
@@ -66,15 +76,14 @@ foreach my $hw_class (@harddrake::data::tree) {
$msg .= N("Some devices were added: %s\n", $item) if @added;
$msg .= N("- %s was added\n", harddrake::data::custom_id($ID{$_}, $item)) foreach @added;
log::explanations("removed $Ident: " . harddrake::data::custom_id($oldconfig->{$_}, $item)) foreach @was_removed;
- log::explanations("added $Ident: " . harddrake::data::custom_id($oldconfig->{$_}, $item)) foreach @added;
+ log::explanations("added $Ident: " . harddrake::data::custom_id($ID{$_}, $item)) foreach @added;
modules::load('ohci1394') if $Ident eq 'FIREWIRE_CONTROLLER' && any { $_->{driver} eq 'ohci1394' } @added;
@added || @was_removed or next;
- $splash and !system('echo verbose > /proc/splash') and $splash = 0;
my @configurator_pool;
if (harddrake::data::is_removable($Ident)) {
foreach my $device (@ID{@added}) {
- push @configurator_pool, harddrake::data::set_removable_configurator($Ident, $device);
+ push @configurator_pool, harddrake::data::set_removable_auto_configurator($Ident, $device);
};
foreach my $device (@$oldconfig{@was_removed}) {
push @configurator_pool, harddrake::data::set_removable_remover($Ident, $device);
@@ -96,13 +105,19 @@ foreach my $hw_class (@harddrake::data::tree) {
} elsif ($Ident eq "AGP") {
# add agpgart modules to modprobe.preload if needed:
modules::write_conf();
+ } elsif ($Ident eq "VIDEO") {
+ require harddrake::autoconf;
+ harddrake::autoconf::xconf();
+ undef @configurator_pool;
}
+ next if $is_globetrotter && $configurator_pool[0] !~ /drakupdate_fstab/;
next unless -x first(split /\s+/, $configurator_pool[0]);
my ($pid, $no, $res);
if (!$hw_class->{automatic}) {
$SIG{ALRM} = sub { $no = 1; kill 15, $pid };
unless ($pid = fork()) {
+ $splash and !system('echo verbose > /proc/splash') and $splash = 0;
exec("/usr/share/harddrake/confirm", $Ident, $timeout, $msg);
}
alarm($timeout);