#!/usr/bin/perl # # Copyright (C) 2001 by Sebastien DUPONT # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) ## description: # # Drakbacup is use to backup system files and user files # Drakbacup allow to restore the system (etc, var files) # from starup or on drakconf utility. # #backup name format: all the time from the / # backup_sys.tar.gz -> default system backup # backup_user_james.tar.gz -> default user backup # backup_user_seb.tar.gz # backup_other.tar.gz -> other directories # # # seems to be good idea to have a txt file where user explain the differences # between all the backup # # save only the differences... # # build iso fs with rescue. # configuration file on /etc/drakconf/drakbackup/drakbakup.conf # # todo: use .backupignore like on CVS # backend : --resore_all, --restore_sys, --restore_users # --build_cd_autoinst # --backup_now --backup_default_now # restore user: pbs with list selection # calcul disk space. # # CD: only create iso image # # WARNING: ne pas ecraser les fichiers /etc/passwd fstab # after a other install # # REQUIRE: cron if daemon # cvs if version control of /etc directory # cdrecord & mkisofs # # cdrw: /sys/dev/cdrom/info # /scsi/host0/bus0/target4/lun0 # # tar --use-compress-prog=bzip2 xf foo.tar.bz2 use Gtk; use lib qw(/usr/lib/libDrakX ); use interactive; use standalone; use my_gtk qw(:helpers :wrappers); use common; use strict; my $in = 'interactive'->vnew('', 'default'); $::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/; #!$::isEmbedded && $in->isa('interactive_gtk') and $::isWizard=1; if ("@ARGV" =~ /--help|-h/) { print q(Backup and monitoring application --list : list of files or directories to backup. --default : save default directories. --build_cd : build restore iso with the currents backups files & rescue options. --build_floppy : build restore floppy. --replace : delete backup files before build new do not update. --save_dir : by default the backup files are saved in in /var/backup directory so write other directory to change to change it. --conf_file : to read other configuration file. --mdk_cc : to include on Mandrake Control Center ); exit(0); } # Backend Options. my $default = 0; my $build_cd = 0; my $build_floppy = 0; my $mode = 0; my $conf_file = 0; my @list_arg = (); my $windows = 0; my $central_widget; my $central_widget_save; my $interactive; my $up_box; my $box; my $backup_choice = 0; my $cfg_file_exist = 0; my @user_and_path_list; my @all_user_list; my $list_other; my $label_cfg_file; my $mdk_cc = 0; my $DEBUG = 0; my $restore_sys = 1; my $restore_user = 1; my $restore_other = 1; my @user_backuped = (); my $sys_backuped = 0; my $other_backuped = 0; my @user_list_to_restore= (); my $retore_box2; # config. FILES -> Default PATH & Global variables. my @sys_files = ("/etc"); my @user_list; my @list_other = () ; my $cfg_file = "/etc/drakxtools/drakbackup/drakbackup.conf"; my $save_path = "/var/drakbackup"; my $option_replace = 1; my $comp_mode = 0; my $backup_sys = 1; my $backup_user = 1; my $backup_daemon = 1; my $backup_sys_cvs = 1; my $what_no_browser = 1; my $cdrw = 0; my $net_proto= ''; my $host_path = ''; my $login_user = ''; my $net_daemon = 0; my $hd_daemon = 0; my $cd_daemon = 0; my $hd_quota = 0; my $where_net= 0; my $where_hd = 1; my $where_cd =0; my $cd_time = 650; my $when_space; my $cd_with_install_boot = 0; my $cd_devive = ''; my $host_name = ''; my $backupignore = 0; my $auth_choice = 0; foreach (@ARGV) { /--default/ and $default = 1, $mode=-1; /--build_cd/ and $build_cd = 1, $mode=-1; /--build_floppy/ and $build_floppy = 1, $mode=-1; /--replace|-r/ and $option_replace = 1, $mode=-1; /--conf_file/ and $mode = 0, next; /--list/ and $mode = 1, next; /--mdk_cc/ and $mdk_cc = 1, next; /--debug/ and $DEBUG = 1, next; $mode == 1 and push @list_arg, $_; } if ($mdk_cc) { $build_floppy || $build_cd || $default || @list_arg || $conf_file ? backend_mod() : interactive_mode(); } else { $build_floppy || $build_cd || $default || @list_arg || $conf_file ? backend_mod() : interactive_mode_my(); } sub debug { print "SYS_FILES: $_ \n" foreach (@sys_files); print "HOME_FILES: $_ \n" foreach (@user_list); print "OTHER_FILES: $_ \n" foreach (@list_other); print "PATH_TO_SAVE: $save_path \n"; print "OPTION_REPLACE: $option_replace \n"; print "OPTION_COMP: $comp_mode \n"; } sub read_passwd { @user_and_path_list = map { (split(':', $_))[0] . ":" . (split(':', $_))[5] } grep {( split(':', $_))[2] > 500} split ('\n', cat_('/etc/passwd')); $DEBUG and print "user_and_path_list: ".$_."\n" foreach (@user_and_path_list); @user_list = (); @all_user_list = (); push @user_and_path_list, 'root:/root'; push @user_list, (split(':', $_))[0] foreach (@user_and_path_list); push @all_user_list, (split(':', $_))[0] foreach (@user_and_path_list); $DEBUG and print "home_files: ".$_."\n" foreach (@user_list); } sub save_conf_file { my @cfg_list = ( "SYS_FILES=@sys_files\n", "HOME_FILES=@user_list\n", "OTHER_FILES=@list_other\n", "PATH_TO_SAVE=$save_path\n", "HOST_PATH=$host_path\n", "NET_PROTO=$net_proto\n", "CD_TIME=$cd_time\n", "DAEMON_TIME_SPACE=$when_space\n", "CDRW_DEVICE=$cd_devive\n", "LOGIN=$login_user\n", "HOST_NAME=$host_name\n" ); $auth_choice or push @cfg_list, "AUTH_CHOICE=0\n" ; if ($auth_choice == 1) { push @cfg_list, "AUTH_CHOICE=1\n" ;} if ($auth_choice == 2) { push @cfg_list, "AUTH_CHOICE=2\n" ;} $cd_with_install_boot and push @cfg_list, "CD_WITH_INSTALL_BOOT\n" ; $net_daemon and push @cfg_list, "NET_DAEMON\n" ; $hd_daemon and push @cfg_list, "HD_DAEMON\n" ; $cd_daemon and push @cfg_list, "CD_DAEMON\n" ; $hd_quota and push @cfg_list, "HD_QUOTA\n" ; $where_hd and push @cfg_list, "USE_HD\n" ; $where_cd and push @cfg_list, "USE_CD\n" ; $where_net and push @cfg_list, "USE_NET\n" ; $cdrw and push @cfg_list, "CDRW\n"; $what_no_browser or push @cfg_list, "BROWSER_CACHE\n" ; $backup_sys_cvs or push @cfg_list, "NO_SYS_CVS\n" ; $option_replace and push @cfg_list, "OPTION_REPLACE\n" ; $backup_sys or push @cfg_list, "NO_SYS_FILES\n"; if ($comp_mode) { push @cfg_list, "OPTION_COMP=TAR.BZ2\n" } else { push @cfg_list, "OPTION_COMP=TAR.GZ\n" } output_p($cfg_file, @cfg_list); save_cron_files(); } sub read_cron_files { if (-f '/etc/cron.hourly/drakbackup') { $when_space = 'hourly'; } elsif (-f '/etc/cron.daily/drakbackup') { $when_space = 'daily'; } elsif (-f '/etc/cron.weekly/drakbackup') { $when_space = 'weekly';} elsif (-f '/etc/cron.monthly/drakbackup') { $when_space = 'monthly';} else {$backup_daemon = 0; } } sub save_cron_files { my @cron_file = ("#!/bin/sh\n", "\n", "/seb/cvs/gi/perl-install/standalone --default" ); if ($backup_daemon) { foreach ('hourly', 'daily', 'weekly', 'monthly'){ -f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup"); } if ( $when_space eq _("hourly")) { output_p('/etc/cron.hourly/drakbackup', @cron_file )} elsif ( $when_space eq _("daily")) { output_p('/etc/cron.daily/drakbackup', @cron_file )} elsif ( $when_space eq _("weekly")) { output_p('/etc/cron.weekly/drakbackup', @cron_file )} elsif ( $when_space eq _("monthly")) { output_p('/etc/cron.monthly/drakbackup', @cron_file )} } else { foreach ('hourly', 'daily', 'weekly', 'monthly'){ -f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup"); } } } sub read_conf_file { read_passwd(); if (-e $cfg_file) { open ( CONF_FILE, "<"."$cfg_file") || die; while () { next unless /\S/; next if /^#/; chomp; if (/^SYS_FILES/) { s/^SYS_FILES=//gi; @sys_files = split(' ', $_ ); } if (/^HOME_FILES/) { s/^HOME_FILES=//gi; @user_list = split(' ', $_ ); } if (/^OTHER_FILES/) { s/^OTHER_FILES=//gi; @list_other = split(' ', $_ ); } if (/^PATH_TO_SAVE/) { s/^PATH_TO_SAVE=//gi; $save_path = $_; } if (/^OPTION_REPLACE/) { $option_replace = 1; } if (/^NO_SYS_FILES/) { $backup_sys = 0;} if (/^NO_USER_FILES/) { $backup_user = 0;} if (/^OPTION_COMP/) { s/^OPTION_COMP=//gi; /TAR.GZ/ and $comp_mode = 0; /TAR.BZ2/ and $comp_mode = 1; } if (/^NO_SYS_CVS/) { $backup_sys_cvs = 0; } if (/^BROWSER_CACHE/) { $what_no_browser = 0; } if (/^CDRW/) { $cdrw = 1; } if (/^NET_PROTO/) { s/^NET_PROTO=//gi; $net_proto = $_; } if (/^HOST_PATH/) { s/^HOST_PATH=//gi; $host_path = $_; } if (/^LOGIN/) { s/^LOGIN=//gi; $login_user = $_; } if (/^NET_DAEMON/) { $net_daemon = 1; } if (/^HD_DAEMON/) { $hd_daemon = 1; } if (/^CD_DAEMON/) { $cd_daemon = 1; } if (/^HD_QUOTA/) { $hd_quota = 1; } if (/^USE_HD/) { $where_hd = 1; } if (/^USE_CD/) { $where_cd = 1; } if (/^USE_NET/) { $where_net = 1; } if (/^CD_TIME/) { s/^CD_TIME=//gi; $cd_time = $_; } if (/^DAEMON_TIME_SPACE/) { s/^DAEMON_TIME_SPACE=//gi; $when_space = $_; } if (/^CD_WITH_INSTALL_BOOT/) { $cd_with_install_boot = 1; } if (/^CDRW_DEVICE/) { s/^CDRW_DEVICE=//gi; $cd_devive = $_;} if (/^HOST_NAME/) { s/^HOST_NAME=//gi; $host_name = $_;} if (/^AUTH_CHOICE/) { s/^AUTH_CHOICE=//gi; $auth_choice = $_; } } read_cron_files(); $cfg_file_exist = 1; } else { $cfg_file_exist = 0; } close CONF_FILE; $DEBUG and debug; } sub backend_mod { } sub build_cd_fct { } sub build_floppy_fct { } sub status_report { my $table; my $pbar = new Gtk::ProgressBar; my $pbar1 = new Gtk::ProgressBar; my $pbar2 = new Gtk::ProgressBar; my $pbar3 = new Gtk::ProgressBar; gtkpack($up_box, $table = create_packtable({ col_spacings => 10, row_spacings => 50}, ["",""], [_("Backup system files"), $pbar, $pbar->{label} = new Gtk::Label(' ' )], [_("Backup user files"), $pbar1,$pbar1->{label} = new Gtk::Label(' ' ) ], [_("Backup other files"), $pbar2, $pbar2->{label} = new Gtk::Label(' ' ) ], [_("Post Install"), $pbar3,$pbar3->{label} = new Gtk::Label(' ' ) ], ), ); $central_widget = \$table; $up_box->show_all(); Gtk->main_iteration while Gtk->events_pending; } sub return_path { my $name = $_; foreach (@user_and_path_list) { if (grep /^$name\:/, $_) { s/^$name\://gi; return $_; } } } sub ftp_client { use Net::FTP; my $ftp = Net::FTP->new("some.host.name"); $ftp->login("anonymous","mon\@adresse.mail"); $ftp->cwd("/pub"); $ftp->get("/ce/repertoire/ce.fichier"); $ftp->quit; } sub build_backup_files { -d $save_path or mkdir_p($save_path); my $path_name; my $tar_cmd; my $tar_ext; my @list_other_; if ($comp_mode) { $tar_cmd = "tar cv --use-compress-program /usr/bin/bzip2 "; $tar_ext = "tar.bz2" } else { $tar_cmd = "tar cvz "; $tar_ext = "tar.gz"} if ( $option_replace ) { $comp_mode and system("cd $save_path && rm -f *.tar.gz"); $comp_mode or system("cd $save_path && rm -f *.tar.bz2"); } if ($where_hd) { print "backup_sys @sys_files\n"; $backup_sys and system("$tar_cmd -f $save_path/backup_sys.$tar_ext @sys_files"); print "backup_other @list_other\n"; if (@list_other) { system("$tar_cmd -f $save_path/backup_other.$tar_ext @list_other"); foreach (@list_other) { push @list_other_, $_ . "\n"; } output_p( $save_path . '/list_other', @list_other_); } if ($backup_user) { foreach (@user_list) { $path_name = return_path($_); print "path of user: $path_name\n"; $what_no_browser or system("$tar_cmd -f $save_path/backup_user_$_.$tar_ext $path_name"); $what_no_browser and system("$tar_cmd --exclude NewCache --exclude Cache --exclude cache -f $save_path/backup_user_$_.$tar_ext $path_name"); } } } if ($where_net) { # $res = Net::SSLeay::write($ssl, $msg); # Perl knows how long $msg is # die_if_ssl_error("ssl write"); # shutdown S, 1; # Half close --> No more output, sends EOF to server # $got = Net::SSLeay::read($ssl); # Perl returns undef on failure # die_if_ssl_error("ssl read"); # print $got; # Net::SSLeay::free ($ssl); # Tear down connection # Net::SSLeay::CTX_free ($ctx); # close S; } if ($where_cd) { } } sub interactive_mode { $interactive = 1; my $box_cfg_state; my $box_cgf_state_replace; my $box_cgf_state_comp; my $mask; my $style; my $box; init Gtk; my $text2 = new Gtk::Text(undef, undef); my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; $window1->signal_connect (delete_event => sub { Gtk->exit(0) }); $window1->set_position(1); $window1->set_title(_("Drakbackup")); read_conf_file(); if ($option_replace) { $box_cgf_state_replace = _("Replace backups (do not update)"), } else { $box_cgf_state_replace = _("Update backups (do not replace)"), } if ($comp_mode) { $box_cgf_state_comp = _("Backups use tar and bzip2 "), } else { $box_cgf_state_comp = _("Backups use tar and gzip"), } if ($cfg_file_exist) { my $label_cfg_file = new Gtk::Label _("Backup Sources: \n-System Files: @sys_files \n-Users Files: @user_list\n-Other Files to backup: @list_other\nPath to save backups: $save_path\nOptions:\n$box_cgf_state_replace\n$box_cgf_state_comp\n\n"); $box_cfg_state = gtkpack(new Gtk::VBox( 0, 0), gtkset_justify( $label_cfg_file , 'left'), ), } else { $box_cfg_state = gtkpack(new Gtk::VBox(0,1), _("No configuration please click Wizard or Advanced.") ), } gtkadd($window1, gtkpack(new Gtk::VBox(0,0), gtkpack(gtkset_usize($up_box = new Gtk::VBox(0,5), 500, 350), $box = gtkpack_(new Gtk::VBox(0,3), 0, _("Welcome on DrakBackup"), 1, gtkadd(new Gtk::Frame(_("State of configuration file.")), gtkpack(new Gtk::VBox(0,10), $box_cfg_state, ), ), 0, gtkpack_(new Gtk::HBox(0, 0), 0, gtksignal_connect(new Gtk::Button(_(" Build Backup ")), clicked => sub { save_conf_file(); Gtk->main_quit() }), ), 0, gtkpack_(new Gtk::HBox(0, 0), 0, gtksignal_connect(new Gtk::Button(_(" Restore ")), clicked => sub { save_conf_file(); Gtk->main_quit() }), ), 0, new Gtk::HSeparator, 0, gtkpack_(gtkset_layout(new Gtk::HButtonBox, -end), 1, gtksignal_connect(new Gtk::Button(_("Advanced Conf.")), clicked => sub { ${$central_widget}->destroy(); advanced() }), 1, gtksignal_connect(new Gtk::Button(_("Wizard Conf.")), clicked => sub { ${$central_widget}->destroy(); wizard() }), 1, gtksignal_connect(new Gtk::Button(_("close")), clicked => sub { save_conf_file(); Gtk->main_quit() }), ), ), ), ), ); $central_widget = \$box; $window1->show_all; $window1->realize; $window1->show_all(); Gtk->main; Gtk->exit(0); } sub list_remove { my($widget, $list) = @_; my @to_remove; push @to_remove, $list->child_position($_) foreach($list->selection); splice @list_other, $_, 1 foreach(reverse sort @to_remove); $list->remove_items($list->selection); } sub file_ok_sel { my ( $widget, $file_selection ) = @_; my $file_name = $file_selection->get_filename(); if(!member($file_name, @list_other)) { push(@list_other, $file_name); $list_other->add(gtkshow(new Gtk::ListItem($file_name))); } } sub filedialog { my $file_dialog; $file_dialog = gtksignal_connect(new Gtk::FileSelection(_("File Selection")), destroy => sub { $file_dialog->destroy(); } ); $file_dialog->ok_button->signal_connect(clicked => \&file_ok_sel, $file_dialog); $file_dialog->ok_button->child->set(_("Add")); $file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy() }); $file_dialog->cancel_button->child->set(_("Close")); $file_dialog->set_filename(_("Select the files or directories and click on 'Add'")); $file_dialog->show(); } sub wizard { my $backup_sys; my $backup_user; my $user; $::isWizard=1; step_1: $::Wizard_no_previous = 1; $in->ask_from(_("Please choose what you want to backup"), (_("Please choose that you want to backup") . "\n\n"), [ { label => _("System Files"), val => \$backup_sys, type => "bool", text => _(" all files on your /etc directory.") }, { label => _("User Files"), val => \$backup_user, type => "bool", text => _(" all user files on your system.") }, ], ); undef $::Wizard_no_previous; step_2: my $res1 = $in->ask_from_list_(_("Backup Configuration wizard"), _("Please choose what you need to backup from your system"), [ __("on Hard Drive"), __("across Network"), __("on CDROM") ]) or goto step_1; if ($res1 eq __("on Hard Drive")) { print "Hard Drive\n"; } elsif ($res1 eq __("across Network")) { print "across Network\n"; } elsif ($res1 eq __("on CDROM")) { } $in->ask_from(_("Backup Configuration wizard"), (_("Please choose when you want to backup") . "\n\n"), [ { label => _("Daemon"), val => \$backup_daemon, type => "bool", text => _(" Select it if you want that backup run as daemon") }, ], ) or goto step_2; $in->ask_from(_("Backup Configuration wizard"), (_("Please choose that you want to do") . "\n\n"), [ { label => _("Build Auto-Boot CDROM"), val => \$user, type => "bool", text => _("This option work only if you have\na CDR-W CDROM drive and allow\n you to restore all your system (data\n and your system variables)") }, ], ) or goto step_2; } sub advanced { my $notebook; my $notebook_what; my $notebook_when; my $notebook_where; my $notebook_options; my $about_box; my $book_open; my $book_open_mask; my $transparent; my $book_closed; my $book_closed_mask; my $box_tmp; my $choice_what_sys; read_conf_file(); my ($pix_time_map, $pix_time_mask) = gtkcreate_png("backup_time"); my ($pix_options_map, $pix_options_mask) = gtkcreate_png("backup_options"); my ($label_what, $label_where, $label_when, $label_options, $label_what_sys, $label_what_user, $label_what_other, $label_where_net, $label_where_cd, $label_where_hd) = map { gtkpack($_->[2] ? new Gtk::VBox(0, 2) : new Gtk::HBox(0, 2), gtkpng($_->[0]), $_->[1]) } (['backup_hd', _('What backup.'), 1], ['backup_net', _('Where backup.'), 1], ['backup_time', _("When backup."), 1], ['backup_options', _("Options"), 1], ['bootloader', _('System'), 0], ['user', _('Users'), 0], ['net_u', _('Other'), 0], ['net', _('Network'), 0], ['cdrom', _("CDROM\nDVDROM"), 0], ['hd', _("Hard Drive\n NFS"), 0], ); my $box_what_sys = gtkpack_(new Gtk::VBox(0,1), 1, _("\nPlease check all options that you need.\n"), 1, _("This options can backup and restore all files on your /etc directory.\n"), 0, my $check_what_sys = new Gtk::CheckButton( _("Backup your System files. (~ 2Mo)")), 0, my $check_what_cvs = new Gtk::CheckButton( _("Need to restore any versions.(~ 10Mo)") ), 0, _("With this option you will be able to restore any version\n of your /etc directory."), 1, " ", ); my %check_what_user; my $box_what_user = gtkpack_(new Gtk::VBox(0,0), 0, _("Please check all user that you want to include inb your backup."), 0, new Gtk::HSeparator, 1, createScrolledWindow( gtkpack(new Gtk::VBox(0,0), map { my $name = $_; my @user_list_tmp; my $b = new Gtk::CheckButton($name); if (grep /^$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 } (@all_user_list) ), ), 0, new Gtk::HSeparator, 0, my $check_what_browser = new Gtk::CheckButton( _(" do not include the browser cache") ), ); $list_other = new Gtk::List(); $list_other->set_selection_mode(-extended); $list_other->add(gtkshow(new Gtk::ListItem($_))) foreach (@list_other); my $box_what_other = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,4), 1, createScrolledWindow($list_other), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("Add")), clicked => sub {filedialog() }), gtksignal_connect(new Gtk::Button(_("Remove Selected")), clicked => \&list_remove, $list_other), ), ); my $combo_where_net_proto = new Gtk::Combo(); $combo_where_net_proto->set_popdown_strings ("scp","ftp", "sftp", "rsync"); my $combo_where_net_auth = new Gtk::Combo(); $combo_where_net_auth->set_popdown_strings ("ssh/identity.pub with passphrase null", "ssh-agent re ask for password between each end of root session", "ask for passwrod each timer", "no pass require"); my $box2 = new Gtk::VBox( 0, 2 ); my $radio1 = new Gtk::RadioButton( " ssh/identity.pub with passphrase null"); $box2->add( $radio1); $radio1->set_active(1); my $radio2 = new Gtk::RadioButton( " ssh-agent ", $radio1); $box2->add( $radio2); my $radio3 = new Gtk::RadioButton( " ask for passwrod each timer", $radio2); $box2->add( $radio3); gtksignal_connect( $radio1, clicked => sub { $auth_choice = 0 }); gtksignal_connect( $radio2, clicked => sub { $auth_choice = 1 }); gtksignal_connect( $radio3, clicked => sub { $auth_choice = 2 }); my $box_where_net = gtkpack_(new Gtk::VBox(0,1), 0, gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::HSeparator, 0, my $check_where_net = new Gtk::CheckButton( _(" Use Network to backup") ), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please choose your protocol"), 0, $combo_where_net_proto, 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please entrer the host name or IP."), 1, my $host_name_entry = new Gtk::Entry(), 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please entrer the directory\n to put the backup on this host. "), 1, my $host_path_entry = new Gtk::Entry(), 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please entrer your login"), 0, my $login_user_entry = new Gtk::Entry(), 0, _(""), ), ), 1, gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::HSeparator, 1, gtkpack_(new Gtk::HBox(0,3), 0, new Gtk::HBox(0,3), 1, _("please choose your authentifycation method"), 1, new Gtk::Button("Help "), ), 0, " ", 1, gtkpack_(new Gtk::HBox(0,10), 1, $box2, 1, gtkpack_(new Gtk::VBox(0,1), 1, new Gtk::Button(" Assistant"), ), ), ), # 0, _("It exists three solutions to authentify with the \n host to backup: "), # 0, _(" - ssh-agent ( correct security)"), # 0, _(" - ssh with empty passphrase. "), # 0, _(" if you are sure\n that nobody can read your\n .ssh/identity.bakup) "), # 0, _(" - ask every time for password. best security "), ); $combo_where_net_proto->entry->set_text($net_proto); $combo_where_net_proto->entry->signal_connect( 'changed', sub { $net_proto = $combo_where_net_proto->entry->get_text()}); $host_path_entry->set_text( $host_path ); $host_name_entry->set_text( $host_name ); $login_user_entry->set_text( $login_user ); $host_name_entry->signal_connect( 'changed', sub { $host_name = $host_name_entry->get_text()}); $host_path_entry->signal_connect( 'changed', sub { $host_path = $host_path_entry->get_text()}); $login_user_entry->signal_connect( 'changed', sub { $login_user = $login_user_entry->get_text()}); my $adj = new Gtk::Adjustment 500.0, 1.0, 10000.0, 1.0, 5.0, 0.0; my $box_where_hd = gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::HSeparator, 0, my $check_where_hd = new Gtk::CheckButton( _(" Use Hard Disk to backup") ), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0,10), 0, _(" "), 0, _("Please entrer the directory to save: "), 1, my $save_path_entry = new Gtk::Entry(), 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 0, _(""), 0, _("Please entrer the maximum size allowed for Drakbackup "), 1, my $spinner = new Gtk::SpinButton( $adj, 0, 0), 0, _(""), ), 0, gtkpack_(new Gtk::HBox(0,10), 1, _(""), 0, my $check_where_hd_quota = new Gtk::CheckButton( _(" Use quota for backup files.") ), 0, _(""), ), ); $save_path_entry->set_text( $save_path ); $save_path_entry->signal_connect( 'changed', sub { $save_path = $save_path_entry->get_text()}); my $combo_where_cd_time = new Gtk::Combo(); $combo_where_cd_time->set_popdown_strings ("650","700", "750", "800"); my $box_where_cd = gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::HSeparator, 0, my $check_where_cd = new Gtk::CheckButton( _(" Use CD/DVDROM to backup") ), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please choose your CD space"), 0, $combo_where_cd_time, 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _(" Please check if you are using CDRW media"), 0, my $check_cdrw = new Gtk::CheckButton(), 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _(" Please check if you want to include install boot on your CD."), 0, my $check_cd_with_install_boot = new Gtk::CheckButton(), 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please enter your CD Writer device name\n ex: 0,1,0"), 0, my $cd_devive_entry = new Gtk::Entry(), 0, _(""), ), ); $cd_devive_entry->set_text( $cd_devive ); $cd_devive_entry->signal_connect( 'changed', sub { $cd_devive = $cd_devive_entry->get_text()}); $combo_where_cd_time->entry->set_text($cd_time); $combo_where_cd_time->entry->signal_connect( 'changed', sub { $cd_time = $combo_where_cd_time->entry->get_text()}); my $box_what = gtkpack(new Gtk::VBox(0,1), $notebook_what = new Gtk::Notebook, $notebook_what->insert_page( $box_what_sys, $label_what_sys, 0), $notebook_what->insert_page( $box_what_user, $label_what_user, 1), $notebook_what->insert_page( $box_what_other, $label_what_other, 2), $notebook_what->set_scrollable(1), ); my $box_where = gtkpack(new Gtk::VBox(0,1), $notebook_where = new Gtk::Notebook, $notebook_where->insert_page( $box_where_net, $label_where_net, 0 ), $notebook_where->insert_page( $box_where_hd, $label_where_hd, 1 ), $notebook_where->insert_page( $box_where_cd, $label_where_cd, 1 ), ); my $combo_when_space = new Gtk::Combo(); $combo_when_space->set_popdown_strings (_("hourly"),_("daily"),_("weekly"),_("monthly")); my $box_when = gtkpack_(new Gtk::VBox(0,1), 0, gtkpack_(new Gtk::HBox(0,10), 1, _(""), 1, new Gtk::Pixmap($pix_time_map, $pix_time_mask), 0, my $check_when_daemon = new Gtk::CheckButton( _(" Use daemon") ), 1, _(""), ), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0,10), 1, _("Please choose interval \nspace between each backup "), 0, $combo_when_space, 0, _(""), ), 0, _(""), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("Please choose media to backup. "), 0, gtkpack_(new Gtk::VBox(0,10), 0, my $check_where_cd_daemon = new Gtk::CheckButton( _(" Use CD/DVDROM with daemon") ), 0, my $check_where_hd_daemon = new Gtk::CheckButton( _(" Use Hard Drive with daemon") ), 0, my $check_where_net_daemon = new Gtk::CheckButton( _(" Use Network with daemon") ), ), ), 0, new Gtk::HSeparator, 1, _("Please be careful that cron deamon is include on your services. "), ); $combo_when_space->entry->set_text( $when_space ); $combo_when_space->entry->signal_connect( 'changed', sub { $when_space = $combo_when_space->entry->get_text(); print $when_space."\n";}); my $box_options = gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::VBox(0,10), 0, gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::VBox(0,10), 1, new Gtk::Pixmap($pix_options_map, $pix_options_mask), 1, _("Please choose correct options to backup. "), 1, new Gtk::VBox(0,10), ), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::VBox(0,10), 0, my $check_tar_bz2 = new Gtk::CheckButton( _(" Use Tar and bzip2 ( very slow)") ), 0, my $check_replace = new Gtk::CheckButton( _(" Replace (no update backup files)")), 0, my $check_backupignore = new Gtk::CheckButton( _(" Use .backupignore files")), ), ), ); gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack(new Gtk::HBox(0,0), gtkpack(my $notebook_box = new Gtk::VBox(0,5), $notebook = new Gtk::Notebook, $notebook->insert_page( $box_what, $label_what, 0), $notebook->insert_page( $box_where, $label_where, 1), $notebook->insert_page( $box_when, $label_when, 2), $notebook->insert_page( $box_options, $label_options, 3), $notebook->set_scrollable( 1 ) ), ), 0, gtkadd(new Gtk::HButtonBox, gtksignal_connect(new Gtk::Button(_("Cancel")), clicked => sub { ${$central_widget}->destroy(); $mdk_cc and interactive_mode(); $mdk_cc or interactive_mode_my(); }), gtksignal_connect(new Gtk::Button(_("Help")), clicked => sub { save_conf_file(); ${$central_widget}->destroy(); adv_help() }), gtksignal_connect(new Gtk::Button(_("Ok")), clicked => sub { save_conf_file(); ${$central_widget}->destroy(); $mdk_cc and interactive_mode(); $mdk_cc or interactive_mode_my(); }), ), ), ), my %rotate = ( top => "right", right => "bottom", bottom => "left", left => "top" ); foreach ([$check_what_sys, \$backup_sys], [$check_what_cvs, \$backup_sys_cvs], [$check_what_browser, \$what_no_browser], [$check_cdrw, \$cdrw], [$check_where_net_daemon, \$net_daemon], [$check_where_hd_daemon, \$hd_daemon], [$check_where_cd_daemon, \$cd_daemon], [$check_where_hd_quota, \$hd_quota], [$check_where_hd, \$where_hd], [$check_where_cd, \$where_cd], [$check_where_net, \$where_net], [$check_when_daemon, \$backup_daemon], [$check_cd_with_install_boot, \$cd_with_install_boot], [$check_tar_bz2, \$comp_mode], [$check_replace, \$option_replace], [$check_backupignore, \$backupignore]) { my $ref = $_->[1]; gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; }) } $notebook->set_tab_pos( $rotate{ $notebook->tab_pos } ); $central_widget = \$about_box; $up_box->show_all(); } sub find_backup_to_restore { my @list_backup_tmp; my @user_backuped_tmp; @user_backuped = (); -d $save_path and my @list_backup = all($save_path); $DEBUG and print $_."\n" foreach @list_backup; if (grep /^backup_other_/, @list_backup) {$other_backuped = 1;} if (grep /^backup_sys_/, @list_backup) {$sys_backuped = 1;} foreach (grep /^backup_user_/, @list_backup) { chomp; s/^backup_user_//gi; s/.tar.gz$//gi; s/.tar.bz2$//gi; push @user_backuped ,$_; } $DEBUG and print $_."\n" foreach @user_backuped; } sub do_cron { } sub do_restore_backend { my $untar_cmd; if (grep /tar.gz$/, all($save_path)) { $untar_cmd = 0; } else { $untar_cmd = 1; } if ($restore_user) { $untar_cmd or system(" echo 'user: $_' && cd /tmp && tar xfz $save_path/backup_user_$_.tar.gz ") foreach @user_list_to_restore; $untar_cmd and system("echo 'user: $_' && cd /tmp && /usr/bin/bzip2 -cd $save_path/backup_user_$_.tar.bz2 | tar xf -") foreach @user_list_to_restore; } if ($restore_sys) { $untar_cmd or system("echo backup_sys && cd /tmp && tar xfz $save_path/backup_sys.tar.gz "); $untar_cmd and system("echo backup_sys cd /tmp && /usr/bin/bzip2 -cd $save_path/backup_sys.tar.bz2 | tar xf - "); } if ($restore_other) { $untar_cmd or system("echo backup_other && cd /tmp && tar xfz $save_path/backup_other.tar.gz "); $untar_cmd and system("echo backup_other && cd /tmp && /usr/bin/bzip2 -cd $save_path/backup_other.tar.bz2 | tar xf - "); } print "End of restore\n"; } sub do_restore { my $do_restore; gtkpack($retore_box2, $do_restore = gtkpack_(new Gtk::VBox(0,10), 1, new Gtk::VBox(0,10), 1, gtkpack(new Gtk::HBox(0,10), new Gtk::VBox(0,10), gtksignal_connect(new Gtk::Button(_(" Restore ")), clicked => sub { do_restore_backend(); }), new Gtk::VBox(0,10), ), 1, new Gtk::VBox(0,10), 0, gtkpack_(new Gtk::HBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { ${$central_widget}->destroy(); restore_step2(); }), ), ), ); $central_widget = \$do_restore; $up_box->show_all(); } sub restore_step_other { my $retore_step_other; $DEBUG and print "user list to restore" . $_."\n" foreach (@user_list_to_restore); gtkpack($retore_box2, $retore_step_other = gtkpack_(new Gtk::VBox(0,10), 1, new Gtk::VBox(0,10), 1, createScrolledWindow( gtkpack(new Gtk::VBox(0,0), gtkadd(new Gtk::Frame(_("Backup of other files content.")), gtkpack(new Gtk::VBox(0,10), cat_("$save_path/list_other"), ), ), ), ), 0, my $check_restore_other_sure = new Gtk::CheckButton(_(" Sure to restore the other files .")), 1, new Gtk::VBox(0,10), 0, gtkpack_(new Gtk::HBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { $retore_step_other->destroy(); restore_step2(); }), 1, new Gtk::VBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Next ")), clicked => sub { ${$central_widget}->destroy(); do_restore(); }), ), ), ); foreach ([$check_restore_other_sure, \$restore_other]) { my $ref = $_->[1]; gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; }) } $central_widget = \$retore_step_other; $up_box->show_all(); } my %check_user_to_restore; sub restore_step_user { my $retore_step_user; gtkpack($retore_box2, $retore_step_user = gtkpack_(new Gtk::VBox(0,10), 0, new Gtk::VBox(0,10), 0, _("User list to restore "), 1, createScrolledWindow( gtkpack(new Gtk::VBox(0,0), map { my $name = $_; my $b = new Gtk::CheckButton($name); if ( grep /^$name$/, @user_list_to_restore) { gtkset_active($b, 1); } else { gtkset_active($b, 0); } $b->signal_connect(toggled => sub { if ($check_user_to_restore{$name}[1] ) { $check_user_to_restore{$name}[1] = 1; if (!member($name, @user_list_to_restore) ) { push @user_list_to_restore, $name;} } else { $check_user_to_restore{$name}[1] = 0; my @user_list_tmp = grep(!/^$name$/,@user_list_to_restore ); @user_list_to_restore = @user_list_tmp; } }); $b } (@user_backuped) ), ), 0, gtkpack_(new Gtk::HBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { $retore_step_user->destroy(); restore_step2(); }), 1, new Gtk::VBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Next ")), clicked => sub { ${$central_widget}->destroy(); if ($restore_other) { restore_step_other();} else{ do_restore();} }), ), ), ); $central_widget = \$retore_step_user; $up_box->show_all(); } sub restore_step_sys { my $retore_step_sys; my $combo_retore_step_sys = new Gtk::Combo(); $combo_retore_step_sys->set_popdown_strings ("12 jan 2002","12 jan 2002", "12 jan 2002", "12 jan 2002"); gtkpack($retore_box2, $retore_step_sys = gtkpack_(new Gtk::VBox(0,10), 1, new Gtk::VBox(0,10), 0, my $check_backup_before = new Gtk::CheckButton(_(" Backup the system files before.")), 0, gtkpack_(new Gtk::HBox(0,10), 1, _("please choose the date to restore"), 0, $combo_retore_step_sys, 0, _(""), ), 1, new Gtk::VBox(0,10), 0, gtkpack_(new Gtk::HBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Previous ")), clicked => sub { $retore_step_sys->destroy(); restore_step2(); }), 1, new Gtk::VBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Next ")), clicked => sub { ${$central_widget}->destroy(); if ($restore_user) { restore_step_user();} elsif ($restore_other){ restore_step_other();} else{ do_restore();} }), ), ), ); $central_widget = \$retore_step_sys; $up_box->show_all(); } sub restore_step2 { my $retore_step2; gtkpack($retore_box2, $retore_step2 = gtkpack_(new Gtk::VBox(0,10), 1, new Gtk::VBox(0,10), 0, my $check_restore_sys = new Gtk::CheckButton(_("Restore system")), 0, my $check_restore_user = new Gtk::CheckButton(_("Restore Users")), 0, my $check_restore_other = new Gtk::CheckButton(_("Restore Other")), 1, new Gtk::VBox(0,10), 0, gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::VBox(0,10), 0, gtksignal_connect(new Gtk::Button(_(" Next ")), clicked => sub { ${$central_widget}->destroy(); if ($restore_sys && $backup_sys_cvs) { restore_step_sys(); } elsif ($restore_user) { restore_step_user();} elsif ($restore_other){ restore_step_other();} else{ do_restore();} }), ), ), ); foreach ([$check_restore_sys, \$restore_sys], [$check_restore_user, \$restore_user], [$check_restore_other, \$restore_other]) { my $ref = $_->[1]; gtksignal_connect(gtkset_active($_->[0], ${$ref}), toggled => sub { ${$ref} = ${$ref} ? 0 : 1; }) } $central_widget = \$retore_step2; $up_box->show_all(); } sub restore { my $retore_box; my $retore_box3; my ($pix_u_map, $pix_u_mask) = gtkcreate_png("backup_title"); my ($pix_l_map, $pix_l_mask) = gtkcreate_png("backup_left2"); my ($pix_r_map, $pix_r_mask) = gtkcreate_png("backup_bot2"); my $check_restore_sys; my $check_restore_user; my $check_restore_other; find_backup_to_restore(); @user_list_to_restore = @user_backuped; if ($other_backuped || $sys_backuped || @user_backuped) { gtkpack($up_box, $retore_box = gtkpack_(new Gtk::VBox(0,1), 0, gtkpng('backup_title'), 1, gtkpack_(new Gtk::HBox(0, 0), 0, gtkpng('backup_left2'), 1, gtkadd(new Gtk::Frame(_("Restoration Step.")), $retore_box2 = gtkpack(new Gtk::VBox(0,10), $retore_box3 = gtkpack_(new Gtk::VBox(0,10), 1, _("Please choose that you want to restore."), 0, gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::HBox(0,10), 1, gtkpack_(new Gtk::VBox(0,10), 0, gtksignal_connect(new Gtk::Button(_("Restore all backups (last)")), clicked => sub { $retore_box3->destroy(); $restore_sys = 1; $restore_other = 1; $restore_user = 1; do_restore(); }), 0, gtksignal_connect(new Gtk::Button(_("Custom Restore")), clicked => sub { $retore_box3->destroy(); restore_step2(); }), ), 1, new Gtk::HBox(0,10), ), 1, new Gtk::HBox(0,10), ),),),), 0, gtkpng('backup_bot2'), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0, 0), 1, gtkpack_(new Gtk::HButtonBox, 1, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { ${$central_widget}->destroy(); $mdk_cc and interactive_mode(); $mdk_cc or interactive_mode_my(); }), 1, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { $retore_box->destroy(); restore_help();}), ), ), ) ); } else { gtkpack($up_box, $retore_box = gtkpack_(new Gtk::VBox(0,1), 0, new Gtk::Pixmap($pix_u_map, $pix_u_mask), 1, gtkpack_(new Gtk::HBox(0, 0), 0, new Gtk::Pixmap($pix_l_map, $pix_l_mask), 1, gtkadd(new Gtk::Frame(_("Restoration Step.")), $retore_box2 = gtkpack(new Gtk::VBox(0,10), $retore_box3 = gtkpack_(new Gtk::VBox(0,10), 1, _("Please Build backup before to restore it..."), 0, gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::HBox(0,10), ), 1, new Gtk::HBox(0,10), ),),),), 0, new Gtk::Pixmap($pix_r_map, $pix_r_mask), 0, new Gtk::HSeparator, 0, gtkpack_(new Gtk::HBox(0, 0), 1, gtkpack_(new Gtk::HButtonBox, 1, gtksignal_connect(new Gtk::Button(_(" Cancel ")), clicked => sub { ${$central_widget}->destroy(); $mdk_cc and interactive_mode(); $mdk_cc or interactive_mode_my(); }), 1, gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { $retore_box->destroy(); restore_help();}), ), ), ) ); } $central_widget = \$retore_box; $up_box->show_all(); } sub interactive_mode_my { $interactive = 1; my $box_cfg_state; my $box_cgf_state_replace; my $box_cgf_state_comp; my $mask; my $style; my $box; my $box_cgf_state_sys = (""); my $text2 = new Gtk::Text(undef, undef); my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; init Gtk; $window1->signal_connect (delete_event => sub { Gtk->exit(0) }); $window1->set_position(1); $window1->set_title(_("Drakbackup")); my ($pix_u_map, $pix_u_mask) = gtkcreate_png("backup_title"); my ($pix_l_map, $pix_l_mask) = gtkcreate_png("backup_left"); my ($pix_r_map, $pix_r_mask) = gtkcreate_png("backup_bot"); read_conf_file(); $backup_sys or $box_cgf_state_sys = _("Do not include System Files"); if ($option_replace) { $box_cgf_state_replace = _("Replace backups (do not update)"), } else { $box_cgf_state_replace = _("Update backups (do not replace)"), } if ($comp_mode) { $box_cgf_state_comp = _("Backups use tar and gzip "), } else { $box_cgf_state_comp = _("Backups use tar and bzip"), } if ($cfg_file_exist) { my $label_cfg_file = new Gtk::Label _("Backup Sources: \n-System Files: @sys_files \n-Users Files: @user_list\n-Other Files: @list_other\nPath to save backups: $save_path\nOptions:\n$box_cgf_state_replace\n$box_cgf_state_comp\n$box_cgf_state_sys\n"); $box_cfg_state = gtkpack(new Gtk::VBox( 0, 0), gtkset_justify( $label_cfg_file , 'left'), ), } else { $box_cfg_state = gtkpack(new Gtk::VBox(0,1), _("No configuration please click Wizard or Advanced.") ), } gtkadd($window1, gtkpack(new Gtk::VBox(0,0), gtkpack(gtkset_usize($up_box = new Gtk::VBox(0, 5), 500, 420), $box = gtkpack_(new Gtk::VBox(0, 3), 0, new Gtk::Pixmap($pix_u_map, $pix_u_mask), 1, gtkpack_(new Gtk::HBox(0, 3), 0, new Gtk::Pixmap($pix_l_map, $pix_l_mask), 1, createScrolledWindow( gtkpack(new Gtk::VBox(0,0), gtkadd(new Gtk::Frame(_("State of configuration.")), gtkpack(new Gtk::VBox(0,10), $box_cfg_state, ),),),),), 0, gtkpack_(new Gtk::HBox(0, 0), 0, new Gtk::Pixmap($pix_r_map, $pix_r_mask), 1, gtkpack_(new Gtk::VBox(0, 1), 1, gtksignal_connect(new Gtk::Button(_(" Build Backup ")), clicked => sub {# ${$central_widget}->destroy(); # status_report(); build_backup_files(); }), 1, gtksignal_connect(new Gtk::Button(_(" Restore ")), clicked => sub {${$central_widget}->destroy(); restore();}), ), ), 0, new Gtk::HSeparator, 0, gtkpack(new Gtk::HButtonBox, gtksignal_connect(new Gtk::Button(_(" Advanced Configuration ")), clicked => sub { ${$central_widget}->destroy(); advanced() }), gtksignal_connect(new Gtk::Button(_(" Wizard Configuration ")), clicked => sub { ${$central_widget}->destroy(); wizard() }), gtksignal_connect(new Gtk::Button(_("close")), clicked => sub { Gtk->main_quit() }), ), ), ), ), ); $central_widget = \$box; $window1->show_all; $window1->realize; $window1->show_all(); Gtk->main; Gtk->exit(0); } sub after_adv { $interactive = 1; my $box_cfg_state; my $box_cgf_state_replace; my $box_cgf_state_comp; my $mask; my $style; my $box_cgf_state_sys = (""); my $box; init Gtk; my $text2 = new Gtk::Text(undef, undef); my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; $window1->signal_connect (delete_event => sub { Gtk->exit(0) }); $window1->set_position(1); $window1->set_title(_("Drakbackup")); my ($pix_u_map, $pix_u_mask) = gtkcreate_png("backup_title"); my ($pix_l_map, $pix_l_mask) = gtkcreate_png("backup_left"); my ($pix_b_map, $pix_b_mask) = gtkcreate_png("backup_bot2"); my ($pix_cd_map, $pix_cd_mask) = gtkcreate_png("cdrom"); my ($pix_hd2_map, $pix_hd2_mask) = gtkcreate_png("hd"); my ($pix_quit_map, $pix_quit_mask) = gtkcreate_png("quit"); my $button_burn_cd = new Gtk::Button(); $button_burn_cd->add( gtkpack(new Gtk::HBox( 0, 2), new Gtk::Pixmap($pix_cd_map, $pix_cd_mask), _("Burn auto\n Install CDROM") ), ); my $button_do_backup = new Gtk::Button(); $button_do_backup->add( gtkpack(new Gtk::HBox( 0, 2), new Gtk::Pixmap($pix_hd2_map, $pix_hd2_mask), _("Build a \nbackupn now") ), ); my $button_quit = new Gtk::Button(); $button_quit->add( gtkpack(new Gtk::HBox( 0, 2), new Gtk::Pixmap($pix_quit_map, $pix_quit_mask), _("Quit DrakBackup") ), ); read_conf_file(); $backup_sys or $box_cgf_state_sys = _("Do not include System Files"); if ($option_replace) { $box_cgf_state_replace = _("Replace backups (do not update)"), } else { $box_cgf_state_replace = _("Update backups (do not replace)"), } if ($comp_mode) { $box_cgf_state_comp = _("Backups use tar and bzip2 "), } else { $box_cgf_state_comp = _("Backups use tar and gzip"), } if ($cfg_file_exist) { my $label_cfg_file = new Gtk::Label _("Backup Sources: \n-System Files: @sys_files \n-Users Files: @user_list\n-Other Files to backup: @list_other\nPath to save backups: $save_path\nOptions:\n$box_cgf_state_replace\n$box_cgf_state_comp\n$box_cgf_state_sys\n"); $box_cfg_state = gtkpack(new Gtk::VBox( 0, 0), gtkset_justify( $label_cfg_file , 'left'), ), } else { $box_cfg_state = gtkpack(new Gtk::VBox(0,1), _("No configuration please click Wizard or Advanced.") ), } gtkadd($window1, gtkpack(new Gtk::VBox(0,0), gtkpack(gtkset_usize($up_box = new Gtk::VBox(0, 5), 500, 420), $box = gtkpack_(new Gtk::VBox(0, 3), 0, new Gtk::Pixmap($pix_u_map, $pix_u_mask), 1, gtkpack_(new Gtk::HBox(0, 3), 0, new Gtk::Pixmap($pix_l_map, $pix_l_mask), 1, createScrolledWindow( gtkpack(new Gtk::VBox(0,0), gtkadd(new Gtk::Frame(_("State of configuration file.")), gtkpack(new Gtk::VBox(0,10), $box_cfg_state, ),),),),), 0, new Gtk::Pixmap($pix_b_map, $pix_b_mask), 0, gtkpack_(new Gtk::HBox(0, 0), 1, gtkpack_(new Gtk::HBox(0, 1), 1, gtksignal_connect($button_quit, clicked => sub { Gtk->main_quit() }), 1, gtksignal_connect($button_do_backup, clicked => sub { ${$central_widget}->destroy(); }), 1, gtksignal_connect($button_burn_cd, clicked => sub { ${$central_widget}->destroy(); }), ), ), ), ), ), ); $central_widget = \$box; $window1->show_all; $window1->realize; $window1->show_all(); Gtk->main; Gtk->exit(0); } sub about { my $text = new Gtk::Text(undef, undef); my $about_box; gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,0), 1, gtktext_insert(gtkset_editable($text, 1), _(" Copyright (C) 2001 by MandrakeSoft (sdupont\@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. ")), 0, new Gtk::VScrollbar($text->vadj), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { ${$central_widget}->destroy(); $mdk_cc and interactive_mode(); $mdk_cc or interactive_mode_my(); }), ), ) ); $central_widget = \$about_box; $up_box->show_all(); } sub adv_help { my $text = new Gtk::Text(undef, undef); my $about_box; gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,0), 1, gtktext_insert(gtkset_editable($text, 1), _(" description: Drakbacup is use to backup system files and user files Drakbacup allow to restore the system (etc, var files) from starup or on drakconf utility. backup name format: all the time from the / dir. system backup: backup_sys.tar.gz user backup backup_user_james.tar.gz backup_user_seb.tar.gz other directories backup_other.tar.gz build iso fs with rescue. configuration file: /etc/drakconf/drakbackup/drakbakup.conf ")), 0, new Gtk::VScrollbar($text->vadj), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { ${$central_widget}->destroy(); advanced(); }), ), ) ); $central_widget = \$about_box; $up_box->show_all(); } sub restore_help { my $text = new Gtk::Text(undef, undef); my $about_box; gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,0), 1, gtktext_insert(gtkset_editable($text, 1), _(" Description: Drakbacup Restore Mode. Drakbacup allow to restore the system (etc, var files) from starup or on drakconf utility. system backup: backup_sys.tar.gz user backup backup_user_james.tar.gz backup_user_seb.tar.gz other directories backup_other.tar.gz ")), 0, new Gtk::VScrollbar($text->vadj), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { ${$central_widget}->destroy(); restore(); }), ), ) ); $central_widget = \$about_box; $up_box->show_all(); } # _____________________________________________________________ DOCS # Comment récupérer la date du jour ? # Cf perldoc -f localtime # ($seconde,$minute,$heure,$jour_du_mois,$annee, # $jour_de_la_semaine,$jour_de_l _annee,$drapeau_heure_ete) = localtime(time); # Il faut ajouter 1900 a l'année pour une date correcte ($annee+=1900) et 1 au jour du mois pour obtenir une date correcte ($jour_du_mois++). # [Perl] Comment récupérer des informations sur un fichier ? # Cf perldoc -f stat # Exemple pour récupérer mtime (date de dernière modification du fichier) # my(@etat); my($fchier)="/tmp/toto"; # # Si le fichier existe on récupère des infos dessus # if (-e $fchier) {@etat=stat($fchier); } # # On convertit avec localtime la valeur de mtime. # my($date)= localtime($etat[9]); # print $date; #Telnet : En utilisant le package Net::Telnet # use strict; # use Net::Telnet; # use CGI qw/:standard :html3 :netscape escape unescape/; # use CGI::Carp qw/fatalsToBrowser/; # my $username="alian"; # my $passwd="password"; # my $HOST="indy.alianet"; # print header; # my $t = new Net::Telnet (Timeout=>undef) or die "Can't connect:$!"; # $t->open($HOST); # $t->login($username, $passwd); # my @lines = $t->cmd("/ma/commande/a/executer"); # print join(' ',@lines); # _____________________________________________________________ OLD CODE # sub build_backup_files { # -d $save_path or mkdir_p($save_path); # my $path_name; # my @list_other_; # if ($where_hd) { # print "backup_sys @sys_files\n"; # $backup_sys and system("tar cvfz $save_path/backup_sys.tar.gz @sys_files"); # print "backup_other @list_other\n"; # if (@list_other) { # system("tar cvfz $save_path/backup_other.tar.gz @list_other"); # foreach (@list_other) { # push @list_other_, $_ . "\n"; # } # output_p( $save_path . '/list_other', @list_other_); # } # if ($backup_user) { # foreach (@user_list) { # $path_name = return_path($_); # print "path of user: $path_name\n"; # $what_no_browser or system("tar cvfz $save_path/backup_user_$_.tar.gz $path_name"); # $what_no_browser and system("tar cvz --exclude NewCache --exclude Cache --exclude cache -f $save_path/backup_user_$_.tar.gz $path_name | grep cahe"); # } # } # } # if ($where_net) { # } # if ($where_cd) { # } # }