aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/install/helper/iohandler/cli_iohandler.php')
0 files changed, 0 insertions, 0 deletions
log/perl-install/standalone'>
path: root/perl-install/standalone
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
commit126777bc019a54afb4ec51299f2cf9d2841698aa (patch)
tree97f76e571902ead55ba138f1156a4b4f00b9b779 /perl-install/standalone
parentf1f67448efc714873378dfeb8279fae68054a90a (diff)
downloaddrakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.gz
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.bz2
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.xz
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.zip
re-sync after the big svn loss
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-xperl-install/standalone/autosetupprintqueues100
-rwxr-xr-xperl-install/standalone/bootloader-config46
-rwxr-xr-xperl-install/standalone/diskdrake7
-rwxr-xr-xperl-install/standalone/drakTermServ2198
-rwxr-xr-xperl-install/standalone/drakautoinst7
-rwxr-xr-xperl-install/standalone/drakbackup4580
-rwxr-xr-xperl-install/standalone/drakboot80
-rwxr-xr-xperl-install/standalone/drakbug54
-rwxr-xr-xperl-install/standalone/drakclock123
-rw-r--r--perl-install/standalone/drakedm5
-rwxr-xr-xperl-install/standalone/drakfloppy64
-rwxr-xr-xperl-install/standalone/drakfont171
-rw-r--r--perl-install/standalone/drakhelp4
-rwxr-xr-xperl-install/standalone/drakperm112
-rwxr-xr-xperl-install/standalone/drakpxe510
-rwxr-xr-xperl-install/standalone/draksec86
-rwxr-xr-xperl-install/standalone/draksound6
-rwxr-xr-xperl-install/standalone/draksplash101
-rw-r--r--perl-install/standalone/draksplash2306
-rwxr-xr-xperl-install/standalone/drakupdate_fstab18
-rwxr-xr-xperl-install/standalone/drakups6
-rwxr-xr-xperl-install/standalone/drakxtv84
-rwxr-xr-xperl-install/standalone/fileshareset4
-rwxr-xr-xperl-install/standalone/finish-install85
-rwxr-xr-xperl-install/standalone/finish-install.xsetup3
-rwxr-xr-xperl-install/standalone/harddrake2141
-rw-r--r--perl-install/standalone/icons/IC-Dhost-48.pngbin3443 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/IC-NFS-48.pngbin2643 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/IC-sambaprt-16.pngbin926 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/IC-winacces1-48.pngbin2992 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/IC-winacces2-16.pngbin982 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/drakbug-16.pngbin0 -> 582 bytes
-rw-r--r--perl-install/standalone/icons/drakconnect.pngbin4854 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/drakfirewall.pngbin3052 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/drakgw.pngbin3391 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle-16.pngbin0 -> 886 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle-24.pngbin0 -> 1768 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle-32.pngbin0 -> 2423 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle-52.pngbin0 -> 3656 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle-64.pngbin0 -> 6564 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle.pngbin0 -> 4361 bytes
-rw-r--r--perl-install/standalone/icons/drakmenustyle_128.pngbin0 -> 14540 bytes
-rw-r--r--perl-install/standalone/icons/draksound-16.pngbin0 -> 559 bytes
-rw-r--r--perl-install/standalone/icons/draksplash-16.pngbin0 -> 763 bytes
-rw-r--r--perl-install/standalone/icons/drakvpn.pngbin3313 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/drakwizard-16.pngbin0 -> 740 bytes
-rw-r--r--perl-install/standalone/icons/fileopen.xpm34
-rw-r--r--perl-install/standalone/icons/find.xpm34
-rw-r--r--perl-install/standalone/icons/findf.xpm31
-rw-r--r--perl-install/standalone/icons/ftin.xpm30
-rw-r--r--perl-install/standalone/icons/ftout.xpm30
-rw-r--r--perl-install/standalone/icons/hwapplet-16.pngbin0 -> 503 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet-24.pngbin0 -> 774 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet-32.pngbin0 -> 1235 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet-52.pngbin0 -> 2070 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet-64.pngbin0 -> 2823 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet.pngbin0 -> 1953 bytes
-rw-r--r--perl-install/standalone/icons/hwapplet_128.pngbin0 -> 7002 bytes
-rw-r--r--perl-install/standalone/icons/ic82-CD-40.pngbin3436 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-back-up-48.pngbin4565 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-discdurwhat-40.pngbin2023 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-dossier-32.pngbin1858 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-moreoption-40.pngbin2354 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-others-40.pngbin2023 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-system-40.pngbin2370 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-users-40.pngbin1638 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-when-40.pngbin2933 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/ic82-where-40.pngbin2514 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/printerdrake.pngbin1602 -> 0 bytes
-rw-r--r--perl-install/standalone/icons/reload.xpm31
-rwxr-xr-xperl-install/standalone/interactive_http/interactive_http.cgi4
-rw-r--r--perl-install/standalone/interactive_http/miniserv.pam8
-rwxr-xr-xperl-install/standalone/listsupportedprinters64
-rwxr-xr-xperl-install/standalone/logdrake22
-rwxr-xr-xperl-install/standalone/lsnetdrake6
-rw-r--r--perl-install/standalone/man/C/man5/drakbackup.542
-rw-r--r--perl-install/standalone/man/C/man5/drakbackup.conf.5193
-rw-r--r--perl-install/standalone/man/C/man8/drakconnect.8109
-rw-r--r--perl-install/standalone/po/Makefile38
-rw-r--r--perl-install/standalone/po/af.po3367
-rw-r--r--perl-install/standalone/po/am.po3151
-rw-r--r--perl-install/standalone/po/ar.po3364
-rw-r--r--perl-install/standalone/po/az.po3332
-rw-r--r--perl-install/standalone/po/be.po3160
-rw-r--r--perl-install/standalone/po/bg.po3214
-rw-r--r--perl-install/standalone/po/bn.po3379
-rw-r--r--perl-install/standalone/po/br.po3232
-rw-r--r--perl-install/standalone/po/bs.po3398
-rw-r--r--perl-install/standalone/po/ca.po3367
-rw-r--r--perl-install/standalone/po/cs.po3389
-rw-r--r--perl-install/standalone/po/cy.po3399
-rw-r--r--perl-install/standalone/po/da.po3403
-rw-r--r--perl-install/standalone/po/de.po3438
-rw-r--r--perl-install/standalone/po/el.po3275
-rw-r--r--perl-install/standalone/po/eo.po3165
-rw-r--r--perl-install/standalone/po/es.po3429
-rw-r--r--perl-install/standalone/po/et.po3381
-rw-r--r--perl-install/standalone/po/eu.po3406
-rw-r--r--perl-install/standalone/po/fa.po3386
-rw-r--r--perl-install/standalone/po/fi.po3396
-rw-r--r--perl-install/standalone/po/fr.po3516
-rw-r--r--perl-install/standalone/po/fur.po3152
-rw-r--r--perl-install/standalone/po/ga.po3160
-rw-r--r--perl-install/standalone/po/gl.po3398
-rw-r--r--perl-install/standalone/po/he.po3330
-rw-r--r--perl-install/standalone/po/hi.po3297
-rw-r--r--perl-install/standalone/po/hr.po3235
-rw-r--r--perl-install/standalone/po/hu.po3403
-rw-r--r--perl-install/standalone/po/id.po3410
-rw-r--r--perl-install/standalone/po/is.po3392
-rw-r--r--perl-install/standalone/po/it.po3422
-rw-r--r--perl-install/standalone/po/ja.po3376
-rw-r--r--perl-install/standalone/po/ko.po3185
-rw-r--r--perl-install/standalone/po/ky.po3261
-rw-r--r--perl-install/standalone/po/libDrakX-standalone.pot3150
-rw-r--r--perl-install/standalone/po/lt.po3163
-rw-r--r--perl-install/standalone/po/ltg.po3216
-rw-r--r--perl-install/standalone/po/lv.po3212
-rw-r--r--perl-install/standalone/po/mk.po3338
-rw-r--r--perl-install/standalone/po/mn.po3183
-rw-r--r--perl-install/standalone/po/ms.po3185
-rw-r--r--perl-install/standalone/po/mt.po3379
-rw-r--r--perl-install/standalone/po/nb.po3412
-rw-r--r--perl-install/standalone/po/nl.po3426
-rw-r--r--perl-install/standalone/po/nn.po3263
-rw-r--r--perl-install/standalone/po/pa_IN.po3336
-rw-r--r--perl-install/standalone/po/pl.po3425
-rw-r--r--perl-install/standalone/po/pt.po3429
-rw-r--r--perl-install/standalone/po/pt_BR.po3431
-rw-r--r--perl-install/standalone/po/ro.po3220
-rw-r--r--perl-install/standalone/po/ru.po3407
-rw-r--r--perl-install/standalone/po/sc.po3181
-rw-r--r--perl-install/standalone/po/sk.po3408
-rw-r--r--perl-install/standalone/po/sl.po3406
-rw-r--r--perl-install/standalone/po/sq.po3364
-rw-r--r--perl-install/standalone/po/sr.po3285
-rw-r--r--perl-install/standalone/po/sr@Latn.po3286
-rw-r--r--perl-install/standalone/po/sv.po3420
-rw-r--r--perl-install/standalone/po/ta.po3191
-rw-r--r--perl-install/standalone/po/tg.po3425
-rw-r--r--perl-install/standalone/po/th.po3168
-rw-r--r--perl-install/standalone/po/tl.po3398
-rw-r--r--perl-install/standalone/po/tr.po3275
-rw-r--r--perl-install/standalone/po/uk.po3402
-rw-r--r--perl-install/standalone/po/uz.po3228
-rw-r--r--perl-install/standalone/po/uz@Latn.po3233
-rw-r--r--perl-install/standalone/po/vi.po3381
-rw-r--r--perl-install/standalone/po/wa.po3425
-rw-r--r--perl-install/standalone/po/zh_CN.po3326
-rw-r--r--perl-install/standalone/po/zh_TW.po3299
-rwxr-xr-xperl-install/standalone/printerdrake616
-rwxr-xr-xperl-install/standalone/scannerdrake62
-rwxr-xr-xperl-install/standalone/service_harddrake52
-rw-r--r--perl-install/standalone/service_harddrake.sh2
154 files changed, 236562 insertions, 9591 deletions
diff --git a/perl-install/standalone/autosetupprintqueues b/perl-install/standalone/autosetupprintqueues
deleted file mode 100755
index 2f9af40a2..000000000
--- a/perl-install/standalone/autosetupprintqueues
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2003-2005 Mandriva
-#
-# Till Kamppeter <till@mandrakesoft.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
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-
-use strict;
-use lib qw(/usr/lib/libDrakX);
-use standalone;
-use printer::printerdrake;
-use printer::main;
-
-# Read mode in which we will run
-my $commandline = join('', @ARGV);
-$commandline =~ /-(auto|nogui|gui|waitforgui)\b/;
-my $gui = $1;
-$gui ||= "auto";
-
-$gui = "nogui" if (! -x "/usr/X11R6/bin/X");
-
-if ($gui ne "nogui") {
- # Auto-detect whether we go in non-X mode or not
- my $desktopuser;
- $desktopuser = `cat /var/run/console.lock 2>/dev/null` or
- $desktopuser = `cat /var/run/console/console.lock 2>/dev/null`;
- if (!$desktopuser) {
- if ($gui eq "auto") {
- # Non-X mode
- $gui = "nogui";
- } elsif ($gui eq "waitforgui") {
- # Wait until a user logs in on the system's X console
- while (!($desktopuser = `cat /var/run/console.lock 2>/dev/null`)) {
- sleep(5);
- }
- # Wait for the window manager to start
- sleep(10);
- $gui = "gui";
- } else {
- # "gui" was requested but no user logged in
- die "Cannot start in '--gui' mode, no user logged in!\n";
- }
- } else {
- # X mode (a user is logged in)
- $gui = "gui";
- }
-
- if ($gui eq "gui") {
- # Allow root's windows to be opened on the user's display and
- # start printerdrake then, in a mode to do nothing else than
- # automatically setting up print queues.
- my $userhome =
- `getent passwd $desktopuser|awk -F: '{print \$6}' 2>&1`;
- chomp $userhome;
- my $errfile = "/dev/null";
- if (-r "$userhome/.Xauthority") {
- system "export DISPLAY=\":0.0\"; export USER=$desktopuser; [ -r /etc/sysconfig/i18n ] >> $errfile 2>&1 && for l in `cat /etc/sysconfig/i18n`; do export \$l; done >> $errfile 2>&1; [ -r $userhome/.i18n ] >> $errfile 2>&1 && for l in `cat $userhome/.i18n`; do export \$l; done >> $errfile 2>&1; export XAUTHORITY=$userhome/.Xauthority; /usr/sbin/printerdrake --onlyautoqueue >> $errfile 2>&1;";
- } else {
- system "export DISPLAY=\":0.0\"; export USER=$desktopuser; [ -r /etc/sysconfig/i18n ] >> $errfile 2>&1 && for l in `cat /etc/sysconfig/i18n`; do export \$l; done >> $errfile 2>&1; [ -r $userhome/.i18n ] >> $errfile 2>&1 && for l in `cat $userhome/.i18n`; do export \$l; done >> $errfile 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost +localhost >> $errfile 2>&1\"; /usr/sbin/printerdrake --onlyautoqueue >> $errfile 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost -localhost >> $errfile 2>&1\"";
- }
- exit 0;
- }
-}
-
-# Data structure for printer data
-my $printer;
-
-# Dummy variable needed to call the subroutines of the printerdrake.pm
-# module. The real data structure is not needed for non-interactive
-# non-X mode
-my $in;
-
-# Run the subroutines of printerdrake.pm in non-interactive non-X mode
-$::noX = 1;
-
-# Subroutines of printerdrake.pm used for automatic setup of print queues
-$::autoqueue = 1;
-
-# Do not let printerdrake ask for the spooler
-$printer->{SPOOLER} ||= 'cups';
-
-# Get info about already installed print queues
-eval { $printer = printer::main::getinfo('') };
-
-# Run the automatic, non-interactive print queue setup of printerdrake
-printer::printerdrake::init($printer, $in);
-
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config
index 5a08d4be3..60afecd16 100755
--- a/perl-install/standalone/bootloader-config
+++ b/perl-install/standalone/bootloader-config
@@ -7,6 +7,8 @@ use common;
use bootloader;
$::isStandalone = 1; #- not using standalone which messes with @ARGV and usage
+c::openlog('bootloader-config' . "[$$]");
+
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
my %options = (
@@ -35,9 +37,11 @@ usage: bootloader-config --action add-kernel (--image <vmlinuz> | --kernel-versi
bootloader-config --action update-splash
bootloader-config --action remove-splash
+
+ bootloader-config --action rebuild-initrds
EOF
-my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash detectloader add-entry remove-entry);
+my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash rebuild-initrds detectloader add-entry remove-entry add-resume2);
$action && member($action, @known_actions) or die "<action> must be one of " . join(' ', @known_actions) . "\n";
if ($image) {
@@ -74,6 +78,7 @@ sub remove_now_broken_boot_symlinks() {
}
sub remove_kernel() {
unlink "/lib/modules/$kernel_version/build";
+ unlink "/lib/modules/$kernel_version/source";
remove_now_broken_boot_symlinks();
my %proposed_labels;
@@ -124,7 +129,7 @@ sub add_kernel() {
root => fs::wild_device::from_part('', $root_part),
initrd_options => $initrd_options,
if_($label, label => $label),
- if_($bootloader->{default_vga}, vga => $bootloader->{default_vga}),
+ (grep_each { member($::a, 'vga', 'lock') } %{$bootloader->{default_options}}),
);
#- short name
bootloader::add_kernel($bootloader, $kernel_str, { %opts }, 0, $no_initrd) if !$no_short_name;
@@ -157,24 +162,43 @@ sub add_entry() {
modify_bootloader();
}
-sub remove_entry() {
+sub _get_entry() {
listlength(grep { $_ } $label, $image, $chainload) == 1 or die "you must give one of --label, --image and --chainload\n";
- my $e = $label ? bootloader::get_label($label, $bootloader) :
- find { $_->{kernel_or_dev} && $_->{kernel_or_dev} eq ($image || $chainload) } @{$bootloader->{entries}};
+ $label ? bootloader::get_label($label, $bootloader) :
+ find { $_->{kernel_or_dev} && $_->{kernel_or_dev} eq ($image || $chainload) } @{$bootloader->{entries}};
+}
- if ($e) {
- @{$bootloader->{entries}} = grep { $_ != $e } @{$bootloader->{entries}};
- }
+sub remove_entry() {
+ my $e = _get_entry() or return;
+ @{$bootloader->{entries}} = grep { $_ != $e } @{$bootloader->{entries}};
modify_bootloader();
}
+sub add_resume2() {
+ my $e = _get_entry() or return;
+
+ my ($simple, $dict) = bootloader::unpack_append($e->{append});
+ if (my $resume = find { $_->[0] eq 'resume' } @$dict) {
+ if (!any { $_->[0] eq 'resume2' } @$dict) {
+ push @$dict, [ resume2 => "swap:$resume->[1]" ];
+ $e->{append} = bootloader::pack_append($simple, $dict);
+
+ modify_bootloader();
+ }
+ }
+}
+
+#-###############################################################################
+sub rebuild_initrds() {
+ bootloader::rebuild_initrds($bootloader);
+ bootloader::action($bootloader, 'when_config_changed') if !$no_launch;
+}
+
#-###############################################################################
sub update_splash() {
- foreach (@{$bootloader->{entries}}) {
- bootloader::add_boot_splash($_->{initrd}, $_->{vga}) if $_->{initrd};
- }
+ bootloader::update_splash($bootloader);
bootloader::action($bootloader, 'when_config_changed') if !$no_launch;
}
diff --git a/perl-install/standalone/diskdrake b/perl-install/standalone/diskdrake
index a3f2cb74f..a1c09ccd0 100755
--- a/perl-install/standalone/diskdrake
+++ b/perl-install/standalone/diskdrake
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# DiskDrake
-# Copyright (C) 1999-2005 Mandriva (pixel@mandrakesoft.com)
+# Copyright (C) 1999-2006 Mandriva (pixel@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -90,8 +90,7 @@ if ($type eq 'list-hd') {
partition_table::write($hd);
} elsif ($type eq 'hd') {
require diskdrake::interactive;
- diskdrake::interactive::main($in, $all_hds, 0, '', sub {
- exec("drakhelp --id diskdrake") unless fork() });
+ diskdrake::interactive::main($in, $all_hds, '');
} elsif ($type eq 'removable') {
require diskdrake::removable;
my ($raw_hd) = $para ?
@@ -100,7 +99,7 @@ if ($type eq 'list-hd') {
if (!$raw_hd->{mntpoint}) {
my $mntpoint = detect_devices::suggest_mount_point($raw_hd);
- $raw_hd->{mntpoint} ||= find { !fs::get::has_mntpoint($_, $all_hds) } map { "/mnt/$mntpoint$_" } '', 2 .. 10;
+ $raw_hd->{mntpoint} ||= find { !fs::get::has_mntpoint($_, $all_hds) } map { "/media/$mntpoint$_" } '', 2 .. 10;
$raw_hd->{is_removable} = 1; #- force removable flag
my $useSupermount = 'magicdev';
diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ
deleted file mode 100755
index eff413cd9..000000000
--- a/perl-install/standalone/drakTermServ
+++ /dev/null
@@ -1,2198 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2002-2005 by Mandriva (sbenedict@mandrakesoft.com)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-use lib qw(/usr/lib/libDrakX);
-
-use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use strict;
-
-use interactive;
-use ugtk2 qw(:helpers :wrappers :create);
-use common;
-use run_program;
-use bootloader;
-use network::pxe;
-
-use Config;
-use POSIX;
-
-my $in = 'interactive'->vnew('su');
-
-my @buff; #- used to display status info
-
-my $central_widget;
-my $window1;
-my $status_box;
-my $main_box;
-my $wizard_buttons;
-my $previous_button;
-my $cancel_button;
-my $next_button;
-my $main_buttons;
-my $progress;
-my $plabel;
-my $in_wizard = 0;
-my $config_written = 0;
-my $clients_set = 0;
-my @nothing = (0..10);
-my %conf;
-$conf{ALLOW_THIN} = 0;
-$conf{CREATE_PXE} = 0;
-
-my $nfs_subnet;
-my $nfs_mask;
-my $cfg_dir = "/etc/drakxtools/draktermserv/";
--e $cfg_dir or mkdir_p($cfg_dir);
-my $cfg_file = $cfg_dir . "draktermserv.conf";
-my $interface = get_net_interface();
-my $server_ip = get_ip_from_sys();
-my $changes_made = 0;
-my $client_cfg = "/etc/dhcpd.conf.etherboot.clients";
-my $tftpboot = "/var/lib/tftpboot";
-my @kernels = bootloader::installed_vmlinuz();
-my $kcount = @kernels;
-my $cmd_line = 1;
-my $mknbi = "/usr/bin/mknbi-set";
-my %help;
-our $ts_prefix = "/var/lib/terminal-server/";
-our $client_prefix = $ts_prefix . "clients";
-our $common_prefix = $ts_prefix . "common";
-
-read_conf_file();
-my $nfs_daemon = $conf{USE_UNIONFS} ? "nfs" : "clusternfs";
-my $ts_package = $conf{USE_UNIONFS} ? "terminal-server2" : "terminal-server";
-
-#- make sure terminal server and friends are installed
-$in->do_pkgs->ensure_is_installed($ts_package, '/usr/bin/drakTermServ') or $in->exit(-1);
-
-my $argc = @ARGV;
-
-if ("@ARGV" =~ /--enable/) {
- enable_ts();
- exit(0);
-}
-
-if ("@ARGV" =~ /--disable/) {
- disable_ts();
- exit(0);
-}
-
-if ("@ARGV" =~ /--restart/) {
- stop_ts();
- start_ts();
- exit(0);
-}
-
-if ("@ARGV" =~ /--start/) {
- start_ts();
- exit(0);
-}
-
-if ("@ARGV" =~ /--stop/) {
- stop_ts();
- exit(0);
-}
-
-if ("@ARGV" =~ /--adduser/) {
- die N("%s: %s requires a username...\n", $0, $ARGV[0]) if $argc < 2;
- adduser($ARGV[1]);
- exit(0);
-}
-
-if ("@ARGV" =~ /--deluser/) {
- die N("%s: %s requires a username...\n", $0, $ARGV[0]) if $argc < 2;
- deluser($ARGV[1]);
- exit(0);
-}
-
-if ("@ARGV" =~ /--syncusers/) {
- sync_users();
- exit(0);
-}
-
-if ("@ARGV" =~ /--addclient/) {
- die N("%s: %s requires hostname, MAC address, IP, nbi-image, 0/1 for THIN_CLIENT, 0/1 for Local Config...\n", $0, $ARGV[0]) if $argc < 7;
- addclient(@ARGV[1..6]);
- exit(0);
-}
-
-if ("@ARGV" =~ /--delclient/) {
- die N("%s: %s requires hostname...\n", $0, $ARGV[0]) if $argc < 2;
- delclient($ARGV[1]);
- exit(0);
-}
-
-interactive_mode() if $argc < 2;
-
-sub setup_tooltips() {
- %help = (
- 'client_name' => N("Host name for client"),
- 'mac_address' => N("MAC address should be in the format 00:11:22:33:44:55"),
- 'ip_address' => N("IP address to be assigned to client"),
- 'netboot_image' => N("Kernel/network adapter image to use to boot client"),
- 'local_hardware' => N("Create masking files to allow configuration tools to run on client"),
- 'thin_client' => N("Applications will run on server machine"),
- );
-}
-
-sub set_help_tip {
- my ($entry, $key) = @_;
- gtkset_tip(Gtk2::Tooltips->new, $entry, formatAlaTeX($help{$key}));
-}
-
-sub read_conf_file() {
- if (-e $cfg_file) {
- substInFile { s/ALLOW_THIN$/ALLOW_THIN=1/ } $cfg_file;
- %conf = getVarsFromSh($cfg_file);
- }
-}
-
-sub write_conf_file() {
- setVarsInSh($cfg_file, \%conf);
- chmod(0600, $cfg_file);
-}
-
-sub write_thin_inittab {
- my ($client_ip) = @_;
- my $suffix;
- my $prefix = $conf{USE_UNIONFS} ? "$client_prefix/$client_ip" : '';
- if ($client_ip eq "CLIENT") {
- $suffix = '$$CLIENT$$';
- } else {
- $suffix = "\$\$IP=$client_ip\$\$";
- }
- $suffix = '' if $conf{USE_UNIONFS};
-
- my $inittab = "
-# /etc/inittab$suffix
-# created by drakTermServ
-
-id:5:initdefault:
-
-# System initialization.
-si::sysinit:/etc/rc.d/rc.sysinit
-
-l0:0:wait:/etc/rc.d/rc 0
-l1:1:wait:/etc/rc.d/rc 1
-l2:2:wait:/etc/rc.d/rc 2
-l3:3:wait:/etc/rc.d/rc 3
-l4:4:wait:/etc/rc.d/rc 4
-l5:5:wait:/etc/rc.d/rc 5
-l6:6:wait:/etc/rc.d/rc 6
-
-# Things to run in every runlevel.
-ud::once:/sbin/update
-
-# Trap CTRL-ALT-DELETE
-ca::ctrlaltdel:/sbin/reboot -f
-
-# Run gettys in standard runlevels
-1:2345:respawn:/sbin/mingetty tty1
-
-# Connect to X server
-x:5:respawn:/usr/X11R6/bin/X -ac -query $server_ip\n";
-
- my $inittab_file = "$prefix/etc/inittab$suffix";
- output_p($inittab_file, $inittab);
-}
-
-sub display_error {
- my ($message) = @_;
- my $error_box;
- destroy_widget();
- gtkpack($status_box,
- $error_box = gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new($message),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub {
- destroy_widget();
- }),
- ),
- )
- );
- $central_widget = \$error_box;
-}
-
-sub interactive_mode() {
- $cmd_line = 0;
- $in = 'interactive'->vnew;
- $::Wizard_title = N("Terminal Server Configuration");
- $::Wizard_pix_up = "ic82-network-40.png";
- $in->isa('interactive::gtk') and $::isWizard = 0;
- $window1 = ugtk2->new(N("Terminal Server Configuration"));
- $window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- $window1->{rwindow}->set_border_width(5);
-
- my $s_buttons = Gtk2::HBox->new;
- gtkpack_($s_buttons,
- 1, gtksignal_connect(Gtk2::Button->new(N("dhcpd Config")), clicked => sub {
- destroy_widget();
- dhcpd_config();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Enable Server")), clicked => sub {
- destroy_widget();
- gtkset_mousecursor_wait();
- enable_ts();
- gtkset_mousecursor_normal();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Disable Server")), clicked => sub {
- destroy_widget();
- gtkset_mousecursor_wait();
- disable_ts();
- gtkset_mousecursor_normal();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Start Server")), clicked => sub {
- destroy_widget();
- gtkset_mousecursor_wait();
- start_ts();
- gtkset_mousecursor_normal();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Stop Server")), clicked => sub {
- destroy_widget();
- gtkset_mousecursor_wait();
- stop_ts();
- gtkset_mousecursor_normal();
- }),
- );
- my $i_buttons = Gtk2::HBox->new;
- gtkpack_($i_buttons,
- 1, gtksignal_connect(Gtk2::Button->new(N("Etherboot Floppy/ISO")), clicked => sub {
- destroy_widget();
- make_boot();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Net Boot Images")), clicked => sub {
- destroy_widget();
- make_nbi();
- }),
- );
- my $c_buttons = Gtk2::HBox->new;
- gtkpack_($c_buttons,
- 1, gtksignal_connect(Gtk2::Button->new(N("Add/Del Users")), clicked => sub {
- destroy_widget();
- maintain_users();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Add/Del Clients")), clicked => sub {
- destroy_widget();
- maintain_clients();
- }),
- );
-
- $main_buttons = Gtk2::Notebook->new;
- $main_buttons->append_page($s_buttons, gtkshow(Gtk2::Label->new(N("Server"))));
- $main_buttons->append_page($i_buttons, gtkshow(Gtk2::Label->new(N("Images"))));
- $main_buttons->append_page($c_buttons, gtkshow(Gtk2::Label->new(N("Clients/Users"))));
- $main_buttons->set_show_border(0);
- $main_buttons->set_tab_pos('bottom');
- gtkadd($window1->{window},
- gtkpack_(gtkset_size_request(Gtk2::VBox->new(0,2), 620, 400),
- 1, gtkpack_(Gtk2::HBox->new(0,2),
- 1, gtkpack_(Gtk2::VBox->new(0,2),
- 1, gtkpack($status_box = Gtk2::VBox->new(0,5),
- $main_box = Gtk2::VBox->new(0,10),
- ),
- 0, $wizard_buttons = gtkpack_(Gtk2::HBox->new(1,2)),
- 0, $main_buttons,
- 0, gtkpack_(Gtk2::HBox->new,
- 0, gtksignal_connect(Gtk2::Button->new(N("Help")),clicked => sub {
- destroy_widget();
- help();
- }),
- 1, "",
- 0, gtksignal_connect(Gtk2::Button->new(N("First Time Wizard")), clicked => sub {
- destroy_widget();
- start_wizard();
- }),
- 1, "",
- 0, gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub {
- write_conf_file();
- restart_server() if $changes_made == 1;
- Gtk2->main_quit;
- }),
- ),
- ),
- ),
- ),
- );
- setup_tooltips();
- $central_widget = \$main_box;
- $window1->{rwindow}->show_all;
- $window1->{rwindow}->realize;
- $window1->{rwindow}->show_all;
- #- strange behavior with tabs, pressing a button actually ends up
- #- activating a hidden button below it
- $main_buttons->set_current_page(2);
- $main_buttons->set_current_page(1);
- $main_buttons->set_current_page(0);
- gtksignal_connect($main_buttons, switch_page => sub { destroy_widget() });
- gtkflush();
- $window1->main;
- ugtk2->exit(0);
-}
-
-sub check_gdm() {
- #- gdm now needs gdm user in /etc/passwd$$CLIENT$$
- my %desktop = getVarsFromSh("/etc/sysconfig/desktop");
- my $dm = $desktop{DISPLAYMANAGER};
- $dm =~ tr/a-z/A-Z/;
- my $gdm = `grep gdm '/etc/passwd\$\$CLIENT\$\$'`;
- if ($dm =~ /GNOME|GDM/ && !$gdm) {
- $in->ask_warn(N("Warning"), N("%s defined as dm, adding gdm user to /etc/passwd\$\$CLIENT\$\$", $dm)) if !$cmd_line;
- warn(N("%s defined as dm, adding gdm user to /etc/passwd\$\$CLIENT\$\$", $dm)) if $cmd_line;
- adduser("gdm");
- }
-}
-
-sub start_wizard() {
- text_view(N("
- This wizard routine will:
- 1) Ask you to select either 'thin' or 'fat' clients.
- 2) Setup DHCP.
-
-After doing these steps, the wizard will:
-
- a) Make all nbis.
- b) Activate the server.
- c) Start the server.
- d) Synchronize the shadow files so that all users, including root,
- are added to the shadow\$\$CLIENT\$\$ file.
- e) Ask you to make a boot floppy.
- f) If it's thin clients, ask if you want to restart KDM.
-"), "wizard");
-}
-
-sub do_wizard() {
- destroy_widget();
- $main_buttons->hide;
- $in_wizard = 1;
- $config_written = 0;
- %conf = '';
- wizard_step(\&client_type, 1);
-}
-
-sub wizard_step {
- my ($do_step, $step) = @_;
- &$do_step();
- gtkadd($wizard_buttons,
- gtksignal_connect($previous_button = Gtk2::Button->new(N("Previous")), clicked => sub {
- clear_buttons();
- if ($step == 1) {
- exit_wizard();
- start_wizard();
- }
- wizard_step(\&client_type, 1) if $step == 2;
- wizard_step(\&dhcpd_config, 2) if $step == 3;
- wizard_step(\&make_nbis, 3) if $step == 4;
- wizard_step(\&enable_ts, 4) if $step == 5;
- wizard_step(\&restart_ts, 5) if $step == 6;
- wizard_step(\&sync_users, 6) if $step == 7;
- wizard_step(\&make_boot, 7) if $step == 8;
- })
- );
- gtkadd($wizard_buttons,
- gtksignal_connect($cancel_button = Gtk2::Button->new(N("Cancel Wizard")), clicked => sub {
- exit_wizard();
- })
- );
- gtkadd($wizard_buttons,
- gtksignal_connect($next_button = Gtk2::Button->new(N("Next")), clicked => sub {
- clear_buttons();
- if ($step == 1) {
- client_X_keyboard() if $conf{SYNC_KBD};
- wizard_step(\&dhcpd_config, 2);
- }
- if ($step == 2) {
- if ($config_written == 1) {
- wizard_step(\&make_nbis, 3);
- } else {
- $in->ask_warn(N("Error"), N("Please save dhcpd config!"));
- wizard_step(\&dhcpd_config, 2);
- }
- }
- wizard_step(\&enable_ts, 4) if $step == 3;
- wizard_step(\&restart_ts, 5) if $step == 4;
- wizard_step(\&sync_users, 6) if $step == 5;
- wizard_step(\&make_boot, 7) if $step == 6;
- wizard_step(\&restart_dm, 8) if $step == 7;
- })
- );
- exit_wizard() if $step == 8;
-}
-
-sub exit_wizard() {
- clear_buttons();
- $in_wizard = 0;
- $main_buttons->show;
-}
-
-sub clear_buttons() {
- destroy_widget();
- $previous_button->destroy;
- $cancel_button->destroy;
- $next_button->destroy;
-}
-
-sub client_type() {
- my $check_allow_thin = Gtk2::CheckButton->new(N("Use thin clients."));
- $check_allow_thin->set_active($conf{ALLOW_THIN});
- my $check_sync_kbd = Gtk2::CheckButton->new(N("Sync client X keyboard settings with server."));
- $check_sync_kbd->set_active($conf{SYNC_KBD});
- text_view(N("Please select default client type (Fat is the default type if 'Use thin' is unchecked).
- '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");
- gtkpack_($$central_widget,
- 0, gtkpack_(Gtk2::HBox->new(0,0),
- 1, Gtk2::VBox->new,
- 0, gtksignal_connect($check_allow_thin, clicked => sub {
- invbool \$conf{ALLOW_THIN};
- client_set("all");
- }),
- 0, gtksignal_connect($check_sync_kbd, clicked => sub {
- invbool \$conf{SYNC_KBD};
- }),
- 1, Gtk2::VBox->new,
- ),
- 0, Gtk2::VBox->new,
- );
-}
-
-sub make_nbis() {
- my $buff = N("Creating net boot images for all kernels");
- $in->ask_warn(N("Information"), N("This will take a few minutes."));
- if (check_nbi_space($kernels[0], $kcount)) {
- $wizard_buttons->hide;
- exit_wizard();
- } else {
- build_w_progress(undef, undef);
- $buff .= "\n\n\t" . N("Done!");
- text_view($buff, "wizard");
- }
-}
-
-sub check_nbi_space {
- my ($kernel, $kcount) = @_;
- log::explanations("Checking for adequate free space to create NBIs for $kcount kernel(s)");
- my $nbi_count = `$mknbi -c -k /boot/$kernel`;
- chomp $nbi_count;
- if ($nbi_count eq '') {
- $in->ask_warn(N("Error"), N("%s failed", $mknbi));
- return 1;
- }
- my $needed_space = $nbi_count * $kcount * 2;
- my $free = `df -P $tftpboot | tail -1`;
- my @line_data = split(/[ \t,]+/, $free);
- #- don't use more than 80%
- my $free_space = int($line_data[3] / 1024);
- if ($needed_space > $free_space * 0.8) {
- $in->ask_warn(N("Error"), N("Not enough space to create\nNBIs in %s.\nNeeded: %d MB, Free: %d MB", $tftpboot, $needed_space, $free_space));
- return 1;
- }
-}
-
-sub sync_users() {
- my $buff = N("Syncing server user list with client list, including root.");
- my @active_users = cat_("/etc/shadow");
-
- my ($shadow, undef) = get_passwd_files();
- 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") {
- push @userlist, $user;
- }
- }
- output_p($shadow, @userlist);
- $buff .= "\n\n\t" . N("Done!");
- text_view($buff, "wizard") if !$cmd_line;
-}
-
-sub restart_dm() {
- if ($clients_set) {
- my $result = $in->ask_okcancel('', N("In order to enable changes made for thin clients, the display manager must be restarted. Restart now?"));
- run_program::run('nohup /sbin/service dm restart') if $result;
- }
-}
-
-sub text_view {
- my ($text, $option) = @_;
- my $box;
- gtkpack($status_box,
- $box = gtkpack_(Gtk2::VBox->new(0,10),
- 1, gtkpack_(Gtk2::HBox->new(0,0),
- 1, create_scrolled_window(gtktext_insert(
- Gtk2::TextView->new, [ [ $text ] ])
- ),
- ),
- 0, gtkpack(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(my $ok_button = Gtk2::Button->new(N("Ok")), clicked => sub {
- destroy_widget() if $option eq "close";
- do_wizard() if $option eq "wizard";
- }),
- ),
- )
- );
- gtkset_size_request($box, 580, 280);
- $central_widget = \$box;
- $status_box->show_all;
- $ok_button->hide if $in_wizard;
- $main_buttons->hide if $in_wizard;
-}
-
-sub help() {
- my $inittab_str = $conf{USE_UNIONFS} ? "$client_prefix/CLIENT_IP/etc/inittab" : '/etc/inittab$$IP=client_ip$$';
- my ($shadow_str, undef) = get_passwd_files();
- my $xfconfig_str = $conf{USE_UNIONFS} ? "$client_prefix/CLIENT_IP/etc/X11/xorg.conf" : '/etc/X11/xorg.conf$$IP=client_ip$$';
- my $filesystem = $conf{USE_UNIONFS} ? "UnionFS" : "ClusterNFS";
- my $application = "drakTermServ";
-
- text_view(N("Terminal Server Overview") . "\n\n" .
-N(" - Create Etherboot Enabled Boot Images:
- To boot a kernel via etherboot, a special kernel/initrd image must be created.
- mkinitrd-net does much of this work and %s is just a graphical
- interface to help manage/customize these images. To create the file
- /etc/dhcpd.conf.etherboot-pcimap.include that is pulled in as an include in
- dhcpd.conf, you should create the etherboot images for at least one full kernel.", $application) . "\n\n" .
-N(" - Maintain /etc/dhcpd.conf:
- To net boot clients, each client needs a dhcpd.conf entry, assigning an IP
- address and net boot images to the machine. %s helps create/remove
- these entries.
-
- (PCI cards may omit the image - etherboot will request the correct image.
- You should also consider that when etherboot looks for the images, it expects
- names like boot-3c59x.nbi, rather than boot-3c59x.2.4.19-16mdk.nbi).
-
- A typical dhcpd.conf stanza to support a diskless client looks like:", $application) . "\n\n" .
-' host curly {
- hardware ethernet 00:20:af:2f:f7:9d;
- fixed-address 192.168.192.3;
- #type fat;
- filename "i386/boot/boot-3c509.2.4.18-6mdk.nbi";
- #hdw_config true;
- }
- ' . "\n" .
-N(" While you can use a pool of IP addresses, rather than setup a specific entry for
- a client machine, using a fixed address scheme facilitates using the functionality
- of client-specific configuration files that %s provides.
-
- Note: The '#type' entry is only used by %s. Clients can either be 'thin'
- or 'fat'. Thin clients run most software on the server via XDMCP, while fat clients run
- most software on the client machine. A special inittab,
- %s is written for thin clients.
- System config files xdm-config, kdmrc, and gdm.conf are modified if thin clients are
- used, to enable XDMCP. Since there are security issues in using XDMCP, hosts.deny and
- hosts.allow are modified to limit access to the local subnet.
-
- Note: The '#hdw_config' entry is also only used by %s. Clients can either
- be 'true' or 'false'. 'true' enables root login at the client machine and allows local
- hardware configuration of sound, mouse, and X, using the 'drak' tools. This is enabled
- by creating separate config files associated with the client's IP address and creating
- read/write mount points to allow the client to alter the file. Once you are satisfied
- with the configuration, you can remove root login privileges from the client.
-
- Note: You must stop/start the server after adding or changing clients.", $filesystem, $application, $inittab_str, $application) . "\n\n" .
-N(" - Maintain /etc/exports:
- %s allows export of the root filesystem to diskless clients. %s
- sets up the correct entry to allow anonymous access to the root filesystem from
- diskless clients.
-
- A typical exports entry for %s is:
-
- / (ro,all_squash)
- /home SUBNET/MASK(rw,root_squash)
-
- With SUBNET/MASK being defined for your network.", $filesystem, $application, $filesystem) .
- "\n\n" .
-N(" - Maintain %s:
- For users to be able to log into the system from a diskless client, their entry in
- /etc/shadow needs to be duplicated in %s.
- %s helps in this respect by adding or removing system users from this
- file.", $shadow_str, $shadow_str, $application) . "\n\n" .
-N(" - Per client %s:
- Through %s, each diskless client can have its own unique configuration files
- on the root filesystem of the server. By allowing local client hardware configuration,
- %s will help create these files.", $xfconfig_str, $filesystem, $application) .
-"\n\n" .
-N(" - Per client system configuration files:
- Through %s, each diskless client can have its own unique configuration files
- on the root filesystem of the server. By allowing local client hardware configuration,
- clients can customize files such as /etc/modules.conf, /etc/sysconfig/mouse,
- /etc/sysconfig/keyboard on a per-client basis.
-
- Note: Enabling local client hardware configuration does enable root login to the terminal
- server on each client machine that has this feature enabled. Local configuration can be
- turned back off, retaining the configuration files, once the client machine is configured.", $filesystem) . "\n\n" .
-N(" - /etc/xinetd.d/tftp:
- %s will configure this file to work in conjunction with the images created
- by mkinitrd-net, and the entries in /etc/dhcpd.conf, to serve up the boot image to
- each diskless client.
-
- A typical TFTP configuration file looks like:
-
- service tftp
- {
- disable = no
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /var/lib/tftpboot
- }
-
- The changes here from the default installation are changing the disable flag to
- 'no' and changing the directory path to /var/lib/tftpboot, where mkinitrd-net
- puts its images.", $application) . "\n\n" .
-N(" - Create etherboot floppies/CDs:
- The diskless client machines need either ROM images on the NIC, or a boot floppy
- or CD to initiate the boot sequence. %s will help generate these
- images, based on the NIC in the client machine.
-
- A basic example of creating a boot floppy for a 3Com 3c509 manually:
-
- cat /usr/share/etherboot/zdsk/3c509.zdsk > /dev/fd0", $application) . "\n\n", "close");
-}
-
-sub make_boot() {
- #- make a boot image on floppy or iso from etherboot images
- my $boot_box;
- my $rom_path = "/usr/share/etherboot";
- #- does not return list sorted
- my @nics = sort(all("/usr/share/etherboot/zdsk"));
- my $list_nics = Gtk2::List->new;
- my $nic;
-
- foreach (@nics) {
- my $t = $_;
- $list_nics->add(gtkshow(gtksignal_connect(Gtk2::ListItem->new($t),
- select => sub { $nic = $t })));
- }
- $list_nics->set_selection_mode('single');
-
- gtkpack($status_box,
- $boot_box = gtkpack_(Gtk2::VBox->new(0,10),
- 0, gtkadd(Gtk2::HBox->new(0,10),
- Gtk2::HBox->new(0,5),
- create_scrolled_window($list_nics),
- gtkadd(Gtk2::VBox->new(1,10),
- Gtk2::HBox->new(0,20),
- gtksignal_connect(Gtk2::Button->new(N("Boot Floppy")), clicked =>
- sub { write_eb_image($nic, $rom_path, "floppy") }),
- gtksignal_connect(Gtk2::Button->new(N("Boot ISO")), clicked =>
- sub { write_eb_image($nic, $rom_path, "iso") }),
- gtksignal_connect(Gtk2::Button->new(N("PXE Image")), clicked =>
- sub { write_eb_image($nic, $rom_path, "pxe") }),
- Gtk2::HBox->new(0,20),
- ),
- Gtk2::HBox->new(0,5),
- ),
- ),
- );
-
- $central_widget = \$boot_box;
- $boot_box->show_all;
-}
-
-sub make_nbi() {
- my $nbi_box;
- my $kernel;
- my $nic;
-
- require list_modules;
- my @nics = sort(list_modules::category2modules(list_modules::ethernet_categories()));
-
- #- kernel/module info in tree view
- my $model = Gtk2::TreeStore->new("Glib::String");
- my $tree_kernels = Gtk2::TreeView->new_with_model($model);
- $tree_kernels->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $tree_kernels->set_headers_visible(0);
- $tree_kernels->get_selection->set_mode('single');
-
- foreach (@kernels) {
- my $t_kernel = $model->append_set(undef, [ 0 => $_ ]);
- foreach (@nics) {
- $model->append_set($t_kernel, [ 0 => $_ ]);
- }
- }
-
- $tree_kernels->get_selection->signal_connect(changed => sub {
- $kernel = '';
- $nic = '';
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- my $value = $model->get($iter, 0);
- my $path = $model->get_path_str($iter);
- if ($path !~ /:/) {
- $kernel = $value;
- } else {
- my @elements = split(/:/, $path);
- $nic = $value;
- $kernel = $kernels[$elements[0]];
- }
- });
-
- # existing nbi images in list
- my $list_model = Gtk2::ListStore->new("Glib::String");
- my $list_nbis = Gtk2::TreeView->new_with_model($list_model);
- $list_nbis->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list_nbis->set_headers_visible(0);
- my $nbi;
- my $nbi_iter;
-
- update_list($list_model);
-
- my $combo_default_kernel = Gtk2::ComboBox->new_with_strings([ N("Default kernel version"),
- map { bootloader::vmlinuz2version($_) } @kernels ]);
-
- my $entry_kargs = Gtk2::Entry->new;
- $entry_kargs->set_width_chars(12);
- my $check_pxe = Gtk2::CheckButton->new(N("Create PXE images"));
- my $check_union = Gtk2::CheckButton->new(N("Use Unionfs (TS2)"));
- #- disable until kernel support appears
- $check_union->set_sensitive(0);
- $check_pxe->set_active($conf{CREATE_PXE});
- $check_pxe->signal_connect('clicked' => sub { invbool \$conf{CREATE_PXE} });
- $check_union->set_active($conf{USE_UNIONFS});
- $check_union->signal_connect('clicked' => sub { invbool \$conf{USE_UNIONFS} });
-
- $combo_default_kernel->set_active(0);
- $combo_default_kernel->entry->signal_connect('changed', sub {
- my $default_kernel = $combo_default_kernel->entry->get_text;
- my $config;
- if ($default_kernel eq translate("Default kernel version")) {
- $config = "";
- } else {
- $config = 'option bootfile-name = pick-first-value ( concat ( "boot-",' . "\n";
- $config .= ' config-option etherboot.kmod, ".' . $default_kernel . '", ".nbi" ), concat' . "\n";
- $config .= ' ( "boot-", config-option etherboot.kmod, ".nbi") ,"boot.nbi" );' . "\n";
- }
- output_p("/etc/dhcpd.conf.etherboot.kernel", $config);
- });
-
- $list_nbis->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $nbi = $model->get($iter, 0);
- $nbi_iter = $iter;
- });
- my $button_i586_kernel;
- if (arch() eq "i686" && !(any { /i586/ } @kernels)) {
- $button_i586_kernel = Gtk2::Button->new(N("Install i586 kernel for older clients"));
- gtksignal_connect($button_i586_kernel, clicked => sub {
- $in->do_pkgs->install('kernel-i586-up-1GB-2.6');
- });
- }
- gtkpack($status_box,
- $nbi_box = gtkpack_(Gtk2::VBox->new(1,10),
- 0, gtkadd(Gtk2::HBox->new(1,5),
- create_scrolled_window($tree_kernels),
- gtkadd(Gtk2::VBox->new(0,5),
- gtksignal_connect(Gtk2::Button->new(N("Build Whole Kernel -->")), clicked => sub {
- if ($kernel) {
- $in->ask_warn(N("Information"), N("This will take a few minutes."));
- gtkset_mousecursor_wait();
- build_n_update($kernel, $list_model, undef, $entry_kargs->get_text) unless check_nbi_space($kernel, 1);
- gtkset_mousecursor_normal();
- } else {
- $in->ask_warn(N("Error"), N("No kernel selected!")) if !($kernel);
- }
- }),
- gtksignal_connect(Gtk2::Button->new(N("Build Single NIC -->")), clicked => sub {
- if ($nic) {
- build_n_update($kernel, $list_model, $nic, $entry_kargs->get_text);
- } else {
- $in->ask_warn(N("Error"), N("No NIC selected!"));
- }
- }),
- gtksignal_connect(Gtk2::Button->new(N("Build All Kernels -->")), clicked => sub {
- $in->ask_warn(N("Information"), N("This will take a few minutes."));
- my $kcount = @kernels;
- if (check_nbi_space($kernels[0], $kcount)) {
- return;
- } else {
- build_w_progress($list_model, undef, $entry_kargs->get_text);
- make_nbi();
- }
- }),
- $button_i586_kernel,
- $combo_default_kernel,
- gtkadd(Gtk2::HBox->new(0,5),
- Gtk2::Label->new(N("Custom\nkernel args")),
- $entry_kargs,
- ),
- $check_pxe,
- $check_union,
- gtksignal_connect(Gtk2::Button->new(N("<-- Delete")), clicked => sub {
- if ($nbi) {
- my $result = clear_nbi($nbi);
- $list_model->remove($nbi_iter) if $result == 1;
- } else {
- $in->ask_warn(N("Error"), N("No image selected!"));
- }
- }),
- gtksignal_connect(Gtk2::Button->new(N("Delete All NBIs")), clicked => sub {
- gtkset_mousecursor_wait();
- foreach (grep { /\.nbi/ } all($tftpboot)) {
- clear_nbi($_);
- }
- $list_model->clear;
- gtkset_mousecursor_normal();
- }),
- ),
- create_scrolled_window($list_nbis),
- ),),
- );
-
- $central_widget = \$nbi_box;
- $nbi_box->show_all;
-}
-
-sub clear_nbi {
- my ($nbi) = @_;
- $nbi = $tftpboot . "/" . $nbi;
- my $result = unlink($nbi) or warn("Can not delete $nbi...");
- $nbi =~ s|boot-|initrd-|;
- $nbi =~ s|nbi|img|;
- unlink($nbi);
- if ($conf{CREATE_PXE}) {
- my $pxe = get_platform_pxe();
- $nbi =~ s|$tftpboot/|$pxe|;
- unlink($nbi);
- del_pxe_entry($nbi) if -d $pxe;
- }
- return $result;
-}
-
-sub update_list {
- my ($list_model) = @_;
- $list_model->clear;
- $list_model->append_set(0, $_) foreach grep { /\.nbi/ } sort(all($tftpboot));
-}
-
-sub build_n_update {
- my ($kernel, $list_model, $nic, @kargs) = @_;
- my $xtra_args = join(" ", @kargs);
- my $command = "-k /boot/$kernel";
- $command .= " -r $nic" if $nic;
- $command .= " -u" if $conf{USE_UNIONFS};
- $command .= " -a '" . $xtra_args . "'" if length($xtra_args);
- run_program::run("$mknbi -v $command") or $in->ask_warn(N("Error"), N("%s failed", $mknbi));
- if ($conf{CREATE_PXE}) {
- my $pxedir = get_platform_pxe();
- if (-d $pxedir) {
- cp_af("/boot/$kernel", $pxedir) if !-f "$pxedir/$kernel";
- link_pxe($kernel, $nic);
- add_pxe_entry($kernel, $nic);
- }
- }
- update_list($list_model) if $list_model;
-}
-
-sub build_w_progress {
- my ($widget, $nic, @kargs) = @_;
- gtkset_mousecursor_wait();
- show_progress();
- my $k = 1;
- foreach (@kernels) {
- build_n_update($_, $widget, $nic, @kargs);
- update_progress($k, $kcount, $_);
- $k++;
- }
- destroy_widget();
- gtkset_mousecursor_normal();
-}
-
-sub show_progress() {
- my $progress_box;
- destroy_widget();
- gtkpack($status_box,
- $progress_box = gtkpack_(Gtk2::VBox->new(0,10),
- 0, Gtk2::Label->new(N("Building images for kernel:")),
- 0, $plabel = Gtk2::Label->new(''),
- 0, $progress = Gtk2::ProgressBar->new,
- 1, Gtk2::HBox->new(0,0)
- )
- );
- $central_widget = \$progress_box;
- $progress_box->show_all;
- mygtk2::flush();
-}
-
-sub update_progress {
- my ($fraction, $total, $kernel) = @_;
- $plabel->set_text($kernel);
- $progress->set_fraction($fraction / $total);
- mygtk2::flush();
-}
-
-sub add_pxe_entry {
- my ($kernel, $nic) = @_;
- my $pxeconf = get_platform_pxe() . "pxelinux.cfg/default";
- $kernel =~ s|vmlinuz-||;
- my $label = uc($nic) . "." . uc($kernel);
- my $conf = network::pxe::read_pxelinux_conf($pxeconf, undef);
- push @{$conf->{entries}}, {label => $label , kernel => "vmlinuz-$kernel", initrd => "initrd-$nic.$kernel.img" };
- network::pxe::write_pxelinux_conf($conf, $pxeconf);
-}
-
-sub del_pxe_entry {
- my ($nbi) = @_;
- my $pxeconf = get_platform_pxe() . "pxelinux.cfg/default";
- $nbi = basename($nbi);
- $nbi =~ s|initrd-||;
- $nbi =~ s|.img||;
- my $conf = network::pxe::read_pxelinux_conf($pxeconf, undef);
-
- my $index = 0;
- foreach (@{$conf->{entries}}) {
- if ($_->{label} eq uc($nbi)) {
- splice @{$conf->{entries}}, $index, 1;
- last;
- }
- $index++;
- }
- network::pxe::write_pxelinux_conf($conf, $pxeconf);
-}
-
-sub link_pxe {
- my ($kernel, $nic) = @_;
- my $pxedir = get_platform_pxe();
- $kernel =~ s|vmlinuz-||;
- if ($nic) {
- #- symlinkf does not work?
- run_program::run("ln -sf ../../initrd-$nic.$kernel.img $pxedir");
- } else {
- foreach (glob_("$tftpboot/initrd*.$kernel.img")) {
- my $img = basename($_);
- run_program::run("ln -sf ../../$img $pxedir");
- }
- }
-}
-
-sub get_platform_pxe() {
- my $adir = "X86PC";
- $adir = "IA64PC" if arch() =~ /x86_64|ia64/;
- $adir = "$tftpboot/$adir/linux/";
- return $adir;
-}
-
-sub maintain_users() {
- #- copy users from /etc/shadow to the client equivalent to allow ts login
- my $user_box;
- my @sys_users = cat_("/etc/shadow");
- my ($shadow_file, undef) = get_passwd_files();
- my @ts_users = cat_($shadow_file);
- my $titer;
-
- #- use /homes to filter system daemons
- #- seems suppressing root is less than useful, let it be added
- my @homes = (all("/home"), "root");
-
- my $list_model = Gtk2::ListStore->new("Glib::String");
- my $list_sys_users = Gtk2::TreeView->new_with_model($list_model);
- $list_sys_users->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list_sys_users->set_headers_visible(0);
-
- my $sys_user;
-
- foreach (@sys_users) {
- my ($s_label) = split(/:/, $_, 2);
- if (any { /$s_label/ } @homes) {
- $list_model->append_set(0, $s_label);
- }
- }
-
- $list_sys_users->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $sys_user = $model->get($iter, 0);
- });
-
- $list_model = Gtk2::ListStore->new("Glib::String");
- my $list_ts_users = Gtk2::TreeView->new_with_model($list_model);
- $list_ts_users->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list_ts_users->set_headers_visible(0);
-
- my $ts_user;
-
- foreach (@ts_users) {
- my ($t_label) = split(/:/, $_, 2);
- my @system_entry = grep { /$t_label/ } @sys_users;
- $t_label = $t_label . " !!!" if $_ ne $system_entry[0];
- $list_model->append_set(0, $t_label);
- }
-
- $list_ts_users->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $ts_user = $model->get($iter, 0);
- $ts_user =~ s| !!!||;
- $titer = $iter;
- });
-
- gtkpack($status_box,
- $user_box = gtkpack_(Gtk2::VBox->new(0,10),
- 0, gtkadd(Gtk2::Label->new(N("!!! Indicates the password in the system database is different than\n the one in the Terminal Server database.\nDelete/re-add the user to the Terminal Server to enable login."))),
- 0, gtkadd(Gtk2::HBox->new(0,20),
- create_scrolled_window($list_sys_users),
- gtkadd(Gtk2::VBox->new(1,10),
- Gtk2::HBox->new(0,10),
- gtksignal_connect(Gtk2::Button->new(N("Add User -->")), clicked =>
- sub { my $result = adduser($sys_user);
- if ($result == 0) {
- $list_model->append_set(0, $sys_user);
- }
- }),
- gtksignal_connect(Gtk2::Button->new(N("<-- Del User")), clicked =>
- sub { deluser($ts_user);
- $list_model->remove($titer);
- }),
- Gtk2::HBox->new(0,10),
- ),
- create_scrolled_window($list_ts_users),
- ),),
- );
-
- $central_widget = \$user_box;
- $user_box->show_all;
-}
-
-sub maintain_clients() {
- #- add client machines to Terminal Server config
- my $client_box;
- my %clients = read_dhcpd_conf();
- my $client;
- my $citer;
- my $local_config = 0;
- my $button_edit;
- my $button_config;
- my $button_delete;
-
- #- client info in tree view
- my $model = Gtk2::TreeStore->new("Glib::String");
- my $tree_clients = Gtk2::TreeView->new_with_model($model);
- $tree_clients->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $tree_clients->set_headers_visible(0);
- $tree_clients->get_selection->set_mode('browse');
-
- foreach my $key (keys(%clients)) {
- my $t_client = $model->append_set(undef, [ 0 => $key ]);
- $model->append_set($t_client, [ 0 => $clients{$key}{hardware} ]);
- $model->append_set($t_client, [ 0 => $clients{$key}{address} ]);
- $model->append_set($t_client, [ 0 => N("type: %s", $clients{$key}{type}) ]);
- if ($clients{$key}{filename}) {
- $model->append_set($t_client, [ 0 => $clients{$key}{filename} ]);
- }
- $model->append_set($t_client, [ 0 => N("local config: %s", $clients{$key}{hdw_config}) ]);
-
- }
-
- $tree_clients->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- my $value = $model->get($iter, 0);
- my $path = $model->get_path_str($iter);
- if ($path !~ /:/) {
- $client = $value;
- $citer = $iter;
- } else {
- $citer = $model->iter_parent($iter);
- $client = $model->get($citer, 0);
- }
- $button_edit->set_sensitive(1);
- $button_config->set_sensitive(1);
- $button_delete->set_sensitive(1);
- });
-
- #- entry boxes for client data entry
- my $label_host = Gtk2::Label->new("Client Name:");
- my $entry_host = Gtk2::Entry->new;
- set_help_tip($entry_host, 'client_name');
- my $label_mac = Gtk2::Label->new("MAC Address:");
- my $entry_mac = Gtk2::Entry->new;
- set_help_tip($entry_mac, 'mac_address');
- my $label_ip = Gtk2::Label->new("IP Address:");
- my $entry_ip = Gtk2::Entry->new;
- set_help_tip($entry_ip, 'ip_address');
- my $label_nbi = Gtk2::Label->new("Kernel Netboot Image:");
- my $entry_nbi = Gtk2::Combo->new;
- set_help_tip($entry_nbi, 'netboot_image');
-
- gtksignal_connect(my $check_hdw_config = Gtk2::CheckButton->new(N("Allow local hardware\nconfiguration.")),
- clicked => sub { invbool \$local_config });
- set_help_tip($check_hdw_config, 'local_hardware');
-
- my @images = grep { /\.nbi/ } all($tftpboot);
- my $have_nbis = @images;
- if ($have_nbis) {
- unshift(@images, "");
- $entry_nbi->set_popdown_strings(@images);
- } else {
- $in->ask_warn(N("Error"), N("No net boot images created!"));
- make_nbi();
- return 1;
- }
-
- my $check_thin;
- my $check_allow_thin;
- my $is_thin = 0;
- my $check_sync_kbd;
-
- gtkpack($status_box,
- $client_box = gtkpack_(Gtk2::VBox->new(0,10),
- 0, gtkadd(Gtk2::HBox->new(1,5),
- gtkadd(Gtk2::VBox->new(0,5),
- gtkadd($label_host), gtkadd($entry_host),
- gtkadd($label_mac), gtkadd($entry_mac),
- gtkadd($label_ip), gtkadd($entry_ip),
- gtkadd($label_nbi), gtkadd($entry_nbi),
- gtkadd($check_hdw_config),
- gtksignal_connect($check_thin = Gtk2::CheckButton->new(N("Thin Client")),
- clicked => sub { invbool \$is_thin }),
- ),
- gtkadd(Gtk2::VBox->new(1,10),
- $check_allow_thin = Gtk2::CheckButton->new(N("Allow Thin Clients")),
- $check_sync_kbd = Gtk2::CheckButton->new(N("Sync client X keyboard\n settings with server.")),
- gtksignal_connect(Gtk2::Button->new(N("Add Client -->")), clicked =>
- sub { my $hostname = $entry_host->get_text;
- my $mac = $entry_mac->get_text;
- $mac =~ s/-| /:/g; #- dashes or spaces
- if (length($mac) == 12) {
- #- no delimiter
- for (my $i = 10; $i >= 2; $i = $i-2) { substr($mac, $i, 0) = ":" }
- }
- local $_ = $mac;
- if (length($mac) != 17 || (tr/://) != 5) {
- $in->ask_warn(N("Error"), N("Unknown MAC address format"));
- return;
- }
- my $ip = $entry_ip->get_text;
- my $nbi = $entry_nbi->entry->get_text;
- if ($hostname && $mac && $ip) {
-
- my $result = addclient($hostname, $mac, $ip, $nbi, $is_thin, $local_config);
-
- if ($result == 0) {
- my $t_client = $model->append_set(undef, [ 0 => $hostname ]);
- $model->append_set($t_client, [ 0 => $mac ]);
- $model->append_set($t_client, [ 0 => $ip ]);
-
- my $client_type = N("type: fat");
- $client_type = N("type: thin") if $is_thin == 1;
- $model->append_set($t_client, [ 0 => $client_type ]);
-
- $model->append_set($t_client, [ 0 => $nbi ]) if $nbi;
- $check_thin->set_active(0);
- $is_thin = 0;
-
- my $hdw_config = N("local config: false");
- $hdw_config = N("local config: true") if $local_config == 1;
- $model->append_set($t_client, [ 0 => $hdw_config ]);
- $check_hdw_config->set_active(0);
- $local_config = 0;
- %clients = read_dhcpd_conf();
- }
- }
- }),
- gtksignal_connect($button_edit = Gtk2::Button->new(N("<-- Edit Client")), clicked =>
- sub { $entry_host->set_text($client);
- $entry_mac->set_text($clients{$client}{hardware});
- $entry_ip->set_text($clients{$client}{address});
- my $type = $clients{$client}{type};
- if ($type eq "thin") {
- $check_thin->set_active(1);
- } else {
- $check_thin->set_active(0);
- }
- $entry_nbi->entry->set_text($clients{$client}{filename});
- my $hdw_config = $clients{$client}{hdw_config};
- if ($hdw_config eq "true") {
- $check_hdw_config->set_active(1);
- } else {
- $check_hdw_config->set_active(0);
- }
- my $result = delclient($client);
- if ($result == 0) {
- $model->remove($citer);
- $button_edit->set_sensitive(0);
- $button_config->set_sensitive(0);
- $button_delete->set_sensitive(0);
- }
- }),
- gtksignal_connect($button_config = Gtk2::Button->new(N("Disable Local Config")), clicked =>
- sub {
- my $hdw_config = $clients{$client}{hdw_config};
- if ($hdw_config eq "true") {
- client_hdw_config($clients{$client}{address}, 0);
- }
- }),
- gtksignal_connect($button_delete = Gtk2::Button->new(N("Delete Client")), clicked =>
- sub { my $result = delclient($client);
- if ($result == 0) {
- $model->remove($citer);
- $button_edit->set_sensitive(0);
- $button_config->set_sensitive(0);
- $button_delete->set_sensitive(0);
- }
- }),
- ),
- create_scrolled_window($tree_clients),
- ),
- ),
- );
-
- $check_allow_thin->set_active($conf{ALLOW_THIN});
- $check_sync_kbd->set_active($conf{SYNC_KBD});
- $check_thin->set_sensitive($conf{ALLOW_THIN});
- set_help_tip($check_thin, 'thin_client');
- gtksignal_connect($check_allow_thin, clicked =>
- 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)"));
- }
- );
- gtksignal_connect($check_sync_kbd, clicked =>
- sub { invbool \$conf{SYNC_KBD};
- client_X_keyboard() if $conf{SYNC_KBD};
- }
- );
- $button_edit->set_sensitive(0);
- $button_config->set_sensitive(0);
- $button_delete->set_sensitive(0);
- $central_widget = \$client_box;
- $client_box->show_all;
-}
-
-sub client_X_keyboard() {
- my $server_conf = "/etc/X11/xorg.conf";
- my $client_conf = '/etc/X11/xorg.conf$$CLIENT$$';
- my @server_X_config = cat_($server_conf);
- foreach (@server_X_config) {
- chomp;
- if (/XkbModel/) {
- my $oldmodel = `grep XkbModel '/etc/X11/xorg.conf\$\$CLIENT\$\$'`;
- chomp $oldmodel;
- my $newmodel = $_;
- substInFile { s/$oldmodel/$newmodel/ } $client_conf;
- log::explanations("Sync XkbModel in $client_conf from $server_conf");
- }
- if (/XkbLayout/) {
- my $oldlayout = `grep XkbLayout '/etc/X11/xorg.conf\$\$CLIENT\$\$'`;
- chomp $oldlayout;
- my $newlayout = $_;
- substInFile { s/$oldlayout/$newlayout/ } $client_conf;
- log::explanations("Sync XkbLayout in $client_conf from $server_conf");
- }
- }
-}
-
-sub client_set {
- my ($default) = @_;
- # 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
- my $inittab = $conf{USE_UNIONFS} ? "$common_prefix/etc/inittab" : '/etc/initab$$CLIENT$$';
- if ($conf{ALLOW_THIN} == 1) {
- if (-f "/etc/sysconfig/autologin") {
- my $answer = $in->ask_yesorno('', N("Thin clients will not work with autologin. Disable autologin?"));
- if ($answer == 1) {
- log::explanations("Renaming /etc/sysconfig/autologin to /etc/sysconfig/autologin.bak");
- `mv /etc/sysconfig/autologin /etc/sysconfig/autologin.bak`;
- }
- }
- substInFile { s/id:3:initdefault:/id:5:initdefault:/ } "/etc/inittab";
- substInFile { s/DisplayManager.requestPort:/! DisplayManager.requestPort:/ } "/etc/X11/xdm/xdm-config";
- substInFile { s/Enable=false/Enable=true/ } "/usr/share/config/kdm/kdmrc";
- # This file had 2 "Enable=" entries, one for XDMCP and one for debug
- change_gdm_xdmcp("true");
- log::explanations("Modified files /etc/inittab, /etc/X11/xdm/xdm-config, /usr/share/config/kdm/kdmrc, /etc/X11/gdm/gdm.conf");
- # just XDMCP in hosts.allow is enough for xdm & kdm, but gdm does not work - x11 does not help either
- update_hosts_allow("enable");
- if ($default eq "all") {
- $in->ask_warn(N("Warning"), N("All clients will use %s", $inittab));
- renamef($inittab, "$inittab.fat") if -f $inittab;
- write_thin_inittab("CLIENT");
- }
- } else {
- if (-f "/etc/sysconfig/autologin.bak") {
- log::explanations("Renaming /etc/sysconfig/autologin.bak to /etc/sysconfig/autologin");
- `mv /etc/sysconfig/autologin.bak /etc/sysconfig/autologin`;
- }
- substInFile { s/id:5:initdefault:/id:3:initdefault:/ } '/etc/inittab';
- substInFile { s/! DisplayManager.requestPort:/DisplayManager.requestPort:/ } "/etc/X11/xdm/xdm-config";
- substInFile { s/Enable=true/Enable=false/ } "/usr/share/config/kdm/kdmrc";
- change_gdm_xdmcp("false");
- log::explanations("Modified files /etc/inittab, /etc/X11/xdm/xdm-config, /usr/share/config/kdm/kdmrc, /etc/X11/gdm/gdm.conf");
- update_hosts_allow("disable");
- renamef("$inittab.fat", $inittab) if $default eq "all" && -f "$inittab.fat";
- }
- $clients_set = 1;
-}
-
-sub dhcpd_config() {
- #- do main dhcp server config
- my $dhcpd_box;
- my @ifvalues;
- my @resolve;
- my %netconfig;
- my @nservers;
- my $button_msg;
- my $new_config = 0;
- my $dh_button;
- my $wrote = 0;
-
- #- entry boxes for data entry
- my $box_subnet = Gtk2::HBox->new(0,0);
- my $label_subnet = Gtk2::Label->new(N("Subnet:"));
- $label_subnet->set_justify('right');
- my $entry_subnet = Gtk2::Entry->new;
- $box_subnet->pack_end($entry_subnet, 0, 0, 2);
- $box_subnet->pack_end($label_subnet, 0, 0, 2);
-
- my $box_netmask = Gtk2::HBox->new(0,0);
- my $label_netmask = Gtk2::Label->new(N("Netmask:"));
- $label_netmask->set_justify('left');
- my $entry_netmask = Gtk2::Entry->new;
- $box_netmask->pack_end($entry_netmask, 0, 0, 2);
- $box_netmask->pack_end($label_netmask, 0, 0, 2);
-
- my $box_routers = Gtk2::HBox->new(0,0);
- my $label_routers = Gtk2::Label->new(N("Routers:"));
- $label_routers->set_justify('left');
- my $entry_routers = Gtk2::Entry->new;
- $box_routers->pack_end($entry_routers, 0, 0, 2);
- $box_routers->pack_end($label_routers, 0, 0, 2);
-
- my $box_subnet_mask = Gtk2::HBox->new(0,0);
- my $label_subnet_mask = Gtk2::Label->new(N("Subnet Mask:"));
- $label_subnet_mask->set_justify('left');
- my $entry_subnet_mask = Gtk2::Entry->new;
- $box_subnet_mask->pack_end($entry_subnet_mask, 0, 0, 2);
- $box_subnet_mask->pack_end($label_subnet_mask, 0, 0, 2);
-
- my $box_broadcast = Gtk2::HBox->new(0,0);
- my $label_broadcast = Gtk2::Label->new(N("Broadcast Address:"));
- $label_broadcast->set_justify('left');
- my $entry_broadcast = Gtk2::Entry->new;
- $box_broadcast->pack_end($entry_broadcast, 0, 0, 2);
- $box_broadcast->pack_end($label_broadcast, 0, 0, 2);
-
- my $box_domain = Gtk2::HBox->new(0,0);
- my $label_domain = Gtk2::Label->new(N("Domain Name:"));
- $label_domain->set_justify('left');
- my $entry_domain = Gtk2::Entry->new;
- $box_domain->pack_end($entry_domain, 0, 0, 2);
- $box_domain->pack_end($label_domain, 0, 0, 2);
-
- my $box_name_servers = Gtk2::HBox->new(0,0);
- my $box_name_servers_entry = Gtk2::VBox->new(0,0);
- my $label_name_servers = Gtk2::Label->new(N("Name Servers:"));
- $label_name_servers->set_justify('left');
- my $entry_name_server1 = Gtk2::Entry->new;
- my $entry_name_server2 = Gtk2::Entry->new;
- my $entry_name_server3 = Gtk2::Entry->new;
- $box_name_servers_entry->pack_start($entry_name_server1, 0, 0, 0);
- $box_name_servers_entry->pack_start($entry_name_server2, 0, 0, 0);
- $box_name_servers_entry->pack_start($entry_name_server3, 0, 0, 0);
- $box_name_servers->pack_end($box_name_servers_entry, 0, 0, 2);
- $box_name_servers->pack_end($label_name_servers, 0, 0, 2);
-
- my $label_ip_range_start = Gtk2::Label->new(N("IP Range Start:"));
- my $label_ip_range_end = Gtk2::Label->new(N("IP Range End:"));
- my $entry_ip_range_start = Gtk2::Entry->new;
- my $entry_ip_range_end = Gtk2::Entry->new;
-
- #- grab some default entries from the running system
-
- if (-e "/etc/sysconfig/network") {
- %netconfig = getVarsFromSh("/etc/sysconfig/network");
- $entry_domain->set_text($netconfig{DOMAINNAME});
- }
-
- my $sys_netmask = get_mask_from_sys();
- $entry_netmask->set_text($sys_netmask);
- $entry_subnet_mask->set_text($sys_netmask);
-
- my $sys_broadcast = get_broadcast_from_sys();
- $entry_broadcast->set_text($sys_broadcast);
- my $sys_subnet = get_subnet_from_sys($sys_broadcast, $sys_netmask);
-
- $entry_subnet->set_text($sys_subnet);
-
- my @route = grep { /^0.0.0.0/ } `/sbin/route -n`;
- @ifvalues = split(/[ \t]+/, $route[0]);
- $entry_routers->set_text($ifvalues[1]);
-
- @resolve = cat_("/etc/resolv.conf");
- my $i = 1;
- chop(@resolve);
-
- foreach (@resolve) {
- @ifvalues = split / /;
- if ($ifvalues[0] =~ /nameserver/ && $i < 4) {
- $nservers[$i++] = $ifvalues[1];
- }
- }
-
- $entry_name_server1->set_text($nservers[1]);
- $entry_name_server2->set_text($nservers[2]);
- $entry_name_server3->set_text($nservers[3]);
-
- my $dhcpd_conf = cat_("/etc/dhcpd.conf");
- if (-e "/etc/dhcpd.conf" && $dhcpd_conf !~ /drakTermServ/) {
- $button_msg = N("Append TS Includes To Existing Config");
- } else {
- $button_msg = N("Write Config");
- $new_config = 1;
- }
-
- gtkpack($status_box,
- $dhcpd_box = gtkpack_(Gtk2::HBox->new(1,10),
- 0, gtkadd(Gtk2::VBox->new,
- gtkadd($box_subnet),
- gtkadd($box_netmask),
- gtkadd($box_routers),
- gtkadd($box_subnet_mask),
- gtkadd($box_broadcast),
- gtkadd($box_domain),
- gtkadd($box_name_servers),
- ),
- 0, gtkadd(Gtk2::VBox->new(0,0),
- Gtk2::Label->new(N("dhcpd Server Configuration") . "\n\n" .
- N("Most of these values were extracted\nfrom your running system.\nYou can modify as needed.")),
- Gtk2::HSeparator->new,
- gtkadd(Gtk2::HBox->new,
- Gtk2::Label->new(N("Dynamic IP Address Pool\n(needed for PXE clients):")),
- ),
- gtkadd(Gtk2::HBox->new(0,0),
- gtkadd(Gtk2::VBox->new,
- gtkadd($label_ip_range_start),
- gtkadd($entry_ip_range_start),
- ),
- gtkadd(Gtk2::VBox->new,
- gtkadd($label_ip_range_end),
- gtkadd($entry_ip_range_end),
- ),
- ),
- gtkadd(Gtk2::HBox->new),
- gtksignal_connect($dh_button = Gtk2::Button->new($button_msg), clicked =>
- sub {
- if ($new_config == 1) {
- $wrote = write_dhcpd_config("full",
- $entry_subnet->get_text,
- $entry_netmask->get_text,
- $entry_routers->get_text,
- $entry_subnet_mask->get_text,
- $entry_broadcast->get_text,
- $entry_domain->get_text,
- $entry_name_server1->get_text,
- $entry_name_server2->get_text,
- $entry_name_server3->get_text,
- $entry_ip_range_start->get_text,
- $entry_ip_range_end->get_text);
- } else {
- if ($dhcpd_conf =~ /dhcpd.conf.terminal-server/) {
- $wrote = 1;
- $config_written = 1;
- } else {
- $wrote = write_dhcpd_config("append", @nothing);
- }
- }
- $dh_button->set_sensitive(0) if $wrote;
- }
- ),
- Gtk2::HBox->new(0,10),
- ),
- ),
- );
-
- $central_widget = \$dhcpd_box;
- $dhcpd_box->show_all;
-}
-
-sub get_net_interface() {
- my @interfaces = `/sbin/route | grep -v lo | grep -v vmnet | tail +3 | awk '{print \$8}' | uniq`;
- chop @interfaces;
- my $count = @interfaces;
- if ($count == 1) {
- return @interfaces[0];
- } else {
- foreach (@interfaces) {
- my $is_default = `/sbin/route | grep $_ | grep default`;
- return $_ if !$is_default;
- }
- }
-}
-
-sub get_mask_from_sys() {
- my %netconfig;
- if (-e "/etc/sysconfig/network-scripts/ifcfg-$interface") {
- %netconfig = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$interface");
- $netconfig{NETMASK};
- }
-}
-
-sub get_subnet_from_sys {
- my ($sys_broadcast, $sys_netmask) = @_;
- my @subnet;
-
- my @netmask = split(/\./, $sys_netmask);
- my @broadcast = split(/\./, $sys_broadcast);
-
- foreach (0..3) {
- #- wasn't evaluating the & as expected
- my $val1 = $broadcast[$_] + 0;
- my $val2 = $netmask[$_] + 0;
- $subnet[$_] = $val1 & $val2;
- }
-
- join(".", @subnet);
-}
-
-sub get_broadcast_from_sys() {
- my @ifconfig = grep { /inet/ } `/sbin/ifconfig $interface`;
- my @ifvalues = split(/[: \t]+/, $ifconfig[0]);
-
- $ifvalues[5];
-}
-
-sub get_ip_from_sys() {
- my @ifconfig = grep { /inet/ } `/sbin/ifconfig $interface`;
- my @ifvalues = split(/[: \t]+/, $ifconfig[0]);
-
- $ifvalues[3];
-}
-
-sub write_dhcpd_config {
- my ($mode, $subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_;
- my @dhcpd_config;
- my @includes;
- push @includes, qq(# Include PXE definitions and defaults\ninclude "/etc/dhcpd.conf.pxe.include";\n) if $conf{CREATE_PXE};
- push @includes, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
- push @includes, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n);
- if ($mode eq "append") {
- append_to_file("/etc/dhcpd.conf", qq(include "/etc/dhcpd.conf.terminal-server";\n));
- push @dhcpd_config, @includes;
- push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- $config_written = write_and_check("/etc/dhcpd.conf.terminal-server", @dhcpd_config);
- return $config_written;
- }
-
- $nfs_subnet = $subnet;
- $nfs_mask = $subnet_mask;
-
- 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, @includes;
- push @dhcpd_config, "# Network-specific section\n\n";
-
- 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 = $pool_start && $pool_end && "\trange dynamic-bootp " . $pool_start . " " . $pool_end . ";\n";
- push @dhcpd_config, $pool_string if $pool_string;
-
- my $ns_string = $ns1 && "\toption domain-name-servers " . $ns1;
- $ns_string = $ns2 && $ns_string . ", " . $ns2;
- $ns_string = $ns3 && $ns_string . ", " . $ns3;
- $ns_string = $ns_string . ";\n" if $ns_string;
- push @dhcpd_config, $ns_string if $ns_string;
-
- push @dhcpd_config, "}\n\n";
-
- push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- $config_written = write_and_check("/etc/dhcpd.conf", @dhcpd_config);
- return $config_written;
-}
-
-sub write_and_check {
- my ($ofile, @values) = @_;
- output_p($ofile, @values);
- my $written = cat_($ofile);
- my $source = join("", @values);
- if ($written ne $source) {
- $in->ask_warn(N("Error"), N("Write to %s failed!", $ofile));
- return 0;
- }
- return 1;
-}
-
-sub write_eb_image {
- #- write a bootable etherboot CD image or floppy - pxe images too
- my ($nic, $rom_path, $type) = @_;
- $in->ask_warn(N("Error"), N("No NIC selected!")) and return if $nic eq '';
- if ($type eq 'floppy') {
- my $in = interactive->vnew;
- if (-e "/dev/fd0") {
- my $result = $in->ask_okcancel('', N("Please insert floppy disk:"));
- return if !($result);
- $result = run_program::run("cat $rom_path/zdsk/$nic > /dev/fd0");
- if ($result == 0) {
- $in->ask_warn(N("Error"), N("Could not access the floppy!"));
- } else {
- $in->ask_warn(N("Information"), N("Floppy can be removed now"));
- }
- } else {
- $in->ask_warn(N("Error"), N("No floppy drive available!"));
- }
- } elsif ($type eq 'pxe') {
- $nic =~ s/.zdsk/.zpxe/;
- run_program::run("cp $rom_path/zpxe/$nic $tftpboot");
- if (-e "$tftpboot/$nic") {
- $in->ask_warn(N("Information"), N("PXE image is %s/%s", $tftpboot, $nic));
- } else {
- $in->ask_warn(N("Error"), N("Error writing %s/%s", $tftpboot, $nic));
- }
- } else {
- my $installed = $in->do_pkgs->install('mkisofs') || -f "/usr/bin/mksofs";
- if ($installed) {
- my $tmp = "/root/tmp";
- mkdir_p("$tmp/eb");
- run_program::run("cat $rom_path/zdsk/$nic > $tmp/eb/eb.img");
- run_program::run("dd if=/dev/zero of=$tmp/eb/eb.img bs=512 seek=72 count=2808");
- run_program::run("mkisofs -b eb.img -o $tmp/$nic.iso $tmp/eb");
- rm_rf("$tmp/eb");
- if (-e "$tmp/$nic.iso") {
- $in->ask_warn(N("Information"), N("Etherboot ISO image is %s", "$tmp/$nic.iso"));
- return;
- }
- }
- $in->ask_warn(N("Error"), N("Something went wrong! - Is mkisofs installed?"));
- }
-}
-
-sub enable_ts() {
- #- setup default config files for terminal server
-
- check_gdm();
-
- @buff = ();
- $buff[0] = "Enabling Terminal Server...\n\n";
- $buff[1] = "\tChecking default /etc/dhcpd.conf...\n";
- my $dhcpd_conf = cat_("/etc/dhcpd.conf");
- if ($dhcpd_conf !~ /drakTermServ/) {
- if (-f "/etc/dhcpd.conf") {
- write_dhcpd_config("append", @nothing) if $dhcpd_conf !~ /dhcpd.conf.terminal-server/;
- } else {
- if ($cmd_line == 1) {
- print("No /etc/dhcpd.conf built yet - use GUI to create!!\n");
- } else {
- $in->ask_warn(N("Error"), N("Need to create /etc/dhcpd.conf first!"));
- dhcpd_config();
- }
- return;
- }
- }
- #- suggestion from jmdault - not always needed
- if (! -f $client_cfg) {
- touch($client_cfg);
- }
- my $buff_index = toggle_chkconfig("on", "dhcpd", 2);
- $buff[$buff_index] = "\tSetting up default /etc/exports...\n";
- cp_af("/etc/exports", "/etc/exports.mdkTS") if -e "/etc/exports";
- my $squash = "root_squash";
- my %msec = getVarsFromSh("/etc/sysconfig/msec");
- $squash = "no_root_squash" if $msec{SECURE_LEVEL} > 2;
- my $exports = "#/etc/exports - generated by drakTermServ\n\n";
- if ($nfs_subnet eq '') {
- $nfs_mask = get_mask_from_sys();
- my $sys_broadcast = get_broadcast_from_sys();
- $nfs_subnet = get_subnet_from_sys($sys_broadcast, $nfs_mask);
- }
- $exports .= "/\t$nfs_subnet/$nfs_mask(ro,$squash)\n";
- $exports .= "/home\t$nfs_subnet/$nfs_mask(rw,root_squash)\n";
- $exports .= "$client_prefix\t$nfs_mask(rw, $squash)\n" if $conf{USE_UNIONFS};
- output_p("/etc/exports", $exports);
- $buff_index = toggle_chkconfig("on", "portmap", $buff_index+1);
- $buff_index = toggle_chkconfig("on", $nfs_daemon, $buff_index+1);
- $buff_index = toggle_chkconfig("on", "tftp", $buff_index);
- $buff_index = service_change("xinetd", "restart", $buff_index);
- $buff[$buff_index] = "\n\tDone!";
-
- if ($cmd_line == 1) {
- print "@buff\n";
- return;
- }
-
- show_status(@buff);
-}
-
-sub disable_ts() {
- #- restore pre-terminal server configs
-
- @buff = ();
- $buff[0] = "Disabling Terminal Server...\n\n";
- $buff[1] = "\tRestoring original /etc/dhcpd.conf...\n";
- cp_af("/etc/dhcpd.conf.mdkTS", "/etc/dhcpd.conf") if -e "/etc/dhcpd.conf.mdkTS";
- substInFile { s|include "/etc/dhcpd.conf.terminal-server";|| } "/etc/dhcpd.conf";
- my $buff_index = toggle_chkconfig("off", "dhcpd", 2);
- $buff[$buff_index] = "\tRestoring default /etc/exports...\n";
- cp_af("/etc/exports.mdkTS", "/etc/exports") if -e "/etc/exports.mdkTS";
- $buff_index = toggle_chkconfig("off", "portmap", $buff_index+1);
- $buff_index = toggle_chkconfig("off", $nfs_daemon, $buff_index+1);
- $buff_index = toggle_chkconfig("off", "tftp", $buff_index);
- $buff_index = service_change("xinetd", "restart", $buff_index);
- $buff[$buff_index] = "\n\tDone!";
-
- if ($cmd_line == 1) {
- print "@buff\n";
- return;
- }
-
- show_status(@buff);
-}
-
-sub toggle_chkconfig {
- #- change service config
- my ($state, $service, $buff_index) = @_;
- run_program::run("/sbin/chkconfig $service $state");
- $buff[$buff_index] = "\tTurning $service $state...\n";
- $buff_index++;
- $buff_index;
-}
-
-sub service_change {
- my ($service, $command, $buff_index) = @_;
- run_program::run("BOOTUP=serial /sbin/service $service $command > /tmp/drakTSservice.status 2>&1");
- my @result = cat_("/tmp/drakTSservice.status");
- foreach (@result) {
- $buff[$buff_index] = "\t$_";
- $buff_index++;
- }
- unlink "/tmp/drakTSservice.status";
- $buff_index;
-}
-
-sub start_ts() {
- #- start the terminal server
- my $pcimap = "/etc/dhcpd.conf.etherboot-pcimap.include";
-
- @buff = ();
- if (-f $pcimap) {
- $buff[0] = "Starting Terminal Server...\n\n";
- touch("/etc/dhcpd.conf.etherboot.kernel") if ! -f "/etc/dhcpd.conf.etherboot.kernel";
- my $buff_index = service_change("dhcpd", "start", 2);
- $buff_index = service_change("portmap", "start", $buff_index);
- $buff_index = service_change($nfs_daemon, "start", $buff_index);
- $buff[$buff_index] = "\n\tDone!";
- } else {
- $buff[0] = "Missing $pcimap - please create net boot images for at least one kernel.";
- }
-
- if ($cmd_line == 1) {
- print "@buff\n";
- return;
- }
-
- show_status(@buff);
-}
-
-sub stop_ts() {
- #- stop the terminal server
-
- @buff = ();
- $buff[0] = "Stopping Terminal Server...\n\n";
- my $buff_index = service_change("dhcpd", "stop", 2);
- $buff_index = service_change("portmap", "stop", $buff_index);
- $buff_index = service_change($nfs_daemon, "stop", $buff_index);
- $buff[$buff_index] = "\n\tDone!";
-
- return if $in_wizard;
-
- if ($cmd_line == 1) {
- print "@buff\n";
- return;
- }
-
- show_status(@buff);
-
-}
-
-#- for the wizard, stop the server first
-sub restart_ts() {
- stop_ts();
- start_ts();
-}
-
-sub show_status() {
- text_view("@buff", "close");
-}
-
-sub get_passwd_files() {
- my $shadow = $conf{USE_UNIONFS} ? "$common_prefix/etc/shadow" : '/etc/shadow$$CLIENT$$';
- my $passwd = $conf{USE_UNIONFS} ? "$common_prefix/etc/passwd" : '/etc/passwd$$CLIENT$$';
- return $shadow, $passwd;
-}
-
-sub adduser {
- my ($username) = @_;
- my @active_users = cat_("/etc/shadow");
- my @passwd_users = cat_("/etc/passwd");
- my ($shadow_file, $passwd_file) = get_passwd_files();
- my @ts_users = cat_($shadow_file);
- my $is_user = any { /$username/ } @active_users;
- my $add_fail = 0;
- my $in_already;
-
- if ($is_user) {
- my @shadow_entry = grep { /$username/ } @active_users;
- my @passwd_entry = grep { /$username/ } @passwd_users;
- my $is_ts_user = any { /$username/ } @ts_users;
- if ($is_ts_user) {
- my @ts_shadow = grep { /$username/ } @ts_users;
- if ($shadow_entry[0] eq $ts_shadow[0]) {
- $in_already = 1;
- } else {
- #in but password changed
- print N("%s passwd bad in Terminal Server - rewriting...\n", $username);
- deluser($username);
- adduser($username);
- }
- } else {
- # new ts user
- append_to_file($shadow_file, $shadow_entry[0]) or $add_fail = 1;
- append_to_file($passwd_file, $passwd_entry[0]) or $add_fail = 1;
- $in_already = 0;
- }
- }
-
- if ($cmd_line == 1) {
- print N("%s is not a user..\n", $username) if !($is_user);
- print N("%s is already a Terminal Server user\n", $username) if $in_already;
- if ($add_fail == 1 || $in_already || !$is_user) {
- print N("Addition of %s to Terminal Server failed!\n", $username);
- } else {
- print N("%s added to Terminal Server\n", $username);
- }
- return;
- } else {
- $in_already;
- }
-}
-
-sub deluser {
- # del a user from the client shadow file
- my ($username) = @_;
- my $user_deleted;
- my ($shadow_file, $passwd_file) = get_passwd_files();
- substInFile { $_ = '', $user_deleted = 1 if begins_with($_, "$username:") } $shadow_file;
- substInFile { $_ = '', $user_deleted = 1 if begins_with($_, "$username:") } $passwd_file;
-
- if ($cmd_line == 1) {
- if ($user_deleted) {
- print N("Deleted %s...\n", $username);
- } else {
- print N("%s not found...\n", $username);
- }
- return;
- }
-}
-
-sub addclient {
- #- add a new client entry after checking for dups
- my ($hostname, $mac, $ip, $nbi, $is_thin, $local_config) = @_;
-
- my $host_in_use = 0;
- my $mac_in_use = 0;
- my $ip_in_use = 0;
- my %ts_clients = read_dhcpd_conf();
-
- foreach my $client (keys(%ts_clients)) {
- $host_in_use = 1 if $hostname eq $client;
- $mac_in_use = 1 if $mac eq $ts_clients{$client}{hardware};
- $ip_in_use = 1 if $ip eq $ts_clients{$client}{address};
- }
-
- if ($cmd_line == 1) {
- print N("%s already in use\n", $hostname) if $host_in_use;
- print N("%s already in use\n", $mac) if $mac_in_use;
- print N("%s already in use\n", $ip) if $ip_in_use;
- if ($host_in_use || $mac_in_use || $ip_in_use) {
- return;
- }
- }
-
- if (!$host_in_use && !$mac_in_use && !$ip_in_use) {
- $ts_clients{$hostname}{hardware} = $mac;
- $ts_clients{$hostname}{address} = $ip;
- if ($is_thin == 1) {
- $ts_clients{$hostname}{type} = "thin";
- } else {
- $ts_clients{$hostname}{type} = "fat";
- }
- $ts_clients{$hostname}{filename} = $nbi;
- if ($local_config == 1) {
- $ts_clients{$hostname}{hdw_config} = "true";
- client_hdw_config($ip, 1);
- } else {
- $ts_clients{$hostname}{hdw_config} = "false";
- client_hdw_config($ip, 0);
- }
- my $client_entry = format_client_entry($hostname, %ts_clients);
- append_to_file($client_cfg, $client_entry);
- $changes_made = 1;
- create_client_sysnetwork($hostname, $ip);
- 0;
- }
-}
-
-sub delclient {
- #- find a client and delete the entry in dhcpd.conf
- my ($hostname) = @_;
- my $host_found;
-
- my %ts_clients = read_dhcpd_conf();
-
- foreach my $client (keys(%ts_clients)) {
- if ($hostname eq $client) {
- $host_found = 1;
- clean_client_config($ts_clients{$client}{address});
- delete $ts_clients{$client};
- write_dhcpd_conf(%ts_clients);
- $changes_made = 1;
- return 0;
- }
- }
-
- if ($cmd_line == 1) {
- print N("%s not found...\n", $hostname) unless $host_found;
- return;
- }
-}
-
-sub change_gdm_xdmcp {
- my ($enable) = @_;
- my @conf_data = cat_("/etc/X11/gdm/gdm.conf");
- for (my $i = 0; $i < @conf_data; $i++) {
- $conf_data[$i] =~ s/^Enable=false/Enable=true/ if $enable eq "true";
- $conf_data[$i] =~ s/^Enable=true/Enable=false/ if $enable eq "false";
- # bail here so we do not alter the debug setting
- if ($conf_data[$i] eq "[debug]\n") {
- output("/etc/X11/gdm/gdm.conf", @conf_data);
- last;
- }
- }
-}
-
-sub update_hosts_allow {
- my ($mode) = @_;
- my $mask = get_mask_from_sys();
- my $subnet = `/sbin/ip route list dev $interface scope link | cut -f1 -d"/"`;
- chop $subnet;
- my $i;
- if ($mode eq "enable") {
- my $has_all = `grep ALL /etc/hosts.allow`;
- if ($has_all) {
- $in->ask_warn(N("Warning"), N("/etc/hosts.allow and /etc/hosts.deny already configured - not changed"));
- return;
- }
- if (!$has_all) {
- log::explanations("Modified file /etc/hosts.allow");
- append_to_file("/etc/hosts.allow", "ALL:\t$subnet/$mask 127.0.0.1\n");
- }
- $has_all = `grep ALL /etc/hosts.deny`;
- if (!$has_all) {
- log::explanations("Modified file /etc/hosts.deny");
- append_to_file("/etc/hosts.deny", "ALL:\tALL\n");
- }
- }
- if ($mode eq "disable") {
- my @allow = cat_("/etc/hosts.allow");
- for ($i = 0; $i < @allow; $i++) {
- if ($allow[$i] =~ /^ALL:\t$subnet/) {
- splice(@allow, $i, 1);
- log::explanations("Modified file /etc/hosts.allow");
- output("/etc/hosts.allow", @allow);
- last;
- }
- }
- my @deny = cat_("/etc/hosts.deny");
- for ($i = 0; $i < @deny; $i++) {
- if ($deny[$i] =~ /^ALL:\tALL/) {
- splice(@deny, $i, 1);
- log::explanations("Modified file /etc/hosts.deny");
- output("/etc/hosts.deny", @deny);
- last;
- }
- }
- }
-}
-
-sub format_client_entry {
- #- create a client entry, in proper format
- my ($client, %ts_clients) = @_;
- my $entry = qq(host $client {\n);
- $entry .= qq(\thardware ethernet\t$ts_clients{$client}{hardware};\n);
- $entry .= qq(\tfixed-address\t\t$ts_clients{$client}{address};\n);
- $entry .= qq(\t#type\t\t\t$ts_clients{$client}{type};\n) if $ts_clients{$client}{type};
- $entry .= qq(\tfilename\t\t"$ts_clients{$client}{filename}";\n) if $ts_clients{$client}{filename};
- $entry .= qq(\t#hdw_config\t\t$ts_clients{$client}{hdw_config};\n) if $ts_clients{$client}{hdw_config};
- $entry .= qq(}\n);
- if ($ts_clients{$client}{type} eq "thin") {
- write_thin_inittab($ts_clients{$client}{address});
- } else {
- if ($conf{USE_UNIONFS}) {
- eval { rm_rf("$ts_prefix/$ts_clients{$client}{address}etc/inittab") };
- } else {
- eval { rm_rf("/etc/inittab\$\$IP=$ts_clients{$client}{address}\$\$") };
- }
- }
- $entry;
-}
-
-sub write_dhcpd_conf {
- my %ts_clients = @_;
- my @client_data;
- foreach my $key (keys(%ts_clients)) {
- my $client_entry = format_client_entry($key, %ts_clients);
- push @client_data, $client_entry;
- }
- output_p($client_cfg, @client_data);
-}
-
-sub read_dhcpd_conf() {
- my $clients = $client_cfg;
- my %ts_clients;
- my $hostname;
-
- #- read and parse current client entries
- my @client_data = cat_($clients);
- foreach (@client_data) {
- my ($name, $val, $val2) = split ' ';
- $val = $val2 if $name =~ /hardware/;
- $val =~ s/[;"]//g;
- if ($name !~ /}/) {
- if ($name =~ /host/) {
- $hostname = $val;
- } else {
- $name = "address" if $name =~ /fixed-address/;
- $name = "type" if $name =~ /#type/;
- $name = "hdw_config" if $name =~ /#hdw_config/;
- $ts_clients{$hostname}{$name} = $val;
- }
- }
- }
- %ts_clients;
-}
-
-sub client_hdw_config {
- my ($client_ip, $mode) = @_;
- # configure the files for a client to be able to
- # run drak tools locally and modify configs
- # mode 0 disables root logins but retains configs
- # mode 1 creates the new template files
- my $suffix = $conf{USE_UNIONFS} ? "" : "\$\$IP=$client_ip\$\$";
- my $prefix = $conf{USE_UNIONFS} ? "$client_prefix/$client_ip" : "";
- if ($mode == 1) {
- log::explanations("Allowing root access for $client_ip");
- my ($shadow_file, undef) = get_passwd_files();
- cp_af($shadow_file, "$prefix/etc/shadow$suffix");
- my @sys_users = cat_("/etc/shadow");
- foreach (@sys_users) {
- if (/^root:/) {
- # need root access to do the hardware config
- append_to_file("$prefix/etc/shadow$suffix", $_);
- last;
- }
- }
- # make all the local config files
- cp_af("/etc/sysconfig/mouse", "$prefix/etc/sysconfig/mouse$suffix") if -f "/etc/sysconfig/mouse";
- cp_af("/etc/X11/XF86Config", "$prefix/etc/X11/XF86Config$suffix") if -f "/etc/X11/XF86Config";
- if ($conf{USE_UNIONFS}) {
- cp_af("$common_prefix/etc/X11/xorg.conf", "$prefix/etc/X11/xorg.conf") if -f "$common_prefix/etc/X11/xorg.conf";
- } else {
- cp_af('/etc/X11/xorg.conf$$CLIENT$$', "/etc/X11/xorg.conf$suffix") if -f '/etc/X11/xorg.conf$$CLIENT$$';
- }
- output("$prefix/etc/modules.conf$suffix", '');
- output("$prefix/etc/modules$suffix", '');
- output("$prefix/etc/modprobe.conf$suffix", '');
- output("$prefix/etc/modprobe.preload$suffix", '');
- # create mount points so they can be edited by the client
- if (!$conf{USE_UNIONFS}) {
- 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/xorg.conf$suffix\t$mnt_access\n");
- }
- } else {
- log::explanations("Removing root access for $client_ip");
- eval { rm_rf("/etc/shadow\$\$IP=$client_ip\$\$") };
- remove_client_mounts($client_ip);
- }
-}
-
-sub create_client_sysnetwork {
- #- this lets gnome operate properly since udhcpc does not get the hostname from the dhcpd server
- my ($hostname, $ip) = @_;
- log::explanations("Adding /etc/sysconfig/network for $ip");
- my $network_file = $conf{USE_UNIONFS} ? "$client_prefix/$ip/etc/sysconfig/network" : "/etc/sysconfig/network\$\$IP=$ip\$\$";
- my @net_data = ("HOSTNAME=$hostname\n", "NETWORKING=yes\n", "FORWARD_IPV4=false\n");
- output_p($network_file, @net_data);
-}
-
-sub restart_server() {
- my $answer = $in->ask_yesorno('', N("Configuration changed - restart %s/dhcpd?", $nfs_daemon));
- if ($answer == 1) {
- stop_ts();
- start_ts();
- $changes_made = 0;
- }
-}
-
-sub clean_client_config {
- my ($client_ip) = @_;
- # this routine entirely removes local hardware config settings
- log::explanations("Removing all local hardware config for $client_ip");
- my $suffix = $conf{USE_UNIONFS} ? "" : "\$\$IP=$client_ip\$\$";
- my $prefix = $conf{USE_UNIONFS} ? "$client_prefix/$client_ip" : "";
- eval { rm_rf("$prefix/etc/shadow$suffix") };
- eval { rm_rf("$prefix/etc/sysconfig/mouse$suffix") };
- eval { rm_rf("$prefix/etc/modules.conf$suffix") };
- eval { rm_rf("$prefix/etc/modules$suffix") };
- eval { rm_rf("$prefix/etc/modprobe.conf$suffix") };
- eval { rm_rf("$prefix/etc/modprobe.preload$suffix") };
- eval { rm_rf("$prefix/etc/X11/XF86Config$suffix") };
- eval { rm_rf("$prefix/etc/X11/xorg.conf$suffix") };
- eval { rm_rf("$prefix/etc/sysconfig/network$suffix") };
- remove_client_mounts($client_ip);
-}
-
-sub remove_client_mounts {
- my ($client_ip) = @_;
- #remove the mount points also
- log::explanations("Removing read/write mount points for $client_ip");
- substInFile {
- $_ = '' if /$client_ip/;
- } "/etc/exports";
-}
-
-sub destroy_widget() {
- if ($central_widget ne '') {
- $$central_widget->destroy;
- $central_widget = '';
- }
-}
diff --git a/perl-install/standalone/drakautoinst b/perl-install/standalone/drakautoinst
index b4b1e3453..8c8e98a24 100755
--- a/perl-install/standalone/drakautoinst
+++ b/perl-install/standalone/drakautoinst
@@ -3,7 +3,7 @@
#
# Guillaume Cottenceau (gc@mandrakesoft.com)
#
-# Copyright 2001-2005 Mandriva
+# Copyright 2001-2006 Mandriva
#
# This software may be freely redistributed under the terms of the GNU
# public license.
@@ -22,7 +22,6 @@ use interactive;
use devices;
use detect_devices;
use steps;
-use commands;
use fs;
use Data::Dumper;
@@ -77,7 +76,7 @@ do {
log::explanations(N("Creating auto install floppy"));
my $_w = $in->wait_message('', N("Creating auto install floppy"));
eval {
- commands::dd("if=$imagefile", "of=$dev", "bs=1440", "count=1024");
+ run_program::run('dd', "if=$imagefile", "of=$dev", "bs=1440", "count=1024");
common::sync();
};
$again = $@; #- grrr... $@ is localized in code block :-(
@@ -91,7 +90,7 @@ if (-f $imagefile2) {
log::explanations(N("Creating auto install floppy (drivers disk)"));
my $_w = $in->wait_message('', N("Creating auto install floppy"));
eval {
- commands::dd("if=$imagefile2", "of=$dev", "bs=1440", "count=1024");
+ run_program::run('dd', "if=$imagefile2", "of=$dev", "bs=1440", "count=1024");
common::sync();
};
$again = $@; #- grrr... $@ is localized in code block :-(
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
deleted file mode 100755
index f5365fd8a..000000000
--- a/perl-install/standalone/drakbackup
+++ /dev/null
@@ -1,4580 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2001,2002,2003,2004,2005 Mandriva by Sebastien DUPONT <dupont_s@epita.fr>
-# Updated 2002-2005 by Stew Benedict <sbenedict@mandriva.com>
-# Redistribution of this file is permitted under the terms of the GNU
-# Public License (GPL)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-use lib qw(/usr/lib/libDrakX);
-use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use strict;
-
-use interactive;
-use common;
-use detect_devices;
-use POSIX;
-
-# Backend Options.
-# make this global for status screen
-my ($window1, $my_win);
-my $central_widget;
-my $previous_widget;
-my $current_widget;
-my $interactive;
-my $up_box;
-my $advanced_box;
-my $box2;
-my $cfg_file_exist = 0;
-my @user_list_all;
-my $DEBUG = 0;
-my $restore_sys = 1;
-my $restore_user = 1;
-my $restore_other = 1;
-my $restore_step_sys_date = "";
-my $restore_step_other_date = "";
-my @user_backuped;
-my @sys_backuped;
-my @other_backuped;
-my @user_list_to_restore;
-my @sys_list_to_restore;
-my @other_list_to_restore;
-my $button_box;
-my $button_box_tmp;
-my $next_widget;
-my $system_state;
-my $restore_state;
-my $save_path_entry;
-my $restore_find_path_entry;
-my $new_path_entry;
-my $pbar;
-my $pbar1;
-my $pbar2;
-my $pbar3;
-my $plabel;
-my $plabel1;
-my $plabel2;
-my $plabel3;
-my $stext;
-my $list_model;
-my $the_time;
-my @user_list_to_restore2;
-my $restore_path = "/";
-my $restore_other_path = 0;
-my $restore_other_src;
-my $path_to_find_restore;
-my $other_media_hd;
-my $backup_bef_restore = 0;
-my $table;
-my @user_list_backuped;
-my @files_corrupted;
-my %check_user_to_restore;
-my $remove_user_before_restore = 0;
-my @file_list_to_send_by_ftp;
-my $results;
-my @net_methods = ("ftp", "rsync", "ssh");
-my @media_types = ("hd", "cd", "tape");
-my %cd_devices;
-my $std_device;
-my @tape_devices;
-my $in;
-my @cron_entries;
-
-# config. FILES -> Default PATH & Global variables.
-my @user_list;
-my $cfg_dir = "/etc/drakxtools/drakbackup/";
-my $cfg_file = $cfg_dir . "drakbackup.conf";
-my $log_file = "/var/log/drakbackup";
-my $log_buff;
-my $manual_user = 0;
-my $backup_daemon = 0;
-my $daemon = 0;
-my $use_hd = 1;
-my $custom_cron = 0;
-my $session_offset = '';
-my $scp_port = 22;
-my $user_home = $ENV{HOME};
-my $nonroot_user = 0;
-my $media_problem = 0;
-my $vol_name = 'Drakbackup';
-my $good_restore_path = 1;
-my @no_devices = translate(N_("No device found"));
-my %help;
-my %conf;
-my $time_string = "* * * * *";
-my $exec_string = "export USER=$ENV{USER}; /usr/sbin/drakbackup";
-my $profile_string;
-my $redir_string = "--daemon > /dev/null 2>&1";
-my $ignore_files_list;
-my @other_files;
-my @sys_files = "/etc";
-my @files_for_direct_tape;
-my $host_passwd;
-my $index_cmd = "| tee ";
-
-# allow not-root user with own config
-if ($ENV{USER} ne 'root' && $ENV{HOME} ne '/root') {
- standalone::explanations("Running as $ENV{USER}...");
- #- does not get defined when run from cron
- $user_home = "/home/$ENV{USER}" if $user_home eq '';
- @user_list = $ENV{USER};
- $cfg_dir = "$user_home/.drakbackup/";
- $conf{PATH_TO_SAVE} = $cfg_dir . "backups";
- $log_file = $cfg_dir . "drakbackup.log";
- $nonroot_user = 1;
- $conf{NO_SYS_FILES} = 1;
-} else {
- $user_home = "/root";
- $conf{PATH_TO_SAVE} = "/var/lib/drakbackup";
-}
-$cfg_file = $cfg_dir . "drakbackup.conf";
-my $backup_key = $user_home . "/.ssh/identity-drakbackup";
-
-foreach (@ARGV) {
- /--default/ and backend_mode();
- /--profile/ and set_profile($_);
- /--daemon/ and daemon_mode();
- /--show-conf/ and show_conf();
- /--cd-info/ and get_cd_info(), exit(0);
- /--debug/ and $DEBUG = 1, next;
-}
-
-sub setup_tooltips() {
- %help = (
- 'use_expect' => N("Expect is an extension to the TCL scripting language that allows interactive sessions without user intervention."),
- 'remember_pass' => N("Store the password for this system in drakbackup configuration."),
- 'erase_cdrw' => N("For a multisession CD, only the first session will erase the cdrw. Otherwise the cdrw is erased before each backup."),
- 'use_incr_decr' => N("This option will save files that have changed. Exact behavior depends on whether incremental or differential mode is used."),
- 'use_incremental' => N("Incremental backups only save files that have changed or are new since the last backup."),
- 'use_differential' => N("Differential backups only save files that have changed or are new since the original 'base' backup."),
- 'choose_archiver' => N("Star should be selected if you want to backup EA or ACLs, otherwise choose tar"),
- 'send_mail_to' => N("This should be a local user or email address that you want the backup results sent to. You will need to define a functioning mail server. Multiple users can be in a comma seperated list"),
- 'send_mail_from' => N("This should be the return address that you want the backup results sent from. Default is drakbackup."),
- 'backupignore' => N("Files or wildcards listed in a .backupignore file at the top of a directory tree will not be backed up."),
- 'delete_files' => N("For backups to other media, files are still created on the hard drive, then moved to the other media. Enabling this option will remove the hard drive tar files after the backup."),
- 'view_log' => N("Selecting this option allows you to view the raw output from the restore process, after a file restore."),
- 'dir_or_module' => N("Some protocols, like rsync, may be configured at the server end. Rather than using a directory path, you would use the 'module' name for the service path."),
- 'when_space' => N("Custom allows you to specify your own day and time. The other options use run-parts in /etc/crontab."),
- );
-}
-
-sub show_conf() {
- print "DrakBackup configuration:\n\n";
- read_conf_file();
- system_state();
- print "$system_state\n";
- exit(0);
-}
-
-sub backend_mode() {
- build_backup_files();
- exit(0);
-}
-
-sub set_profile {
- my ($argn) = @_;
- my $profile = $ARGV[$argn + 1];
- die "Usage: --profile <filename>...\n" if $profile =~ /^--/;
- $profile .= ".conf" if $profile !~ /.conf/;
- $cfg_file = $cfg_dir . $profile;
- die "Profile $cfg_file not found...\n" if !-e $cfg_file;
- return;
-}
-
-sub daemon_mode() {
- $daemon = 1;
- build_backup_files();
- exit(0);
-}
-
-if (check_for_xserver()) {
- eval { require ugtk2 };
- die "Can not load ugtk2...\n" if $@;
- ugtk2->import(qw(:create :dialogs :helpers :wrappers));
- interactive_mode();
-} else {
- die "Can not run in console mode...";
-}
-
-sub set_help_tip {
- my ($entry, $key) = @_;
- gtkset_tip(Gtk2::Tooltips->new, $entry, formatAlaTeX($help{$key}));
-}
-
-sub all_user_list() {
- if ($nonroot_user) {
- @user_list_all = $ENV{USER};
- return;
- }
- my $user;
- my $uid;
- @user_list_all = ();
-
- my @passwd = cat_("/etc/passwd");
- foreach (@passwd) {
- ($user, $uid) = (split(/:/, $_))[0, 2];
- if ($uid >= 500 && $uid < 65000 || $uid == 0) {
- push @user_list_all, $user;
- }
- }
-}
-
-sub the_time() {
- my ($sec, $min, $hour, $day, $month, $year) = localtime(time());
- sprintf("_%d%02d%02d_%02d%02d%02d", $year + 1900, $month + 1, $day, $hour, $min, $sec);
-}
-
-sub get_tape_info() {
- my @line_data;
- my $info = "$ENV{HOME}/tmp/dmesg";
- @tape_devices = ();
- system("dmesg -s 100000 | grep 'st[0-9] at' > $info");
-
- my @info = cat_($info);
- foreach (@info) {
- @line_data = split(/[ \t,]+/, $_);
- push @tape_devices, "/dev/" . $line_data[3];
- }
- unlink($info);
-}
-
-sub get_free_space {
- my ($dir) = @_;
- my $free = `df -P $dir | tail -1`;
- my @line_data = split(/[ \t,]+/, $free);
- my $free_space = int($line_data[3] / 1024);
- return $free_space;
-}
-
-sub check_storage_quota {
- my ($dir) = @_;
- my $used = `du -b $dir`;
- my $used_space = $used / 1024 / 1024;
- if ($used_space > $conf{MAX_SPACE}) {
- return $used_space;
- } else {
- return 0;
- }
-}
-
-sub get_cd_info() {
- my @line_data;
- my @drive_names;
- my $i;
- # just trying load ide-cd, since it does not seem to be loaded by default
- if (!-f "/proc/sys/dev/cdrom") {
- $nonroot_user ? `cdrecord -scanbus -dev=ATA > /dev/null 2>&1` : `modprobe ide-cd`;
- }
- my @cd_info = cat_("/proc/sys/dev/cdrom/info");
- my %data = (
- "drive speed" => 'speed',
- "Can change speed" => 'chg_speed',
- "Can read multisession" => 'multisession',
- "Can write CD-R" => 'cdr',
- "Can write CD-RW" => 'cdrw',
- "Can write DVD-R" => 'dvdr',
- "Can write DVD-RAM" => 'dvdram'
- );
-
- my $cd_drives;
- foreach (@cd_info) {
- @line_data = split(/[:\t]+/, $_);
- if ($line_data[0] =~ /drive name/) {
- $cd_drives = @line_data-1;
- chop($line_data[$cd_drives]);
- @drive_names = @line_data;
- print "drives: $cd_drives\n" unless $interactive;
- }
- chop($line_data[$cd_drives]) if $cd_drives;
- foreach my $key (keys %data) {
- if ($line_data[0] eq $key) {
- for ($i = 1; $i <= $cd_drives; $i++) {
- $cd_devices{$drive_names[$i]}{$data{$key}} = $line_data[$i];
- }
- }
- }
- }
-
- #- now just report the data if we called --cd-info from the command line
- foreach my $key (keys %cd_devices) {
- my $rec_dev = $key;
- my $prefix;
- $rec_dev =~ s/sr/sg/;
- $prefix = "ATAPI:" if $rec_dev =~ /hd/;
- my $can_record = $cd_devices{$key}{cdr} || $cd_devices{$key}{cdrw} || $cd_devices{$key}{dvdr};
- $cd_devices{$key}{rec_dev} = $prefix . "/dev/" . $rec_dev if $can_record;
- if (!$interactive) {
- print "\n{$key}->{rec_dev} = $cd_devices{$key}{rec_dev}\n";
- print "{$key}->{speed} = $cd_devices{$key}{speed}\n";
- print "{$key}->{chg_speed} = $cd_devices{$key}{chg_speed}\n";
- print "{$key}->{multisession} = $cd_devices{$key}{multisession}\n";
- print "{$key}->{cdr} = $cd_devices{$key}{cdr}\n";
- print "{$key}->{cdrw} = $cd_devices{$key}{cdrw}\n";
- 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 '';
- }
- }
-}
-
-
-sub save_conf_file() {
- write_password_file() if $conf{NET_PROTO} eq 'rsync' && $conf{PASSWD};
- return 1 if $conf{SEND_MAIL} && verify_mail_setup();
- #- do not save this, but retain it for this session
- if ($conf{REMEMBER_PASS} != 1) {
- $host_passwd = $conf{PASSWD};
- $conf{PASSWD} = undef;
- }
- if ($backup_daemon && $conf{DAEMON_MEDIA} eq '') {
- show_warning("f", N("No media selected for cron operation."));
- return 1;
- }
- if ($backup_daemon && $conf{DAEMON_TIME_SPACE} eq '') {
- show_warning("f", N("No interval selected for cron operation."));
- return 1;
- }
- if (!$backup_daemon) {
- $conf{DAEMON_TIME_SPACE} = "";
- $conf{DAEMON_MEDIA} = "";
- }
- $conf{NO_USER_FILES} = '' if @user_list == ();
- $conf{OTHER_FILES} = list_to_conf(@other_files);
- $conf{HOME_FILES} = list_to_conf(@user_list);
- $conf{SYS_FILES} = list_to_conf(@sys_files);
- mkdir_p($cfg_dir) if !-d $cfg_dir;
- setVarsInSh($cfg_file, \%conf);
- $conf{PASSWD} = $host_passwd if $conf{REMEMBER_PASS} != 1;
- chmod(0600, $cfg_file);
- save_cron_files();
- 0;
-}
-
-sub read_cron_files() {
- my $daemon_found = 0;
- foreach (qw(hourly daily weekly monthly)) {
- if (-f "/etc/cron.$_/drakbackup" && !$nonroot_user) {
- $conf{DAEMON_TIME_SPACE} = $_;
- $daemon_found = 1;
- last;
- }
- }
- if ($conf{DAEMON_TIME_SPACE} ne "custom") {
- !$daemon_found and $backup_daemon = 0;
- } else {
- read_user_cron();
- }
-}
-
-sub read_user_cron() {
- @cron_entries = `crontab -l`;
- chomp @cron_entries;
-}
-
-sub save_cron_files() {
- my $tmpcron = $ENV{HOME} . tmpnam() . ".tmp";
- my @cron_output;
-
- if ($nonroot_user && $conf{DAEMON_TIME_SPACE} ne "custom" && $conf{DAEMON_TIME_SPACE} ne '' && $backup_daemon) {
- show_warning("w", N("Interval cron not available as non-root"));
- $conf{DAEMON_TIME_SPACE} = 'custom';
- return 1;
- } else {
- foreach (qw(hourly daily weekly monthly)) {
- -f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup") if !$nonroot_user;
- }
- }
- my @cron_file = ("#!/bin/sh\n", "export USER=root\n", "/usr/sbin/drakbackup --daemon > /dev/null 2>&1\n");
-
- if ($conf{DAEMON_TIME_SPACE} ne "custom" && $conf{DAEMON_TIME_SPACE} ne '' && $backup_daemon) {
- output_p("/etc/cron.$conf{DAEMON_TIME_SPACE}/drakbackup", @cron_file);
- system("chmod +x /etc/cron.$conf{DAEMON_TIME_SPACE}/drakbackup");
- }
-
- if ($conf{DAEMON_TIME_SPACE} eq "custom" && $backup_daemon) {
- foreach (@cron_entries) {
- next if /^#/;
- push @cron_output, $_ . "\n";
- }
- output($tmpcron, @cron_output);
- system("crontab $tmpcron");
- unlink($tmpcron);
- }
-}
-
-sub upgrade_conf_file() {
- my @new_conf;
- $DEBUG and print "Old syntax...upgrading...\n";
- my @conf_data = cat_($cfg_file);
- chop @conf_data;
- foreach (@conf_data) {
- push @new_conf, $_ . "=1\n" if !/=/;
- if (/^OTHER_FILES/) {
- my (@new_data) = split /=/;
- my @new_args = split(" ", $new_data[1]);
- push @new_conf, $new_data[0] . "=" . join(",", @new_args) . "\n";
- } elsif (/=/ && !/TAR.GZ/) {
- my $has_arg = split /=/;
- push @new_conf, "$_\n" if $has_arg > 1;
- } elsif (/=/ && /TAR.GZ/) {
- push @new_conf, "OPTION_COMP=tar.gz";
- }
- }
- output_p($cfg_file, @new_conf);
-}
-
-sub read_conf_file() {
- if (-e $cfg_file) {
- my $conf_version = `grep USE_HD $cfg_file`;
- upgrade_conf_file() if $conf_version !~ /^USE_HD=1/;
- %conf = getVarsFromSh($cfg_file);
- @other_files = conf_to_list($conf{OTHER_FILES});
- @user_list = conf_to_list($conf{HOME_FILES}) if exists($conf{HOME_FILES});
- @sys_files = conf_to_list($conf{SYS_FILES}) if exists($conf{SYS_FILES});
- $backup_daemon = 1 if exists($conf{DAEMON_TIME_SPACE});
- $conf{PASSWD} = $host_passwd if $conf{REMEMBER_PASS} != 1;
- read_cron_files();
- $cfg_file_exist = 1;
- } else {
- $cfg_file_exist = 0;
- #- these were 1 by default, but that made it so the user could never save the
- #- inverse behavior. this allows incremental as the default if not configured
- $conf{SYS_INCREMENTAL_BACKUPS} = 1;
- $conf{USER_INCREMENTAL_BACKUPS} = 1;
- }
- # some basic defaults
- $conf{SMTP_SERVER} = "localhost" if !exists($conf{SMTP_SERVER});
- $conf{MAX_SPACE} = 1000.0 if !exists($conf{MAX_SPACE});
- $conf{USE_HD} = 1 if !exists($conf{USE_HD});
- $conf{OPTION_COMP} = "tar.gz" if !exists($conf{OPTION_COMP});
- $conf{ARCHIVER} = "tar" if !exists($conf{ARCHIVER});
- $conf{FROM_MAIL} = "drakbackup" if !exists($conf{FROM_MAIL});
- $conf{DEL_OLD} = 0 if !exists($conf{DEL_OLD});
- # deal with users that may have been deleted from the system
- check_valid_users() if $cfg_file_exist;
- $use_hd = !($conf{USE_CD} || $conf{USE_TAPE} || $conf{USE_NET});
-}
-
-sub verify_mail_setup() {
- all_user_list() if @user_list_all == ();
- my @mlist = split(',', $conf{USER_MAIL});
- foreach (@mlist) {
- if ($_ ne "root" && !/[\w.-]*\@[\w.-]/ && !member($_, @user_list_all)) {
- show_warning("f", N("\"%s\" neither is a valid email nor is an existing local user!", $conf{USER_MAIL}));
- return 1;
- }
- if (member($_, @user_list_all) && $conf{SMTP_SERVER} ne "localhost") {
- show_warning("f", N("\"%s\" is a local user, but you did not select a local smtp, so you must use a complete email address!", $conf{USER_MAIL}));
- return 1;
- }
- }
-}
-
-sub check_valid_users() {
- all_user_list();
- my @new_user_list = intersection(\@user_list, \@user_list_all);
- if (@user_list != @new_user_list) {
- log::l(N("Valid user list changed, rewriting config file."));
- if ($DEBUG) {
- print N("Old user list:\n");
- print "@user_list\n";
- print N("New user list:\n");
- print "@new_user_list\n";
- }
- @user_list = @new_user_list;
- save_conf_file();
- }
-}
-
-sub write_password_file() {
- output_p("$cfg_dir/rsync.user", "$conf{PASSWD}\n");
- chmod(0600, "$cfg_dir/rsync.user");
-}
-
-sub show_warning {
- my ($mode, $warning) = @_;
- $mode = N("Warning") if $mode eq "w";
- $mode = N("Error") if $mode eq "f";
- $mode = N("Information") if $mode eq "i";
- if ($interactive) {
- $in->ask_warn($mode, translate($warning));
- } else {
- warn "$mode: $warning\n";
- }
- $log_buff .= "\n$mode: $warning\n";
-}
-
-sub complete_results() {
- system_state();
- $results .= "***********************************************************************\n\n";
- $daemon or $results .= N("\n DrakBackup Report \n");
- $daemon and $results .= N("\n DrakBackup Daemon Report\n");
- my $datem = `date`;
- $results .= " $datem\n\n";
- $results .= "***********************************************************************\n\n";
- $results .= $system_state;
- $results .= "\n\n***********************************************************************\n\n";
- $results .= N("\n DrakBackup Report Details\n\n\n");
- $results .= "***********************************************************************\n\n";
-}
-
-sub ftp_client() {
- use Net::FTP;
- my $ftp;
-
- foreach (1..5) {
- $ftp = Net::FTP->new($conf{HOST_NAME}, Debug => 0) or return 1;
- $ftp && $ftp->login($conf{LOGIN}, $conf{PASSWD}) and last;
- log::l("ftp login failed, sleeping before trying again");
- sleep 5 * $_;
- $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);
- $interactive and progress($pbar, $plabel, 0.5, $_);
- $interactive and $pbar->set_text($_);
- $ftp->put($_, undef, undef);
- $interactive and progress($pbar, $plabel, 0.5, $_);
- $interactive and $pbar->set_text($_);
- $interactive and progress($pbar3, $plabel3, 1/@file_list_to_send_by_ftp, N("Total progress"));
- }
- $ftp->quit;
- return 0;
-}
-
-sub do_expect {
-
- #- Sort of a general purpose expect routine, we use it to backup files to
- #- a remote server, as well as transfer a key and restore.
- #- Using the key after it is setup is preferred.
-
- my ($mode) = @_;
-
- eval { require Expect };
-
- if ($@) {
- #- should have already been installed during configuration
- $log_buff .= "perl-Expect not installed!" if check_pkg_needs();
- return 1;
- }
-
- #- for debugging set to 1
- $Expect::Exp_Internal = 0;
- #- for debugging set to 1
- $Expect::Debug = 0;
- $Expect::Log_Stdout = 0;
-
- my $spawn_ok;
- my $no_perm;
- my $bad_passwd;
- my $bad_dir;
- my $had_err;
- my $timeout = 20;
-
- my $exp_command;
- my @send_files = "$backup_key.pub";
-
- #- just bypass progress for sendkey for now
- my $no_prog = 1;
- $no_prog = 0 if $mode eq "sendkey";
-
- @send_files = @file_list_to_send_by_ftp if $mode eq "backup";
-
- $interactive && $no_prog and $pbar->set_fraction(0);
- $interactive && $no_prog and $pbar3->set_fraction(0);
- $interactive && $no_prog and progress($pbar, $plabel, 0.5, "File Transfer...");
-
- foreach (@send_files) {
- $exp_command = "scp -P $scp_port $_ $conf{LOGIN}\@$conf{HOST_NAME}:$conf{HOST_PATH}" if $mode eq "backup";
- $exp_command = "ssh-copy-id -i $_ $conf{LOGIN}\@$conf{HOST_NAME}" if $mode eq "sendkey";
-
- if (-e $backup_key && $mode eq "sendkey") {
- if ($in->ask_yesorno(N("Warning"), N("%s exists, delete?\n\nIf you've already done this process you'll probably\n need to purge the entry from authorized_keys on the server.", $backup_key))) {
- unlink($backup_key);
- unlink($backup_key . '.pub');
- } else {
- return 0;
- }
- }
-
- if (!(-e $backup_key) && $mode eq "sendkey") {
- $in->ask_warn(N("Information"), N("This may take a moment to generate the keys."));
- gtkset_mousecursor_wait();
- #- not using a passphrase for the moment
- system("ssh-keygen", "-P", "", "-t", "dsa", "-f", $backup_key);
- gtkset_mousecursor_normal();
- }
-
- my $exp = Expect->spawn($exp_command) or $in->ask_warn(N("Error"), N("Cannot spawn %s.", $exp_command));
-
- $interactive && $no_prog and progress($pbar3, $plabel3, 1/@send_files, N("Total progress"));
- $interactive && $no_prog and $stext->set_text($_);
-
- #- run scp, look for some common errors and try to track successful progress for GUI
- $exp->expect($timeout,
- [ qr 'password: $', sub {
- $spawn_ok = 1;
- my $fh = shift;
- $fh->send("$conf{PASSWD}\n");
- Expect::exp_continue() } ],
- [ '-re', 'please try again', sub { $bad_passwd = 1; Expect::exp_continue() } ],
- [ '-re', 'Permission denied', sub { $no_perm = 1; Expect::exp_continue() } ],
- [ '-re', 'No such file or directory', sub { $bad_dir = 1; Expect::exp_continue() } ],
-# [ '-re', '%', sub { update_scp_progress(); Expect::exp_continue(); } ],
- [ eof => sub {
- if (!$spawn_ok) { show_warning("f", N("No password prompt on %s at port %s", $conf{HOST_NAME}, $scp_port)) }
- if ($bad_passwd) { show_warning("f", N("Bad password on %s", $conf{HOST_NAME})) }
- if ($no_perm) { show_warning("f", N("Permission denied transferring %s to %s", $_, $conf{HOST_NAME})) }
- if ($bad_dir) { show_warning("f", N("Can not find %s on %s", $conf{HOST_PATH}, $conf{HOST_NAME})) }
- $had_err = !$spawn_ok || $bad_passwd || $no_perm || $bad_dir;
- }
- ],
- [ timeout => sub { show_warning("f", N("%s not responding", $conf{HOST_NAME})) } ],
- );
-
- my $exit_stat = $exp->exitstatus;
- $in->ask_warn(N("Information"), N("Transfer successful\nYou may want to verify you can login to the server with:\n\nssh -i %s %s\@%s\n\nwithout being prompted for a password.", $backup_key, $conf{LOGIN}, $conf{HOST_NAME})) if $exit_stat == 0 && !$had_err && $mode eq "sendkey";
- $log_buff .= "$_\n" if $exit_stat == 0 && $mode eq "backup";
- $exp->hard_close;
- }
- $interactive && $no_prog and progress($pbar, $plabel, 0.5, "Done...");
-}
-
-sub ssh_client() {
- $DEBUG and print "file list to send: $_\n " foreach @file_list_to_send_by_ftp;
- my $command;
- my $value;
-
- foreach (@file_list_to_send_by_ftp) {
- if ($conf{USER_KEYS}) {
- $command = "scp -P $scp_port $_ $conf{LOGIN}\@$conf{HOST_NAME}:$conf{HOST_PATH}";
- } else {
- $command = "scp -P $scp_port -i $backup_key $_ $conf{LOGIN}\@$conf{HOST_NAME}:$conf{HOST_PATH}";
- }
- $interactive and $pbar->set_fraction(0);
- $interactive and progress($pbar, $plabel, 0.5, "File Transfer...");
- $interactive and $stext->set_text($_);
- $log_buff .= $command . "\n\n";
- my $TMP;
- open $TMP, "$command 2>&1 |";
- while ($value = <$TMP>) {
- $log_buff .= $value;
- }
- close $TMP;
- $log_buff .= "\n";
- $interactive and progress($pbar, $plabel, 0.5, "Done...");
- $interactive and progress($pbar3, $plabel3, 1/@file_list_to_send_by_ftp, N("Total progress"));
- }
- return 0;
-}
-
-sub rsync_client() {
- $DEBUG and print "file list to send: $_\n " foreach @file_list_to_send_by_ftp;
- my $rsync_cmd = "rsync -tv $conf{PATH_TO_SAVE}/* ";
- $rsync_cmd = $rsync_cmd . "--password-file=$cfg_dir/rsync.user " if $conf{PASSWD};
- $rsync_cmd = $rsync_cmd . "$conf{LOGIN}\@" if $conf{LOGIN};
- $rsync_cmd = $rsync_cmd . $conf{HOST_NAME} . "::" . $conf{HOST_PATH};
- spawn_progress($rsync_cmd, "Running rsync");
- return 0;
-}
-
-sub check_for_cd() {
- #- check for a cd
- my $command = "cdrecord dev=$conf{CD_DEVICE} -atip";
- spawn_progress($command, "Check for media in drive");
- if ($log_buff =~ /No disk/) {
- show_warning("f", N("No CD-R/DVD-R in drive!"));
- return 1;
- }
- if ($log_buff !~ /ATIP info from disk|ATIP start of lead in|Found DVD media/) {
- show_warning("f", N("Does not appear to be recordable 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}) {
- $command = "cdrecord -s dev=$conf{CD_DEVICE} -msinfo";
- spawn_progress($command, "Check for previous session status");
- #- if we do not find a previous session, start fresh
- if ($log_buff =~ /Cannot read session offset/) {
- $conf{MEDIA_ERASE} = 1;
- return 0;
- } else {
- #- extract the session info from $log_buff
- my $code_loc = rindex($log_buff, "msinfo") + 8;
- if ($code_loc != -1) {
- my $bufflen = length($log_buff);
- $session_offset = substr($log_buff, $code_loc, $bufflen-$code_loc-1);
- return 0;
- }
- return 1;
- }
- }
-}
-
-sub write_on_cd() {
- my $command = "cdrecord -v dev=$conf{CD_DEVICE} -data ";
- # 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
- $command .= "-multi -pad " if $conf{MULTI_SESSION};
- $command .= "$conf{PATH_TO_SAVE}/drakbackup.iso";
-
- spawn_progress($command, "Running cdrecord");
- unlink("$conf{PATH_TO_SAVE}/drakbackup.iso");
-}
-
-sub erase_cdrw() {
- #- we can only hit this via interactive
- $interactive = 0;
- $in->ask_warn(N("Information"), N("This may take a moment to erase the media."));
- gtkset_mousecursor_wait();
- my $command = "cdrecord dev=$conf{CD_DEVICE} -blank=fast";
- spawn_progress($command, "Erasing CDRW...");
- gtkset_mousecursor_normal();
- $interactive = 1;
-}
-
-sub spawn_progress {
- my ($command, $descr) = @_;
- my $value;
- my $timer;
- $interactive and progress($pbar3, $plabel3, 0, translate($descr));
- $interactive and $pbar3->set_pulse_step(0.1);
- $interactive and $timer = Glib::Timeout->add(20, sub { $pbar3->pulse });
-
- $log_buff .= "\n" . $descr . ":\n";
- $log_buff .= $command . "\n\n";
-
- standalone::explanations("Running $command");
- my $TMP;
- open $TMP, "$command 2>&1 |";
- while ($value = <$TMP>) {
- $log_buff .= $value;
- if ($interactive) {
- $stext->set_text($value);
- gtkflush();
- }
- }
- close $TMP;
- $interactive and Glib::Source->remove($timer);
-}
-
-sub get_cd_volname() {
- my $vol_device = $conf{CD_DEVICE};
- $vol_device =~ s/sg/scd/;
- $vol_name = `volname $vol_device` if $conf{CD_DEVICE};
- $vol_name =~ s/[ \t]+\n$//;
- $vol_name;
-}
-
-sub build_iso() {
- if ($conf{MULTI_SESSION} && $session_offset) {
- $vol_name = get_cd_volname();
- } else {
- $vol_name = "Drakbackup" . $the_time;
- }
- #this is safe to change the volname on rewrites, as is seems to get ignored anyway
- my $command = "mkisofs -r -J -T -v -V '$vol_name' ";
- $command .= "-C $session_offset -M $conf{CD_DEVICE} " if $conf{MULTI_SESSION} && $session_offset;
- $command .= "-o $conf{PATH_TO_SAVE}/drakbackup.iso @file_list_to_send_by_ftp";
- spawn_progress($command, "Running mkisofs...");
-}
-
-sub build_cd() {
- if (!check_for_cd()) {
- build_iso();
- if ($log_buff =~ /Permission denied/) {
- show_warning("f", N("Permission problem accessing CD."));
- $media_problem = 1;
- return 1;
- } else {
- write_on_cd();
- }
- }
-}
-
-sub get_tape_label {
- my ($device) = @_;
- gtkset_mousecursor_wait();
- system("mt -f $device rewind");
- system("$conf{ARCHIVER} -C $cfg_dir -x -f $device");
- my @volname = cat_("$cfg_dir/drakbackup.label");
- unlink("$cfg_dir/drakbackup.label");
- $vol_name = $volname[0];
- gtkset_mousecursor_normal();
- $vol_name;
-}
-
-sub build_tape() {
- my $command;
- my $dt_list;
- #- do we have a tape?
- $command = "mt -f $conf{TAPE_DEVICE} status";
- spawn_progress($command, "Checking for tape");
- if ($log_buff =~ /DR_OPEN/) {
- show_warning("f", N("No tape in %s!", $conf{TAPE_DEVICE}));
- return 1;
- }
- #- enable compression if configured
- if ($conf{HDW_COMP}) {
- $command = "mt -f $conf{TAPE_DEVICE} compression";
- spawn_progress($command, "Enabling compression");
- }
- #- try to roll to the end of the data if we're not erasing
- $command = "mt -f $conf{TAPE_DEVICE} rewind";
- # if we're using the rewinding device, change modes briefly
- if (!$conf{TAPE_NOREWIND}) {
- $conf{TAPE_DEVICE} =~ s|/st|/nst|;
- }
- if (!$conf{MEDIA_ERASE}) {
- spawn_progress($command, "Rewind to find tape label");
- $command = "$conf{ARCHIVER} -t -f $conf{TAPE_DEVICE}";
- spawn_progress($command, "Check for label");
- if ($log_buff =~ /drakbackup.label/) {
- $command = "mt -f $conf{TAPE_DEVICE} rewind";
- spawn_progress($command, "Rewind to get tape label");
- $command = "$conf{ARCHIVER} -C $cfg_dir -x -f $conf{TAPE_DEVICE}";
- spawn_progress($command, "Reading tape label");
- my @volname = cat_("$cfg_dir/drakbackup.label");
- unlink("$cfg_dir/drakbackup.label");
- $vol_name = $volname[0];
- }
- $command = "mt -f $conf{TAPE_DEVICE} eod";
- spawn_progress($command, "Running mt to find eod");
- } else {
- spawn_progress($command, "Running mt to rewind");
- # make a tape label for the catalog
- $vol_name = "Drakbackup" . $the_time;
- my $f = "$cfg_dir/drakbackup.label";
- output($f, $vol_name);
- $command = "$conf{ARCHIVER} -C $cfg_dir -c -f $conf{TAPE_DEVICE} drakbackup.label;";
- spawn_progress($command, "Creating tape label");
- unlink $f;
- }
- # restore device setup
- if (!$conf{TAPE_NOREWIND}) {
- $conf{TAPE_DEVICE} =~ s|/nst|/st|;
- }
-
- #- do the backup
- $command = "$conf{ARCHIVER} -cv -f $conf{TAPE_DEVICE} ";
- if ($conf{DIRECT_TAPE}) {
- $command .= handle_ignores($command !~ /-V/, @files_for_direct_tape);
- $command .= " @files_for_direct_tape";
- $dt_list = $conf{PATH_TO_SAVE} . "/list_direct_tape" . $the_time . ".txt";
- $command .= " $index_cmd $dt_list";
- } else {
- $command .= " @file_list_to_send_by_ftp";
- }
- spawn_progress($command, "Running tar to tape");
- gzip($dt_list);
-
- #- eject the tape?
- if ($conf{MEDIA_EJECT}) {
- $command = "mt -f $conf{TAPE_DEVICE} rewoff";
- spawn_progress($command, "Running mt to eject tape");
- }
-}
-
-sub send_mail {
- my ($result) = @_;
- my $datem = `date`;
- use Mail::Mailer;
- my @mlist = split(',', $conf{USER_MAIL});
- my $mailer = Mail::Mailer->new('smtp', Server => $conf{SMTP_SERVER});
- foreach (@mlist) {
- $mailer->open({ From => $conf{FROM_MAIL},
- To => $_,
- Subject => "DrakBackup report on $datem" }) or return 1;
- print $mailer $result;
- $mailer->close;
- }
- 0;
-}
-
-sub build_backup_files() {
- my $path_name;
- my $tar_cmd;
- my $more_recent;
- my $tar_cmd_sys;
- my $tar_cmd_user;
- my $tar_cmd_other;
- my @dir_content;
- my $incr;
- my $base;
- my $find_args = "! -type d -print";
-
- local $_;
- $results = "";
- $log_buff = "";
- #- flush these so if the user does 2 runs in a row we do not try to send the same files
- @file_list_to_send_by_ftp = ();
- @files_for_direct_tape = ();
-
- $interactive and gtkset_mousecursor_wait();
- check_archiver();
- read_conf_file();
- $the_time = the_time();
- $conf{SEND_MAIL} and complete_results();
- -d $conf{PATH_TO_SAVE} or mkdir_p($conf{PATH_TO_SAVE});
-
- $tar_cmd = "$conf{ARCHIVER} -cv -p ";
- $tar_cmd .= $conf{ARCHIVER} eq 'tar' ? "-P " : "-acl -xattr -tpath ";
- $tar_cmd .= set_compression($conf{OPTION_COMP});
-
- clean_old_backups();
- my $used_space = check_storage_quota($conf{PATH_TO_SAVE});
- if ($used_space) {
- my $msg = N("Backup destination quota exceeded!\n%d MB used vs %d MB allocated.", $used_space, $conf{MAX_SPACE});
- show_warning("f", $msg);
- $interactive and gtkset_mousecursor_normal();
- $results .= $msg;
- $interactive and show_status();
- results_to_logfile();
- return 1;
- }
- $tar_cmd_sys = $tar_cmd;
- $tar_cmd_user = $tar_cmd;
- $tar_cmd_other = $tar_cmd;
- my $exclude_cmd = $conf{ARCHIVER} eq 'tar' ? " --exclude=" : " pat=*/";
- my $invert_cmd = $conf{ARCHIVER} eq 'tar' ? "" : " -V";
- $conf{NO_CRITICAL_SYS} and $tar_cmd_sys .= $invert_cmd . $exclude_cmd . "passwd" . $exclude_cmd . "fstab" . $exclude_cmd . "group" . $exclude_cmd . "mtab";
- $conf{NO_BROWSER_CACHE} and $tar_cmd_user .= $invert_cmd . $exclude_cmd . "NewCache" . $exclude_cmd . "Cache" . $exclude_cmd . "cache";
- $nonroot_user and $tar_cmd_user .= $invert_cmd . $exclude_cmd . ".drakbackup";
-
- -d $conf{PATH_TO_SAVE} and @dir_content = all($conf{PATH_TO_SAVE});
-
- if ($conf{USE_HD} && !$daemon || $daemon) {
- $interactive and progress($pbar, $plabel, 0.5, N("Backup system files..."));
- unless ($conf{NO_SYS_FILES}) {
- my $find_args_sys = $find_args;
- my $first_done;
- $ignore_files_list = '';
- $tar_cmd_sys .= handle_ignores($tar_cmd_sys !~ /-V/, "/etc");
- if ($conf{SYS_INCREMENTAL_BACKUPS}) {
- $base = $incr = "incr_sys";
- ($base, $incr) = swap_prefix($base, $incr) if $conf{SYS_DIFFERENTIAL_BACKUPS};
- $base =~ s/incr/base/ if !any { /^list_incr_sys/ } @dir_content;
- if (any { /^list_base_sys/ } @dir_content) {
- $more_recent = get_more_recent($base, @dir_content);
- my $list_file = name_list_file($incr);
- do_find($more_recent, $find_args_sys, $list_file, @sys_files);
- if (check_rm_list($list_file)) {
- do_tar($tar_cmd_sys, "backup_$incr", $list_file, undef);
- }
- $first_done = 1;
- } else {
- $incr = "base_sys";
- }
- } else {
- $incr = "sys";
- clean_dest($incr);
- }
- if (!$first_done) {
- my $list_file = name_list_file($incr);
- do_tar($tar_cmd_sys, "backup_$incr", $list_file, @sys_files);
- }
- push_list("list_$incr") if $incr =~ /_sys/;
- files_to_results($incr);
- }
- $interactive and progress($pbar, $plabel, 0.5, N("Backup system files..."));
- $interactive and progress($pbar3, $plabel3, 0.3, N("Hard Disk Backup files..."));
-
- unless ($conf{NO_USER_FILES}) {
- foreach (@user_list) {
- my $user = $_;
- my $tar_cmd_cuser = $tar_cmd_user;
- $path_name = return_path($user);
- $ignore_files_list = '';
- $tar_cmd_cuser .= handle_ignores($tar_cmd_cuser !~ /-V/, $path_name);
- my $find_args_user = $find_args;
- my $first_done;
- if ($conf{USER_INCREMENTAL_BACKUPS}) {
- $base = $incr = "incr_user_";
- ($base, $incr) = swap_prefix($base, $incr) if $conf{USER_DIFFERENTIAL_BACKUPS};
- $base =~ s/incr/base/ if !any { /^list_incr_user_$user/ } @dir_content;
- if (any { /^list_base_user_$user/ } @dir_content) {
- $more_recent = get_more_recent("$base$user", @dir_content);
- 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_cuser, "backup_$incr$user", $list_file, $path_name);
- }
- $first_done = 1;
- } else {
- $incr = "base_user_";
- }
- } else {
- $incr = "user_";
- clean_dest("$incr$user");
- }
- if (!$first_done) {
- my $list_file = name_list_file($incr . $user);
- do_tar($tar_cmd_cuser, "backup_$incr$user", $list_file, $path_name);
- }
- push_list("list_$incr$user") if $incr =~ /_user/;
- files_to_results("$incr$user");
- }
- }
- $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}) {
- my $find_args_other = $find_args;
- my $first_done;
- $ignore_files_list = '';
- $tar_cmd_other .= handle_ignores($tar_cmd_other !~ /-V/, @other_files);
- if ($conf{OTHER_INCREMENTAL_BACKUPS}) {
- $base = $incr = "incr_other";
- ($base, $incr) = swap_prefix($base, $incr) if $conf{OTHER_DIFFERENTIAL_BACKUPS};
- $base =~ s/incr/base/ if !any { /^list_incr_other/ } @dir_content;
- if (any { /^list_base_other/ } @dir_content) {
- $more_recent = get_more_recent($base, @dir_content);
- my $list_file = name_list_file($incr);
- do_find($more_recent, $find_args_other, $list_file, @other_files);
- if (check_rm_list($list_file)) {
- do_tar($tar_cmd_other, "backup_$incr", $list_file, undef);
- }
- $first_done = 1;
- } else {
- $incr = "base_other";
- }
- } else {
- $incr = "other";
- clean_dest($incr);
- }
- if (!$first_done) {
- my $list_file = name_list_file($incr);
- do_tar($tar_cmd_other, "backup_$incr", $list_file, @other_files);
- }
- push_list("list_$incr") if $incr =~ /_other/;
- files_to_results($incr);
- }
- $interactive and progress($pbar2, $plabel2, 1, N("Backup Other files..."));
- $interactive and progress($pbar3, $plabel3, 0.3, N("Hard Disk Backup Progress..."));
- }
-
- my $filecount = @file_list_to_send_by_ftp;
- if (!$filecount && !$conf{DIRECT_TAPE}) {
- my $msg = N("No changes to backup!");
- show_warning("w", $msg);
- $interactive and gtkset_mousecursor_normal();
- $interactive and interactive_mode_box();
- results_to_logfile();
- return 1;
- }
-
- #- should hit this block if running daemon mode only
- if ($daemon && $conf{DAEMON_MEDIA}) {
- rsync_client() if $conf{DAEMON_MEDIA} eq 'rsync';
- ssh_client() if $conf{DAEMON_MEDIA} eq 'ssh' && !$conf{USE_EXPECT};
- do_expect("backup") if $conf{DAEMON_MEDIA} eq 'ssh' && $conf{USE_EXPECT};
- build_cd() if $conf{DAEMON_MEDIA} eq 'cd';
- build_tape() if $conf{DAEMON_MEDIA} eq 'tape';
-
- $results .= N("\nDrakbackup activities via %s:\n\n", $conf{DAEMON_MEDIA}) if $conf{DAEMON_MEDIA} ne 'hd';
- $results .= $log_buff;
- }
-
- #- leave this one alone for now - works well
- #- integrate with other methods later
- if (($conf{USE_NET} && !$daemon && $conf{NET_PROTO} eq 'ftp') || $daemon && $conf{DAEMON_MEDIA} eq 'ftp') {
- $interactive and build_backup_ftp_status();
- if (ftp_client()) {
- $results .= N("\n FTP connection problem: It was not possible to send your backup files by FTP.\n");
- $interactive and $in->ask_warn(N("Error"), N("Error during sending file via FTP. Please correct your FTP configuration."));
- } else {
- $results .= N("file list sent by FTP: %s\n", $_) foreach @file_list_to_send_by_ftp;
- }
- }
-
- #- consolidate all the other methods under here - interactive and --default should land here
- if (!$daemon) {
- if ($conf{USE_NET} && $conf{NET_PROTO} && $conf{NET_PROTO} ne 'ftp') {
- rsync_client() if $conf{NET_PROTO} eq 'rsync';
- ssh_client() if $conf{NET_PROTO} eq 'ssh' && !$conf{USE_EXPECT};
- do_expect("backup") if $conf{NET_PROTO} eq 'ssh' && $conf{USE_EXPECT};
- $results .= N("\nDrakbackup activities via %s:\n\n", $conf{NET_PROTO});
- }
-
- if ($conf{USE_CD}) {
- build_cd();
- $results .= N("\nDrakbackup activities via CD:\n\n");
- }
-
- if ($conf{USE_TAPE}) {
- build_tape();
- $results .= N("\nDrakbackup activities via tape:\n\n");
- }
- $results .= $log_buff;
- }
-
- results_to_logfile();
-
- if ($conf{SEND_MAIL}) {
- if (send_mail($results)) {
- $interactive and $in->ask_warn(N("Error"), N("Error sending mail. Your report mail was not sent."));
- $interactive or print N(" Error while sending mail. \n");
- }
- }
-
- #- write our catalog file
- if (!$media_problem) {
- my $catalog = substr($the_time, 1);
- my $direct_tape = "";
- $direct_tape = "Direct" if $conf{DIRECT_TAPE};
- if (!$conf{USE_NET} && !$conf{USE_TAPE} && !$conf{USE_CD}) {
- $catalog .= ":HD:localhost:$conf{PATH_TO_SAVE}";
- $conf{NET_PROTO} = '';
- }
- $catalog .= ":$conf{NET_PROTO}:$conf{LOGIN}\@$conf{HOST_NAME}:$conf{HOST_PATH}" if $conf{NET_PROTO};
- $catalog .= ":CD:$vol_name:$conf{CD_DEVICE}" if $conf{USE_CD};
- $catalog .= ":" . $direct_tape . "Tape:$vol_name:$conf{TAPE_DEVICE}" if $conf{USE_TAPE};
- $catalog .= ":System" unless $conf{NO_SYS_FILES};
- $catalog .= ":I" if $conf{SYS_INCREMENTAL_BACKUPS} && !$conf{NO_SYS_FILES} && !$conf{SYS_DIFFERENTIAL_BACKUPS};
- $catalog .= ":D" if $conf{SYS_INCREMENTAL_BACKUPS} && !$conf{NO_SYS_FILES} && $conf{SYS_DIFFERENTIAL_BACKUPS};
- $catalog .= ":F" if !$conf{SYS_INCREMENTAL_BACKUPS} && !$conf{NO_SYS_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 .= ":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};
- $catalog .= ":F" if !$conf{OTHER_INCREMENTAL_BACKUPS} && $conf{OTHER_FILES};
- $catalog .= "\n";
-
- append_to_file("$cfg_dir/drakbackup_catalog", $catalog) or show_warning("w", N("Can not create catalog!"));
- }
-
- #- clean up HD files if del_hd_files and media is not hd
- if ($conf{DEL_HD_FILES} && ($conf{USE_CD} || $conf{USE_TAPE} || $conf{USE_NET}) && $conf{DAEMON_MEDIA} ne 'hd') {
- foreach (@file_list_to_send_by_ftp) {
- unlink($_) if /$conf{OPTION_COMP}$/;
- }
- }
-
- #- if we had a media problem then get rid of the text log of the backed up files too
- if ($media_problem) {
- system("rm $conf{PATH_TO_SAVE}/list*$the_time.txt");
- }
-
- $interactive and gtkset_mousecursor_normal();
- $interactive and show_status();
-}
-
-sub swap_prefix {
- my ($base, $incr) = @_;
- $incr =~ s/incr/diff/;
- $base =~ s/incr/base/;
- return $base, $incr;
-}
-
-sub name_list_file {
- my ($suffix) = @_;
- return $conf{PATH_TO_SAVE} . "/list_" . $suffix . $the_time . ".txt";
-}
-
-sub check_rm_list {
- my ($list_file) = @_;
- $list_file .= ".tmp";
- if (!catMaybeCompressed($list_file)) {
- unlink($list_file);
- return 0;
- } else {
- return 1;
- }
-}
-
-sub get_more_recent {
- my ($match, @directory) = @_;
- $match = "list_" . $match;
- my @more_recent = grep { /^$match/ } sort @directory;
- my $more_recent = pop @more_recent;
- $DEBUG and print "more recent file: $more_recent\n";
- return $more_recent;
-}
-
-sub clean_dest {
- my ($wildcard) = @_;
- system("cd $conf{PATH_TO_SAVE} && rm -f backup*$wildcard*");
-}
-
-sub clean_old_backups() {
- if ($conf{DEL_OLD} && $conf{USE_HD}) {
- foreach ('*_diff_*', '*_incr_*') {
- system("find $conf{PATH_TO_SAVE} -name $_ -mtime +$conf{DEL_OLD} | xargs rm -f");
- }
- }
-}
-
-sub do_find {
- my ($newer, $more_args, $into, @where) = @_;
- #- $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.tmp") : system("find @where $more_args > $into.tmp");
-}
-
-sub do_tar {
- my ($tar_cmd, $dest_file, $list_file, @files) = @_;
- my $full_dest_file = $conf{PATH_TO_SAVE} . "/" . $dest_file . $the_time . "." . $conf{OPTION_COMP};
- my $tmp_list = $list_file . ".tmp";
- if ($conf{DIRECT_TAPE}) {
- log::explanations("Direct tape backup - tar deferred...");
- @files = cat_($tmp_list) and chomp @files if -e $tmp_list;
- push @files_for_direct_tape, @files;
- renamef($tmp_list, $list_file) if -e $tmp_list;
- } else {
- #- if $list_file is undefined, then use the @files list
- my $list_cmd = $conf{ARCHIVER} eq "tar" ? "-T " : "list=";
- #- FIXME? no --index-file equiv for star, use pipe to cat for now
- -e $tmp_list ? system("$tar_cmd -f $full_dest_file $list_cmd$tmp_list $index_cmd $list_file") : system("$tar_cmd -f $full_dest_file @files $index_cmd $list_file");
- unlink($tmp_list) if -e $tmp_list;
- }
- gzip($list_file);
- chmod(0600, $full_dest_file) if -e $full_dest_file;
- push_list($dest_file);
-}
-
-sub gzip {
- my ($gz_file) = @_;
- if (-e $gz_file) {
- chmod(0600, $gz_file);
- system("gzip $gz_file");
- }
-}
-
-sub push_list {
- my ($prefix) = @_;
- 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 if -e $filename;
-}
-
-sub files_to_results {
- my ($basename) = @_;
- if ($conf{DIRECT_TAPE}) {
- $results .= "\nDirect to tape:\n\n";
- } else {
- $results .= "\nfile: " . $conf{PATH_TO_SAVE} . "/backup_" . $basename . $the_time . "." . $conf{OPTION_COMP} . "\n\n";
- $results .= catMaybeCompressed("$conf{PATH_TO_SAVE}/list_" . $basename . $the_time . ".txt");
- }
- $results .= "\nignored:\n" . $ignore_files_list . "\n" if $ignore_files_list;
-}
-
-sub handle_ignores {
- #- not quite the expected behavior for "other" files: .backupignore entries in one dir will affect others
- my ($needs_V, @list) = @_;
- return if !$conf{BACKUPIGNORE};
- my $tar_cmd;
- foreach my $dir (@list) {
- if (-d $dir) {
- if (-f "$dir/.backupignore") {
- my @ignores = cat_("$dir/.backupignore");
- $ignore_files_list .= join('',@ignores);
- if ($conf{ARCHIVER} eq 'star') {
- chomp @ignores;
- my $ignore_args = $needs_V ? " -V" : "";
- foreach (@ignores) {
- #- FIXME star -V pat= doesn't quite map to gnu tar behavior
- next if $_ eq '';
- $ignore_args .= " pat=";
- $ignore_args .= "*/" if !m,^/|^\*,;
- $ignore_args .= -d "$dir/$_" ? $_ . "*" : $_;
- }
- $tar_cmd .= $ignore_args;
- } else {
- $tar_cmd .= " -X $dir/.backupignore";
- }
- }
- }
- }
- return $tar_cmd;
-}
-
-sub check_pkg_needs() {
- my @extra_pkg;
- if ($conf{USE_NET}) {
- @extra_pkg = "rsync" if $conf{NET_PROTO} eq 'rsync';
- @extra_pkg = "perl-Expect" if $conf{NET_PROTO} eq 'ssh' && ($conf{USE_EXPECT} || $conf{DRAK_KEYS});
- }
- @extra_pkg = "mt-st" if $conf{USE_TAPE};
- @extra_pkg = ("mkisofs", "cdrecord") if $conf{USE_CD};
- push @extra_pkg, "star" if $conf{ARCHIVER} eq 'star';
- if (@extra_pkg) {
- if (!$in->do_pkgs->install(@extra_pkg)) {
- $in->ask_warn(N("Error"), N("Problem installing %s", join(', ', @extra_pkg)));
- return 1;
- }
- }
-}
-
-sub show_status() {
- my $text = Gtk2::TextView->new;
- destroy_widget();
- my $scrolled_window = Gtk2::ScrolledWindow->new;
- $scrolled_window->set_border_width(10);
- $scrolled_window->add_with_viewport($text);
- gtktext_insert(gtkset_editable($text, 0), [ [ $results ] ]);
-
- gtkpack($advanced_box,
- $table = gtkpack_(Gtk2::VBox->new(0,10), 1, $scrolled_window)
- );
- $central_widget = \$table;
- $table->show_all;
-}
-
-sub results_to_logfile() {
- output_p($log_file, $results);
-}
-
-sub conf_to_list {
- my ($config) = @_;
- return split(",", $config);
-}
-
-sub list_to_conf {
- my (@list) = @_;
- return join(",", @list);
-}
-
-sub filedialog_generic {
- #- a more generic file dialog
- #- a title prompt, the widget to get updated
- my ($prompt, $widget) = @_;
-
- my $file_dialog = Gtk2::FileChooserDialog->new($prompt, $my_win->{real_window}, 'select-folder', N("Cancel") => 'cancel', N("Ok") => 'ok');
- $file_dialog->show;
- while (my $answer = $file_dialog->run) {
- if (member($answer, qw(cancel delete-event))) {
- $file_dialog->destroy;
- return;
- } elsif ($answer eq 'ok') {
- if (defined($widget)) {
- $$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(0, $file_name);
- }
- }
- $file_dialog->destroy;
- return;
- }
- }
-}
-
-################################################ ADVANCED ################################################
-
-sub check_list {
- foreach (@_) {
- my $ref = $_->[1];
- $_->[2] ? gtkset_active($_->[0], !$$ref) : gtkset_active($_->[0], $$ref);
- gtksignal_connect($_->[0], toggled => sub {
- invbool $ref;
- destroy_widget();
- $current_widget->();
- });
- }
-}
-
-sub fonction_env {
- ($central_widget, $current_widget, $previous_widget, $next_widget) = @_;
-}
-
-sub advanced_what_sys() {
- my $box_what_sys;
-
- gtkpack($advanced_box,
- $box_what_sys = gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 15),
- 0, my $check_what_sys = Gtk2::CheckButton->new(N("Backup your System files. (/etc directory)")),
- 0, my $check_what_versions = Gtk2::CheckButton->new(N("Use Incremental/Differential Backups (do not replace old backups)")),
- 0, gtkpack__(Gtk2::HBox->new(0,0),
- my @mode_buttons = gtkradio((N("Use Incremental Backups")) x 2, N("Use Differential Backups")),
- ),
- 0, my $check_what_critical = Gtk2::CheckButton->new(N("Do not include critical files (passwd, group, fstab)")),
- 1, Gtk2::VBox->new(0, 15),
- ),
- );
- check_list([$check_what_sys, \$conf{NO_SYS_FILES}, 1], [$check_what_critical, \$conf{NO_CRITICAL_SYS}]);
- $check_what_versions->set_active($conf{SYS_INCREMENTAL_BACKUPS});
- $check_what_versions->signal_connect('toggled' => sub {
- invbool \$conf{SYS_INCREMENTAL_BACKUPS};
- $mode_buttons[0]->set_sensitive($conf{SYS_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{SYS_INCREMENTAL_BACKUPS});
-
- });
- $mode_buttons[1]->set_active($conf{SYS_DIFFERENTIAL_BACKUPS});
- $mode_buttons[0]->signal_connect('toggled' => sub { $conf{SYS_DIFFERENTIAL_BACKUPS} = $mode_buttons[1]->get_active });
- $mode_buttons[0]->set_sensitive($conf{SYS_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{SYS_INCREMENTAL_BACKUPS});
- set_help_tip($check_what_versions, 'use_incr_decr');
- set_help_tip($mode_buttons[0], 'use_incremental');
- set_help_tip($mode_buttons[1], 'use_differential');
- fonction_env(\$box_what_sys, \&advanced_what_sys, \&advanced_what);
- $up_box->show_all;
-}
-
-sub advanced_what_user {
- my ($previous_function) = @_;
- my $box_what_user;
- my %check_what_user;
-
- all_user_list();
- gtkpack($advanced_box,
- $box_what_user = gtkpack_(Gtk2::VBox->new(0, 15),
- 0, N("Please check all users that you want to include in your backup."),
- 0, Gtk2::HSeparator->new,
- 1, create_scrolled_window(
- gtkpack__(Gtk2::VBox->new(0,0),
- map { my $name = $_;
- my @user_list_tmp;
- my $b = Gtk2::CheckButton->new($name);
- if (any { /^$name$/ } @user_list) {
- $check_what_user{$_}[1] = 1;
- gtkset_active($b, 1);
- } else {
- $check_what_user{$_}[1] = 0;
- gtkset_active($b, 0);
- }
- $b->signal_connect(toggled => sub {
- if ($check_what_user{$name}[1]) {
- $check_what_user{$name}[1] = 0;
- @user_list_tmp = grep { !/^$name$/ } @user_list;
- @user_list = @user_list_tmp;
- } else {
- $check_what_user{$name}[1] = 1;
- if (!member($name, @user_list)) { push @user_list, $name }
- }
- });
- $b } (@user_list_all)
- ),
- ),
- 0, my $check_what_browser = Gtk2::CheckButton->new(N("Do not include the browser cache")),
- 0, my $check_what_user_versions = Gtk2::CheckButton->new(N("Use Incremental/Differential Backups (do not replace old backups)")),
- 0, gtkpack__(Gtk2::HBox->new(0,0),
- my @mode_buttons = gtkradio((N("Use Incremental Backups")) x 2, N("Use Differential Backups")),
- ),
- ),
- );
- check_list([$check_what_browser, \$conf{NO_BROWSER_CACHE}]);
- $check_what_user_versions->set_active($conf{USER_INCREMENTAL_BACKUPS});
- $check_what_user_versions->signal_connect('toggled' => sub {
- invbool \$conf{USER_INCREMENTAL_BACKUPS};
- $mode_buttons[0]->set_sensitive($conf{USER_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{USER_INCREMENTAL_BACKUPS});
- });
- $mode_buttons[1]->set_active($conf{USER_DIFFERENTIAL_BACKUPS});
- $mode_buttons[0]->signal_connect('toggled' => sub { $conf{USER_DIFFERENTIAL_BACKUPS} = $mode_buttons[1]->get_active });
- $mode_buttons[0]->set_sensitive($conf{USER_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{USER_INCREMENTAL_BACKUPS});
- set_help_tip($check_what_user_versions, 'use_incr_decr');
- set_help_tip($mode_buttons[0], 'use_incremental');
- set_help_tip($mode_buttons[1], 'use_differential');
-
- if ($previous_function) { fonction_env(\$box_what_user, \&advanced_what_user, \&$previous_function, \&$previous_function) }
- else { fonction_env(\$box_what_user, \&advanced_what_user, \&advanced_what) }
- $up_box->show_all;
-}
-
-sub advanced_what_other() {
- my $box_what_other;
- my $file_iter;
- my $other_file;
-
- $list_model = Gtk2::ListStore->new("Glib::String");
- my $list_others = Gtk2::TreeView->new_with_model($list_model);
- $list_others->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list_others->set_headers_visible(0);
-
- foreach (@other_files) {
- $list_model->append_set(0, $_);
- }
-
- $list_others->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $other_file = $model->get($iter, 0);
- $file_iter = $iter;
- });
-
- gtkpack($advanced_box,
- $box_what_other = gtkpack_(Gtk2::VBox->new(0, 15),
- 1, gtkpack_(Gtk2::HBox->new(0,4),
- 1, create_scrolled_window($list_others),
- ),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("Add")), clicked => sub { filedialog_generic(N("Select the files or directories and click on 'OK'"), undef) }),
- gtksignal_connect(Gtk2::Button->new(N("Remove Selected")), clicked => sub {
- $list_model->remove($file_iter) if $file_iter;
- my $iindex = 0;
- foreach (@other_files) {
- if ($other_files[$iindex] eq $other_file) {
- splice(@other_files, $iindex, 1);
- last;
- }
- $iindex++;
- }
- }),
- ),
- 0, my $check_what_other_versions = Gtk2::CheckButton->new(N("Use Incremental/Differential Backups (do not replace old backups)")),
- 0, gtkpack__(Gtk2::HBox->new(0,0),
- my @mode_buttons = gtkradio((N("Use Incremental Backups")) x 2, N("Use Differential Backups")),
- ),
- ),
-
- );
- $check_what_other_versions->set_active($conf{OTHER_INCREMENTAL_BACKUPS});
- $check_what_other_versions->signal_connect('toggled' => sub {
- invbool \$conf{OTHER_INCREMENTAL_BACKUPS};
- $mode_buttons[0]->set_sensitive($conf{OTHER_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{OTHER_INCREMENTAL_BACKUPS});
- });
- $mode_buttons[1]->set_active($conf{OTHER_DIFFERENTIAL_BACKUPS});
- $mode_buttons[0]->signal_connect('toggled' => sub { $conf{OTHER_DIFFERENTIAL_BACKUPS} = $mode_buttons[1]->get_active });
- $mode_buttons[0]->set_sensitive($conf{OTHER_INCREMENTAL_BACKUPS});
- $mode_buttons[1]->set_sensitive($conf{OTHER_INCREMENTAL_BACKUPS});
- set_help_tip($check_what_other_versions, 'use_incr_decr');
- set_help_tip($mode_buttons[0], 'use_incremental');
- set_help_tip($mode_buttons[1], 'use_differential');
-
- fonction_env(\$box_what_other, \&advanced_what_other, \&advanced_what);
- $up_box->show_all;
-}
-
-sub advanced_what() {
- my $box_what;
-
- gtkpack($advanced_box,
- $box_what = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtksignal_connect(my $button_what_sys = Gtk2::Button->new,
- clicked => sub { $box_what->destroy; advanced_what_sys() }),
- 1, gtksignal_connect(my $button_what_user = Gtk2::Button->new,
- clicked => sub { destroy_widget(); advanced_what_user(undef) }),
- 1, gtksignal_connect(my $button_what_other = Gtk2::Button->new,
- clicked => sub { destroy_widget(); advanced_what_other() }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- $button_what_sys->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-system-40"),
- Gtk2::Label->new(N("System")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_what_user->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-users-40"),
- Gtk2::Label->new(N("Users")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_what_other->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-others-40"),
- Gtk2::Label->new(N("Other")),
- Gtk2::HBox->new(0, 5)
- ));
- gtkset_sensitive($button_what_sys, !$nonroot_user);
- fonction_env(\$box_what, \&advanced_what, \&advanced_box);
- $up_box->show_all;
-}
-
-sub advanced_where_net_types {
- my ($previous_function) = @_;
- my $box_where_net;
-
- gtkpack($advanced_box,
- $box_where_net = gtkpack_(Gtk2::VBox->new(0, 10),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, my $check_where_use_net = Gtk2::CheckButton->new(N("Use network connection to backup")),
- 1, Gtk2::HBox->new(0,10),
- 0, Gtk2::Label->new(N("Net Method:")),
- 0, gtkset_sensitive(my $entry_net_type = Gtk2::ComboBox->new_text, $conf{USE_NET}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,5),
- 0, gtkset_sensitive(my $check_use_expect = Gtk2::CheckButton->new(N("Use Expect for SSH")), ($conf{USE_NET} && $conf{NET_PROTO} eq 'ssh')),
- 0, gtkset_sensitive(my $check_xfer_keys = Gtk2::CheckButton->new(N("Create/Transfer backup keys for SSH")), ($conf{USE_NET} && $conf{NET_PROTO} eq 'ssh')),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $button_xfer_keys = Gtk2::Button->new(N("Transfer Now")), $conf{DRAK_KEYS}),
- ),
- 0, gtkset_sensitive(my $check_user_keys = Gtk2::CheckButton->new(N("Other (not drakbackup) keys in place already")), ($conf{USE_NET} && $conf{NET_PROTO} eq 'ssh')),
- 0, Gtk2::HSeparator->new,
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Host name or IP.")), $conf{USE_NET}),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $host_name_entry = Gtk2::Entry->new, $conf{USE_NET}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Directory (or module) to put the backup on this host.")), $conf{USE_NET}),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $host_path_entry = Gtk2::Entry->new, $conf{USE_NET}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Login name")), $conf{USE_NET}),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $login_user_entry = Gtk2::Entry->new, $conf{USE_NET}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Password")), $conf{USE_NET}),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $check_remember_pass = Gtk2::CheckButton->new(N("Remember this password")), $conf{USE_NET}),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $passwd_user_entry = Gtk2::Entry->new, $conf{USE_NET}),
- ),
- ),
- );
- $entry_net_type->set_popdown_strings('', @net_methods);
- $entry_net_type->entry->set_text($conf{NET_PROTO});
- $button_xfer_keys->signal_connect('clicked', sub {
- if ($conf{PASSWD} && $conf{LOGIN} && $conf{HOST_NAME}) {
- do_expect("sendkey") unless check_pkg_needs();
- } else {
- $in->ask_warn(N("Error"), N("Need hostname, username and password!"));
- }
- });
- $passwd_user_entry->set_visibility(0);
- $passwd_user_entry->set_text($conf{PASSWD});
- $passwd_user_entry->signal_connect('changed', sub { $conf{PASSWD} = $passwd_user_entry->get_text });
- $host_path_entry->set_text($conf{HOST_PATH});
- $host_name_entry->set_text($conf{HOST_NAME});
- $login_user_entry->set_text($conf{LOGIN});
- $host_name_entry->signal_connect('changed', sub { $conf{HOST_NAME} = $host_name_entry->get_text });
- $host_path_entry->signal_connect('changed', sub { $conf{HOST_PATH} = $host_path_entry->get_text });
- $login_user_entry->signal_connect('changed', sub { $conf{LOGIN} = $login_user_entry->get_text });
- $entry_net_type->entry->signal_connect('changed', sub {
- $conf{NET_PROTO} = $entry_net_type->entry->get_text;
- my $sensitive = 0;
- $sensitive = 1 if $conf{NET_PROTO} eq 'ssh';
- $check_use_expect->set_sensitive($sensitive);
- $check_xfer_keys->set_sensitive($sensitive);
- $button_xfer_keys->set_sensitive($sensitive);
- $check_user_keys->set_sensitive($sensitive);
- });
- check_list([$check_remember_pass, \$conf{REMEMBER_PASS}]);
- gtksignal_connect(gtkset_active($check_where_use_net, $conf{USE_NET}), toggled => sub {
- invbool \$conf{USE_NET};
- #- assure other methods disabled
- if ($conf{USE_NET} == 1) {
- $conf{USE_CD} = 0;
- $conf{USE_TAPE} = 0;
- }
- $conf{NET_PROTO} = '' if $conf{USE_NET} == 0;
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_use_expect, $conf{USE_EXPECT}), toggled => sub {
- invbool \$conf{USE_EXPECT};
- #- assure other methods disabled
- if ($conf{USE_EXPECT} == 1) {
- $conf{DRAK_KEYS} = 0;
- $conf{USER_KEYS} = 0;
- }
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_xfer_keys, $conf{DRAK_KEYS}), toggled => sub {
- invbool \$conf{DRAK_KEYS};
- #- assure other methods disabled
- if ($conf{DRAK_KEYS} == 1) {
- $conf{USE_EXPECT} = 0;
- $conf{USER_KEYS} = 0;
- }
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_user_keys, $conf{USER_KEYS}), toggled => sub {
- invbool \$conf{USER_KEYS};
- #- assure other methods disabled
- if ($conf{USER_KEYS} == 1) {
- $conf{DRAK_KEYS} = 0;
- $conf{USE_EXPECT} = 0;
- }
- destroy_widget();
- $current_widget->($previous_function);
- });
- set_help_tip($check_use_expect, 'use_expect');
- set_help_tip($check_remember_pass, 'remember_pass');
- set_help_tip($host_path_entry, 'dir_or_module');
- if ($previous_function) {
- fonction_env(\$box_where_net, \&advanced_where_net_types, \&$previous_function, \&wizard_step3);
- button_box_wizard();
- } else {
- fonction_env(\$box_where_net, \&advanced_where_net_types, \&advanced_where);
- }
- $up_box->show_all;
-}
-
-sub advanced_where_cd {
- my ($previous_function) = @_;
- my $box_where_cd;
- my %dev_codes;
-
- get_cd_info();
-
- foreach my $key (keys %cd_devices) {
- $dev_codes{$cd_devices{$key}{rec_dev}} = $key;
- }
-
- my $combo_where_cd_device = Gtk2::ComboBox->new_with_strings(%cd_devices ? [ sort keys %dev_codes ] : \@no_devices);
- my $combo_where_cd_time = Gtk2::ComboBox->new_with_strings([ "650 MB", "700 MB", "750 MB", "800 MB", "4.7 GB" ]);
-
- gtkpack($advanced_box,
- $box_where_cd = gtkpack_(Gtk2::VBox->new(0, 6),
- 0, my $check_where_cd = Gtk2::CheckButton->new(N("Use CD-R/DVD-R to backup")),
- 0, Gtk2::HSeparator->new,
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Choose your CD/DVD device")), $conf{USE_CD}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive($combo_where_cd_device, $conf{USE_CD}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Choose your CD/DVD media size")), $conf{USE_CD}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive($combo_where_cd_time, $conf{USE_CD}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Multisession CD")), $conf{USE_CD}),
- 0, gtkset_sensitive(my $check_multisession = Gtk2::CheckButton->new, $conf{USE_CD}),
- 0, gtkset_sensitive(Gtk2::Label->new(N("CDRW media")), $conf{USE_CD}),
- 0, gtkset_sensitive(my $check_cdrw = Gtk2::CheckButton->new, $conf{USE_CD}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Erase your RW media (1st Session)")), $conf{CDRW} && $conf{USE_CD}),
- 0, gtkset_sensitive(my $button_erase_now = Gtk2::Button->new(N(" Erase Now ")), $conf{CDRW}),
- 0, gtkset_sensitive(my $check_cdrw_erase = Gtk2::CheckButton->new, $conf{CDRW} && $conf{USE_CD}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("DVD+RW media")), $conf{USE_CD}),
- 0, gtkset_sensitive(my $check_dvdrw = Gtk2::CheckButton->new, $conf{USE_CD}),
- 0, gtkset_sensitive(Gtk2::Label->new(N("DVD-R media")), $conf{USE_CD}),
- 0, gtkset_sensitive(my $check_dvdr = Gtk2::CheckButton->new, $conf{USE_CD}),
- 0, gtkset_sensitive(Gtk2::Label->new(N("DVDRAM device")), $conf{USE_CD}),
- 0, gtkset_sensitive(my $check_dvdram = Gtk2::CheckButton->new, $conf{USE_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($check_where_cd, $conf{USE_CD}), toggled => sub {
- $conf{USE_CD} = $conf{USE_CD} ? 0 : 1;
- #- toggle where_net, where_tape off
- if ($conf{USE_CD} == 1) {
- $conf{USE_NET} = 0;
- $conf{USE_TAPE} = 0;
- }
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_cdrw, $conf{CDRW}), toggled => sub {
- $conf{CDRW} = $conf{CDRW} ? 0 : 1;
- $conf{MEDIA_ERASE} = $conf{MEDIA_ERASE} ? 0 : 1;
- $check_cdrw_erase->set_sensitive($conf{CDRW});
- destroy_widget();
- $current_widget->($previous_function);
- });
- $button_erase_now->signal_connect('clicked', sub {
- if ($conf{CD_DEVICE}) {
- erase_cdrw();
- } else {
- $in->ask_warn(N("Error"), N("No CD device defined!"));
- }
- });
-
- $combo_where_cd_time->entry->set_text($conf{CD_TIME}) if $conf{CD_TIME};
- $combo_where_cd_time->entry->signal_connect('changed', sub { $conf{CD_TIME} = $combo_where_cd_time->entry->get_text });
-
- $combo_where_cd_device->entry->set_text($conf{CD_DEVICE}) if $conf{CD_DEVICE};
- $combo_where_cd_device->entry->signal_connect('changed', sub {
- $conf{CD_DEVICE} = $combo_where_cd_device->entry->get_text;
- $std_device = $dev_codes{$conf{CD_DEVICE}};
- $check_dvdr->set_active($cd_devices{$std_device}{dvdr});
- $check_dvdrw->set_active($cd_devices{$std_device}{dvdr});
- $check_dvdram->set_active($cd_devices{$std_device}{dvdram});
- $check_cdrw->set_active($cd_devices{$std_device}{cdrw});
- });
-
- set_help_tip($button_erase_now, 'erase_cdrw');
-
- if ($previous_function) {
- fonction_env(\$box_where_cd, \&advanced_where_cd, \&$previous_function, \&wizard_step3);
- button_box_wizard();
- } else {
- fonction_env(\$box_where_cd, \&advanced_where_cd, \&advanced_where);
- }
- $up_box->show_all;
-}
-
-sub advanced_where_tape {
- my ($previous_function) = @_;
-
- #- look for tape devices;
- get_tape_info();
-
- my $combo_where_tape_device = Gtk2::ComboBox->new_with_strings(@tape_devices ? \@tape_devices : \@no_devices);
-
- my $box_where_tape;
- local $_;
-
- gtkpack($advanced_box,
- $box_where_tape = gtkpack_(Gtk2::VBox->new(0, 6),
- 0, Gtk2::HSeparator->new,
- 0, my $check_where_tape = Gtk2::CheckButton->new(N("Use tape to backup")),
- 0, Gtk2::HSeparator->new,
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Device name to use for backup")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 6),
- 0, gtkset_sensitive($combo_where_tape_device, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Backup directly to tape")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(my $direct_to_tape = Gtk2::CheckButton->new, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Use tape hardware compression (EXPERIMENTAL)")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(my $hdw_compression = Gtk2::CheckButton->new, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Do not rewind tape after backup")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(my $check_tape_rewind = Gtk2::CheckButton->new, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Erase tape before backup")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(my $check_tape_erase = Gtk2::CheckButton->new, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Eject tape after the backup")), $conf{USE_TAPE}),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkset_sensitive(my $check_tape_eject = Gtk2::CheckButton->new, $conf{USE_TAPE}),
- ),
- 0, Gtk2::VBox->new(0, 6),
- 0, gtkpack_(Gtk2::HBox->new(0,10),),
- ),
- );
- gtksignal_connect(gtkset_active($check_where_tape, $conf{USE_TAPE}), toggled => sub {
- $conf{USE_TAPE} = $conf{USE_TAPE} ? 0 : 1;
- #- assure other methods are off
- if ($conf{USE_TAPE} == 1) {
- $conf{USE_NET} = 0;
- $conf{USE_CD} = 0;
- }
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_tape_rewind, $conf{TAPE_NOREWIND}), toggled => sub {
- $conf{TAPE_NOREWIND} = $conf{TAPE_NOREWIND} ? 0 : 1;
- $_ = $conf{TAPE_DEVICE};
- if ($conf{TAPE_NOREWIND}) {
- $conf{TAPE_DEVICE} =~ s|/st|/nst|;
- } else {
- $conf{TAPE_DEVICE} =~ s|/nst|/st|;
- }
- $combo_where_tape_device->entry->set_text($conf{TAPE_DEVICE});
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($direct_to_tape, $conf{DIRECT_TAPE}), toggled => sub {
- $conf{DIRECT_TAPE} = $conf{DIRECT_TAPE} ? 0 : 1;
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($hdw_compression, $conf{HDW_COMP}), toggled => sub {
- $conf{HDW_COMP} = $conf{HDW_COMP} ? 0 : 1;
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_tape_erase, $conf{MEDIA_ERASE}), toggled => sub {
- $conf{MEDIA_ERASE} = $conf{MEDIA_ERASE} ? 0 : 1;
- destroy_widget();
- $current_widget->($previous_function);
- });
- gtksignal_connect(gtkset_active($check_tape_eject, $conf{MEDIA_EJECT}), toggled => sub {
- $conf{MEDIA_EJECT} = $conf{MEDIA_EJECT} ? 0 : 1;
- destroy_widget();
- $current_widget->($previous_function);
- });
- $combo_where_tape_device->entry->set_text($conf{TAPE_DEVICE}) if $conf{TAPE_DEVICE};
- $combo_where_tape_device->entry->signal_connect('changed', sub {
- $conf{TAPE_DEVICE} = $combo_where_tape_device->entry->get_text;
- });
- if ($previous_function) {
- fonction_env(\$box_where_tape, \&advanced_where_tape, \&$previous_function, \&wizard_step3);
- button_box_wizard();
- } else {
- fonction_env(\$box_where_tape, \&advanced_where_tape, \&advanced_where);
- }
- $up_box->show_all;
-}
-
-sub advanced_where_hd {
- my ($previous_function) = @_;
- my $box_where_hd;
- my $button;
- if ($conf{MAX_SPACE} == 1000.0) {
- $conf{MAX_SPACE} = int(0.8 * get_free_space($conf{PATH_TO_SAVE})) if -d $conf{PATH_TO_SAVE};
- }
- my $adj = Gtk2::Adjustment->new($conf{MAX_SPACE}, 0.0, $conf{MAX_SPACE}, 10.0, 5.0, 0.0);
- my $adj2 = Gtk2::Adjustment->new($conf{DEL_OLD}, 0.0, 300.0, 1.0, 10.0, 0.0);
- my $spinner;
- my $spinner2;
-
- my $size_group = Gtk2::SizeGroup->new('horizontal');
- my $label_size_group = Gtk2::SizeGroup->new('horizontal');
- gtkpack($advanced_box,
- $box_where_hd = gtkpack_(Gtk2::VBox->new(0, 6),
- 0, Gtk2::HSeparator->new,
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $l1 = Gtk2::Label->new(N("Enter the directory to save to:")), $conf{USE_HD}),
- 1, gtkpack_(my $select_box = Gtk2::HBox->new(0,10),
- 1, gtkset_sensitive($save_path_entry = Gtk2::Entry->new, $conf{USE_HD}),
- 0, gtkset_sensitive($button = gtksignal_connect(Gtk2::Button->new, clicked => sub {
- filedialog_generic(N("Directory to save to"), \$save_path_entry);
- }), $conf{USE_HD})),
- ),
- 0, Gtk2::VBox->new(0, 6),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $l2 = Gtk2::Label->new(N("Maximum disk space\n allocated for backups (MB)")), $conf{USE_HD}),
- 1, gtkset_sensitive($spinner = Gtk2::SpinButton->new($adj, 0, 0), $conf{USE_HD}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $l3 = Gtk2::Label->new(N("Delete incremental or differential\n backups older than N days\n (0 is keep all backups) to save space")), $conf{USE_HD}),
- 1, gtkset_sensitive($spinner2 = Gtk2::SpinButton->new($adj2, 0, 0), $conf{USE_HD}),
- ),
- ),
- );
- $size_group->add_widget($_) foreach $select_box, $spinner, $spinner2;
- $label_size_group->add_widget($_) foreach $l1, $l2, $l3;
-
- $button->add(gtkpack(Gtk2::HBox->new(0,10), gtkcreate_img("ic82-dossier-32")));
- $save_path_entry->set_text($conf{PATH_TO_SAVE});
- $spinner->signal_connect('changed', sub { $conf{MAX_SPACE} = $spinner->get_text });
- $spinner2->signal_connect('changed', sub { $conf{DEL_OLD} = $spinner2->get_text });
- $save_path_entry->signal_connect('changed', sub {
- $conf{PATH_TO_SAVE} = $save_path_entry->get_text;
- if (-d $conf{PATH_TO_SAVE}) {
- $conf{MAX_SPACE} = int(0.8 * get_free_space($conf{PATH_TO_SAVE}));
- # seems to be the easiest way to avoid the widgets fighting over values
- # and getting garbage in $max_value
- destroy_widget();
- $current_widget->($previous_function);
- }
- });
- if ($previous_function) {
- fonction_env(\$box_where_hd, \&advanced_where_hd, \&$previous_function, \&wizard_step3);
- button_box_wizard();
- } else {
- fonction_env(\$box_where_hd, \&advanced_where_hd, \&advanced_where);
- }
- $up_box->show_all;
-}
-
-sub advanced_where() {
- my $box_where;
-
- gtkpack($advanced_box,
- $box_where = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtksignal_connect(my $button_where_net = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- advanced_where_net_types(undef);
- }),
- 1, gtksignal_connect(my $button_where_cd = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- advanced_where_cd(undef);
- }),
- 1, gtksignal_connect(my $button_where_hd = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- advanced_where_hd(undef);
- }),
- 1, gtksignal_connect(my $button_where_tape = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- advanced_where_tape(undef);
- }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- $button_where_net->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-network-40"),
- Gtk2::Label->new(N("Network")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_where_cd->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-CD-40"),
- Gtk2::Label->new(N("CD-R / DVD-R")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_where_hd->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-discdurwhat-40"),
- Gtk2::Label->new(N("HardDrive / NFS")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_where_tape->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-tape-40"),
- Gtk2::Label->new(N("Tape")),
- Gtk2::HBox->new(0, 5)
- ));
- fonction_env(\$box_where, \&advanced_where, \&advanced_box);
- $up_box->show_all;
-}
-
-sub advanced_when() {
- my $box_when;
- my $allow_custom = $backup_daemon && $custom_cron;
- my $combo_when_space = Gtk2::ComboBox->new_with_strings([ "", N("hourly"), N("daily"), N("weekly"), N("monthly"), N("custom") ]);
- my %trans = (N("hourly") => 'hourly',
- N("daily") => 'daily',
- N("weekly") => 'weekly',
- N("monthly") => 'monthly',
- N("custom") => 'custom');
- my %trans2 = ('hourly' => N("hourly"),
- 'daily' => N("daily"),
- 'weekly' => N("weekly"),
- 'monthly' => N("monthly"),
- 'custom' => N("custom"));
- set_help_tip($combo_when_space, 'when_space');
-
- #- custom setup - let user specify month, day of month, day of week, hour, minute
- my @months = ("*", N("January"), N("February"), N("March"),
- N("April"), N("May"), N("June"), N("July"), N("August"), N("September"),
- N("October"), N("November"), N("December"));
- my $combo_month_when = Gtk2::ComboBox->new_with_strings(\@months);
- my $combo_day_when = Gtk2::ComboBox->new_with_strings([ "*", (1..31) ]);
- my @weekdays = ("*", N("Sunday"), N("Monday"), N("Tuesday"),
- N("Wednesday"), N("Thursday"), N("Friday"), N("Saturday"));
- my $combo_weekday_start = Gtk2::ComboBox->new_with_strings(\@weekdays);
- my $combo_weekday_end = Gtk2::ComboBox->new_with_strings(\@weekdays);
- my $combo_hour_when = Gtk2::ComboBox->new_with_strings([ "*", (0..23) ]);
- my $combo_minute_when = Gtk2::ComboBox->new_with_strings([ "*", (0..59) ]);
- my @profiles = glob_("$cfg_dir/*.conf");
- @profiles = map { basename($_) } @profiles;
- @profiles = difference2(\@profiles, [ ("drakbackup.conf") ]);
- unshift(@profiles, N("Default"));
- my $combo_profile = Gtk2::ComboBox->new_with_strings(\@profiles);
-
- my $cron_model = Gtk2::ListStore->new("Glib::String");
- my $list_cron = Gtk2::TreeView->new_with_model($cron_model);
- $list_cron->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list_cron->set_headers_visible(0);
- my $cron_iter;
- my $cron_entry;
-
- read_user_cron();
- foreach (@cron_entries) {
- $cron_model->append_set(0, $_) if !/^#/;
- }
-
- $list_cron->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $cron_entry = $model->get($iter, 0);
- $cron_iter = $iter;
- });
-
- my $del_button = Gtk2::Button->new(N("Delete cron entry"));
- my $add_button = Gtk2::Button->new(N("Add cron entry"));
-
- $del_button->signal_connect(clicked => sub {
- $cron_model->remove($cron_iter) if $cron_iter;
- my $iindex = 0;
- foreach (@cron_entries) {
- if ($_ eq $cron_entry) {
- splice(@cron_entries, $iindex, 1);
- last;
- }
- $iindex++;
- }
- });
-
- my $entry_crontab = Gtk2::Entry->new;
- gtkset_editable($entry_crontab, 0);
-
- $add_button->signal_connect(clicked => sub {
- my $entry = $entry_crontab->get_text;
- $cron_model->append_set(0, $entry);
- push @cron_entries, $entry;
- });
-
- my @time_list = split(" ", $time_string);
- $combo_minute_when->entry->set_text($time_list[0]);
- $combo_hour_when->entry->set_text($time_list[1]);
- $combo_day_when->entry->set_text($time_list[2]);
- if ($time_list[3] =~ /\*/) {
- $combo_month_when->entry->set_text($time_list[3]);
- } else {
- $combo_month_when->entry->set_text($months[$time_list[3]]);
- }
- my $start;
- my $end = "*";
- if ($time_list[4] =~ /\*/) {
- $start = "*";
- } else {
- if (length($time_list[4]) > 1) {
- my @span = split("-", $time_list[4]);
- $start = $weekdays[$span[0] + 1];
- $end = $weekdays[$span[1] + 1];
- } else {
- $start = $weekdays[$time_list[4] + 1];
- }
- }
- $combo_weekday_start->entry->set_text($start);
- $combo_weekday_end->entry->set_text($end);
-
- $combo_profile->entry->set_text(substr($profile_string, 10)) if $profile_string ne "";
-
- #- drop down list of possible media - default to config value
- my $combo_media_type = Gtk2::ComboBox->new_with_strings([ sort(@net_methods, @media_types) ], $conf{DAEMON_MEDIA});
-
- gtkpack($advanced_box,
- $box_when = gtkpack_(Gtk2::VBox->new(0, 5),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::HBox->new(0,10),
- 1, gtkcreate_img("ic82-when-40"),
- 0, my $check_when_daemon = Gtk2::CheckButton->new(N("Use daemon")),
- 1, Gtk2::HBox->new(0,10),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Please choose the time interval between each backup")), $backup_daemon),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive($combo_when_space, $backup_daemon),
- ),
- 0, Gtk2::HSeparator->new,
- 0, gtkset_sensitive($entry_crontab, $allow_custom),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Minute")), $allow_custom),
- 0, gtkset_sensitive($combo_minute_when, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Hour")), $allow_custom),
- 0, gtkset_sensitive($combo_hour_when, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Day")), $allow_custom),
- 0, gtkset_sensitive($combo_day_when, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Month")), $allow_custom),
- 0, gtkset_sensitive($combo_month_when, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Weekday (start)")), $allow_custom),
- 0, gtkset_sensitive($combo_weekday_start, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Weekday (end)")), $allow_custom),
- 0, gtkset_sensitive($combo_weekday_end, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Profile")), $allow_custom),
- 0, gtkset_sensitive($combo_profile, $allow_custom),
- ),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, gtkset_sensitive($del_button, $allow_custom),
- 1, gtkset_sensitive(Gtk2::Label->new(N("Current crontab:")), $allow_custom),
- 1, gtkset_sensitive($add_button, $allow_custom),
- ),
- 1, gtkpack_(Gtk2::HBox->new(0,4),
- 1, create_scrolled_window(gtkset_sensitive($list_cron, $allow_custom)),
- ),
- 0, Gtk2::HSeparator->new,
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Please choose the media for backup.")), $backup_daemon),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive($combo_media_type, $backup_daemon),
- ),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Please be sure that the cron daemon is included in your services.")), $backup_daemon),
- 0, gtkset_sensitive(Gtk2::Label->new(N("If your machine is not on all the time, you might want to install anacron.")), $backup_daemon),
- ),
- );
-
- gtksignal_connect(gtkset_active($check_when_daemon, $backup_daemon), toggled => sub {
- $backup_daemon = $backup_daemon ? 0 : 1;
- destroy_widget();
- advanced_when();
- });
- $combo_when_space->entry->set_text($trans2{$conf{DAEMON_TIME_SPACE}});
- $combo_when_space->entry->signal_connect('changed', sub {
- $conf{DAEMON_TIME_SPACE} = $trans{$combo_when_space->entry->get_text};
- $custom_cron = $conf{DAEMON_TIME_SPACE} eq "custom" ? 1 : 0;
- destroy_widget();
- advanced_when();
- });
- if ($custom_cron) {
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- }
-
- $combo_minute_when->entry->signal_connect('changed', sub {
- combo_to_cron_string($combo_minute_when->get_text, 0);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_hour_when->entry->signal_connect('changed', sub {
- combo_to_cron_string($combo_hour_when->get_text, 1);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_day_when->entry->signal_connect('changed', sub {
- combo_to_cron_string($combo_day_when->get_text, 2);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_month_when->entry->signal_connect('changed', sub {
- combo_to_cron_string($combo_month_when->get_active, 3);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_weekday_start->entry->signal_connect('changed', sub {
- my $start = $combo_weekday_start->get_active - 1;
- my $end = $combo_weekday_end->get_active - 1;
- $start = $start . "-" . $end if $end > -1 && $start < $end;
- combo_to_cron_string($start, 4);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_weekday_end->entry->signal_connect('changed', sub {
- my $start = $combo_weekday_start->get_active - 1;
- my $end = $combo_weekday_end->get_active - 1;
- $start = $start . "-" . $end if $start > -1 && $start < $end;
- combo_to_cron_string($start, 4);
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_profile->entry->signal_connect('changed', sub {
- $profile_string = "--profile " . $combo_profile->get_text;
- $profile_string = "" if $combo_profile->get_active == 0;
- $entry_crontab->set_text("$time_string $exec_string $profile_string $redir_string");
- });
- $combo_media_type->entry->signal_connect('changed', sub { $conf{DAEMON_MEDIA} = $combo_media_type->entry->get_text });
- fonction_env(\$box_when, \&advanced_when, \&advanced_box);
- $up_box->show_all;
-}
-
-sub combo_to_cron_string {
- my ($field, $location) = @_;
- $field = "*" if $field == 0 && $location == 3;
- $field = "*" if $field == -1 && $location == 4;
- my @time_list = split(" ", $time_string);
- splice(@time_list, $location, 1, $field);
- $time_string = join(" ", @time_list);
-}
-
-sub advanced_options() {
- my $box_options;
- my $entry_archiver = Gtk2::ComboBox->new_with_strings([ "tar", "star" ], $conf{ARCHIVER});
- my $entry_comp_mode = Gtk2::ComboBox->new_with_strings([ "tar", "tar.gz", "tar.bz2" ], $conf{OPTION_COMP});
- gtkpack($advanced_box,
- $box_options = gtkpack_(Gtk2::VBox->new(0, 15),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, Gtk2::Label->new(N("Please choose the archive program")),
- 1, Gtk2::HBox->new(0,10),
- 0, $entry_archiver,
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, Gtk2::Label->new(N("Please choose the compression type")),
- 1, Gtk2::HBox->new(0,10),
- 0, $entry_comp_mode,
- ),
- 0, my $check_backupignore = Gtk2::CheckButton->new(N("Use .backupignore files")),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, my $check_mail = Gtk2::CheckButton->new(N("Send mail report after each backup to:")),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $mail_entry = Gtk2::Entry->new, $conf{SEND_MAIL}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::HBox->new(0,10),
- 0, N("Return address for sent mail:"),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $from_entry = Gtk2::Entry->new, $conf{SEND_MAIL}),
- ),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::HBox->new(0,10),
- 0, N("SMTP server for mail:"),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(my $smtp_entry = Gtk2::Entry->new, $conf{SEND_MAIL}),
- ),
- 0, my $check_del_hd_files = Gtk2::CheckButton->new(N("Delete Hard Drive tar files after backup to other media.")),
- 0, my $check_view_restore_log = Gtk2::CheckButton->new(N("View restore log after file restore.")),
- ),
- );
- check_list([$check_mail, \$conf{SEND_MAIL}], [$check_del_hd_files, \$conf{DEL_HD_FILES}], [$check_backupignore, \$conf{BACKUPIGNORE}], [$check_view_restore_log, \$conf{VIEW_RESTORE_LOG}]);
- $mail_entry->set_text($conf{USER_MAIL});
- $mail_entry->signal_connect('changed', sub { $conf{USER_MAIL} = $mail_entry->get_text });
- $from_entry->set_text($conf{FROM_MAIL});
- $from_entry->signal_connect('changed', sub { $conf{FROM_MAIL} = $from_entry->get_text });
- $smtp_entry->set_text($conf{SMTP_SERVER});
- $smtp_entry->signal_connect('changed', sub { $conf{SMTP_SERVER} = $smtp_entry->get_text });
- $entry_archiver->entry->signal_connect('changed', sub { $conf{ARCHIVER} = $entry_archiver->entry->get_text });
- $entry_comp_mode->entry->signal_connect('changed', sub { $conf{OPTION_COMP} = $entry_comp_mode->entry->get_text });
- set_help_tip($entry_archiver, 'choose_archiver');
- set_help_tip($check_backupignore, 'backupignore');
- set_help_tip($check_mail, 'send_mail_to');
- set_help_tip($from_entry, 'send_mail_from');
- set_help_tip($check_del_hd_files, 'delete_files');
- set_help_tip($check_view_restore_log, 'view_log');
- fonction_env(\$box_options, \&advanced_options, \&advanced_box);
- $up_box->show_all;
-}
-
-sub advanced_box() {
- my $box_adv;
-
- gtkpack($advanced_box,
- $box_adv = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtksignal_connect(my $button_what = Gtk2::Button->new, clicked => sub {
- destroy_widget(); advanced_what() }),
- 1, gtksignal_connect(my $button_where = Gtk2::Button->new, clicked => sub {
- destroy_widget(); advanced_where() }),
- 1, gtksignal_connect(my $button_when = Gtk2::Button->new, clicked => sub {
- destroy_widget(); advanced_when() }),
- 1, gtksignal_connect(my $button_options = Gtk2::Button->new, clicked => sub {
- destroy_widget(); advanced_options() }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- $button_what->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-discdurwhat-40"),
- Gtk2::Label->new(N("What")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_where->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-where-40"),
- Gtk2::Label->new(N("Where")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_when->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-when-40"),
- Gtk2::Label->new(N("When")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_options->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-moreoption-40"),
- Gtk2::Label->new(N("More Options")),
- Gtk2::HBox->new(0, 5)
- ));
- fonction_env(\$box_adv, \&advanced_box, \&interactive_mode_box);
- $up_box->show_all;
-}
-
-################################################ WIZARD ################################################
-
-sub wizard_step3() {
- destroy_widget();
- 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..."));
- advanced_where_net_types(\&wizard_step2) if $conf{USE_NET};
- advanced_where_cd(\&wizard_step2) if $conf{USE_CD};
- advanced_where_tape(\&wizard_step2) if $conf{USE_TAPE};
- return;
- }
- if (check_pkg_needs()) {
- interactive_mode_box();
- return;
- }
- my $text = Gtk2::TextView->new;
- save_conf_file();
- read_conf_file();
- system_state();
- gtktext_insert($text, [ [ $system_state ] ]);
- button_box_restore_main();
-
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, gtkpack_(Gtk2::VBox->new(0,10),
- 0, N("Drakbackup Configuration"),
- 1, create_scrolled_window($text),
- ),
- ),
- );
- fonction_env(\$box2, \&wizard_step3, \&wizard_step2);
- button_box_wizard_end();
- $up_box->show_all;
-}
-
-sub wizard_step2() {
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 0, N("Please choose where you want to backup"),
- 0, gtkpack_(Gtk2::HBox->new(0, 15),
- 0, gtkpack__(Gtk2::VBox->new(0, 10),
- my @where_radio = gtkradio('', N("Hard Drive used to prepare backups for all media"), N("Across Network"), N("On CD-R"), N("On Tape Device")),
- ),
- 1, gtkpack_(Gtk2::HBox->new(0,5),),
- 0, gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Configure")), clicked => sub {
- destroy_widget();
- advanced_where_hd(\&wizard_step2);
- }), $use_hd),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Configure")), clicked => sub {
- destroy_widget();
- advanced_where_net_types(\&wizard_step2);
- }), $conf{USE_NET}),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Configure")), clicked => sub {
- destroy_widget();
- advanced_where_cd(\&wizard_step2);
- }), $conf{USE_CD}),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Configure")), clicked => sub {
- destroy_widget();
- advanced_where_tape(\&wizard_step2);
- }), $conf{USE_TAPE}),
- ),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- my @wheres = ($use_hd, $conf{USE_NET}, $conf{USE_CD}, $conf{USE_TAPE});
- foreach my $i (0..3) {
- $where_radio[$i]->set_active($wheres[$i]);
- $where_radio[$i]->signal_connect(toggled => sub {
- if ($where_radio[$i]->get_active) {
- @wheres = (0, 0, 0, 0);
- $wheres[$i] = 1;
- ($use_hd, $conf{USE_NET}, $conf{USE_CD}, $conf{USE_TAPE}) = @wheres;
- destroy_widget();
- wizard_step2();
- }
- });
- }
- fonction_env(\$box2, \&wizard_step2, \&wizard, undef);
- button_box_wizard();
- $up_box->show_all;
-}
-
-sub wizard() {
- my $user_string = N("Backup Users");
- $user_string .= N(" (Default is all users)") if !$nonroot_user;
- if (!$conf{NO_USER_FILES} && !$manual_user) {
- all_user_list() if @user_list_all == ();
- @user_list = @user_list_all;
- } elsif (!$manual_user) {
- @user_list = ();
- }
-
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 0, N("Please choose what you want to backup"),
- 0, gtkset_sensitive(my $check_wizard_sys = Gtk2::CheckButton->new(N("Backup System")), !$nonroot_user),
- 0, my $check_wizard_user = Gtk2::CheckButton->new($user_string),
- 0, gtksignal_connect(Gtk2::Button->new(N("Select user manually")), clicked => sub {
- $manual_user = 1;
- destroy_widget();
- advanced_what_user(\&wizard);
- }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- foreach ([$check_wizard_sys, \$conf{NO_SYS_FILES}], [$check_wizard_user, \$conf{NO_USER_FILES}]) {
- my $ref = $_->[1];
- gtksignal_connect(gtkset_active($_->[0], !$$ref), toggled => sub {
- $$ref = $$ref ? 0 : 1;
- if (!$conf{NO_SYS_FILES} || !$conf{NO_USER_FILES} && @user_list) {
- $next_widget = \&wizard_step2;
- } else {
- $next_widget = \&wizard;
- }
- if (!$conf{NO_USER_FILES}) {
- @user_list = @user_list_all;
- } else {
- @user_list = ();
- }
- });
- }
- if (!$conf{NO_SYS_FILES} || !$conf{NO_USER_FILES} && @user_list) {
- fonction_env(\$box2, \&wizard, \&interactive_mode_box, \&wizard_step2);
- } else {
- $in->ask_warn(N("Error"), N("Please select data to backup..."));
- fonction_env(\$box2, \&wizard, \&interactive_mode_box, \&wizard);
- }
- button_box_wizard();
- $up_box->show_all;
-}
-
-################################################ RESTORE ################################################
-
-sub find_backup_to_restore() {
- my @list_backup;
- my @list_backup_tmp2;
- my $to_put;
- my $nom;
- @sys_backuped = ();
- local $_;
-
- @user_backuped = ();
- -d $path_to_find_restore and @list_backup_tmp2 = all($path_to_find_restore);
-
- foreach (@list_backup_tmp2) {
- s/_base//gi;
- s/_incr//gi;
- push @list_backup , $_;
- }
- foreach (grep { /^backup_sys_/ } @list_backup) {
- ($to_put, undef) = file_to_put($_, "sys");
- push @sys_backuped , $to_put;
- }
- $restore_step_sys_date = $to_put;
- foreach (grep { /^backup_other_/ } @list_backup) {
- ($to_put, undef) = file_to_put($_, "other");
- push @other_backuped , $to_put;
- }
- $restore_step_other_date = $to_put;
- foreach (grep { /^backup_user_/ } @list_backup) {
- ($to_put, $nom) = file_to_put($_, "user");
- push @user_backuped , $to_put;
- any { /^$nom$/ } @user_list_backuped or push @user_list_backuped, $nom;
- }
-}
-
-sub file_to_put {
- my ($name, $type) = @_;
- my $to_put;
- my ($nom, $date, $heure);
- local $_ = $name;
- chomp;
- $name = "backup_" . $type . "_";
- s/^$name//gi;
- s/.tar|.gz|.bz2$//gi;
- if ($type eq "user") {
- ($nom, $date, $heure) = /^(.*)_([^_]*)_([^_]*)$/;
- } else {
- ($date, $heure) = /^(.*)_([^_]*)$/;
- }
- my $year = substr($date, 0, 4);
- my $month = substr($date, 4, 2);
- my $day = substr($date, 6, 2);
- my $hour = substr($heure, 0, 2);
- my $min = substr($heure, 2, 2);
- if ($type eq "user") {
- $to_put = "$_ user: $nom, date: $day/$month/$year, hour: $hour:$min";
- return $to_put, $nom;
- } else {
- $to_put = "$day/$month/$year $hour:$min $_";
- return $to_put, undef;
- }
-}
-
-sub system_state() {
- if ($cfg_file_exist) {
- $system_state = N("\nBackup Sources: \n");
- $conf{NO_SYS_FILES} or $system_state .= N("\n- System Files:\n");
- $conf{NO_SYS_FILES} or $system_state .= "\t\t$_\n" foreach @sys_files;
- $conf{NO_USER_FILES} or $system_state .= N("\n- User Files:\n");
- $conf{NO_USER_FILES} or $system_state .= "\t\t$_\n" foreach @user_list;
- $conf{OTHER_FILES} and $system_state .= N("\n- Other Files:\n");
- $conf{OTHER_FILES} and $system_state .= "\t\t$_\n" foreach @other_files;
- $conf{USE_HD} and $system_state .= N("\n- Save on Hard drive on path: %s\n", $conf{PATH_TO_SAVE});
- $conf{USE_HD} and $system_state .= N("\tLimit disk usage to %s MB\n", $conf{MAX_SPACE});
- $conf{DEL_OLD} and $system_state .= N("\tDelete backups older than %s day(s)\n", $conf{DEL_OLD});
-
- if ($conf{DEL_HD_FILES} && ($conf{USE_CD} || $conf{USE_TAPE} || $conf{USE_NET}) && $conf{DAEMON_MEDIA} ne 'hd') {
- $system_state .= N("\n- Delete hard drive tar files after backup.\n");
- }
-
- #- tape and CDRW share some features
- my $erase_media = $conf{MEDIA_ERASE} && ($conf{USE_CD} || $conf{USE_TAPE}) ? N("Yes") : N("No");
- $conf{USE_CD} and $system_state .= N("\n- Burn to CD");
- $conf{USE_CD} and $conf{CDRW} and $system_state .= N("RW");
- $conf{USE_CD} and $system_state .= N(" on device: %s", $conf{CD_DEVICE});
- $conf{USE_CD} && $conf{MULTI_SESSION} and $system_state .= N(" (multi-session)");
- $conf{USE_TAPE} and $system_state .= N("\n- Save to Tape on device: %s", $conf{TAPE_DEVICE});
- (($conf{USE_CD} || $conf{USE_TAPE}) && $conf{MEDIA_ERASE}) and $system_state .= N("\t\tErase=%s", $erase_media);
- $conf{USE_CD} || $conf{USE_TAPE} and $system_state .= "\n";
- $conf{USE_TAPE} && $conf{DIRECT_TAPE} and $system_state .= N("\tBackup directly to Tape\n");
-
- $conf{USE_NET} and $system_state .= N("\n- Save via %s on host: %s\n", $conf{NET_PROTO}, $conf{HOST_NAME});
- $conf{USE_NET} and $system_state .= N("\t\t user name: %s\n\t\t on path: %s \n", $conf{LOGIN}, $conf{HOST_PATH});
- $system_state .= N("\n- Options:\n");
- $conf{NO_SYS_FILES} and $system_state .= N("\tDo not include System Files\n");
-
- $system_state .= N("\tBackups use %s and bzip2\n", $conf{ARCHIVER}) if $conf{OPTION_COMP} eq "tar.bz2";
- $system_state .= N("\tBackups use %s and gzip\n", $conf{ARCHIVER}) if $conf{OPTION_COMP} eq "tar.gz";
- $system_state .= N("\tBackups use %s only\n", $conf{ARCHIVER}) if $conf{OPTION_COMP} eq "tar";
-
- $system_state .= N("\tUse .backupignore files\n") if $conf{BACKUPIGNORE};
- $system_state .= N("\tSend mail to %s\n", $conf{USER_MAIL}) if $conf{SEND_MAIL};
- $system_state .= N("\tSend mail from %s\n", $conf{FROM_MAIL}) if $conf{SEND_MAIL};
- $system_state .= N("\tUsing SMTP server %s\n", $conf{SMTP_SERVER}) if $conf{SEND_MAIL};
-
- $conf{DAEMON_MEDIA} and $system_state .= N("\n- Daemon, %s via:\n", $conf{DAEMON_TIME_SPACE});
- $conf{DAEMON_MEDIA} eq 'hd' and $system_state .= N("\t-Hard drive.\n");
- $conf{DAEMON_MEDIA} eq 'cd' and $system_state .= N("\t-CD-R.\n");
- $conf{DAEMON_MEDIA} eq 'tape' and $system_state .= N("\t-Tape \n");
- $conf{DAEMON_MEDIA} eq 'ftp' and $system_state .= N("\t-Network by FTP.\n");
- $conf{DAEMON_MEDIA} eq 'ssh' and $system_state .= N("\t-Network by SSH.\n");
- $conf{DAEMON_MEDIA} eq 'rsync' and $system_state .= N("\t-Network by rsync.\n");
- } else {
- $system_state = N("No configuration, please click Wizard or Advanced.\n");
- }
-}
-
-sub restore_state() {
- $restore_state = N("List of data to restore:\n\n");
- if ($restore_sys) {
- $restore_state .= N("- Restore System Files.\n");
- my @tmp = split(' ', $restore_step_sys_date);
- $restore_state .= N(" - from date: %s %s\n", $tmp[0], $tmp[1]);
- }
- if ($restore_user) {
- $restore_state .= N("- Restore User Files: \n");
- $restore_state .= "\t\t$_\n" foreach @user_list_to_restore2;
- push @user_list_to_restore, (split(',', $_))[0] foreach @user_list_to_restore2;
- }
- if ($restore_other) {
- $restore_state .= N("- Restore Other Files: \n");
- my @tmp = split(' ', $restore_step_other_date);
- $restore_state .= N(" - from date: %s %s\n", $tmp[0], $tmp[1]);
- }
- if ($restore_other_path) {
- $restore_state .= "- Path to Restore: $restore_path \n";
- }
-}
-
-sub select_most_recent_selected_of {
- my ($user_name) = @_;
- my @tmp = sort @user_list_to_restore2;
- my @list_tmp2 = grep { /$user_name/ } sort @tmp;
- return pop @list_tmp2;
-}
-
-sub select_user_data_to_restore() {
- my $var_eq = 1;
- my @list_backup;
- my @list_tmp;
- my @list_tmp2;
- @user_list_to_restore = ();
- local $_;
-
- 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;
- s/_incr//gi;
- push @list_backup , $_;
- }
- foreach my $var_tmp (@user_list_backuped) {
- $var_eq = 1;
- my $more_recent = (split(' ', select_most_recent_selected_of($var_tmp)))[0];
- foreach (grep { /^backup_user_$var_tmp/ } sort @list_backup) {
- s/.$conf{OPTION_COMP}//gi;
- if ($more_recent) {
- if (/$more_recent/) {
- push @list_tmp , $_;
- $var_eq = 0;
- } else {
- #- only if user asked for it - previously this was restoring everything (SB)
- my $tmp_name = $_;
- s/backup_user_//gi;
- foreach my $buff (@user_list_to_restore2) {
- if (index($buff, $_) >= 0) {
- $var_eq and push @list_tmp , $tmp_name;
- }
- }
- }
- }
- }
- }
- foreach my $var_to_restore (@list_tmp) {
- $var_to_restore =~ s/backup_//gi;
- foreach my $var_exist (sort @list_tmp2) {
- if ($var_exist =~ /$var_to_restore/) {
- push @user_list_to_restore, $var_exist;
- }
- }
- }
- $DEBUG and print "real user list to restore: $_ \n" foreach @user_list_to_restore;
-}
-
-sub select_sys_data_to_restore() {
- my $var_eq = 1;
- my @list_tmp;
- local $_;
-
- -d $path_to_find_restore and @list_tmp = grep { /^backup/ } all($path_to_find_restore);
- my @more_recent = split(' ', $restore_step_sys_date);
- my $more_recent = pop @more_recent;
- foreach my $var_exist (grep { /_sys_/ } sort @list_tmp) {
- if ($var_exist =~ /$more_recent/) {
- push @sys_list_to_restore, $var_exist;
- $var_eq = 0;
- } else {
- $var_eq and push @sys_list_to_restore, $var_exist;
- }
- }
- $DEBUG and print "sys list to restore: $_\n " foreach @sys_list_to_restore;
-}
-
-sub select_other_data_to_restore() {
- my $var_eq = 1;
- my @list_tmp;
- local $_;
- @other_list_to_restore = ();
-
- -d $path_to_find_restore and @list_tmp = grep { /^backup/ } all($path_to_find_restore);
- my @more_recent = split(' ', $restore_step_other_date);
- my $more_recent = pop @more_recent;
- foreach my $var_exist (grep { /_other_/ } sort @list_tmp) {
- if ($var_exist =~ /$more_recent/) {
- push @other_list_to_restore, $var_exist;
- $var_eq = 0;
- } else {
- $var_eq and push @other_list_to_restore, $var_exist;
- }
- }
- $DEBUG and print "other list to restore: $_\n " foreach @other_list_to_restore;
-}
-
-sub show_backup_details {
- my ($function, $mode, $name) = @_;
- my $archive_file_detail;
- my $value;
- my $command2;
- my $tarfile;
-
- if ($mode eq "user") {
- #- we've only got a partial filename in this case
- $tarfile = "$path_to_find_restore/backup_*" . $name . ".tar*";
- }
- if ($mode eq "sys") {
- #- funky string here we need to use to reconstruct the filename
- my @flist = split(/[ \t,]+/, $name);
- $tarfile = "$path_to_find_restore/backup_*" . $flist[2] . ".tar*";
- }
- my @tarfiles = glob($tarfile);
- if ($tarfiles[0] eq "") {
- destroy_widget();
- $function->();
- }
- $tarfile = $tarfiles[0];
- my $command1 = "stat " . $tarfile;
-
-### $command2 = "$conf{ARCHIVER} -t -v";
- $command2 = set_tar("list", $tarfile);
- $command2 .= " $tarfile";
-
- log::explanations("Running $command1");
- $archive_file_detail = `$command1 2>&1` . "\n\n";
- log::explanations("Running $command2");
- my $TMP;
- open $TMP, "$command2 2>&1 |";
- while ($value = <$TMP>) {
- #- drop the permissions display for the sake of readability
- $archive_file_detail .= substr($value, 11);
- }
- close $TMP;
-
- my $text = Gtk2::TextView->new;
- my $advanced_box_archive;
- gtktext_insert(gtkset_editable($text, 0), $archive_file_detail);
- gtkpack($advanced_box,
- $advanced_box_archive = gtkpack_(Gtk2::VBox->new(0,10),
- 1, gtkpack_(Gtk2::HBox->new(0,0),
- 1, create_scrolled_window($text),
- ),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("Done")), clicked => sub {
- destroy_widget();
- $function->() }),
- ),
- )
- );
- $central_widget = \$advanced_box_archive;
- $up_box->show_all;
-}
-
-sub valid_backup_test {
- my (@files_list) = @_;
- @files_corrupted = ();
- my $is_corrupted = 0;
- my $comp_test;
- foreach (@files_list) {
- $comp_test = set_tar("list", $_);
- if (system("$comp_test $path_to_find_restore/$_ > /dev/null 2>&1") > 1) {
- push @files_corrupted, $_;
- $is_corrupted = -1;
- }
- }
- return $is_corrupted;
-}
-
-sub restore_aff_backup_problems() {
- my $do_restore;
- my $text = Gtk2::TextView->new;
- my $restore_pbs_state = N("List of data corrupted:\n\n");
- $restore_pbs_state .= "\t\t$_\n" foreach @files_corrupted;
- $restore_pbs_state .= N("Please uncheck or remove it on next time.");
- gtktext_insert($text, [ [ $restore_pbs_state ] ]);
- button_box_restore_main();
-
- gtkpack($advanced_box,
- $do_restore = gtkpack_(Gtk2::VBox->new(0,10),
- 0, Gtk2::VBox->new(0,10),
- 1, gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtkcreate_img('warning'),
- 0, N("Backup files are corrupted"),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 0, Gtk2::VBox->new(0,10),
- 1, create_scrolled_window($text),
- ),
- );
- button_box_restore_pbs_end();
- fonction_env(\$do_restore, \&restore_aff_backup_problems, "restore_pbs");
- $up_box->show_all;
-}
-
-sub restore_aff_result() {
- my $do_restore;
- my $text = Gtk2::TextView->new;
- gtktext_insert($text, [ [ $restore_state ] ]);
- button_box_restore_main();
-
- gtkpack($advanced_box,
- $do_restore = gtkpack_(Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 0, N(" All of your selected data have been "),
- 0, N(" Successfully Restored on %s ", $restore_path),
- 1, Gtk2::VBox->new(0,10),
- ),
- );
- button_box_ok_only();
- $central_widget = \$do_restore;
- $up_box->show_all;
-}
-
-sub return_path {
- my ($username) = @_;
- my $usr;
- my $home_dir;
- my @passwords = cat_("/etc/passwd");
- foreach my $line (@passwords) {
- chomp($line);
- ($usr, $home_dir) = (split(/:/, $line))[0,5];
- last if $usr eq $username;
- }
- return $home_dir;
-}
-
-sub restore_backend() {
- my $exist_problem = 0;
- my $user_dir;
- my $username;
- local $_;
- -d $restore_path or mkdir_p $restore_path;
-
- if ($restore_user) {
- select_user_data_to_restore();
- if (valid_backup_test(@user_list_to_restore) == -1) {
- $exist_problem = 1;
- restore_aff_backup_problems();
- } else {
- foreach (@user_list_to_restore) {
- if ($conf{USER_INCREMENTAL_BACKUPS}) {
- (undef, $username, undef) = /^(\w+_\w+_user_)(.*)_(\d+_\d+.*)$/;
- } else {
- (undef, $username, undef) = /^(\w+_user_)(.*)_(\d+_\d+.*)$/;
- }
-
- $user_dir = return_path($username);
- -d $user_dir and rm_rf($user_dir) if $remove_user_before_restore;
-
- my $user_untar = set_tar("restore", $_);
- $DEBUG and print "user name to restore: $username, user directory: $user_dir\n";
- system("$user_untar $path_to_find_restore/$_ -C $restore_path");
- }
- #- flush this out for another cycle (SB)
- @user_list_to_restore2 = ();
- }
- }
-
- if ($restore_sys) {
- select_sys_data_to_restore();
- if (valid_backup_test(@sys_list_to_restore) == -1) {
- $exist_problem = 1;
- restore_aff_backup_problems();
- } else {
- foreach (@sys_list_to_restore) {
- my $sys_untar = set_tar("restore", $_);
- system("$sys_untar $path_to_find_restore/$_ -C $restore_path");
- }
- }
- }
- if ($restore_other) {
- if (valid_backup_test(@other_list_to_restore) == -1) {
- $exist_problem = 1;
- restore_aff_backup_problems();
- } else {
- foreach (@other_list_to_restore) {
- my $other_untar = set_tar("restore", $_);
- system("$other_untar $path_to_find_restore/$_ -C $restore_path");
- }
- }
- }
- $exist_problem or restore_aff_result();
-}
-
-sub set_tar {
- my ($mode, $filename) = @_;
- my $untar_cmd;
- $untar_cmd = "$conf{ARCHIVER} -C $restore_path -x" if $mode eq "restore";
- $untar_cmd = "$conf{ARCHIVER} -t" if $mode eq "list";
- $untar_cmd .= " -acl -xattr" if $conf{ARCHIVER} eq "star";
- $untar_cmd .= set_compression($filename);
- $untar_cmd .= " -f";
- return $untar_cmd;
-}
-
-sub set_compression {
- my ($extension) = @_;
- return " -j" if $extension =~ /tar.bz2$/;
- return " -z" if $extension =~ /tar.gz$/;
-}
-
-sub check_archiver() {
- if (!-x "/usr/bin/star") {
- #- sane fallback, star is still in contrib
- $conf{ARCHIVER} = "tar";
- show_warning("i", N("/usr/bin/star not found, using tar..."));
- save_conf_file();
- }
-}
-
-sub restore_do() {
- if ($backup_bef_restore) {
- if ($restore_sys) {
- $conf{NO_SYS_FILES} = 0;
- } else {
- $conf{NO_SYS_FILES} = 1;
- }
- if ($restore_user) {
- $conf{NO_USER_FILES} = 0;
- @user_list = @user_list_to_restore;
- } else {
- $conf{NO_USER_FILES} = 1;
- }
- build_backup_status();
- read_conf_file();
- build_backup_files();
- $table->destroy;
- }
- restore_do2();
-}
-
-sub restore_do2() {
- destroy_widget();
- my $do_restore;
- my $text = Gtk2::TextView->new;
- restore_state();
- gtktext_insert($text, [ [ $restore_state ] ]);
- button_box_restore_main();
-
- gtkpack($advanced_box,
- $do_restore = gtkpack_(Gtk2::VBox->new(0,10),
- 0, N(" Restore Configuration "),
- 1, create_scrolled_window($text),
- ),
- );
- button_box_restore_end();
- fonction_env(\$do_restore, \&restore_do2, \&restore_box);
- $up_box->show_all;
-}
-
-sub restore_step_other() {
- my $retore_step_other;
- my $text = Gtk2::TextView->new;
- my $untar_cmd = "$conf{ARCHIVER} -t -z -f";
- my $other_rest = "";
- select_other_data_to_restore();
- if ($restore_other) {
- foreach (@other_list_to_restore) {
- if (/tar.bz2$/) {
- $untar_cmd = "$conf{ARCHIVER} -t -j -f";
- }
- $other_rest .= "/" . `$untar_cmd $path_to_find_restore/$_ -C $restore_path`;
- }
- }
- gtktext_insert($text, [ [ $other_rest ] ]);
- gtkpack($advanced_box,
- $retore_step_other = gtkpack_(Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 1, create_scrolled_window($text),
- 0, my $check_restore_other_sure = Gtk2::CheckButton->new(N("OK to restore the other files.")),
- 1, Gtk2::VBox->new(0,10),
- ),
- );
- check_list([$check_restore_other_sure, \$restore_other]);
- fonction_env(\$retore_step_other, \&restore_step_other, \&restore_step2, \&restore_do);
- $up_box->show_all;
-}
-
-sub restore_step_user() {
- my $retore_step_user;
- my @tmp_list = sort @user_backuped;
- @user_backuped = @tmp_list;
- gtkpack($advanced_box,
- $retore_step_user = gtkpack_(Gtk2::VBox->new(0,10),
- 0, Gtk2::VBox->new(0,10),
- 0, N("User list to restore (only the most recent date per user is important)"),
- 1, create_scrolled_window(gtkpack__(Gtk2::VBox->new(0,0),
- map { my $name;
- my $var2;
- my $name_complet = $_;
- $name = (split(' ', $name_complet))[0];
- my @user_list_tmp;
- my $restore_row = Gtk2::HBox->new(0,5);
- my $b = Gtk2::CheckButton->new($name_complet);
- my $details = Gtk2::Button->new(N("Details"));
-
- $restore_row->pack_start($b, 1, 1, 0);
- $restore_row->pack_end(Gtk2::VBox->new(1,5), 0, 0, 0);
- $restore_row->pack_end($details, 0, 0, 0);
-
- foreach (@user_list_to_restore2) {
- if ($name_complet eq $_) {
- gtkset_active($b, 1);
- $check_user_to_restore{$name_complet}[1] = 1;
- } else {
- gtkset_active($b, 0);
- $check_user_to_restore{$name_complet}[1] = 0;
- }
- }
- $b->signal_connect(toggled => sub {
- 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;
- }
- } else {
- $check_user_to_restore{$name_complet}[1] = 0;
- foreach (@user_list_to_restore2) {
- $var2 = (split(' ', $_))[0];
- if ($name ne $var2) {
- push @user_list_tmp, $_;
- }
- }
- @user_list_to_restore2 = @user_list_tmp;
- }
- });
- $details->signal_connect('clicked', sub {
- destroy_widget();
- show_backup_details(\&restore_step_user, "user", $name);
- });
- $restore_row } (@user_backuped)
- ),
- ),
- ),
- );
- if ($restore_other) {
- fonction_env(\$retore_step_user, \&restore_step_user, "", \&restore_step_other);
- } elsif ($restore_sys) {
- fonction_env(\$retore_step_user, \&restore_step_user, \&restore_step_sys, \&restore_step_other);
- } else {
- fonction_env(\$retore_step_user, \&restore_step_user, \&restore_step2, \&restore_do);
- }
- $up_box->show_all;
-}
-
-sub restore_step_sys() {
- my $restore_step_sys;
- my $combo_restore_step_sys = Gtk2::ComboBox->new_with_strings(\@sys_backuped, $restore_step_sys_date);
- gtkpack($advanced_box,
- $restore_step_sys = gtkpack_(Gtk2::VBox->new(0,10),
- 0, N("Please choose the date to restore:"),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, Gtk2::HBox->new(0,10),
- 0, $combo_restore_step_sys,
- 0, my $details = Gtk2::Button->new(N("Details")),
- 1, Gtk2::HBox->new(0,10),
- ),
- ),
- );
- $combo_restore_step_sys->entry->signal_connect('changed', sub {
- $restore_step_sys_date = $combo_restore_step_sys->entry->get_text;
- });
- $details->signal_connect('clicked', sub {
- #- we're only passing a portion of the filename to
- #- the subroutine so we need to let it know this
- $restore_step_sys_date = $combo_restore_step_sys->entry->get_text;
- destroy_widget();
- show_backup_details(\&restore_step_sys, "sys", $restore_step_sys_date);
- });
- fonction_env(\$restore_step_sys, \&restore_step_sys, \&restore_step2, "restore");
- if ($restore_user) {
- fonction_env(\$restore_step_sys, \&restore_step_sys, \&restore_step2, \&restore_step_user);
- } elsif ($restore_other) {
- fonction_env(\$restore_step_sys, \&restore_step_sys, \&restore_step2, \&restore_step_other);
- } else {
- fonction_env(\$restore_step_sys, \&restore_step_sys, \&restore_step2, \&restore_do);
- }
- $up_box->show_all;
-}
-
-sub restore_other_media() {
- my $box_find_restore;
- my $button;
-
- gtkpack($advanced_box,
- $box_find_restore = gtkpack_(Gtk2::VBox->new(0, 6),
- 0, Gtk2::HSeparator->new,
- 0, my $check_other_media_hd = Gtk2::CheckButton->new(N("Restore from Hard Disk.")),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(Gtk2::Label->new(N("Enter the directory where backups are stored")), $other_media_hd),
- 1, Gtk2::VBox->new(0, 6),
- 0, gtkset_size_request(gtkset_sensitive($restore_find_path_entry = Gtk2::Entry->new, $other_media_hd), 152, 20),
- 0, gtkset_sensitive($button = gtksignal_connect(Gtk2::Button->new, clicked => sub {
- filedialog_generic(N("Directory with backups"), \$restore_find_path_entry);
- }), $other_media_hd),
- ),
- 1, Gtk2::VBox->new(0, 6),
- 0, Gtk2::VBox->new(0, 6),
- ),
- );
- gtksignal_connect(gtkset_active($check_other_media_hd, $other_media_hd), toggled => sub {
- $other_media_hd = $other_media_hd ? 0 : 1;
- destroy_widget();
- $current_widget->();
- });
- $button->add(gtkpack(Gtk2::HBox->new(0,10), gtkcreate_img("ic82-dossier-32")));
- $restore_find_path_entry->set_text($path_to_find_restore);
- $restore_find_path_entry->signal_connect('changed', sub { $path_to_find_restore = $restore_find_path_entry->get_text });
- fonction_env(\$box_find_restore, \&restore_other_media, \&restore_step2, \&restore_do);
- $up_box->show_all;
-}
-
-sub restore_step2() {
- my $retore_step2;
- my $other_exist;
- 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";
- $info_prefix = "list" if $conf{USE_NET} || $conf{USE_TAPE};
-
- if (any { /_other_/ } grep { /^$info_prefix/ } all("$restore_info_path/")) {
- $other_exist = 1;
- } else {
- $other_exist = 0; $restore_other = 0;
- }
- if (any { /_sys_/ } grep { /^$info_prefix/ } all("$restore_info_path/")) {
- $sys_exist = 1;
- } else {
- $sys_exist = 0; $restore_sys = 0;
- }
- if (any { /_user_/ } grep { /^$info_prefix/ } all("$restore_info_path/")) {
- $user_exist = 1;
- } else {
- $user_exist = 0; $restore_user = 0;
- }
-
- my $restore_path_entry = Gtk2::Entry->new;
- gtkpack($advanced_box,
- $retore_step2 = gtkpack_(Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, my $check_restore_other_src = Gtk2::CheckButton->new(N("Select another media to restore from")),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Other Media")), clicked => sub {
- destroy_widget();
- restore_other_media();
- }), $restore_other_src),
- ),
- 0, gtkset_sensitive(my $check_restore_sys = Gtk2::CheckButton->new(N("Restore system")), $sys_exist),
- 0, gtkset_sensitive(my $check_restore_user = Gtk2::CheckButton->new(N("Restore Users")), $user_exist),
- 0, gtkset_sensitive(my $check_restore_other = Gtk2::CheckButton->new(N("Restore Other")), $other_exist),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 0, my $check_restore_other_path = Gtk2::CheckButton->new(N("Select path to restore (instead of /)")),
- 1, Gtk2::HBox->new(0,10),
- 0, gtkset_sensitive($restore_path_entry, $restore_other_path),
- 0, gtksignal_connect(my $button = Gtk2::Button->new->new, clicked => sub {
- filedialog_generic(N("Path To Restore To"), \$restore_path_entry);
- }),
- ),
- 0, gtkset_sensitive(my $check_backup_bef_restore = Gtk2::CheckButton->new(N("Do new backup before restore (only for incremental backups.)")),
- $conf{SYS_INCREMENTAL_BACKUPS} || $conf{USER_INCREMENTAL_BACKUPS}),
- 0, gtkset_sensitive(my $check_remove_user_dir = Gtk2::CheckButton->new(N("Remove user directories before restore.")), $user_exist),
- 1, Gtk2::VBox->new(0,10),
- ),
- );
-
- foreach ([$check_restore_sys, \$restore_sys],
- [$check_backup_bef_restore, \$backup_bef_restore],
- [$check_restore_user, \$restore_user],
- [$check_remove_user_dir, \$remove_user_before_restore],
- [$check_restore_other, \$restore_other]) {
- my $ref = $_->[1];
- gtksignal_connect(gtkset_active($_->[0], $$ref), toggled => sub {
- $$ref = $$ref ? 0 : 1;
- if (!$restore_sys && !$restore_user && !$restore_other) {
- $next_widget = \&message_norestore_box;
- } elsif ($restore_sys && $conf{SYS_INCREMENTAL_BACKUPS}) {
- $next_widget = \&restore_step_sys;
- } elsif ($restore_user) {
- $next_widget = \&restore_step_user;
- } elsif ($restore_other) {
- $next_widget = \&restore_step_other;
- } 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;
- destroy_widget();
- $current_widget->();
- });
- gtksignal_connect(gtkset_active($check_restore_other_src, $restore_other_src), toggled => sub {
- $restore_other_src = $restore_other_src ? 0 : 1;
- destroy_widget();
- $current_widget->();
- });
- $central_widget = \$retore_step2;
- fonction_env(\$retore_step2, \&restore_step2, \&restore_box);
- if (!$restore_sys && !$restore_user && !$restore_other) {
- $next_widget = \&message_norestore_box;
- } elsif ($restore_sys && $conf{SYS_INCREMENTAL_BACKUPS}) {
- $next_widget = \&restore_step_sys;
- } elsif ($restore_user) {
- $next_widget = \&restore_step_user;
- } elsif ($restore_other) {
- $next_widget = \&restore_step_other;
- } else {
- $next_widget = \&restore_do;
- }
- $button->add(gtkpack(Gtk2::HBox->new(0,10), gtkcreate_img("ic82-dossier-32")));
- $restore_path_entry->set_text($restore_path);
- $restore_path_entry->signal_connect('changed', sub {
- $restore_path = $restore_path_entry->get_text;
- });
- $up_box->show_all;
-}
-
-sub find_files_to_restore() {
- local $_;
- my $file_restore;
- my $start_restore;
- my $files_selected = 0;
- my @possible_sources;
- my %catalog_entries;
- 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);
- $file_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $file_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 1));
- $file_list->append_column(my $valcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 2));
- $file_list->set_headers_visible(0);
- $file_list->get_selection->set_mode('browse');
- $valcolumn->set_visible(0);
- my $unselected = gtkcreate_pixbuf('unselected');
- my $selected = gtkcreate_pixbuf('selected');
- my $file_wildcard_entry = Gtk2::Entry->new;
-
- gtkpack($advanced_box,
- $file_restore = gtkpack_(Gtk2::VBox->new(0,10),
- 0, Gtk2::Label->new(N("Filename text substring to search for (empty string matches all):")),
- 0, gtkpack_(Gtk2::HBox->new(0,10),
- 1, $file_wildcard_entry,
- 0, gtksignal_connect(Gtk2::Button->new(N("Search Backups")), clicked => sub {
- local $_ = $file_wildcard_entry->get_text;
- s|^\*|\\*|g;
- my $wildcard = $_;
- @possible_sources = glob "$conf{PATH_TO_SAVE}/list*";
- $model->clear;
- my $match = 0;
- foreach my $list (@possible_sources) {
- $list =~ s|.gz||;
- my @matches = grep { /$wildcard/ } catMaybeCompressed($list);
- if (@matches) {
- my $list_entry = $model->append_set(undef, [ 0 => $list, 2 => '' ]);
- foreach (@matches) {
- chop;
- $model->append_set($list_entry, [ 0 => $_, 1 => $unselected, 2 => 0 ]);
- }
- $match = 1;
- }
- }
- show_warning("i", N("No matches found...")) if $match == 0;
- }),
- ),
- 1, create_scrolled_window($file_list),
- 0, gtkset_sensitive(gtksignal_connect($start_restore = Gtk2::Button->new(N("Restore Selected")), clicked => sub {
- @files_to_restore = ();
- my $last_entry = '';
- my $catalog_entry;
- my $restore_file;
- foreach (sort keys %catalog_entries) {
- if ($catalog_entries{$_} == 1) {
- ($catalog_entry, $restore_file) = split("###", $_);
- $last_entry = $catalog_entry if $last_entry eq '';
- if ($catalog_entry ne $last_entry) {
- restore_catalog_entry($cat_entry, @files_to_restore);
- @files_to_restore = ();
- push @files_to_restore, $restore_file;
- } else {
- push @files_to_restore, $restore_file;
- }
- $last_entry = $catalog_entry;
- }
- }
- restore_catalog_entry($cat_entry, @files_to_restore);
- destroy_widget();
- find_files_to_restore() if view_log_or();
- }), 0),
- ),
- );
-
- $file_list->get_selection->signal_connect(changed => sub {
- my ($lmodel, $iter) = $_[0]->get_selected;
- $lmodel && $iter or return;
- my ($s, $val) = $lmodel->get($iter, 0, 2);
- if (! any { /$s/ } @possible_sources) {
- my $parent_iter = Gtk2::TreeModel::iter_parent($lmodel, $iter);
- my $parent_name = $lmodel->get($parent_iter, 0);
- $cat_entry = substr($parent_name, -19, 15);
- my @full_cat_entry = grep { /^$cat_entry/ } @catalog;
- chop @full_cat_entry;
- $cat_entry = $full_cat_entry[0];
- $val ? $lmodel->set($iter, 1, $unselected, 2, 0) : $lmodel->set($iter, 1, $selected, 2, 1);
- $val ? $files_selected-- : $files_selected++;
- $catalog_entries{$cat_entry . "###" . $s} = 1 - $val;
- $files_selected ? gtkset_sensitive($start_restore, 1) : gtkset_sensitive($start_restore, 0);
- }
- });
- $central_widget = \$file_restore;
-}
-
-sub catalog_restore {
- my ($call_method) = @_;
- my $catalog_box;
- 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);
- $tree_catalog->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
-
- $tree_catalog->set_headers_visible(0);
- $tree_catalog->get_selection->set_mode('single');
-
- # file details in list widget
- my $lmodel = Gtk2::ListStore->new("Glib::String");
- my $tree_files = Gtk2::TreeView->new_with_model($lmodel);
- $tree_files->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
-
- $tree_files->set_headers_visible(0);
- $tree_files->get_selection->set_mode('multiple');
-
- #- read the catalog
- my @catalog = cat_("$cfg_dir/drakbackup_catalog");
-
- foreach (@catalog) {
- chop;
- my @line_data = split(':', $_);
- my $t = $line_data[0];
-
- my $t_catalog = $model->append_set(undef, [ 0 => $t ]);
-
- my $indexer = 0;
- foreach (@line_data) {
- if ($indexer != 0) {
- my $m;
- $m = "Media: " if $indexer == 1;
- $m = "Label or Host: " if $indexer == 2;
- $m = "Device or Path: " if $indexer == 3;
- $m = "Type: Incremental" if $_ eq "I";
- $m = "Type: Differential" if $_ eq "D";
- $m = "Type: Full" if $_ eq "F";
- $m .= $_ if $_ ne "I" && $_ ne "F" && $_ ne "D";
- $model->append_set($t_catalog, [ 0 => $m ]);
- }
- $indexer++;
- }
- }
-
- $tree_catalog->get_selection->signal_connect(changed => sub {
- my ($model, $iter) = $_[0]->get_selected;
- $model && $iter or return;
- $cat_entry = $model->get($iter, 0);
- my $parent_iter = Gtk2::TreeModel::iter_parent($model, $iter);
- if ($parent_iter) {
- $cat_entry = '';
- return;
- }
- gtkset_mousecursor_wait();
- @restore_files = ();
- $lmodel->clear;
- foreach my $filename (glob("$conf{PATH_TO_SAVE}/list*$cat_entry.txt*")) {
- $filename =~ s|.gz||;
- my @contents = catMaybeCompressed($filename);
- foreach (@contents) {
- chop;
- my $s = $_;
- $lmodel->append_set(0, $s);
- }
- }
- gtkset_mousecursor_normal();
- my @full_cat_entry = grep { /^$cat_entry/ } @catalog;
- $cat_entry = $full_cat_entry[0];
- });
-
- $tree_files->get_selection->signal_connect(changed => sub {
- my (@what) = $_[0]->get_selected_rows;
- @restore_files = ();
- foreach (@what) {
- my $iter = $lmodel->get_iter($_);
- my $s = $lmodel->get($iter, 0);
- push @restore_files, $s;
- }
- });
-
- gtkpack($advanced_box,
- $catalog_box = gtkpack_(Gtk2::HBox->new(0,10),
- 1, gtkpack_(Gtk2::VBox->new(0,5),
- 0, N("Click date/time to see backup files.\nCtrl-Click files to select multiple files."),
- 1, gtkpack_(Gtk2::VBox->new(0, 10),
- 1, create_scrolled_window($tree_catalog),
- 1, create_scrolled_window($tree_files),
- ),
- 0, gtkpack_(Gtk2::HBox->new(1, 10),
- 1, gtksignal_connect(Gtk2::Button->new(N("Restore Selected\nCatalog Entry")), clicked => sub {
- if ($cat_entry) {
- my $media_check = restore_catalog_entry($cat_entry, ());
- if (! $media_check) {
- destroy_widget();
- interactive_mode_box() if view_log_or();
- }
- }
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Restore Selected\nFiles")), clicked => sub {
- my $files = @restore_files;
- #- grab the array before the widget clears it
- my @passed_files = @restore_files;
- if ($cat_entry && $files) {
- my $media_check = restore_catalog_entry($cat_entry, @passed_files);
- if (! $media_check) {
- destroy_widget();
- interactive_mode_box() if view_log_or();
- }
- }
- }),
- 1, gtkpack_(Gtk2::VBox->new(0, 5),
- 0, Gtk2::Label->new("Restore To Path"),
- 0, $restore_path_entry = Gtk2::Entry->new,
- ),
- 0, gtksignal_connect(my $button = Gtk2::Button->new, clicked => sub {
- filedialog_generic(N("Path To Restore To"), \$restore_path_entry);
- }),
- ),
- 0, Gtk2::VBox->new(0,10),
- ),
- 0, Gtk2::VBox->new(0,10),
- ),
- );
-
- $restore_path_entry->set_text($restore_path);
- gtksignal_connect($restore_path_entry, changed => sub {
- $restore_path = $restore_path_entry->get_text;
- });
- $button->add(gtkpack(Gtk2::HBox->new(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_box, \&catalog_restore) if $call_method eq "button";
- $central_widget = \$catalog_box;
- $up_box->show_all;
-}
-
-sub restore_catalog_entry {
- restore_status();
-
- my ($cat_entry, @restore_files) = @_;
- my $username;
- my $userpass = $conf{PASSWD};
- my $restore_result = 1;
- $log_buff = "";
-
- my @line_data = split(':', $cat_entry);
- my $backup_time = $line_data[0];
-
- #- use our own variables here so we do not trash a saved config accidentally
- my $media = $line_data[1];
-
- #- can be a volume name or a host name
- my $vol_host = $line_data[2];
-
- #- see if we have a username embedded in the host
- if (index($vol_host, "@") != -1) {
- my @user_host = split("@", $vol_host);
- $username = $user_host[0];
- $vol_host = $user_host[1];
- } else {
- $username = $conf{LOGIN};
- }
-
- #- create a restore work directory if we do not have one
- -d "$cfg_dir/restores" or mkdir_p "$cfg_dir/restores";
-
- #- can be a device name or a path
- my $dev_path = $line_data[3];
-
- if ($media eq 'HD') {
- #- shouldn't really happen, should have just browsed
- #- to the $conf{PATH_TO_SAVE} in the previous step - deal with it anyway
- my @restore_tar_files = glob("$dev_path/*$backup_time*$conf{OPTION_COMP}");
- my $matches = @restore_tar_files;
- if ($matches == 0) {
- show_warning("f", N("Backup files not found at %s.", $dev_path));
- return 0;
- } else {
- my $save_path_org = $conf{PATH_TO_SAVE};
- $conf{PATH_TO_SAVE} = $dev_path;
- $restore_result = restore_hd_or_cd($cat_entry, $dev_path, @restore_files);
- $conf{PATH_TO_SAVE} = $save_path_org;
- }
- }
-
- if ($media eq 'CD') {
- #- we know the cdrecord device, and the label
- #- prompt the user for the right CD
- $in->ask_okcancel(N("Restore From CD"), N("Insert the CD with volume label %s\n in the CD drive under mount point /mnt/cdrom", $vol_host) ,1) ? ($vol_name = get_cd_volname()) : return 0;
- if ($vol_name ne $vol_host) {
- show_warning("f", N("Not the correct CD label. Disk is labelled %s.", $vol_name));
- return 0;
- } else {
- $restore_result = restore_hd_or_cd($cat_entry, '/mnt/cdrom', @restore_files);
- }
- }
-
- if ($media =~ /^DirectTape|^Tape/) {
- #- a little more complicated, we need to check if other backups
- #- were done on this tape, and try to find the offset to this one
- $in->ask_okcancel(N("Restore From Tape"), N("Insert the tape with volume label %s\n in the tape drive device %s", $vol_host, $dev_path) ,1) ? ($vol_name = get_tape_label($dev_path)) : return 0;
- if ($vol_name ne $vol_host) {
- show_warning("f", N("Not the correct tape label. Tape is labelled %s.", $vol_name));
- return 0;
- } else {
- $restore_result = restore_tape($media, $cat_entry, $dev_path, @restore_files);
- }
- }
-
- if ($media eq 'ftp' || $media eq 'ssh' || $media eq 'rsync') {
- #- show the user what we know of the connection from the catalog
- #- and the config file, let them override if necessary
-
- $in->ask_from(N("Restore Via Network"), N("Restore Via Network Protocol: %s", $media),
- [ { label => N("Host Name"), val => \$vol_host },
- { label => N("Host Path or Module"), val => \$dev_path },
- { label => N("Username"), val => \$username },
- { label => N("Password"), val => \$userpass, hidden => 1 },
- ]) or goto return 0;
-
- if ($media eq 'ftp' || $media eq 'rsync') {
- if ($userpass eq '') {
- show_warning("f", N("Password required"));
- return 0;
- }
- }
- if ($media eq 'ftp' || $media eq 'rsync' || $media eq 'ssh') {
- if ($username eq '') {
- show_warning("f", N("Username required"));
- return 0;
- } elsif ($vol_host eq '') {
- show_warning("f", N("Hostname required"));
- return 0;
- }
- }
- if ($dev_path eq '') {
- show_warning("f", N("Path or Module required"));
- return 0;
- }
-
- $restore_result = restore_ftp($cat_entry, $vol_host, $dev_path, $username, $userpass, @restore_files) if $media eq 'ftp';
- $restore_result = restore_rsync_ssh($cat_entry, $vol_host, $dev_path, $username, $media, @restore_files) if $media eq 'rsync' || $media eq 'ssh';
- }
-
- # cleanup our restore dir - unlink fails here?
- system("rm -fr $cfg_dir/restores/*");
-
- if (!$restore_result) {
- show_warning("i", N("Files Restored..."));
- return 0;
- } else {
- show_warning("f", N("Restore Failed..."));
- return 1;
- }
-
-}
-
-sub view_log_or() {
- if ($conf{VIEW_RESTORE_LOG}) {
- button_box_ok_only();
- show_status();
- } else {
- return 1;
- }
-}
-
-sub untar {
- my ($cmd, $msg, $tarfile, $restorefile) = @_;
- my $message = "Untarring from \n$tarfile \nto $restore_path.";
- $message = "Untarring \n$restorefile from \n$tarfile \nto $restore_path." if $msg eq "files";
- my $untar_cmd = set_tar("restore", $tarfile);
- my $command = "$untar_cmd $cmd";
- spawn_progress($command, $message);
- $results = $log_buff;
-}
-
-sub no_tarfile {
- my ($tarfile) = @_;
- if (!-e "$cfg_dir/restores/$tarfile") {
- show_warning("f", N("%s not retrieved...", $tarfile));
- return 1;
- }
-}
-
-sub restore_hd_or_cd {
- my ($cat_entry, $tarfile_dir, @restore_files) = @_;
- my $indv_files = @restore_files;
- my $wild_card = catalog_to_wildcard($cat_entry);
-
- if ($indv_files == 0) {
- #- full catalog specified
- foreach (wildcard_to_tarfile($wild_card)) {
- untar("$tarfile_dir/$_", "all", $_, undef);
- }
- } else {
- #- individual files - pull from appropriate catalog
- foreach (@restore_files) {
- my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
- untar("$tarfile_dir/$tarfile $restorefile", "files", $tarfile, $restorefile);
- }
- }
- return 0;
-}
-
-sub restore_tape {
- my ($media, $cat_entry, $dev_path, @restore_files) = @_;
- my $indv_files = @restore_files;
- my $wild_card = catalog_to_wildcard($cat_entry);
- $dev_path =~ s|/st|/nst|;
- my $command = "$conf{ARCHIVER} -C $restore_path -x -f $dev_path";
-
- if ($media eq "DirectTape") {
- position_tape($cat_entry, $dev_path);
- if ($indv_files != 0) {
- foreach (@restore_files) {
- $command .= " " . substr($_, 1);
- }
- }
- spawn_progress($command, "Restoring files from $dev_path to $restore_path.");
- $results = $log_buff;
- return 0;
- }
-
- if ($indv_files == 0) {
- #- full catalog specified
- foreach (wildcard_to_tarfile($wild_card)) {
- position_tape($cat_entry, $dev_path);
- get_tarfile_from_tape($dev_path);
- return 1 if no_tarfile("$conf{PATH_TO_SAVE}/$_");
- untar("$cfg_dir/restores/$conf{PATH_TO_SAVE}/$_", "all", $_, undef);
- }
- } else {
- #- individual files - pull from appropriate catalog
- foreach (@restore_files) {
- my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
- if (!-e "$cfg_dir/restores/$tarfile") {
- position_tape($cat_entry, $dev_path);
- get_tarfile_from_tape($dev_path);
- }
- return 1 if no_tarfile("$conf{PATH_TO_SAVE}/$tarfile");
- untar("$cfg_dir/restores/$conf{PATH_TO_SAVE}/$tarfile $restorefile", "files", $tarfile, $restorefile);
- }
- }
- return 0;
-}
-
-sub restore_ftp {
- use Net::FTP;
- my $ftp;
- my ($cat_entry, $hostname, $hostpath, $username, $userpass, @restore_files) = @_;
- my $indv_files = @restore_files;
-
- $DEBUG and print "file list to retrieve: $cat_entry\n ";
- if ($DEBUG && $interactive) { $ftp = Net::FTP->new($hostname, Debug => 1) or return 1 }
- elsif ($interactive) { $ftp = Net::FTP->new($hostname, Debug => 0) or return 1 }
- 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);
-
- if ($indv_files == 0) {
- #- full catalog specified
- foreach (wildcard_to_tarfile($wild_card)) {
- $ftp->get($_, "$cfg_dir/restores/$_");
- return 1 if no_tarfile($_);
- untar("$cfg_dir/restores/$_", "all", $_, undef);
- }
- } else {
- #- individual files - pull from appropriate catalog
- foreach (@restore_files) {
- my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
- if (!-e "$cfg_dir/restores/$tarfile") {
- $ftp->get($tarfile, "$cfg_dir/restores/$tarfile");
- }
- return 1 if no_tarfile($tarfile);
- untar("$cfg_dir/restores/$tarfile $restorefile", "files", $tarfile, $restorefile);
- }
- }
- $ftp->quit;
- return 0;
-}
-
-sub restore_rsync_ssh {
- my ($cat_entry, $hostname, $hostpath, $username, $mode, @restore_files) = @_;
- my $indv_files = @restore_files;
- my $wild_card = catalog_to_wildcard($cat_entry);
- if ($indv_files == 0) {
- #- full catalog specified
- foreach (wildcard_to_tarfile($wild_card)) {
- get_file_from_net($mode, $_, $hostname, $hostpath, $username);
- return 1 if no_tarfile($_);
- untar("$cfg_dir/restores/$_", "all", $_, undef);
- }
- } else {
- #- individual files - pull from appropriate catalog
- foreach (@restore_files) {
- my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
- get_file_from_net($mode, $tarfile, $hostname, $hostpath, $username) if !-e "$cfg_dir/restores/$tarfile";
- return 1 if no_tarfile($tarfile);
- untar("$cfg_dir/restores/$tarfile $restorefile", "files", $tarfile, $restorefile);
- }
- }
- return 0;
-}
-
-sub get_file_from_net {
- my ($mode, $tarfile, $hostname, $hostpath, $username) = @_;
- my $command;
- if ($mode eq 'ssh') {
- $command = "scp $username\@$hostname:$hostpath/$tarfile $cfg_dir/restores/";
- } elsif ($mode eq 'rsync') {
- $command = "rsync --password-file=$cfg_dir/rsync.user $username\@$hostname" . "::" . "$hostpath/$tarfile $cfg_dir/restores/";
- } else {
- $command = "wget http://$hostname/$hostpath/$tarfile -P $cfg_dir/restores/";
- }
- spawn_progress($command, "Retrieving backup file \n$tarfile \nvia $mode.");
-}
-
-sub catalog_to_wildcard {
- my ($cat_entry) = @_;
- my @line_data = split(':', $cat_entry);
- my $wildcard = $line_data[0];
- $wildcard;
-}
-
-sub wildcard_to_tarfile {
- my ($wildcard) = @_;
- my (@tarfile) = glob("$conf{PATH_TO_SAVE}/*$wildcard.txt*");
- foreach (@tarfile) {
- $_ = basename($_);
- s/txt/$conf{OPTION_COMP}/;
- s/list/backup/;
- }
- @tarfile;
-}
-
-sub file_to_tarfile {
- my ($restore_file, $wildcard) = @_;
- #- remove leading "/" - only when using star (behavior change from before, now tar uses -P to archive for consistancy)
- check_archiver();
- $restore_file = substr($restore_file, 1) if $conf{ARCHIVER} eq 'star';
- #- filename with spaces
- $restore_file = "'" . $restore_file . "'" if $restore_file =~ / /;
- #- can be in more than one tarfile (misuse of "other")
- my @tarfiles = `zgrep -l $restore_file $conf{PATH_TO_SAVE}/*$wildcard.txt*`;
- chomp @tarfiles;
- my $tarfile = $tarfiles[0];
- $tarfile = basename($tarfile);
- $tarfile =~ s/.gz//;
- $tarfile =~ s/txt/$conf{OPTION_COMP}/;
- $tarfile =~ s/list/backup/;
- $restore_file, $tarfile;
-}
-
-sub find_tape_offset {
- my ($cat_entry) = @_;
- my @line_data = split(':', $cat_entry);
- my $label = $line_data[2];
- my @catalog = cat_("$cfg_dir/drakbackup_catalog");
- #- always off by 1 for tape label.
- my $offset = 1;
- foreach (@catalog) {
- chomp;
- if (index($_, $label) > 0) {
- if ($_ ne $cat_entry) {
- $offset++;
- } else {
- return $offset;
- }
- }
- }
-}
-
-sub position_tape {
- my ($cat_entry, $dev_path) = @_;
- 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.");
-}
-
-sub get_tarfile_from_tape {
- my ($dev_path) = @_;
- spawn_progress("$conf{ARCHIVER} -C $cfg_dir/restores -x -f $dev_path", "Untarring from $dev_path to work directory.");
-}
-
-sub restore_box() {
- destroy_widget();
-
- if ($good_restore_path) {
- $path_to_find_restore = $conf{PATH_TO_SAVE} if $conf{USE_HD};
- $path_to_find_restore = "/mnt/cdrom" if $conf{USE_CD};
- }
-
- find_backup_to_restore();
- button_box_restore_main();
-
- if (@other_backuped || @sys_backuped || @user_backuped) {
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0,1),
- 1, Gtk2::VBox->new(0,10),
- 1, gtkpack_(Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- 1, gtksignal_connect(Gtk2::Button->new(N("Search for files to restore")), clicked => sub {
- button_box_file_restore();
- find_files_to_restore();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Restore all backups")), clicked => sub {
- button_box_restore();
- @user_list_to_restore2 = sort @user_backuped;
- $restore_sys = 1;
- $restore_other = 1;
- $restore_user = 1;
- restore_do();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Custom Restore")), clicked => sub {
- button_box_restore();
- restore_step2();
- }),
- 1, gtksignal_connect(Gtk2::Button->new(N("Restore From Catalog")), clicked => sub {
- catalog_restore("button");
- }),
- 1, Gtk2::VBox->new(0,10),
- 1, Gtk2::VBox->new(0,10),
- ),
- 1, Gtk2::HBox->new(0,10),
- ),
- );
- } else {
- destroy_widget();
- restore_find_media_box();
- }
- fonction_env(\$box2, \&restore_box, \&interactive_mode_box);
- $central_widget = \$box2;
- $up_box->show_all;
-}
-
-sub restore_find_media_box() {
- my $mount_media = 1;
- $good_restore_path = 0;
- my $message = N("Unable to find backups to restore...\n");
- $message .= N("Verify that %s is the correct path", $path_to_find_restore) if $conf{USE_HD} && $conf{USE_CD};
- $message .= N(" and the CD is in the drive") if $conf{USE_CD};
- if ($conf{USE_TAPE} || $conf{NET_PROTO}) {
- $message .= N("Backups on unmountable media - Use Catalog to restore");
- $mount_media = 0;
- }
- $message .= ".";
-
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::VBox->new(0, 5),
- 1, gtkpack(Gtk2::HBox->new(0, 15),
- Gtk2::VBox->new(0, 5),
- gtkcreate_img('warning'),
- translate($message),
- Gtk2::VBox->new(0, 5),
- ),
- 1, gtkpack(Gtk2::HBox->new(0, 15),
- Gtk2::VBox->new(0, 5),
- gtkpack(Gtk2::VBox->new(0, 10),
- gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("CD in place - continue.")), clicked => sub {
- $good_restore_path = 1;
- interactive_mode_box("restore");
- }), $mount_media),
- $new_path_entry = gtkset_sensitive(Gtk2::Entry->new, $mount_media),
- gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Browse to new restore repository.")), clicked => sub {
- filedialog_generic(N("Directory To Restore From"), \$new_path_entry);
- }), $mount_media),
- gtksignal_connect(Gtk2::Button->new(N("Restore From Catalog")), clicked => sub {
- $box2->destroy;
- catalog_restore("need media");
- }),
- gtksignal_connect(Gtk2::Button->new(N("Search for files to restore")), clicked => sub {
- $box2->destroy;
- button_box_file_restore();
- find_files_to_restore();
- }),
- ),
- Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- $new_path_entry->set_text($path_to_find_restore);
- $new_path_entry->signal_connect('changed', sub { $path_to_find_restore = $new_path_entry->get_text });
- $central_widget = \$box2;
- button_box_find_media($mount_media);
- $up_box->show_all;
-}
-
-sub restore_status() {
- destroy_widget();
- $pbar3 = Gtk2::ProgressBar->new;
- $stext = Gtk2::Label->new("");
- gtkpack($advanced_box,
- $table = gtkpack(Gtk2::VBox->new(0, 5),
- Gtk2::HBox->new(0,5),
- create_packtable({ col_spacings => 10, row_spacings => 5 },
- [""],
- [""],
- [""],
- [""],
- [N("Restore Progress")],
- [""],
- [""],
- [$pbar3],
- [""],
- [""],
- [$plabel3 = Gtk2::Label->new(' ')],
- [""],
- ),
- $stext,
- ),
- );
- $central_widget = \$table;
- $up_box->show_all;
- gtkflush();
-}
-
-################################################ BUTTON_BOX ################################################
-
-sub hbutton() {
- 0, gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => \&adv_help);
-}
-
-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);
-}
-
-sub pbutton() {
- 0, gtksignal_connect(Gtk2::Button->new(N("Previous")), clicked => sub {
- destroy_widget();
- $previous_widget->();
- });
-}
-
-sub hspace() {
- 1, Gtk2::HBox->new(0, 1);
-}
-
-sub button_box_adv() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- pbutton(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Save")), clicked => sub {
- return if check_pkg_needs();
- if (!save_conf_file()) {
- destroy_widget();
- $previous_widget->();
- }
- }),
- ),
- );
-}
-
-sub button_box_restore_main() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- ibutton(N("Previous")),
- ibutton(N("Next")),
- ),
- );
-}
-
-sub button_box_file_restore() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- 0, gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&restore_box),
- hbutton(),
- hspace(),
- ),
- );
-}
-
-sub button_box_ok_only() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- hspace(),
- ibutton(N("Ok")),
- ),
- );
-}
-
-sub button_box_backup_end() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- pbutton(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Build Backup")), clicked => sub {
- destroy_widget();
- build_backup_status();
- build_backup_files();
- }),
- ),
- );
-}
-
-sub button_box_wizard_end() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- pbutton(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Save")), clicked => sub {
- save_conf_file();
- interactive_mode_box();
- }),
- ),
- );
-}
-
-sub button_box_restore_end() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbuttonr(),
- hbutton(),
- hspace(),
- pbutton(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Restore")), clicked => sub {
- destroy_widget();
- restore_backend();
- }),
- ),
- );
-}
-
-sub button_box_restore_pbs_end() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- hspace(),
- hbutton(),
- ibutton(N("Ok")),
- ),
- );
-}
-
-sub button_box_restore() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbuttonr(),
- hbutton(),
- hspace(),
- pbutton(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Next")), clicked => sub {
- destroy_widget();
- $next_widget->();
- }),
- ),
- );
-}
-
-sub button_box_find_media {
- my ($mount_media) = @_;
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- ibutton(N("Previous")),
- 0, gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("Next")), clicked => sub {
- interactive_mode_box("restore");
- }), $mount_media),
- ),
- );
-}
-
-sub button_box_wizard() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- cbutton(),
- hbutton(),
- hspace(),
- 0, gtksignal_connect(Gtk2::Button->new($previous_widget ? N("Previous") : N("Ok")), clicked => sub {
- destroy_widget();
- $previous_widget ? $previous_widget->() : $next_widget->();
- }),
- if_($next_widget, 0, gtksignal_connect(Gtk2::Button->new(N("Next")), clicked => sub {
- destroy_widget();
- $next_widget ? $next_widget->() : $previous_widget->();
- })),
- ),
- );
-}
-
-sub button_box_main() {
- $button_box_tmp->destroy;
- gtkpack($button_box,
- $button_box_tmp = gtkpack_(Gtk2::HButtonBox->new,
- hbutton(),
- hspace(),
- 0, gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { ugtk2->exit(0) }),
- ),
- );
-}
-
-################################################ MESSAGES ################################################
-
-sub message_norestore_box() {
- $box2->destroy;
-
- gtkadd($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack(Gtk2::HBox->new(0, 15),
- Gtk2::VBox->new(0, 5),
- gtkcreate_img('warning'),
- N("Please select data to restore..."),
- Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- button_box_restore_main();
- $central_widget = \$box2;
- $up_box->show_all;
-}
-
-################################################ BUILD_BACKUP ################################################
-
-sub progress {
- my ($progressbar, $plabel, $incr, $label_text) = @_;
- my ($new_val) = $progressbar->get_fraction;
- $new_val += $incr;
- if ($new_val > 1) { $new_val = 1 }
- $progressbar->set_fraction($new_val);
- $plabel->set_text($label_text);
- gtkflush();
-}
-
-sub build_backup_status() {
- $pbar = Gtk2::ProgressBar->new;
- $pbar1 = Gtk2::ProgressBar->new;
- $pbar2 = Gtk2::ProgressBar->new;
- $pbar3 = Gtk2::ProgressBar->new;
- $plabel = Gtk2::Label->new(" ");
- $plabel1 = Gtk2::Label->new(" ");
- $plabel2 = Gtk2::Label->new(" ");
- $plabel3 = Gtk2::Label->new(" ");
-
- $stext = Gtk2::Label->new("");
- button_box_ok_only();
-
- my $table = Gtk2::Table->new(10, 2, 1);
- $table->set_row_spacings(5);
- $table->set_col_spacings(10);
-
- $table->attach_defaults(Gtk2::Label->new(N("Backup system files")), 0, 1, 0, 1);
- $table->attach_defaults($pbar, 0, 1, 1, 2);
- $table->attach_defaults($plabel, 1, 2, 1, 2);
- $table->attach_defaults(Gtk2::Label->new(N("Backup user files")), 0, 1, 2, 3);
- $table->attach_defaults($pbar1, 0, 1, 3, 4);
- $table->attach_defaults($plabel1, 1, 2, 3, 4);
- $table->attach_defaults(Gtk2::Label->new(N("Backup other files")), 0, 1, 4, 5);
- $table->attach_defaults($pbar2, 0, 1, 5, 6);
- $table->attach_defaults($plabel2, 1, 2, 5, 6);
- $table->attach_defaults(Gtk2::Label->new(N("Total Progress")), 0, 1, 6, 7);
- $table->attach_defaults($pbar3, 0, 1, 7, 8);
- $table->attach_defaults($plabel3, 1, 2, 7, 8);
-
- gtkpack($advanced_box,
- my $tbox = gtkpack(Gtk2::VBox->new(0, 5),
- $table,
- $stext,
- ),
- );
-
- $central_widget = \$tbox;
- $up_box->show_all;
- gtkflush();
-}
-
-sub build_backup_ftp_status() {
- $pbar = Gtk2::ProgressBar->new;
- $pbar3 = Gtk2::ProgressBar->new;
- destroy_widget();
- button_box_ok_only();
- $pbar->set_fraction(0);
- $pbar3->set_fraction(0);
-
- gtkpack($advanced_box,
- $table = gtkpack_(Gtk2::VBox->new(0, 15),
- 1, N("Sending files by FTP"),
- 1, Gtk2::VBox->new(0, 15),
- 1, create_packtable({ col_spacings => 10, row_spacings => 5 },
- [N("Sending files...")],
- [""],
- [ $plabel = Gtk2::Label->new(' ') ],
- [ $pbar ],
- [""],
- [N("Total Progress")],
- [ $plabel3 = Gtk2::Label->new(' ') ],
- [$pbar3],
- ),
- 1, Gtk2::VBox->new(0, 15),
- ),
- );
- $central_widget = \$table;
- $up_box->show_all;
- gtkflush();
-}
-
-sub build_backup_box_see_conf {
- my ($caller) = @_;
- my $text = Gtk2::TextView->new;
- read_conf_file();
- system_state();
- gtktext_insert($text, [ [ $system_state ] ]);
- button_box_restore_main();
-
- gtkpack($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, gtkpack_(Gtk2::VBox->new(0,10),
- 0, N("Drakbackup Configuration"),
- 1, create_scrolled_window($text),
- ),
- ),
- );
- button_box_backup_end();
- $central_widget = \$box2;
- $current_widget = \&build_backup_box_see_conf;
- if ($caller eq "interactive") {
- $previous_widget = \&interactive_mode_box;
- } else {
- $previous_widget = \&build_backup_box;
- }
- $up_box->show_all;
-}
-
-sub build_backup_box() {
- destroy_widget();
-
- gtkadd($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtksignal_connect(my $button_from_conf_file = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- build_backup_status();
- build_backup_files();
- }),
- 0, Gtk2::VBox->new(0, 5),
- 1, gtksignal_connect(my $button_see_conf = Gtk2::Button->new, clicked => sub {
- destroy_widget();
- build_backup_box_see_conf(undef);
- }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
-
- $button_from_conf_file->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-discdurwhat-40"),
- Gtk2::Label->new(N("Backup Now from configuration file")),
- Gtk2::HBox->new(0, 5)
- ));
- $button_see_conf->add(gtkpack(Gtk2::HBox->new(0,10),
- gtkcreate_img("ic82-moreoption-40"),
- Gtk2::Label->new(N("View Backup Configuration.")),
- Gtk2::HBox->new(0, 5)
- ));
-
- button_box_restore_main();
- fonction_env(\$box2, \&build_backup_box, \&interactive_mode_box);
- $up_box->show_all;
-}
-
-################################################ INTERACTIVE ################################################
-
-sub interactive_mode_box {
-
- my ($o_mode) = @_;
- if ($o_mode eq "restore") {
- $central_widget = \$box2;
- restore_box();
- return 0;
- }
-
- destroy_widget();
- gtkadd($advanced_box,
- $box2 = gtkpack_(Gtk2::HBox->new(0, 15),
- 1, Gtk2::VBox->new(0, 5),
- 1, gtkpack_(Gtk2::VBox->new(0, 5),
- 1, Gtk2::VBox->new(0, 5),
- 0, gtksignal_connect(Gtk2::Button->new(N("Wizard Configuration")), clicked => sub {
- destroy_widget();
- read_conf_file();
- wizard();
- }),
- 0, gtksignal_connect(Gtk2::Button->new(N("Advanced Configuration")), clicked => sub {
- button_box_adv();
- destroy_widget();
- advanced_box();
- }),
- 0, gtksignal_connect(Gtk2::Button->new(N("View Configuration")), clicked => sub {
- destroy_widget();
- build_backup_box_see_conf("interactive");
- }),
- 0, gtksignal_connect(Gtk2::Button->new(N("View Last Log")), clicked => sub {
- $results = cat_($log_file);
- button_box_ok_only();
- show_status();
- }),
- 0, gtksignal_connect(Gtk2::Button->new(N("Backup Now")), clicked => sub {
- if ($cfg_file_exist) {
- build_backup_box();
- } else {
- $in->ask_warn(N("Error"), N("No configuration file found \nplease click Wizard or Advanced."));
- }
- }),
- 0, gtksignal_connect(Gtk2::Button->new(N("Restore")), clicked => sub {
- restore_box();
- }),
- 1, Gtk2::VBox->new(0, 5),
- ),
- 1, Gtk2::VBox->new(0, 5),
- ),
- );
- $central_widget = \$box2;
- button_box_main();
- $up_box->show_all;
-}
-
-sub profile_chooser {
- my ($mode, $prompt) = @_;
- my $file_dialog = Gtk2::FileChooserDialog->new($prompt, $my_win->{real_window}, $mode, N("Cancel") => 'cancel', N("Ok") => 'ok');
- my $filter = Gtk2::FileFilter->new;
- $filter->add_pattern("*.conf");
- $file_dialog->set_current_folder($cfg_dir);
- $file_dialog->add_filter($filter);
- $file_dialog->set('do-overwrite-confirmation', 1);
- $file_dialog->show;
- while (my $answer = $file_dialog->run) {
- if (member($answer, qw(cancel delete-event))) {
- $file_dialog->destroy;
- return;
- } elsif ($answer eq 'ok') {
- my $file_name = $file_dialog->get_filename;
- $file_dialog->destroy;
- return $file_name;
- }
- }
-}
-
-sub load_profile() {
- my $profile = profile_chooser('open', N("Load profile"));
- if ($profile =~ /.conf$/) {
- $cfg_file = $profile;
- read_conf_file();
- interactive_mode_box();
- }
-}
-
-sub save_profile() {
- my $profile = profile_chooser('save', N("Save profile as..."));
- if ($profile =~ /.conf$/) {
- $cfg_file = $profile;
- save_conf_file();
- }
-}
-
-sub get_items() {
- my @items = (
- [ "/_File", undef, undef, undef, '<Branch>', ],
- [ "/_File/_Load profile", undef, \&load_profile, 1, '<StockItem>', 'gtk-execute' ],
- [ "/_File/_Save profile as...", undef, \&save_profile, 1, '<StockItem>', 'gtk-execute' ],
- [ "/_File/_Exit", undef, sub { ugtk2->exit(0) }, 1, '<StockItem>', 'gtk-quit' ],
- [ "/_Help/_Help", undef, \&adv_help, 1, '<StockItem>', 'gtk-help' ],
- );
- return @items;
-}
-
-sub interactive_mode() {
- $interactive = 1;
-
- $in = 'interactive'->vnew;
- $::Wizard_title = N("Drakbackup");
- $::Wizard_pix_up = "ic82-back-up-48.png";
- $in->isa('interactive::gtk') and $::isWizard = 0;
- $my_win = ugtk2->new(N("Drakbackup"));
- $window1 = $my_win->{window};
- $my_win->{rwindow}->set_size_request(600,440);
- $my_win->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- my @items = get_items();
- my $factory = Gtk2::ItemFactory->new('Gtk2::MenuBar', '<main>', undef);
- $factory->create_items('menu', @items);
- my $menu = $factory->get_widget('<main>');
- read_conf_file();
-
- gtkadd($window1,
- gtkpack(Gtk2::VBox->new(0,0),
- gtkpack($up_box = Gtk2::VBox->new(0, 5),
- gtkpack_(Gtk2::VBox->new(0, 3),
- 0, $menu,
- 1, gtkpack_(Gtk2::HBox->new(0, 3),
- 1, $advanced_box = Gtk2::HBox->new(0, 15),
- ),
- 0, Gtk2::HSeparator->new,
- 0, $button_box = gtkpack(Gtk2::VBox->new(0, 15),
- $button_box_tmp = gtkpack(Gtk2::VBox->new(0, 0),),
- ),
- ),
- ),
- ),
- );
- setup_tooltips();
- interactive_mode_box();
- button_box_main();
- $central_widget = \$box2;
- $window1->realize;
- $window1->show_all;
- $my_win->main;
- $my_win->exit(0);
-}
-
-sub adv_help() {
- exec("drakhelp --id drakbackup") unless fork();
-}
-
-sub destroy_widget() {
- if ($central_widget ne '') {
- $$central_widget->destroy;
- $central_widget = '';
- }
-}
diff --git a/perl-install/standalone/drakboot b/perl-install/standalone/drakboot
index dfa8f306a..7c3a66daf 100755
--- a/perl-install/standalone/drakboot
+++ b/perl-install/standalone/drakboot
@@ -2,7 +2,7 @@
# DrakBoot
# $Id$
-# Copyright (C) 2001-2005 Mandriva
+# Copyright (C) 2001-2006 Mandriva
# Yves Duret, Thierry Vignaud
#
# This program is free software; you can redistribute it and/or modify
@@ -47,21 +47,20 @@ my $cmdline = cat_('/proc/cmdline');
my $bootloader = bootloader::read($all_hds);
if (!$bootloader) {
$in->ask_okcancel('', N("No bootloader found, creating a new configuration"), 0) or $in->exit;
- bootloader::suggest($bootloader ||= {}, $all_hds,
- vga_fb => first($cmdline =~ /\bvga=(\S+)/), #- don't use $1 here, otherwise perl will hit you because of the other "=~" below
- quiet => $cmdline =~ /\bsplash=silent\b/,
- );
+ any::setupBootloaderBeforeStandalone($in->do_pkgs, $bootloader ||= {}, $all_hds, $fstab);
}
if (!$in->isa('interactive::gtk') || any { /^--boot$/ } @ARGV) {
$::isWizard = 1;
- eval { lilo_choice() };
+ eval { any::setupBootloaderUntilInstalled($in, $bootloader, $all_hds, $fstab, $ENV{SECURE_LEVEL}) };
die if $@ && $@ !~ /^wizcancel/;
$in->exit(0);
}
require ugtk2;
ugtk2->import(qw(:helpers :wrappers :create));
+require mygtk2;
+mygtk2->import(qw(gtknew));
if (any { /^--splash$/ } @ARGV) {
splash_choice();
@@ -87,7 +86,7 @@ sub run_boot_window {
create_factory_menu($w->{rwindow}, @menu_items);
######### menus end
}
- gtkadd($window, gtkpack_(Gtk2::VBox->new(0,0),
+ gtkadd($window, gtknew('VBox', children => [
@$pack_list,
0, create_okcancel({
cancel_clicked => sub { ugtk2->exit(0) },
@@ -95,7 +94,7 @@ sub run_boot_window {
$apply_sub->();
ugtk2->exit(0);
}
- })));
+ }) ]));
$window->show_all;
gtkflush();
$w->main;
@@ -110,10 +109,10 @@ sub splash_choice() {
my $theme = bootsplash::themes_read_sysconfig($cur_res);
$bootsplash_available or $theme->{enabled} = 0;
- my $boot_pic = gtkcreate_img($bootsplash::default_thumbnail);
+ my $boot_pic = gtknew('Image', file => $bootsplash::default_thumbnail);
change_image($boot_pic, $theme->{name}, $cur_res);
- my $theme_combo = Gtk2::ComboBox->new_with_strings([ bootsplash::themes_list_for_resolution($cur_res) ], $theme->{name});
+ my $theme_combo = gtknew('ComboBox', text => $theme->{name}, list => [ bootsplash::themes_list_for_resolution($cur_res) ]);
$theme_combo->entry->signal_connect(changed => sub {
$theme->{name} = $theme_combo->entry->get_text;
change_image($boot_pic, $theme->{name}, $cur_res);
@@ -126,7 +125,7 @@ sub splash_choice() {
verbose => N("Verbose"),
silent => N("Silent"),
);
- my $mode_combo = Gtk2::ComboBox->new_with_strings([ values %modes ], $modes{$theme->{enabled} ? $cmdline =~ /\bsplash=silent\b/ ? 'silent' : 'verbose' : 'text'});
+ my $mode_combo = gtknew('ComboBox', text => $modes{$theme->{enabled} ? $cmdline =~ /\bsplash=silent\b/ ? 'silent' : 'verbose' : 'text'}, list => [ values %modes ]);
$mode_combo->entry->signal_connect(changed => sub {
$theme->{enabled} = $mode_combo->entry->get_text ne $modes{text};
if ($boot_warn && !$bootsplash_available && $theme->{enabled}) {
@@ -141,22 +140,22 @@ sub splash_choice() {
$splash_box->set_sensitive($theme->{enabled});
});
- my $_thm_button = Gtk2::Button->new(N("Install themes"));
+ my $_thm_button = gtknew('Button', text => N("Install themes"));
run_boot_window(N("Graphical boot theme selection"),
[
- 1, gtkpack_(gtkset_border_width(Gtk2::VBox->new(0, 5), 5),
- 0, gtkpack__(Gtk2::HBox->new(0, 5), Gtk2::Label->new(N("Graphical boot mode:")), $mode_combo),
- 0, gtkpack(gtkset_sensitive($splash_box = Gtk2::HBox->new(0, 0), $theme->{enabled}),
+ 1, gtknew('VBox', spacing => 5, border_width => 5, children => [
+ 0, gtknew('HBox', spacing => 5, children_tight => [ gtknew('Label', text => N("Graphical boot mode:")), $mode_combo ]),
+ 0, $splash_box = gtknew('HBox', sensitive => $theme->{enabled}, children_loose => [
gtkadd(gtkcreate_frame(N("Theme")),
- gtkpack__(Gtk2::VBox->new(0, 5),
+ gtknew('VBox', spacing => 5, children_tight => [
$theme_combo,
- gtksignal_connect(gtkset_active(Gtk2::CheckButton->new(N("Display theme\nunder console")),
+ gtksignal_connect(gtkset_active(gtknew('CheckButton', text => N("Display theme\nunder console")),
$theme->{keep_logo}),
- clicked => sub { invbool(\$theme->{keep_logo}) }))),
- Gtk2::VSeparator->new,
- gtkpack__(Gtk2::VBox->new(0, 5), $boot_pic)),
- 0, gtksignal_connect(Gtk2::Button->new(N("Create new theme")), clicked => sub { exec '/usr/sbin/draksplash' })),
+ clicked => sub { invbool(\$theme->{keep_logo}) }) ])),
+ gtknew('VSeparator'),
+ gtknew('VBox', spacing => 5, children_tight => [ $boot_pic ]) ]),
+ 0, gtknew('Button', text => N("Create new theme"), clicked => sub { exec '/usr/sbin/draksplash' }) ]),
],
sub {
bootsplash::set_logo_console($theme->{keep_logo});
@@ -184,12 +183,12 @@ sub autologin_choice() {
$user = "root";
push @users, $user;
}
- my $user_combo = Gtk2::ComboBox->new_with_strings(\@users, $user);
+ my $user_combo = gtknew('ComboBox', text => $user, list => \@users);
my $desktop_combo = Gtk2::ComboBox->new_with_strings(\@sessions, if_(member($auto_mode->{desktop}, @sessions), $auto_mode->{desktop}));
- my $auto_box = create_packtable({ col_spacings => 5, row_spacings => 5, homogenous => 1 },
- [ Gtk2::Label->new(N("Default user")), $user_combo ],
- [ Gtk2::Label->new(N("Default desktop")), $desktop_combo ]);
+ my $auto_box = gtknew('Table', col_spacings => 5, row_spacings => 5, homogeneous => 1, children => [
+ [ gtknew('Label_Left', text => N("Default user")), $user_combo ],
+ [ gtknew('Label_Left', text => N("Default desktop")), $desktop_combo ] ]);
$auto_box->set_sensitive($auto_mode->{autologin} ? 1 : 0);
my @auto_buttons = gtkradio((N("No, I do not want autologin")) x 2,
@@ -202,40 +201,29 @@ sub autologin_choice() {
my $x_box;
run_boot_window(N("System mode"),
[
- 1, gtkpack__(Gtk2::VBox->new(0, 5),
- gtksignal_connect(gtkset_active(Gtk2::CheckButton->new(N("Launch the graphical environment when your system starts")),
+ 1, gtknew('VBox', spacing => 5, children_tight => [
+ gtksignal_connect(gtkset_active(gtknew('CheckButton', text => N("Launch the graphical environment when your system starts")),
$x_mode),
clicked => sub {
$x_box->set_sensitive(!$x_mode);
$x_mode = !$x_mode;
}),
- gtkpack__(gtkset_sensitive($x_box = Gtk2::VBox->new(0, 0), $x_mode),
- gtkpack__(Gtk2::VBox->new(0, 0), @auto_buttons),
+ $x_box = gtknew('VBox', sensitive => $x_mode, children_tight => [
+ gtknew('VBox', children_tight => [ @auto_buttons ]),
$auto_box
- ))
+ ]) ])
],
sub {
Xconfig::various::runlevel($x_mode ? 5 : 3);
$::testing and return;
if ($auto_buttons[1]->get_active) {
- any::set_autologin($user_combo->entry->get_text, $desktop_combo->entry->get_text);
- } else {
- any::set_autologin();
- }
+ any::set_autologin($in->do_pkgs, $user_combo->entry->get_text, $desktop_combo->entry->get_text);
+ } else {
+ any::set_autologin($in->do_pkgs);
+ }
});
}
-sub lilo_choice() {
- do {
- my $before = fs::fstab_to_string($all_hds);
- any::setupBootloader($in, $bootloader, $all_hds, $fstab, $ENV{SECURE_LEVEL}) or $in->exit;
- if ($before ne fs::fstab_to_string($all_hds)) {
- #- for /tmp using tmpfs when "clean /tmp" is chosen
- fs::write_fstab($all_hds);
- }
- } while !any::installBootloader($in, $bootloader, $all_hds);
-}
-
#-------------------------------------------------------------
# launch autologin functions
@@ -245,7 +233,7 @@ sub change_image {
my ($boot_pic, $theme, $res) = @_;
my $img_file = bootsplash::theme_get_image_for_resolution($theme, $res);
-f $img_file or return;
- my $boot_pixbuf = gtkcreate_pixbuf($img_file);
+ my $boot_pixbuf = gtknew('Pixbuf', file => $img_file);
$boot_pixbuf = $boot_pixbuf->scale_simple(300, 200, 'nearest');
$boot_pic->set_from_pixbuf($boot_pixbuf);
}
diff --git a/perl-install/standalone/drakbug b/perl-install/standalone/drakbug
index dc19c5e9b..40676fd21 100755
--- a/perl-install/standalone/drakbug
+++ b/perl-install/standalone/drakbug
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Drak Bug Report
-# Copyright (C) 2002-2005 Mandriva (daouda at mandriva dot com)
+# Copyright (C) 2002-2006 Mandriva (daouda at mandriva dot com)
# Stew Benedict (sbenedict at mandriva dot com)
#
# This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@ use lib qw(/usr/lib/libDrakX);
use any;
use standalone;
use common;
+use mygtk2 qw(gtknew);
use ugtk2 qw(:all);
use Config;
@@ -38,6 +39,7 @@ foreach (@ARGV) {
/^--incident$/ && shift @ARGV and do { $incident = 1; $prog = shift @ARGV };
}
+$ugtk2::wm_icon = 'drakbug-16';
my $window = ugtk2->new(N("Mandriva Linux Bug Report Tool"), center => 1);
$window->{rwindow}->set_border_width(5);
$window->{window}->signal_connect("delete_event", sub { ugtk2->exit(0) });
@@ -47,21 +49,17 @@ my $mdk_app = {
N("First Time Wizard") => 'drakfw',
N("Synchronization tool") => 'draksync',
N("Standalone Tools") => 'drakxtools',
- N("HardDrake") => 'harddrake2',
+ "harddrake" => 'harddrake2',
N("Mandriva Online") => 'mdkonline',
- N("Menudrake") => 'menudrake',
- N("Msec") => 'msec',
N("Remote Control") => 'rfbdrake',
N("Software Manager") => 'rpmdrake',
- N("Urpmi") => 'urpmi',
N("Windows Migration tool") => 'transfugdrake',
- N("Userdrake") => 'userdrake',
N("Configuration Wizards") => 'wizdrake',
};
my @generic_tool = keys %$mdk_app;
-my @all_drakxtools = ('adduserdrake', 'diskdrake', 'drakautoinst', 'drakbackup', 'drakboot', 'DrakBug', 'DrakClock', 'DrakConnect', 'drakfloppy', 'drakfirewall', 'drakfont', 'drakhosts', 'draknfs', 'draksambashare', 'drakgw', 'DrakSec', 'draksplash', 'drakvpn', 'drakxservices', 'drakxtools', 'drakxtv', 'keyboardrake', 'logdrake', 'mousedrake', 'net_monitor', 'printerdrake', 'scannerdrake', 'XFdrake');
-push(@generic_tool,@all_drakxtools);
+my @all_drakxtools = qw(adduserdrake diskdrake drakautoinst drakboot drakbug drakclock drakfloppy drakfont draksec drakxservices draksplash drakxtools drakxtv logdrake scannerdrake);
+push @generic_tool, @all_drakxtools, qw(MandrivaUpdate drakbackup drakconnect drakfirewall drakhosts drakmenustyle draknfs draksambashare drakgw drakroam drakvpn keyboarddrake msec mousedrake net_monitor printerdrake urpmi userdrake XFdrake);
my $kernel_release = chomp_(`uname -r`);
my $mandrake_release = chomp_(cat_('/etc/mandrakelinux-release'));
@@ -78,37 +76,32 @@ $bugzilla = 'http://qa.mandriva.com/enter_bug.cgi';
$wizard_name = "Bugzilla";
$table = create_packtable({ col_spacings => 5, row_spacings => 10 },
- [ Gtk2::Label->new(N("Select Mandriva Tool:")), $comb_app = Gtk2::ComboBox->new_text, $comb_app->set_wrap_width(3) ],
- [ Gtk2::Label->new(N("or Application Name\n(or Full Path):")),
- gtkpack_(Gtk2::HBox->new(0,5),
+ [ gtknew('Label_Left', text => N("Select Mandriva Tool:")), $comb_app = Gtk2::ComboBox->new_text, $comb_app->set_wrap_width(3) ],
+ [ gtknew('Label_Left', text => N("or Application Name\n(or Full Path):")),
+ gtkpack_(Gtk2::HBox->new(0, 5),
1, $com_app = gtkset_editable(Gtk2::Entry->new, 1),
0, $button_pkg = Gtk2::Button->new(N("Find Package")),
) ],
- [ Gtk2::Label->new(N("Package: ")), $package = Gtk2::Entry->new_with_text("...") ], # complain on gtk-perl@ml
- [ Gtk2::Label->new(N("Kernel:")), gtkset_editable(Gtk2::Entry->new_with_text($kernel_release), 0) ]
+ [ gtknew('Label_Left', text => N("Package: ")), $package = Gtk2::Entry->new_with_text("...") ], # complain on gtk-perl@ml
+ [ gtknew('Label_Left', text => N("Kernel:")), gtkset_editable(Gtk2::Entry->new_with_text($kernel_release), 0) ]
);
$comb_app->set_popdown_strings("", sort(@generic_tool));
$comb_app->set_text("");
gtkadd($window->{window},
- gtkpack_(Gtk2::VBox->new(0,5),
- 0, gtkpack(Gtk2::HBox->new(0,0),
- gtkpack(gtkset_justify(Gtk2::WrappedLabel->new($mandrake_release), "left")),
- ),
- 0, gtkpack(Gtk2::HSeparator->new),
+ gtkpack_(Gtk2::VBox->new(0, 5),
+ 0, gtknew('Title1', label => $mandrake_release),
+ 0, gtkset_justify(Gtk2::WrappedLabel->new(formatAlaTeX(N("To submit a bug report, click on the report button. \nThis will open a web browser window on %s where you'll find a form to fill in. The information displayed above will be transferred to that server. \nThings useful to include in your report are the output of lspci, kernel version, and /proc/cpuinfo.", $wizard_name))), "left"),
0, gtkadd($table),
- 0, gtkpack(Gtk2::HBox->new(0,0),
- gtkpack(gtkset_justify(Gtk2::WrappedLabel->new(formatAlaTeX(N("To submit a bug report, click on the report button. \nThis will open a web browser window on %s where you'll find a form to fill in. The information displayed above will be transferred to that server. \nThings useful to include in your report are the output of lspci, kernel version, and /proc/cpuinfo.", $wizard_name))), "left")),
- ),
0, gtkpack(Gtk2::HSeparator->new),
- 0, gtkpack_(Gtk2::HBox->new(0,0),
- 0, gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub { system("drakhelp --id drakbug &") }),
- 1, Gtk2::Label->new(""),
- 0, gtksignal_connect(Gtk2::Button->new(N("Report")), clicked => sub {
+ 0, gtkpack(create_hbox('edge'),
+ gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub { system("drakhelp --id drakbug &") }),
+ gtkpack(create_hbox('end'),
+ gtksignal_connect(Gtk2::Button->new(N("Report")), clicked => sub {
my $options = "mdkbugreport=1";
$options .= "&incident=1" if $incident;
my $p = $package->get_text;
- my ($product, $version) = $p =~ /^(.*)-([^-]+-[^-]+mdk)$/;
+ my ($product, $version) = $p =~ /^(.*)-([^-]+-[^-]+(mdk|mdv.*))$/; # FIXME: fragile!
my $app = $comb_app->entry->get_text;
my $component = $app ?
if_(member($app, @all_drakxtools), $app) || $mdk_app->{$app} :
@@ -123,8 +116,8 @@ gtkadd($window->{window},
run_program::raw({ detach => 1 }, '/usr/bin/www-browser', "$bugzilla?$options");
}
),
- 0, gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { ugtk2->exit(0) }),
- )));
+ gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { ugtk2->exit(0) }),
+ ))));
if (defined $prog) {
update_app($prog);
@@ -149,13 +142,13 @@ sub update_app {
my ($text) = @_;
my $app_choice;
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
- if (member($text,@all_drakxtools) || $text eq N("Standalone Tools")) {
+ if (member($text, @all_drakxtools) || $text eq N("Standalone Tools")) {
$app_choice = chomp_(`rpm -q drakxtools`);
} elsif (exists($mdk_app->{$text})) {
$app_choice = get_package($mdk_app->{$text});
} else {
+ $app_choice = get_package($text);
if (my $tool = { reverse %$mdk_app }->{$text}) {
- $app_choice = get_package($text);
$prog = $tool;
}
}
@@ -169,6 +162,7 @@ sub get_package {
my ($rpm_package, $which_app);
$rpm_package = $packages{$executable};
if (!defined $rpm_package) {
+ local $ENV{PATH} = "$ENV{PATH}:/sbin:/usr/sbin";
$which_app = chomp_(`which '$executable' 2> /dev/null`);
# deush, rpm can takes some time aka it'll sleeps if something has opened rpm db !
$rpm_package = $which_app eq "" ? N("Package not installed") : chomp_(`rpm -qf '$which_app' 2>&1`);
diff --git a/perl-install/standalone/drakclock b/perl-install/standalone/drakclock
index 7b0f346a1..805e13d9b 100755
--- a/perl-install/standalone/drakclock
+++ b/perl-install/standalone/drakclock
@@ -6,6 +6,7 @@ use POSIX;
use common;
# i18n : IMPORTANT to get correct namespace (drakconf instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakconf' }
+use mygtk2 qw(gtknew);
use ugtk2 qw(:all);
use interactive;
use standalone;
@@ -26,33 +27,27 @@ $ugtk2::wm_icon = "/usr/share/mcc/themes/default/time-mdk.png";
my $ntpfile = '/etc/ntp.conf';
my $ntpdlock = '/var/lock/subsys/ntpd';
-my $my_win = ugtk2->new(N("DrakClock"));
+my $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings"));
$my_win->{window}->signal_connect(delete_event => sub { ugtk2->exit(0) });
-my $calendar = Gtk2::Calendar->new;
+my $calendar = gtknew('Calendar');
$calendar->signal_connect($_ => \&cal_changed) foreach 'month-changed', 'day-selected', 'day-selected-double-click', 'prev-month', 'next-month', 'prev-year', 'next-year';
-$in->{timezone} = {};
-add2hash($in->{timezone}, timezone::read());
+my $timezone = timezone::read();
-my $label_timezone = Gtk2::Label->new(defined($in->{timezone}{timezone}) ? $in->{timezone}{timezone} : N("not defined"));
+my $label_timezone = gtknew('Label', text => $timezone->{timezone} || N("not defined"));
-my $button_time = Gtk2::Button->new(N("Change Time Zone"));
+my $button_time = gtknew('Button', text => N("Change Time Zone"));
$button_time->signal_connect(clicked => sub {
local $::isEmbedded = 0; # to prevent sub window embedding
- my $timezone = $in->{timezone}{timezone};
- $in->{timezone}{timezone} = $in->ask_from_treelist(N("Timezone - DrakClock"), N("Which is your timezone?"), '/', [ timezone::getTimeZones() ], $timezone);
- if (defined($in->{timezone}{timezone})) {
- $in->{timezone}{UTC} = $in->ask_yesorno(N("GMT - DrakClock"), N("Is your hardware clock set to GMT?"), $in->{timezone}{UTC});
- timezone::write($in->{timezone});
- $label_timezone->set_text($in->{timezone}{timezone});
- } else {
- $in->{timezone}{timezone} = $timezone;
- $label_timezone->set_text($timezone);
- }
+ if ($timezone->{timezone} = $in->ask_from_treelist(N("Timezone - DrakClock"), N("Which is your timezone?"), '/', [ timezone::getTimeZones() ], $timezone->{timezone})) {
+ $timezone->{UTC} = $in->ask_yesorno(N("GMT - DrakClock"), N("Is your hardware clock set to GMT?"), $timezone->{UTC});
+ timezone::write($timezone);
+ }
+ $label_timezone->set_text($timezone->{timezone});
});
-#my $button_ntp = Gtk2::Button->new(N("Use NTP"));
+#my $button_ntp = gtknew('Button', text => N("Use NTP"));
#$button_time->signal_connect(clicked => sub { ask_ntp($in, $) });
my $drawing_area;
@@ -61,48 +56,48 @@ my $adjh = Gtk2::Adjustment->new(0.0, 0.0, 23.0, 1.0, 5.0, 0.0);
my $adjm = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0);
my $adjs = Gtk2::Adjustment->new(0.0, 0.0, 59.0, 1.0, 5.0, 0.0);
-my ($button_reset, $check_ntp, $hb_ntp, $combo_ntpserver, $fullntp, $ntp);
+my ($button_reset, $check_ntp, $hb_ntp, $combo_ntpserver, $ntp);
my $mode = 0;
my (undef, undef, $h_old, $old_day, $old_month, $old_year) = localtime(time());
my @image_size = (200, 200);
-$my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedded ? 0 : 5),
- 1, gtkpack_(Gtk2::HBox->new,
- 1, gtkpack_(Gtk2::VBox->new,
+$my_win->{window}->add(gtknew('VBox', border_width => $::isEmbedded ? 0 : 5, children => [
+ 1, gtknew('HBox', children => [
+ 1, gtknew('VBox', children => [
0, $calendar,
- 1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Network Time Protocol")), 'etched_in'),
- gtkpack_(gtkset_border_width(Gtk2::VBox->new, 5),
- 0, Gtk2::Label->new(N("Your computer can synchronize its clock\n with a remote time server using NTP")),
- 0, gtksignal_connect(gtkset_active($check_ntp = Gtk2::CheckButton->new(N("Enable Network Time Protocol")), $mode), clicked => sub {
+ 1, gtknew('Frame', text => N("Network Time Protocol"), shadow_type => 'etched_in', child =>
+ gtknew('VBox', border_width => 5, children => [
+ 0, gtknew('Label', text => N("Your computer can synchronize its clock\n with a remote time server using NTP")),
+ 0, gtksignal_connect(gtkset_active($check_ntp = gtknew('CheckButton', text => N("Enable Network Time Protocol")), $mode), clicked => sub {
$mode = !$mode;
$hb_ntp->set_sensitive($mode);
if ($mode == 1 && !$in->do_pkgs->is_installed('ntp')) {
install_ntp();
}
}),
- 0, gtkpack_(gtkset_border_width($hb_ntp = Gtk2::HBox->new, 5),
- 0, Gtk2::Label->new(N("Server:")),
+ 0, $hb_ntp = gtknew('HBox', border_width => 5, children => [
+ 0, gtknew('Label', text => N("Server:")),
1, $combo_ntpserver = Gtk2::Combo->new
- )
- ))
- ),
- 0, gtkpack_(Gtk2::VBox->new,
- 0, gtkpack_(Gtk2::HBox->new,
+ ])
+ ]))
+ ]),
+ 0, gtknew('VBox', children => [
+ 0, gtknew('HBox', children => [
0, $drawing_area = gtkset_size_request(Gtk2::DrawingArea->new, @image_size),
- ),
- 0, gtkpack_(my $time_box = Gtk2::HBox->new(1,0),
+ ]),
+ 0, my $time_box = gtknew('HBox', homogenous => 1, children => [
0, my $spinner_h = Gtk2::SpinButton->new($adjh, 0, 0),
0, my $spinner_m = Gtk2::SpinButton->new($adjm, 0, 0),
0, my $spinner_s = Gtk2::SpinButton->new($adjs, 0, 0),
- ),
- 1, gtkadd(gtkset_shadow_type(Gtk2::Frame->new(N("Timezone")), 'etched_in'),
- gtkpack__(gtkset_border_width(Gtk2::VBox->new, 5),
+ ]),
+ 1, gtknew('Frame', text => N("Timezone"), shadow_type => 'etched_in', child =>
+ gtknew('VBox', border_width => 5, children_tight => [
$label_timezone,
- $button_time)),
- ),
- ),
+ $button_time])),
+ ]),
+ ]),
0, create_okcancel(my $w =
{
cancel_clicked => sub { ugtk2->exit(0) },
@@ -110,8 +105,12 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
my $need_date = 1;
if ($check_ntp->get_active) {
my $choosed_serv = $combo_ntpserver->entry->get_text;
- $choosed_serv =~ s/(\S+)\s*(.*)$/$1/;
- timezone::ntp_server($1);
+ $choosed_serv =~ s/^[^:]+: (.+)/$1/;
+ if (!$choosed_serv) {
+ err_dialog(N("Error"), N("Please enter a valid NTP server address."));
+ return;
+ }
+ timezone::set_ntp_server($choosed_serv);
system("/sbin/chkconfig --level 35 ntpd on");
system("service ntpd stop");
#verify that we have a valid hostname (thx sam)
@@ -119,10 +118,14 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
if (!system("/usr/sbin/ntpdate", $choosed_serv)) {
update_time(); #- get the new time before updating the hwclock
system("service ntpd start");
- $need_date = 0
+ $need_date = 0;
} else {
- warn_dialog(N("Error"), N("Could not synchronize with %s.", $choosed_serv));
- return
+ $in->ask_from_no_check({
+ title => N("Error"),
+ messages => N("Could not synchronize with %s.", $choosed_serv),
+ ok => N("Quit"),
+ cancel => N("Retry"),
+ }, []) or return;
}
} else {
if (-e $ntpdlock) {
@@ -151,7 +154,7 @@ $my_win->{window}->add(gtkpack_(gtkset_border_width(Gtk2::VBox->new, $::isEmbedd
$its_reset = 0;
} ]
),
- )
+ ])
);
$button_reset = $w->{buttons}{N("Reset")};
@@ -162,11 +165,13 @@ $combo_ntpserver->set_popdown_strings(@$servers);
if (-e $ntpfile && -e $ntpdlock) {
$ntp = timezone::ntp_server();
$ntp and ntp_widget_state(1);
- foreach my $s (@$servers) {
- $s =~ /^\Q$ntp / and $fullntp = $s;
- $fullntp and last
+ my $fullntp = $ntp;
+ my $short_ntp = $ntp;
+ #- strip digits from \d+.foo.pool.ntp.org
+ $short_ntp =~ s/^\d+\.//;
+ foreach (@$servers) {
+ /^[^:]+: \Q$short_ntp\E$/ and $fullntp = $_, last;
}
- $fullntp |= $ntp;
$combo_ntpserver->entry->set_text($fullntp);
} else { ntp_widget_state(0) }
@@ -221,18 +226,12 @@ sub ntp_widget_state {
}
sub install_ntp() {
$my_win->{window}->set_sensitive(0);
- if (warn_dialog(N("Warning"), N("We need to install ntp package\n to enable Network Time Protocol
-
-Do you want to install ntp?"))) {
- $in->do_pkgs->install('ntp');
- } else {
- ntp_widget_state(0);
- }
+ $in->do_pkgs->ensure_is_installed('ntp') or ntp_widget_state(0);
$my_win->{window}->set_sensitive(1);
}
sub get_server() {
my $servs = timezone::ntp_servers();
- [ map { "$_ ($servs->{$_})" } sort keys %$servs ]
+ [ map { "$servs->{$_}: $_" } sort { $servs->{$a} cmp $servs->{$b} || $a cmp $b } keys %$servs ];
}
sub update_time() {
my (undef, undef, undef, $mday, $mon, $year) = localtime(time());
@@ -243,7 +242,7 @@ sub update_time() {
$calendar->select_month($mon, $year);
$its_reset = $old_its_reset;
Repaint($drawing_area, 1);
-};
+}
sub cal_changed() {
!$its_reset and $timer and Glib::Source->remove($timer);
@@ -322,7 +321,7 @@ sub time_to_rad {
sub Repaint {
my ($drawing_area, $o_update_time) = @_;
- my ($sec,$min,$hour) = localtime(time());
+ my ($sec, $min, $hour) = localtime(time());
time_to_rad($sec, $min, $hour) if $o_update_time;
my ($width, $height) = ($drawing_area->allocation->width, $drawing_area->allocation->height);
my $dRadians_hour_real = $dRadians_hour + $dRadians_min / 12;
@@ -350,7 +349,7 @@ sub DrawSec {
$pixmap->draw_line($gc,
$midx+$dec, $midy+$dec,
$midx+$dec + (8/10 * $radius * sin($dRadians)),
- $midy+$dec - (8/10 * $radius * cos($dRadians)))
+ $midy+$dec - (8/10 * $radius * cos($dRadians)));
}
sub DrawMin {
@@ -389,7 +388,7 @@ sub DrawPointAt {
$pixmap->draw_points($black_gc,
$cx + 95/100 * $radius * sin($dRadians),
- $cy - 95/100 * $radius * cos($dRadians))
+ $cy - 95/100 * $radius * cos($dRadians));
}
diff --git a/perl-install/standalone/drakedm b/perl-install/standalone/drakedm
index 6f4e62c90..03e3213cf 100644
--- a/perl-install/standalone/drakedm
+++ b/perl-install/standalone/drakedm
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# DrakxDM -- Display Manager chooser
-# Copyright (C) 2003-2005 Mandriva (tvignaud@mandriva.com)
+# Copyright (C) 2003-2006 Mandriva (tvignaud@mandriva.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ use common;
use any;
use interactive;
use services;
+use run_program;
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakedm-mdk.png";
@@ -71,7 +72,7 @@ several different X sessions on your local machine at the same time.")),
if (any::running_window_manager()) {
$in->ask_yesorno('', N("The change is done, do you want to restart the dm service?"), 1) and
$in->ask_yesorno('', N("You are going to close all running programs and lose your current session. Are you really sure that you want to restart the dm service?"), 1) and
- system("nohup /etc/rc.d/init.d/dm restart &>/dev/null");
+ run_program::raw({ detach => 1 }, '/etc/rc.d/init.d/dm', '>', '/dev/null', '2>', '/dev/null', 'restart');
}
}
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy
index 9cdfb3e82..1dcc5b0d6 100755
--- a/perl-install/standalone/drakfloppy
+++ b/perl-install/standalone/drakfloppy
@@ -3,7 +3,7 @@
# DrakFloppy
# $Id$
#
-# Copyright (C) 2001-2005 Mandriva
+# Copyright (C) 2001-2006 Mandriva
# Yves Duret
# Thierry Vignaud
#
@@ -29,16 +29,16 @@ use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use common;
+use mygtk2 qw(gtknew);
use ugtk2 qw(:create :dialogs :helpers :wrappers);
use detect_devices;
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakfloppy-mdk.png";
require_root_capability();
-my $window = ugtk2->new('drakfloppy');
+my $window = ugtk2->new(N("Boot Floppy"));
unless ($::isEmbedded) {
$window->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- $window->{rwindow}->set_title(N("drakfloppy"));
$window->{rwindow}->set_border_width(5);
### menus definition
@@ -63,38 +63,38 @@ eval { %options = getVarsFromSh($conffile) };
######## up part
# device part
-my $device_combo = Gtk2::ComboBox->new_with_strings([ map { "/dev/$_" } detect_devices::floppies_dev() ]);
+my $device_combo = gtknew('ComboBox', list => [ map { "/dev/$_" } detect_devices::floppies_dev() ]);
$device_combo->set_active(0);
# kernel part
-my $kernel_combo = Gtk2::ComboBox->new_with_strings([ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ], chomp_(`uname -r`));
+my $kernel_combo = gtknew('ComboBox', text => chomp_(`uname -r`), list => [ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ]);
##########################################################
### main window
$window->{window}->add(
- gtkpack_(Gtk2::VBox->new,
- if_($::isEmbedded, 0, Gtk2::Label->new(N("Boot disk creation"))),
- 0, gtkadd(Gtk2::Frame->new(N("General")),
- gtkpack__(Gtk2::VBox->new(0, 0),
- gtkpack__(Gtk2::HBox->new(1, 0),
- Gtk2::Label->new(N("Device")),
+ gtknew('VBox', children => [
+ if_($::isEmbedded, 0, gtknew('Label', text => N("Boot disk creation"))),
+ 0, gtknew('Frame', text => N("General"), child =>
+ gtknew('VBox', children_tight => [
+ gtknew('HBox', homogenous => 1, children_tight => [
+ gtknew('Label', text => N("Device")),
$device_combo,
- gtksignal_connect(Gtk2::Button->new(N("Default")),
+ gtknew('Button', text => N("Default"),
clicked => sub { $device_combo->entry->set_text("/dev/fd0") }),
- ),
- gtkpack__(Gtk2::HBox->new(1, 0),
- Gtk2::Label->new(N("Kernel version")),
+ ]),
+ gtknew('HBox', homogenous => 1, children_tight => [
+ gtknew('Label', text => N("Kernel version")),
$kernel_combo,
- gtksignal_connect(Gtk2::Button->new(N("Default")),
+ gtknew('Button', text => N("Default"),
clicked => sub {
$kernel_combo->entry->set_text(chomp_(`uname -r`));
}),
- ),
- ),
+ ]),
+ ]),
),
- 1, Gtk2::VBox->new,
+ 1, gtknew('VBox'),
0, create_okcancel({
cancel_clicked => sub { ugtk2->exit(0) },
ok_clicked => \&build_it,
@@ -102,7 +102,7 @@ $window->{window}->add(
undef, undef, '',
[ N("Preferences"), \&pref_dialog, 0 ],
),
- ),
+ ]),
);
$window->{rwindow}->show_all;
@@ -136,24 +136,24 @@ sub pref_dialog() {
} (N("Module name"), N("Size"));
gtkpack_($dialog->vbox,
- 0, gtkadd(Gtk2::Frame->new(N("Mkinitrd optional arguments")),
- gtkpack__(Gtk2::VBox->new(0, 5),
- $buttons{force} = Gtk2::CheckButton->new(N("force")),
- $buttons{raid} = Gtk2::CheckButton->new(N("omit raid modules")),
- $buttons{needed} = Gtk2::CheckButton->new(N("if needed")),
- $buttons{scsi} = Gtk2::CheckButton->new(N("omit scsi modules")),
- ),
+ 0, gtknew('Frame', text => N("Mkinitrd optional arguments"), child =>
+ gtknew('VBox', spacing => 5, children_tight => [
+ $buttons{force} = gtknew('CheckButton', text => N("force")),
+ $buttons{raid} = gtknew('CheckButton', text => N("omit raid modules")),
+ $buttons{needed} = gtknew('CheckButton', text => N("if needed")),
+ $buttons{scsi} = gtknew('CheckButton', text => N("omit scsi modules")),
+ ]),
),
- 1, gtkadd(Gtk2::Frame->new(N("Add a module")),
+ 1, gtknew('Frame', text => N("Add a module"), child =>
create_hpaned(
gtkset_size_request(
- create_scrolled_window($tree),
+ gtknew('ScrolledWindow', child => $tree),
200, $::isEmbedded ? 0 : 175),
- gtkpack_(Gtk2::VBox->new(0, 0),
+ gtknew('VBox', children => [
1, gtkadd(Gtk2::ScrolledWindow->new,
$list
),
- 0, gtksignal_connect($remove_but = Gtk2::Button->new(N("Remove a module")),
+ 0, $remove_but = gtknew('Button', text => N("Remove a module"),
clicked => sub {
my $iter = ($list->get_selection->get_selected)[1];
return unless $iter;
@@ -162,7 +162,7 @@ sub pref_dialog() {
@temp_modules = grep { $_ ne $removed } @temp_modules;
$remove_but->set_sensitive(scalar @temp_modules);
}),
- ),
+ ]),
),
),
);
diff --git a/perl-install/standalone/drakfont b/perl-install/standalone/drakfont
index 490398bfd..7dcfbdfad 100755
--- a/perl-install/standalone/drakfont
+++ b/perl-install/standalone/drakfont
@@ -1,6 +1,7 @@
#!/usr/bin/perl
+# -*- coding: utf-8 -*-
#
-# Copyright (C) 2001-2005 by Mandriva
+# Copyright (C) 2001-2007 by Mandriva SA
# DUPONT Sebastien
# Damien Chaumette
# Thierry Vignaud
@@ -76,18 +77,21 @@
# - ttf2pt1: by Andrew Weeks, Frank Siegert, Thomas Henlich, Sergey Babkin convert ttf font files to afm and pfb fonts
#
#
-# directory to install fonts /usr/X11R6/lib/X11/fonts/
-# -->> /usr/X11R6/lib/X11/fonts/drakfont
+# directory to install fonts /usr/lib/X11/fonts/
+# -->> /usr/lib/X11/fonts/drakfont
use strict;
use diagnostics;
+use utf8;
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version
use ugtk2 qw(:create :dialogs :helpers :wrappers);
use common;
+use run_program;
require_root_capability();
@@ -145,7 +149,8 @@ foreach my $i (@application) {
# PATH and binary full path
#my $xfs_conffile = '/etc/fonts/fonts.conf';
-my $drakfont_dir = '/usr/X11R6/lib/X11/fonts/drakfont';
+my $font_dir = '/usr/share/fonts';
+my $drakfont_dir = "$font_dir/drakfont";
my $ttf2pt1 = '/usr/sbin/ttf2pt1';
my $pfm2afm = '/usr/sbin/pfm2afm';
my $type1inst = '/usr/sbin/type1inst';
@@ -225,7 +230,7 @@ sub search_windows_font() {
1;
}
-my @font_extensions = qw(ttf ttc pfa pfb pcf pcf.gz pfm gsf);
+my @font_extensions = qw(ttf ttc pfa pfb pcf pcf.gz pfm gsf ttc otf);
sub is_a_font($) {
my ($file) = @_;
@@ -277,13 +282,7 @@ sub print_list() {
sub dir_created() {
return if $::testing;
- -e $drakfont_dir or mkdir_p($drakfont_dir);
- -e $drakfont_dir . "/Type1" or mkdir_p($drakfont_dir . "/Type1");
- -e $drakfont_dir . "/ttf" or mkdir_p($drakfont_dir . "/ttf");
- -e $drakfont_dir . "/tmp" or mkdir_p($drakfont_dir . "/tmp");
- -e $drakfont_dir . "/tmp/ttf" or mkdir_p($drakfont_dir . "/tmp/ttf");
- -e $drakfont_dir . "/tmp/Type1" or mkdir_p($drakfont_dir . "/tmp/Type1");
- -e $drakfont_dir . "/tmp/tmp" or mkdir_p($drakfont_dir . "/tmp/tmp");
+ do { my $dir = "$drakfont_dir/$_"; -e $dir or mkdir_p($dir) } foreach qw(Type1 ttf otf ttc tmp/ttf tmp/Type1 tmp/tmp);
}
@@ -308,11 +307,19 @@ sub move_fonts {
system("cd $src_dir && mv @fonts $dest_dir") if @fonts;
}
+sub my_rm_rf {
+ my ($target) = @_;
+ eval { rm_rf(@_) };
+ if (my $err = $@) {
+ warn "cannot remove $target: $err\n";
+ }
+}
+
sub put_font_dir_real {
my ($subdir, $command, $progress, $title) = @_;
system("cd $drakfont_dir/$subdir && $fccache && $command");
interactive_progress($pbar2, $progress, $title);
- return "$chkfontpath -a $drakfont_dir/$subdir; rm -f /usr/X11R6/lib/X11/fonts/fonts.cache-1";
+ return "$chkfontpath -a $drakfont_dir/$subdir; rm -f $font_dir/fonts.cache-1";
}
sub put_font_dir() {
@@ -325,12 +332,13 @@ sub put_font_dir() {
}
interactive_progress($pbar1, 0.01, N("done"));
interactive_progress($pbar2, 0.10, N("True Type fonts installation"));
- foreach my $font (glob("$drakfont_dir/tmp/tmp/*.TTF")) {
+ my $temp_dir = "$drakfont_dir/tmp/tmp/";
+ foreach my $font (glob("$temp_dir/*.TTF")) {
my $newfont = $font;
$newfont =~ s/\.TTF$/.ttf/;
rename($font, $newfont);
}
- system('cd ' . $drakfont_dir . '/tmp/tmp && cp *.ttf ../../ttf; chmod 644 ../../ttf/*ttf');
+ system('cd ' . $temp_dir . ' && cp *.ttf ../../ttf; chmod 644 ../../ttf/*ttf') if glob("$temp_dir/*.ttf");
interactive_progress($pbar2, 0.20, N("please wait during ttmkfdir..."));
my $update_chkfontpath = put_font_dir_real("ttf", "$ttmkfdir -u > fonts.dir", 0.10, N("True Type install done"));
@@ -341,10 +349,10 @@ sub put_font_dir() {
interactive_progress($pbar2, 0.1, N("type1inst building"));
if ($so) {
-e "$drakfont_dir/tmp/Type1/Fontmap"
- and system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript | grep Fontmap.GS` ");
+ and system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript-common | grep Fontmap.GS` ");
move_fonts("$drakfont_dir/tmp/Type1", "../../Type1", qw(afm gsf pfb pfm));
} else {
- system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript | grep Fontmap.GS` ");
+ system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript-common | grep Fontmap.GS` ");
move_fonts("$drakfont_dir/tmp/Type1", "../../Type1", qw(afm gsf pfb pfm));
}
$update_chkfontpath .= "; " . put_font_dir_real("Type1", $type1inst, 0.05, N("Ghostscript referencing"));
@@ -356,9 +364,16 @@ sub put_font_dir() {
$update_chkfontpath .= put_font_dir_real("Type1", $type1inst, 0.14, N("type1inst building"));
}
+ foreach my $subdir (qw(otf ttc)) {
+ my $dir = "$drakfont_dir/$subdir";
+ move_fonts("$drakfont_dir/tmp/tmp", "../../$subdir", $subdir);
+ run_program::run($_, $dir) foreach qw(mkfontscale mkfontdir), $fccache;
+ run_program::run($chkfontpath, '-a', $dir);
+ }
+
interactive_progress($pbar2, 1, N("done"));
interactive_progress($pbar3, 0.25, N("Suppress Temporary Files"));
- rm_rf("$drakfont_dir/tmp/");
+ my_rm_rf("$drakfont_dir/tmp/");
print "\n\nretarting xfs......\n";
interactive_progress($pbar3, 0.5, N("Restart XFS"));
system($update_chkfontpath);
@@ -374,7 +389,7 @@ sub remove_gs_fonts() {
if (all("$drakfont_dir/remove")) {
system(" cd $drakfont_dir/remove && $type1inst");
my @Fontmap_out = cat_("$drakfont_dir/remove/Fontmap");
- my $FontmapGS = `rpm -ql ghostscript | grep Fontmap.GS`;
+ my $FontmapGS = `rpm -ql ghostscript-common | grep Fontmap.GS`;
chomp($FontmapGS);
my @FontmapGS_list = cat_($FontmapGS);
foreach my $font_gs (@FontmapGS_list) {
@@ -399,10 +414,10 @@ sub remove_fonts() {
} else {
next if $::testing;
if (/.ttf$/) {
- rm_rf($_);
+ my_rm_rf($_);
# rebuild of the fonts.dir and fc-cache files
system("cd `dirname $_` && $fccache && $ttmkfdir -u > fonts.dir");
- } else { rm_rf($i) }
+ } else { my_rm_rf($i) }
}
$i =~ s!/\w*\.\w*!!gi;
any { $i } @list_dir or push @list_dir, $i;
@@ -418,15 +433,15 @@ sub remove_fonts() {
}
interactive_progress($pbar2, 1 / @list_dir, N("Suppress Fonts Files"));
}
- interactive_progress($pbar2, 0.01, N("xfs restart"));
+ interactive_progress($pbar2, 0.01, N("Restart XFS"));
system("/etc/rc.d/init.d/xfs restart");
system('xset fp rehash');
- -e "/usr/share/ghostscript" and rm_rf("$drakfont_dir/remove") if !$::testing;
+ -e "/usr/share/ghostscript" and my_rm_rf("$drakfont_dir/remove") if !$::testing;
interactive_progress($pbar2, 0.01, N("done"));
}
sub license_msg() {
- print N("Before installing any fonts, be sure that you have the right to use and install them on your system.\n\nYou can install the fonts the normal way. In rare cases, bogus fonts may hang up your X Server.") . "\n";
+ N("Before installing any fonts, be sure that you have the right to use and install them on your system.\n\nYou can install the fonts the normal way. In rare cases, bogus fonts may hang up your X Server.") . "\n";
}
sub backend_mod() {
@@ -434,7 +449,7 @@ sub backend_mod() {
$list_all_font_path and system($chkfontpath);
if ($windows) {
- license_msg();
+ print license_msg();
print "\nWindows fonts Installation........\n";
search_installed_fonts();
if (search_windows_font()) {
@@ -445,7 +460,7 @@ sub backend_mod() {
}
if (@install) {
- license_msg();
+ print license_msg();
print "\nInstall Specifics Fonts...........\n";
search_installed_fonts();
search_dir_font();
@@ -466,12 +481,10 @@ sub backend_mod() {
sub interactive_mode() {
$interactive = 1;
- $window1 = ugtk2->new('drakfont');
+ $window1 = ugtk2->new(N("Font Installation"));
+ $::main_window = $window1->{real_window};
$window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- if (!$::isEmbedded) {
- $window1->{rwindow}->set_position('center');
- $window1->{rwindow}->set_title(N("DrakFont"));
- }
+ $window1->{rwindow}->set_position('center') if !$::isEmbedded;
my $button = {};
my $disable = sub { my ($b) = @_; $button->{$_}->set_sensitive($_ ne $b) foreach keys %$button };
@@ -480,7 +493,7 @@ sub interactive_mode() {
gtkadd($window1->{window},
gtkpack_(Gtk2::VBox->new(0, 2),
if_(!$::isEmbedded, 0, Gtk2::Banner->new("drakfont", N("DrakFont"))),
- 0, Gtk2::WrappedLabel->new(N("Font List")),
+ 0, gtknew('Title2', label => N("Font List")),
1, Gtk2::FontSelection->new,
0, gtkadd(create_hbox(),
gtksignal_connect(Gtk2::Button->new(N("Get Windows Fonts")), clicked => sub { $windows = 1; import_status(); $windows = 0 }),
@@ -508,47 +521,33 @@ sub interactive_mode() {
$list_all_font_path || $xlsfonts || $windows || @install || @uninstall ? backend_mod() : interactive_mode();
sub help() {
- ugtk2::create_dialog(N("Help"), formatAlaTeX(
- #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
- N("Copyright (C) 2001-2006 by Mandriva")
-
-. "\n\n\n" . N("This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
-
-. "\n\n\n" . N("Thanks:
-
- - pfm2afm:
- by Ken Borgendale:
- Convert a Windows .pfm file to a .afm (Adobe Font Metrics)
-
- - type1inst:
- by James Macnicol:
- type1inst generates files fonts.dir fonts.scale & Fontmap.
-
- - ttf2pt1:
- by Andrew Weeks, Frank Siegert, Thomas Henlich, Sergey Babkin
- Convert ttf font files to afm and pfb fonts
-")));
+ my $license = formatAlaTeX(translate($::license));
+ $license =~ s/\n/\n\n/sg; # nicer formatting
+ my $w = gtknew('AboutDialog', name => N("Drakfont"),
+ version => '2007',
+ copyright => N("Copyright (C) 2001-2006 by Mandriva"),
+ license => $license, wrap_license => 1,
+ comments => N("Font installer."),
+ website => 'http://mandrivalinux.com',
+ website_label => N("Mandriva Linux"),
+ authors => 'Sébastien Dupont
+Damien Chaumette
+Thierry Vignaud <vignaud@mandriva.com>',
+ artists => 'Hélène Durosini <ln@mandriva.com>',
+ translator_credits =>
+ #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
+ N("_: Translator(s) name(s) & email(s)\n"),
+ transient_for => $window1->{real_window}, modal => 1, position_policy => 'center-on-parent',
+ );
+ $w->show_all;
+ $w->run;
}
sub appli_choice() {
dialog(N("Options"),
[
- 0, N("Choose the applications that will support the fonts:"),
- 0, Gtk2::WrappedLabel->new(license_msg()),
+ 0, gtknew('Title2', label => N("Choose the applications that will support the fonts:")),
+ 0, Gtk2::WrappedLabel->new(formatAlaTeX(license_msg())),
(map {
my ($label, $ref) = @$_;
(0, gtkpack_(Gtk2::HBox->new,
@@ -559,7 +558,7 @@ sub appli_choice() {
),
);
} ([ N("Ghostscript"), \$gs ],
- [ N("StarOffice"), \$so ],
+ [ N("OpenOffice.org"), \$so ],
[ N("Abiword"), \$abi ],
[ N("Generic Printers"), \$printer ],
),
@@ -576,7 +575,7 @@ sub appli_choice() {
sub font_choice() {
my $file_dialog;
my $_select_font_msg = N("Select the font file or directory and click on 'Add'");
- $file_dialog = Gtk2::FileChooserDialog->new(N("File Selection"), $window1->{real_window}, 'open', N("Cancel") => 'cancel', N("Ok") => 'ok'); # 'select_folder'
+ $file_dialog = Gtk2::FileChooserDialog->new(N("File Selection"), $::main_window, 'open', N("Cancel") => 'cancel', N("Ok") => 'ok'); # 'select_folder'
$file_dialog->set_select_multiple(1);
my $filter = Gtk2::FileFilter->new;
@@ -614,13 +613,15 @@ sub list_remove() { #- TODO : multi-selection
sub exitdialog() { Gtk2->main_quit }
sub dialog {
- my ($title, $widgets, $buttons, $o_main_loop) = @_;
- my $dialog = _create_dialog($title, { transient => $window1->{real_window} });
+ my ($title, $widgets, $buttons, $o_main_loop, $o_options) = @_;
+ $o_options ||= {};
+ my $dialog = _create_dialog($title, { transient => $::main_window });
+ local $::main_window = $dialog;
$dialog->signal_connect(delete_event => \&exitdialog);
+ $dialog->set_size_request(@{$o_options->{size}}) if ref $o_options->{size};
gtkpack_($dialog->vbox, @$widgets);
gtkpack($dialog->action_area, @$buttons) if $buttons;
$dialog->show_all;
- $window1->{rwindow}->set_sensitive(0);
if ($o_main_loop) {
gtkflush();
$o_main_loop->();
@@ -629,7 +630,6 @@ sub dialog {
}
$dialog->destroy if $dialog;
undef $dialog;
- $window1->{rwindow}->set_sensitive(1);
}
sub advanced_install() {
@@ -644,16 +644,25 @@ sub advanced_install() {
$model->signal_connect("row-deleted" => sub { $button and $button->set_sensitive($model->get_iter_first) });
dialog(N("Import fonts"),
- [ 1, create_scrolled_window($list) ],
[
- gtksignal_connect(Gtk2::Button->new(N("Add")), clicked => \&font_choice),
- gtksignal_connect(Gtk2::Button->new(N("Remove Selected")), clicked => \&list_remove),
- gtksignal_connect($button = gtkset_sensitive(Gtk2::Button->new(N("Install fonts")), 0),
+ 0, gtknew('Title2', label => N("Font List")),
+ 1, gtknew('HBox', children => [
+ 1, create_scrolled_window($list),
+ 0, gtknew('VBox', children_tight => [
+ gtksignal_connect(Gtk2::Button->new(N("Add")), clicked => \&font_choice),
+ gtksignal_connect(Gtk2::Button->new(N("Remove")), clicked => \&list_remove),
+ ]),
+ ]),
+ ],
+ [
+ gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&exitdialog),
+ gtksignal_connect($button = gtkset_sensitive(Gtk2::Button->new(N("Install")), 0),
clicked => sub {
import_status() if @install;
}),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&exitdialog),
],
+ undef,
+ { size => [ 300, 200 ] },
);
}
@@ -674,7 +683,7 @@ sub show_list_to_remove() {
$list->get_selection->set_mode('browse');
$list->set_rules_hint(1);
- $model->append_set(undef, [ 0 => $_ ]) foreach @uninstall;
+ $model->append_set(undef, [ 0 => $_ ]) foreach sort @uninstall;
dialog(N("Warning"),
[
@@ -705,7 +714,7 @@ sub uninstall() { #- TODO : add item to right list with gtksignal_connect
$left_list->set_rules_hint(1);
$left_list->get_selection->set_mode('multiple');
- $left_model->append_set(undef, [ 0 => $_ ]) foreach @installed_fonts_path;
+ $left_model->append_set(undef, [ 0 => $_ ]) foreach sort @installed_fonts_path;
#- right part
$right_model = Gtk2::TreeStore->new("Glib::String");
diff --git a/perl-install/standalone/drakhelp b/perl-install/standalone/drakhelp
index 54fd10435..f99c2bb0f 100644
--- a/perl-install/standalone/drakhelp
+++ b/perl-install/standalone/drakhelp
@@ -15,11 +15,11 @@ use log;
sub usage() {
print STDERR N(" drakhelp 0.1
-Copyright (C) 2003-2005 Mandriva.
+Copyright (C) %s Mandriva.
This is free software and may be redistributed under the terms of the GNU GPL.
Usage:
-") . N(" --help - display this help
+", '2003-2006') . N(" --help - display this help
") . N(" --id <id_label> - load the html help page which refers to id_label
") . N(" --doc <link> - link to another web page ( for WM welcome frontend)
");
diff --git a/perl-install/standalone/drakperm b/perl-install/standalone/drakperm
index 37ae77249..e37b76c74 100755
--- a/perl-install/standalone/drakperm
+++ b/perl-install/standalone/drakperm
@@ -6,6 +6,7 @@ use lib qw(/usr/lib/libDrakX);
use standalone;
use common;
+use mygtk2 qw(gtknew gtkset);
use ugtk2 qw(:create :dialogs :helpers :wrappers);
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakperm-mdk.png";
@@ -28,14 +29,14 @@ my ($editable, $modified) = (0, 0);
my @rules;
#- Widget declaration
-my $w = ugtk2->new('drakperm');
+my $w = ugtk2->new(N("Security Permissions"));
$w->{rwindow}->set_size_request(620, 400) unless $::isEmbedded;
my $W = $w->{window};
$W->signal_connect(delete_event => sub { ugtk2->exit });
my $model = Gtk2::ListStore->new("Gtk2::Gdk::Pixbuf", ("Glib::String") x 5);
my $permList = Gtk2::TreeView->new_with_model($model);
-my $pixbuf = gtkcreate_pixbuf('non-editable');
+my $pixbuf = gtknew('Pixbuf', file => 'non-editable');
my @column_sizes = (150, 100, 100, 15, -1);
@@ -51,7 +52,8 @@ my $index = 0;
load_perms();
#- widgets settings
-my $combo_perm = Gtk2::ComboBox->new_with_strings([ sort(values %perm_l10n) ]);
+my $combo_perm_value = $perm_l10n{all};
+my $combo_perm = gtknew('ComboBox', list => [ sort(values %perm_l10n) ], text_ref => \$combo_perm_value);
sub add_callback() {
row_setting_dialog(N("Add a new rule"));
@@ -102,45 +104,43 @@ $permList->signal_connect(button_press_event => sub {
my $tips = Gtk2::Tooltips->new;
-$W->add(gtkpack_(Gtk2::VBox->new(0,5),
- 0, Gtk2::WrappedLabel->new(N("Here you can see files to use in order to fix permissions, owners, and groups via msec.\nYou can also edit your own rules which will owerwrite the default rules."), 0.5),
- 1, gtkadd(Gtk2::Frame->new,
- gtkpack_(gtkset_border_width(Gtk2::VBox->new, 5),
- 0, Gtk2::WrappedLabel->new(N("The current security level is %s.
-Select permissions to see/edit", $level), 0.5),
- 0, gtkpack_(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
+$W->add(gtknew('VBox', spacing => 5, children => [
+ 0, gtknew('Label_Left', text => N("Here you can see files to use in order to fix permissions, owners, and groups via msec.\nYou can also edit your own rules which will owerwrite the default rules."), alignment => [ 0.5, 0 ]),
+ 1, gtknew('VBox', border_width => 0, children => [
+ 0, gtknew('Label_Left', text => N("The current security level is %s.
+Select permissions to see/edit", $level), alignment => [ 0, 0 ]),
+ 0, gtknew('HButtonBox', layout => 'start', children => [
0, $combo_perm,
- ),
- 1, create_scrolled_window($permList),
- 0, my $up_down_box = gtkadd(Gtk2::HBox->new(0, 5), @buttons =
+ ]),
+ 0, gtknew('Label'),
+ 1, gtknew('ScrolledWindow', child => $permList),
+ 0, my $up_down_box = gtknew('HBox', spacing => 5, children_loose => [ @buttons =
map {
gtkset_tip($tips,
- gtksignal_connect(Gtk2::Button->new($_->[0]), clicked => $_->[2]),
+ gtknew('Button', text => $_->[0], clicked => $_->[2]),
$_->[1]);
} ([ N("Up"), N("Move selected rule up one level"), sub { move_callback('up') } ],
[ N("Down"), N("Move selected rule down one level"), sub { move_callback('down') } ],
[ N("Add a rule"), N("Add a new rule at the end"), \&add_callback ],
[ N("Delete"), N("Delete selected rule"), \&del_callback ],
- [ N("Edit"), N("Edit current rule"), \&edit_callback ])),
- 0, Gtk2::VBox->new,
- ),
- ),
+ [ N("Edit"), N("Edit current rule"), \&edit_callback ])]),
+ 0, gtknew('VBox'),
+ ]),
0, create_okcancel({
cancel_clicked => sub { ugtk2->exit },
ok_clicked => \&save_perm,
},
undef, undef, '',
- [ N("Help"), sub { unless (fork()) { exec("drakhelp --id drakperm") } } ],
+ [ N("Help"), sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'drakperm') } ],
)
- )
+ ])
);
$W->show_all;
$w->{rwindow}->set_position('center') unless $::isEmbedded;
-$combo_perm->entry->set_text($perm_l10n{all});
display_perm('all');
my $_combo_sig = $combo_perm->entry->signal_connect(changed => sub {
- my $class = $rev_perm_l10n{$combo_perm->entry->get_text};
+ my $class = $rev_perm_l10n{$combo_perm_value};
$permList->set_reorderable($class eq 'editable');
display_perm($class , @_);
});
@@ -234,13 +234,13 @@ sub load_perms() {
sub row_setting_dialog {
my ($title, $o_iter) = @_;
- my $dlg = Gtk2::Dialog->new;
+ my $dlg = gtknew('Dialog');
$dlg->set_transient_for($w->{real_window});
$dlg->set_title($title);
$dlg->set_modal(1);
# $dlg->set_resizable(0);
- my $browse = Gtk2::Button->new(N("browse"));
- my $file = Gtk2::Entry->new;
+ my $browse = gtknew('Button', text => N("browse"));
+ my $file = gtknew('Entry');
my ($other, $group, $user, $s) = $o_iter ? reverse(split(//, $model->get($o_iter, 4))) : ();
my @bits = qw(sticky gid suid);
my @rights = qw(read write execute);
@@ -280,22 +280,21 @@ sub row_setting_dialog {
my $alrd_exsts = defined $o_iter;
$file->set_text($model->get($o_iter, 1)) if $o_iter;
- my $users = Gtk2::ComboBox->new_with_strings([ my @users = get_user_or_group('users') ]);
+ my $users = gtknew('ComboBox', list => [ my @users = get_user_or_group('users') ]);
$users->entry->set_text($model->get($o_iter, 2)) if $o_iter;
$users->set_wrap_width(3);
- my $groups = Gtk2::ComboBox->new_with_strings([ my @groups = get_user_or_group('groups') ]);
+ my $groups = gtknew('ComboBox', list => [ my @groups = get_user_or_group('groups') ]);
$groups->entry->set_text($model->get($o_iter, 3)) if $o_iter;
$groups->set_wrap_width(3);
- my $id_box = gtkadd(Gtk2::HBox->new,
- Gtk2::Label->new(N("User:")),
- $users,
- Gtk2::Label->new(N("Group:")),
- $groups,
+ my $id_box = gtknew('Table', homogeneous => 0, xpadding => 0.1, ypadding => 0, border_width => 0, children => [
+ [ gtknew('Label_Left', text => N("User:")), $users ],
+ [ gtknew('Label_Left', text => N("Group:")), $groups ],
+ ]
);
- my $usr_check = gtksignal_connect(gtkset_tip($tips, Gtk2::CheckButton->new(N("Current user")),
+ my $usr_check = gtksignal_connect(gtkset_tip($tips, gtknew('CheckButton', text => N("Current user")),
N("When checked, owner and group will not be changed")),
clicked => sub { $id_box->set_sensitive(!$_[0]->get_active) });
@@ -320,48 +319,47 @@ sub row_setting_dialog {
my %perms;
gtkpack_($dlg->vbox,
- 0, gtkadd(Gtk2::Frame->new(N("Path")),
- gtkpack_(gtkset_border_width(Gtk2::HBox->new, 3),
+ 0, gtknew('Title2', label => N("Path")),
+ 0, gtknew('HBox', border_width => 18, children => [
1, $file,
0, $browse
- )
+ ]
),
- 0, gtkadd(Gtk2::Frame->new(N("Property")),
- gtkadd(gtkset_border_width(Gtk2::VBox->new, 3),
- $usr_check,
- $id_box,
- ),
+ 0, gtknew('Title2', label => N("Property")),
+ 0, gtknew('VBox', border_width => 18, children => [
+ 0, $usr_check,
+ ]
),
- 1, gtkadd(Gtk2::Frame->new(N("Permissions")),
- gtkpack(gtkset_border_width(Gtk2::HBox->new, 3),
- gtkadd(Gtk2::VBox->new,
- Gtk2::Label->new(""),
- map { Gtk2::Label->new($checks{$_}{label}) } @rights,
- ),
+ 0, $id_box,
+ 0, gtknew('Title2', label => N("Permissions")),
+ 1, gtknew('HBox', border_width => 0, children_loose => [
+ gtknew('VBox', border_width => 0, children_loose => [
+ gtknew('Label', text => ""),
+ map { gtknew('Label_Left', text => $checks{$_}{label}, alignment => [ 0, 0 ]) } @rights,
+ ]),
(map {
my $owner = $_;
$perms{$owner} = { get_right($rights{$owner}) };
- my $vbox = gtkadd(Gtk2::VBox->new,
- Gtk2::Label->new($rights_labels{$owner}),
+ my $vbox = gtknew('VBox', children_loose => [
+ gtknew('Label', text => $rights_labels{$owner}),
map {
my $c = $_;
my $active = $perms{$owner}{$c};
- $perms{$owner}{$c} = Gtk2::CheckButton->new;
+ $perms{$owner}{$c} = gtknew('CheckButton');
$tips->set_tip($perms{$owner}{$c},
$checks{$c}{tip}{$owner},
);
gtkset_active($perms{$owner}{$c}, $active);
} @rights,
- );
+ ]);
$vbox;
} @owners),
- gtkpack(Gtk2::VBox->new,
- Gtk2::Label->new(' '),
- map { $perms{$_} = gtkset_tip($tips, Gtk2::CheckButton->new($checks{$_}{label}), $checks{$_}{tip}) } @bits,
- ),
- ),
- ),
+ gtknew('VBox', children_loose => [
+ gtknew('Label', text => ' '),
+ map { $perms{$_} = gtkset(gtknew('CheckButton', text => $checks{$_}{label}), tip => $checks{$_}{tip}) } @bits,
+ ]),
+ ]),
);
$perms{sticky}->set_active($s_right{execute});
$perms{gid}->set_active($s_right{write});
diff --git a/perl-install/standalone/drakpxe b/perl-install/standalone/drakpxe
deleted file mode 100755
index 2c0486dab..000000000
--- a/perl-install/standalone/drakpxe
+++ /dev/null
@@ -1,510 +0,0 @@
-#!/usr/bin/perl
-#
-# Fran,cois Pons <fpons@mandrakesoft.com>
-#
-# Copyright 2003-2005 Mandriva
-#
-# 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
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-
-use strict;
-use lib qw(/usr/lib/libDrakX);
-
-use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-
-use common;
-use interactive;
-use network::network;
-use log;
-use c;
-
-$::isInstall and die "Not supported during install.\n";
-
-$::Wizard_pix_up = "drakgw.png"; #- to change ? keep existing one, nobody will see (too late) ;-)
-my $direct = grep { /-direct/ } @ARGV;
-
-
-#
-#my $sysconf_network = "/etc/sysconfig/network";
-#my $sysconf_dhcpd = "/etc/sysconfig/dhcpd";
-#my $rc_firewall_generic = "/etc/rc.d/rc.firewall";
-#my $rc_firewall_drakgw = "/etc/rc.d/rc.firewall.inet_sharing";
-#my $rc_firewall_24 = "/etc/rc.d/rc.firewall.inet_sharing-2.4";
-#my $masq_file = "/etc/shorewall/masq";
-#my $cups_conf = "/etc/cups/cupsd.conf";
-#
-#my $shorewall = network::shorewall::read();
-#
-#- get network configuration.
-my $net = {};
-network::network::read_net_conf($net);
-
-my $in = 'interactive'->vnew('su');
-$::Wizard_title = N("PXE Server Configuration");
-
-!$::isEmbedded && $in->isa('interactive::gtk') and $::isWizard = 1;
-
-#pur_gtk_mode() if $::isEmbedded && $in->isa('interactive::gtk');
-
-sub sys { system(@_) == 0 or log::l("[drakpxe] Warning, sys failed for $_[0]") }
-
-sub start_daemons () {
- log::explanations("Starting daemons");
-
- system("/etc/rc.d/init.d/dhcpd status >/dev/null") == 0 and sys("/etc/rc.d/init.d/dhcpd stop");
-
- sys("/etc/rc.d/init.d/$_ start >/dev/null"), sys("/sbin/chkconfig --level 345 $_ on") foreach 'httpd', 'dhcpd';
-}
-
-sub stop_daemons () {
- log::explanations("Stopping daemons");
- foreach (qw(dhcpd httpd)) {
- system("/etc/rc.d/init.d/$_ status >/dev/null 2>/dev/null") == 0 and sys("/etc/rc.d/init.d/$_ stop");
- }
- sys("/sbin/chkconfig --level 345 $_ off") foreach 'dhcpd', 'httpd';
-}
-
-my $wait_configuring;
-
-sub quit_global {
- my ($in, $exitcode) = @_;
- $in->exit($exitcode);
- goto begin
-}
-
-sub fatal_quit ($) {
- log::l("[drakpxe] FATAL: $_[0]");
- undef $wait_configuring;
- $in->ask_warn('', $_[0]);
- quit_global($in, -1);
-}
-
-#my ($kernel_version) = c::kernel_version() =~ /(...)/;
-#log::l("[drakgw] kernel_version $kernel_version");
-#
-#$kernel_version >= 2.4 or fatal_quit(N("Sorry, we support only 2.4 kernels."));
-
-begin:
-
-#- **********************************
-#- * 0th step: verify if we have multiple network interface.
-
-$::Wizard_no_previous = 1;
-
-$direct or $in->ask_okcancel(N("Installation Server Configuration"),
-N("You are about to configure your computer to install a PXE server as a DHCP server
-and a TFTP server to build an installation server.
-With that feature, other computers on your local network will be installable using this computer as source.
-
-Make sure you have configured your Network/Internet access using drakconnect before going any further.
-
-Note: you need a dedicated Network Adapter to set up a Local Area Network (LAN)."), 1) or quit_global($in, 0);
-
-undef $::Wizard_no_previous;
-
-
-#- **********************************
-#- * 1st step: verify if we have multiple network interface.
-
-step_check_intf:
-
-my @intf = grep { exists $_->{NETWORK} } map {
- unless ($_->{NETWORK}) {
- foreach my $s (split "\n", `route`) {
- print STDERR "$s\n";
- $s =~ /^(\S+)\s+\S+\s+$_->{NETMASK}\s+.*$_->{DEVICE}/ and $_->{NETWORK} = $1;
- }
- } $_ } values %{$net->{ifcfg}};
-if (@intf < 1) {
- #- no interface already configured found, ask user to configure.
- $in->ask_warn(N("No network adapter on your system!"),
- N("No ethernet network adapter has been detected on your system. Please run the hardware configuration tool."));
- quit_global($in, 0);
-} elsif (@intf > 1) {
- #- there are more than one interface, we need to choose one of them.
- @intf = $in->ask_from_listf(N("Choose the network interface"),
- N("Please choose which network interface will be used for the dhcp server."),
- sub { N("Interface %s (on network %s)", $_[0]{DEVICE}, $_[0]{NETWORK}) },
- \@intf,
- ) or goto begin;
-}
-
-
-#- **********************************
-#- * 3rd step: select installation directory to be used (if not present, next step
-#- will be creation and copy from existing one).
-
-step_ip_range:
-
-#- read current configuration, or create a default suitable automatically.
-my $dhcpd_conf = parse_dhcpd_conf("/etc/dhcpd.conf", {}, $net, $intf[0]);
-
-#- get back default of ip.
-my $pool;
-foreach (@{$dhcpd_conf->{network}{pool}}) {
- exists $_->{allow}{$dhcpd_conf->{class_PXE}} and $pool = $_, last;
-}
-my ($start_ip, $end_ip) = @{$pool || { start_ip => join('.', (split '\.', $intf[0]{NETWORK})[0..2], 16),
- end_ip => join('.', (split '\.', $intf[0]{NETWORK})[0..2], 253) }}{qw(start_ip end_ip)};
-
-#- it become too complicated to handle address range, so ask user directly.
-$in->ask_from('DHCP Server Configuration',
- N("The DHCP server will allow other computer to boot using PXE in the given range of address.
-
-The network address is %s using a netmask of %s.
-
-", $intf[0]{NETWORK}, $intf[0]{NETMASK}), [ { label => N("The DHCP start ip"), val => \$start_ip, type => 'entry' },
- { label => N("The DHCP end ip"), val => \$end_ip, type => 'entry' }, ])
- or goto begin;
-
-
-#- **********************************
-#- * 3rd step: select installation directory to be used (if not present, next step
-#- will be creation and copy from existing one).
-
-step_install_dir:
-
-my $dir = "/export"; #- TODO change according configuration?
-
-$in->ask_from('Choose the installation image directory',
- N("Please indicate where the installation image will be available.
-
-If you do not have an existing directory, please copy the CD or DVD contents.
-
-"),
- [ { label => N("Installation image directory"), val => \$dir, type => 'entry' }, ])
- or goto step_ip_range;
-
-unless (-d $dir && -e "$dir/VERSION" && -d "$dir/install/isolinux" && -d "$dir/install/stage2") {
- $in->ask_warn(N("No image found"),
- N("No CD or DVD image found, please copy the installation program and rpm files."));
- goto step_install_dir;
-}
-
-#- **********************************
-#- * 4st step: ask user for auto installation file.
-
-step_auto_install:
-
-my $auto_inst_cfg = "install/auto_inst.cfg"; #- TODO change according configuration?
--e "$dir/$auto_inst_cfg" or $auto_inst_cfg = '';
-
-$in->ask_from('Choose auto installation',
- N("Please indicate where the auto_install.cfg file is located.
-
-Leave it blank if you do not want to set up automatic installation mode.
-
-"),
- [ { label => N("Location of auto_install.cfg file"), val => \$auto_inst_cfg, type => 'entry' }, ])
- or goto step_install_dir;
-
-#- now install packages...
-my %rpm2file = ('dhcp-server' => '/usr/sbin/dhcpd',
- 'pxe' => '/usr/sbin/pxe',
- 'tftp-server' => '/usr/sbin/in.tftpd',
- if_(! -x '/usr/sbin/httpd' && ! -x '/usr/sbin/httpd-perl', 'apache2' => '/usr/sbin/httpd2'));
-
-#- first: try to install all in one step
-my @needed_to_install = grep { !-e $rpm2file{$_} } keys %rpm2file;
-@needed_to_install and $in->do_pkgs->install(@needed_to_install);
-#- second: try one by one if failure detected
-if (any { !-e $rpm2file{$_} } keys %rpm2file) {
- foreach (keys %rpm2file) {
- -e $rpm2file{$_} or $in->do_pkgs->install($_);
- -e $rpm2file{$_} or fatal_quit(N("Problems installing package %s", $_));
- }
-}
-
-#- check if a pool already exist allowing PXE, else create one wich will be correct.
-if ($pool) {
- @$pool{qw(start_ip end_ip)} = ($start_ip, $end_ip);
-} else {
- $pool = { start_ip => $start_ip, end_ip => $end_ip };
- foreach (keys %{$dhcpd_conf->{class}}) {
- $pool->{$_ eq $dhcpd_conf->{class_PXE} || $_ eq 'Etherboot' ? 'allow' : 'deny'}{$_} = undef;
- }
- push @{$dhcpd_conf->{network}{pool}}, $pool;
-}
-build_dhcpd_conf($dhcpd_conf, "/etc/dhcpd.conf");
-
-#- make kernel and initrd available for initrd.
-mkdir "/var/lib/tftpboot/PXEClient/images";
-sys("cp", "-af", "$dir/install/isolinux/alt0", "/var/lib/tftpboot/PXEClient/images/");
-
-my $pxelinux_cfg = parse_pxelinux_cfg("/var/lib/tftpboot/PXEClient/pxelinux.cfg/default");
-my $label;
-foreach my $i (0..99) {
- $label = undef;
- foreach my $e (@{$pxelinux_cfg->{entry}}) {
- $e->{label} eq "halt$i" and $label = "halt$i", last;
- }
- defined $label or $label = "halt$i", last;
-}
-my $server = $intf[0]{IPADDR} || $net->{network}{HOSTNAME};
-push @{$pxelinux_cfg->{entry}}, { label => $label,
- kernel => "images/alt0/vmlinuz",
- append => "initrd=images/alt0/all.rdz vga=788 " . ($auto_inst_cfg ? "kickstart=$auto_inst_cfg " : "") . "automatic=met:http,netw:dhcp,int:eth0,dns:$net->{resolv}{dnsServer},ser:$server,dir:$dir" };
-build_pxelinux_cfg($pxelinux_cfg, "/var/lib/tftpboot/PXEClient/pxelinux.cfg/default");
-
-#- make directory available for httpd.
-log::explanations("Linking $dir in /var/www/html to make it available");
-system "mkdir", "-p", "/var/www/html/$dir";
-rmdir "/var/www/html/$dir";
-symlink $dir, "/var/www/html/$dir";
-
-stop_daemons();
-start_daemons();
-
-#- sub for reading/writing dhcpd.conf and pxelinux.cfg/default...
-sub parse_dhcpd_conf {
- my ($file, undef, $net, $intf) = @_;
- my (%dhcpd_conf, $pool);
- local (*F, $_);
-
- #- fake reading configuration from dhcpd.conf file which is really too complex for this tools.
- $dhcpd_conf{class_PXE} = 'PXE';
- $dhcpd_conf{class} = { PXE => undef, Etherboot => undef, known => undef };
- add2hash($dhcpd_conf{network} = { pool => [] }, $intf);
- add2hash($dhcpd_conf{network}, $net->{network});
- add2hash($dhcpd_conf{network}, $net->{resolv});
-
- if (open F, $file) {
- while (<F>) {
- if (/^\s*pool\s*{/ .. /}/) {
- /^\s*range\s+(\S+)\s+(\S+)\s*;/ and ($pool->{start_ip}, $pool->{end_ip}) = ($1, $2);
- /^\s*(allow|deny)\s+members\s+of\s+"([^"]*)"\s*;/ and $pool->{$1}{$2} = undef;
- /}/ and do { push @{$dhcpd_conf{network}{pool}}, $pool; $pool = undef };
- }
- }
- close F;
- }
-
- \%dhcpd_conf;
-}
-
-sub build_dhcpd_conf {
- my ($dhcpd_conf, $file) = @_;
- local *F;
- my $server = $dhcpd_conf->{network}{IPADDR} || $dhcpd_conf->{network}{HOSTNAME};
- open F, ">$file" or return;
- log::explanations("Modified file $file");
- print F qq(# for explanation in french go to : http://www.delafond.org/traducmanfr/man/man5/dhcpd.conf.5.html
-ddns-update-style none;
-allow booting;
-allow bootp;
-
-# Your dhcp server is not master on your network !
-#not authoritative;
-# Your dhcpd server is master on your network !
-#authoritative;
-not authoritative;
-
-#Interface where dhcpd is active
-DHCPD_INTERFACE = "$dhcpd_conf->{network}{DEVICE}";
-
-# Definition of PXE-specific options
-# Code 1: Multicast IP address of bootfile
-# Code 2: UDP port that client should monitor for MTFTP responses
-# Code 3: UDP port that MTFTP servers are using to listen for MTFTP requests
-# Code 4: Number of secondes a client must listen for activity before trying
-# to start a new MTFTP transfer
-# Code 5: Number of secondes a client must listen before trying to restart
-# a MTFTP transfer
-
-# define Option for the PXE class
-option space PXE;
-option PXE.mtftp-ip code 1 = ip-address;
-option PXE.mtftp-cport code 2 = unsigned integer 16;
-option PXE.mtftp-sport code 3 = unsigned integer 16;
-option PXE.mtftp-tmout code 4 = unsigned integer 8;
-option PXE.mtftp-delay code 5 = unsigned integer 8;
-option PXE.discovery-control code 6 = unsigned integer 8;
-option PXE.discovery-mcast-addr code 7 = ip-address;
-
-#Define options for pxelinux
-option space pxelinux;
-option pxelinux.magic code 208 = string;
-option pxelinux.configfile code 209 = text;
-option pxelinux.pathprefix code 210 = text;
-option pxelinux.reboottime code 211 = unsigned integer 32;
-site-option-space "pxelinux";
-# These lines should be customized to your setup
-#option pxelinux.configfile "configs/common";
-#option pxelinux.pathprefix "/pxelinux/files/";
-#filename "/pxelinux/pxelinux.bin";
-
-option pxelinux.magic f1:00:74:7e;
-option pxelinux.reboottime 30;
-#if exists dhcp-parameter-request-list {
- # Always send the PXELINUX options
-# append dhcp-parameter-request-list 208, 209, 210, 211;
-# append dhcp-parameter-request-list 208,211;
-# }
-
-#Class that determine the options for Etherboot 5.x requests
-class "Etherboot" {
-
-#if The vendor-class-identifier equal Etherboot-5.0
-match if substring (option vendor-class-identifier, 0, 9) = "Etherboot";
-
-# filename define the file retrieve by the client, there nbgrub
-# our TFTP is chrooted so is just the path to the file
-filename "/etherboot/nbgrub";
-
-#Used by etherboot to detect a valid pxe dhcp server
-option vendor-encapsulated-options 3c:09:45:74:68:65:72:62:6f:6f:74:ff;
-
-# Set the "vendor-class-identifier" field to "PXEClient" in dhcp answer
-# if this field is not set the pxe client will ignore the answer !
-option vendor-class-identifier "Etherboot";
-
-vendor-option-space PXE;
-option PXE.mtftp-ip 0.0.0.0;
-
-# IP of you TFTP server
-next-server $server;
-}
-
-
-# create the Class PXE
-class "PXE" {
-# if the "vendor-class-identifier" is set to "PXEClient" in the client dhcp request
-match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
-
-# filename define the file retrieve by the client, there pxelinux.0
-# our TFTP is chrooted so is just the path to the file
-# If you prefer use grub, use pxegrub compiled for your ethernet card.
-#filename "/PXEClient/pxegrub";
-filename "/PXEClient/pxelinux.0";
-
-# Set the "vendor-class-identifier" field to "PXEClient" in dhcp answer
-# if this field is not set the pxe client will ignore the answer !
-option vendor-class-identifier "PXEClient";
-
-
-vendor-option-space PXE;
-option PXE.mtftp-ip 0.0.0.0;
-
-# IP of you TFTP server
-next-server $server;
-}
-
-# the class know exist just for deny the response to other DHCP request
-class "known" {
- match hardware;
- one-lease-per-client on;
- ddns-updates on;
- ddns-domainname = "$dhcpd_conf->{network}{DOMAINNAME}";
- option domain-name "$dhcpd_conf->{network}{DOMAINNAME}";
- option domain-name-servers $dhcpd_conf->{network}{dnsServer};
- ddns-hostname = pick-first-value(ddns-hostname, option host-name);
- option fqdn.no-client-update on;
- set vendor_class_identifier = option vendor-class-identifier;
-}
-
-# Tags uses by setup_node_mac_to_dhcp
-# TAG: NODE_LIST_BEGIN
-
-# TAG: NODE_LIST_END
-shared-network "mynetwork" {
- subnet $dhcpd_conf->{network}{NETWORK} netmask $dhcpd_conf->{network}{NETMASK} {
- option subnet-mask $dhcpd_conf->{network}{NETMASK};
- option routers $dhcpd_conf->{network}{GATEWAY};
- default-lease-time 28800;
- max-lease-time 86400;
- option domain-name "$dhcpd_conf->{network}{DOMAINNAME}";
- option domain-name-servers $dhcpd_conf->{network}{dnsServer};
-# Used by clusterautosetup-client to find its server
- next-server $server;
-
-);
- foreach (@{$dhcpd_conf->{network}{pool}}) {
- print F " pool {
- range $_->{start_ip} $_->{end_ip};
-";
- print F qq( allow members of "$_";\n) foreach keys %{$_->{allow}};
- print F qq( deny members of $_";\n) foreach keys %{$_->{deny}};
- print F " }\n";
- }
-print F qq(
-
-# pool {
-# range 192.168.200.200 192.168.200.254;
-# give an address of the the pool for PXE client and deny the other
-#allow members of "PXE";
-#deny members of "known";
-#allow members of "Etherboot";
-# }
- }
-}
-);
- close F;
-}
-
-sub parse_pxelinux_cfg {
- my ($file) = @_;
- my (%pxelinux_cfg, $entry);
- local (*F, $_);
-
- if (open F, $file) {
- while (<F>) {
- chomp;
- s/#.*//; next if /^\s*$/;
- if (/^\s*(PROMPT|DEFAULT|DISPLAY|TIMEOUT)\s+(.*)/i) {
- $pxelinux_cfg{$1} = $2;
- } elsif (/^\s*label\s+(.*)/i) {
- $entry and push @{$pxelinux_cfg{entry}}, $entry;
- $entry = { label => $1 },
- } elsif (/^\s*(LOCALBOOT|KERNEL|APPEND)\s+(.*)/i) {
- $entry->{$1} = $2;
- } else {
- log::l("ignoring line in file $file due to parsing error");
- }
- }
- $entry and push @{$pxelinux_cfg{entry}}, $entry;
- close F;
- }
- #- try to fix bad file (first version of drakpxe for example).
- my %default_pxelinux_cfg = (PROMPT => 1,
- DEFAULT => "local",
- DISPLAY => "messages",
- TIMEOUT => 50,
- entry => [ { label => "local",
- LOCALBOOT => 0 } ],
- );
- foreach (qw(PROMPT DEFAULT DISPLAY TIMEOUT entry)) {
- length $pxelinux_cfg{$_} > 0 or $pxelinux_cfg{$_} = $default_pxelinux_cfg{$_};
- }
- \%pxelinux_cfg;
-}
-
-sub build_pxelinux_cfg {
- my ($pxelinux_cfg, $file) = @_;
- local *F;
- open F, ">$file" or return;
- log::explanations("Modified file $file");
- foreach (keys %$pxelinux_cfg) {
- /^entry$/ and next;
- print F "$_ $pxelinux_cfg->{$_}\n";
- }
- foreach my $e (@{$pxelinux_cfg->{entry}}) {
- print F "label $e->{label}\n";
- foreach (keys %$e) {
- /^label$/ and next;
- print F " $_ $e->{$_}\n";
- }
- }
- close F;
-}
-
diff --git a/perl-install/standalone/draksec b/perl-install/standalone/draksec
index ba207d6bc..aa5422c59 100755
--- a/perl-install/standalone/draksec
+++ b/perl-install/standalone/draksec
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#*****************************************************************************
#
-# Copyright (c) 2002-2005 Christian Belisle
+# Copyright (c) 2002-2006 Christian Belisle
# Thierry Vignaud <tvignaud@mandrakesoft.com>
#
# This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,8 @@ use lib qw(/usr/lib/libDrakX);
use common;
use standalone;
use vars qw($MODE %options);
+use interactive;
+use mygtk2 qw(gtknew gtkset);
use ugtk2 qw(:helpers :wrappers :ask :create);
use run_program;
use security::level;
@@ -38,6 +40,8 @@ use security::l10n;
#/^-?-(\S+)$/ and $options{$1} = 1 foreach @ARGV;
+my $in = 'interactive'->vnew('su');
+
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/draksec-mdk.png";
my ($w, %fields);
@@ -58,7 +62,7 @@ my %inv_translations = reverse %translations;
sub to_i18n { map { $translations{$_} || $_ } @_ }
sub from_i18n { $inv_translations{$_[0]} || $_[0] }
-sub resize { gtkset_size_request($_[0], 50, -1) }
+sub resize { gtkset($_[0], width => 50) }
%fields = security::l10n::fields();
my %inv_fields = reverse %fields;
@@ -66,7 +70,7 @@ my %inv_fields = reverse %fields;
# factorize this with rpmdrake and harddrake2
sub wait_msg {
my $mainw = ugtk2->new(N("Please wait"), (modal => 1, transient => $w->{real_window}));
- $mainw->{window}->add(Gtk2::WrappedLabel->new($_[0]));
+ $mainw->{window}->add(gtknew('WrappedLabel', text => $_[0]));
$mainw->{rwindow}->show_all;
gtkset_mousecursor_wait($mainw->{rwindow}->window);
# ugly workaround for gtk+ not displaying subdialog contents:
@@ -78,25 +82,11 @@ sub wait_msg {
sub remove_wait_msg { $_[0]->destroy }
sub basic_seclevel_explanations() {
- my $text = Gtk2::TextView->new;
+ my $text = gtknew('TextView');
use Gtk2::Pango;
my %common_opts = ('left-margin' => '10', 'right-margin' => '10');
- # this is a small parser for a Pango Text Attribute Markup Language-like for TextViews widget
- gtktext_insert($text, [ map {
- if (s!^/span>!!) {
- [ $_, \%common_opts ];
- } elsif (s!span !!) {
- my %tags = %common_opts;
- while (s!(\w+?)="(\w+?)"!!) {
- $tags{weight} ||= Gtk2::Pango->PANGO_WEIGHT_BOLD if $1 eq 'foreground';
- $tags{$1} = $2 eq "bold" ? Gtk2::Pango->PANGO_WEIGHT_BOLD : $2;
- }
- s/^>//;
- [ $_, \%tags ];
- } else {
- [ $_, \%common_opts ];
- }
- } split("<", formatAlaTeX(
+
+ gtktext_insert($text, ugtk2::markup_to_TextView_format(formatAlaTeX(
#-PO: Do not alter the <span ..> and </span> tags.
#-PO: Translate the security levels (Poor, Standard, High, Higher and Paranoid) in the same way, you translated these individuals words.
#-PO: keep the double empty lines between sections, this is formatted a la LaTeX.
@@ -133,13 +123,14 @@ your machine is only a client on the Internet, you should choose a lower level.
<span foreground=\"royalblue3\">Paranoid</span>: This is similar to the previous
level, but the system is entirely closed and security features are at their
-maximum"))) ]);
- create_scrolled_window($text, [ 'never', 'automatic' ]);
+maximum")), \%common_opts));
+
+ gtknew('ScrolledWindow', h_policy => 'never', child => $text);
}
sub new_nonedit_combo {
my ($string_list, $o_default_value) = @_;
- Gtk2::ComboBox->new_with_strings([ to_i18n(@$string_list) ], to_i18n($o_default_value));
+ gtknew('ComboBox', text => to_i18n($o_default_value), list => [ to_i18n(@$string_list) ]);
}
sub register_help_page {
@@ -172,7 +163,7 @@ sub register_help_entry {
}
my $msec = new security::msec;
-$w = ugtk2->new('draksec');
+$w = ugtk2->new(N("Security Level and Checks"));
my $window = $w->{window};
@@ -188,7 +179,7 @@ unless ($::isEmbedded) {
$window->signal_connect('delete_event', sub { $window->destroy });
$window->signal_connect('destroy', sub { ugtk2->exit });
-$window->add(my $vbox = gtkshow(Gtk2::VBox->new(0, 0)));
+$window->add(my $vbox = gtkshow(gtknew('VBox')));
# Create the notebook (for bookmarks at the top)
my $notebook = create_notebook();
@@ -198,7 +189,7 @@ my $common_opts = { col_spacings => 10, row_spacings => 5, mcc => 1 };
######################## BASIC OPTIONS PAGE ################################
my ($seclevel_entry, $secadmin_entry);
-$notebook->append_page(gtkshow(gtkpack_(Gtk2::VBox->new(0, 0),
+$notebook->append_page(gtkshow(gtknew('VBox', children => [
1, basic_seclevel_explanations(),
0, create_packtable($common_opts,
[
@@ -209,16 +200,16 @@ $notebook->append_page(gtkshow(gtkpack_(Gtk2::VBox->new(0, 0),
push(@sec_levels, $current_level) unless member($current_level, @sec_levels);
$seclevel_entry = new_nonedit_combo(\@sec_levels, $current_level);
- Gtk2::WrappedLabel->new(N("Security Level:")), $seclevel_entry;
+ gtknew('Label_Left', text => N("Security Level:")), $seclevel_entry;
}
],
- [ Gtk2::WrappedLabel->new(N("Security Alerts:")),
- my $secadmin_check = gtksignal_connect(Gtk2::CheckButton->new, toggled => sub {
+ [ gtknew('Label_Left', text => N("Security Alerts:")),
+ my $secadmin_check = gtksignal_connect(gtknew('CheckButton'), toggled => sub {
$secadmin_entry->set_sensitive($_[0]->get_active);
}) ],
- [ Gtk2::WrappedLabel->new(N("Security Administrator:")),
- $secadmin_entry = Gtk2::Entry->new_with_text($msec->get_check_value("MAIL_USER")) ]))),
- Gtk2::Label->new(N("Basic options")));
+ [ gtknew('Label_Left', text => N("Security Administrator:")),
+ $secadmin_entry = Gtk2::Entry->new_with_text($msec->get_check_value("MAIL_USER")) ]) ])),
+ gtknew('Label', text => N("Basic options")));
if ($msec->get_check_value("MAIL_WARN") eq "yes") {
$secadmin_check->set_active(1);
@@ -236,7 +227,7 @@ foreach ([ 'network', N("Network Options") ], [ 'system', N("System Options") ])
my ($domain, $label) = @$_;
register_help_page($label);
my %values;
- gtkappend_page($notebook, gtkshow(gtkpack_(Gtk2::VBox->new,
+ gtkappend_page($notebook, gtkshow(gtknew('VBox', children => [
1, create_scrolled_window(create_packtable($common_opts,
map {
my $i = $_;
@@ -248,19 +239,19 @@ foreach ([ 'network', N("Network Options") ], [ 'system', N("System Options") ])
$values{$i} = new_nonedit_combo(member($default, @yesno_choices) ? \@yesno_choices : if_(member($default, @alllocal_choices), \@alllocal_choices));
$entry = $values{$i}->entry;
} else {
- $values{$i} = Gtk2::Entry->new;
+ $values{$i} = gtknew('Entry');
$entry = $values{$i};
}
$entry->set_text(to_i18n($msec->get_function_value($opt)));
register_help_entry($i, $default, $opt);
- [ Gtk2::WrappedLabel->new($i), resize($values{$i}) ];
+ [ gtknew('Label_Left', line_wrap => 1, text => $i), resize($values{$i}) ];
} sort map { $fields{$_} || $_ } $msec->list_functions($domain),
),
[ 'never', 'automatic' ],
),
- )
+ ])
),
- Gtk2::WrappedLabel->new($label));
+ gtknew('Label_Left', text => $label));
$options_values{$domain} = \%values;
}
@@ -270,16 +261,16 @@ my %security_checks_value;
my $check_string = N("Periodic Checks");
register_help_page($check_string);
-gtkappend_page($notebook, gtkshow(gtkpack_(Gtk2::VBox->new,
+gtkappend_page($notebook, gtkshow(gtknew('VBox', children => [
1, create_scrolled_window(create_packtable($common_opts,
map {
my $i = $_;
my $opt = $inv_fields{$i} || $i;
$security_checks_value{$i} = new_nonedit_combo([ 'yes', 'no', 'default' ], $msec->get_check_value($opt));
register_help_entry($i, $msec->get_check_default($opt), $opt);
- [ gtkshow(Gtk2::WrappedLabel->new($i)), resize($security_checks_value{$i}) ];
- } sort map { $fields{$_} || $_ } $msec->list_checks)))),
- Gtk2::Label->new($check_string));
+ [ gtkshow(gtknew('Label_Left', line_wrap => 1, text => $i)), resize($security_checks_value{$i}) ];
+ } sort map { $fields{$_} || $_ } $msec->list_checks)) ])),
+ gtknew('Label', text => $check_string));
####################### OK CANCEL BUTTONS ##################################
@@ -331,10 +322,8 @@ gtkpack_($vbox,
remove_wait_msg($w);
- if ($secadmin_value ne $msec->get_check_value('CHKROOTKIT_CHECK') && ! -f '/usr/sbin/chkrootkit') {
- require do_pkgs;
- my $do_pkgs = do_pkgs_standalone->new;
- $do_pkgs->is_available('chkrootkit') and $do_pkgs->install('chkrootkit');
+ if ($secadmin_value ne $msec->get_check_value('CHKROOTKIT_CHECK')) {
+ $in->do_pkgs->ensure_is_installed_if_available('chkrootkit', '/usr/sbin/chkrootkit');
}
ugtk2->exit(0);
@@ -342,7 +331,7 @@ gtkpack_($vbox,
},
undef, undef, '',
[ N("Help"), sub {
- my $text = Gtk2::TextView->new;
+ my $text = gtknew('TextView');
create_dialog(N("Help"),
gtktext_insert($text,
[
@@ -367,10 +356,7 @@ $oc->{buttons}{N("Help")}->set_sensitive(0);
$oc->{cancel}->can_default(1);
$oc->{cancel}->grab_default;
-if (!-x '/usr/sbin/msec') {
- require do_pkgs;
- do_pkgs_standalone->new->install('msec');
-}
+$in->do_pkgs->ensure_is_installed('msec', '/usr/sbin/msec');
$w->main;
ugtk2->exit(0);
diff --git a/perl-install/standalone/draksound b/perl-install/standalone/draksound
index 3e19b5653..5812f388a 100755
--- a/perl-install/standalone/draksound
+++ b/perl-install/standalone/draksound
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# DrakxSound
-# Copyright (C) 2002-2005 Mandriva (tvignaud@mandriva.com)
+# Copyright (C) 2002-2006 Mandriva (tvignaud@mandriva.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,10 +29,10 @@ use detect_devices;
my $in = 'interactive'->vnew('su');
-
+$ugtk2::wm_icon = 'draksound-16';
my $modules_conf = modules::any_conf->read;
-if (my @devices = modules::probe_category('multimedia/sound')) {
+if (my @devices = detect_devices::probe_category('multimedia/sound')) {
# TODO: That need some work for multiples sound cards
map_index {
# allocate sound-slot in the same order as install2.pm
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash
index 000e28871..475acf5d3 100755
--- a/perl-install/standalone/draksplash
+++ b/perl-install/standalone/draksplash