summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-05-28 08:21:15 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-05-28 08:21:15 +0000
commit7db099c14da7fde27be0cd6dbe0bf79183420a4f (patch)
tree646b1d606c8f0c60d18d54b43861e099a93c21cd /perl-install/standalone
parentbb5d5f6f9a104490f1d4497a091d3ed9adac0ca2 (diff)
downloaddrakx-backup-do-not-use-7db099c14da7fde27be0cd6dbe0bf79183420a4f.tar
drakx-backup-do-not-use-7db099c14da7fde27be0cd6dbe0bf79183420a4f.tar.gz
drakx-backup-do-not-use-7db099c14da7fde27be0cd6dbe0bf79183420a4f.tar.bz2
drakx-backup-do-not-use-7db099c14da7fde27be0cd6dbe0bf79183420a4f.tar.xz
drakx-backup-do-not-use-7db099c14da7fde27be0cd6dbe0bf79183420a4f.zip
merge fixes from HEAD
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-xperl-install/standalone/drakTermServ157
-rwxr-xr-xperl-install/standalone/drakbackup19
-rwxr-xr-xperl-install/standalone/net_monitor10
3 files changed, 73 insertions, 113 deletions
diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ
index 9f3b5bfcc..1b3a62220 100755
--- a/perl-install/standalone/drakTermServ
+++ b/perl-install/standalone/drakTermServ
@@ -47,10 +47,11 @@ my $in_wizard = 0;
my $config_written = 0;
my $clients_set = 0;
my @nothing = (0..10);
+my %conf;
+$conf{ALLOW_THIN} = 0;
my $nfs_subnet;
my $nfs_mask;
-my $thin_clients = 0;
my $cfg_dir = "/etc/drakxtools/draktermserv/";
my $cfg_file = $cfg_dir . "draktermserv.conf";
my $interface = get_net_interface();
@@ -150,24 +151,13 @@ interactive_mode() if $#ARGV < 1;
sub read_conf_file() {
if (-e $cfg_file) {
- local *CONF_FILE;
- open(CONF_FILE, "<" . $cfg_file) || print N("You must be root to read configuration file. \n");
- local $_;
- while (<CONF_FILE>) {
- if (/^\bALLOW_THIN\b/) {
- $thin_clients = 1;
- last;
- }
- }
+ substInFile { s/ALLOW_THIN$/ALLOW_THIN=1/ } $cfg_file;
+ %conf = getVarsFromSh($cfg_file);
}
}
sub write_conf_file() {
- my @cfg_list;
- if ($thin_clients == 1) {
- @cfg_list = "ALLOW_THIN\n";
- }
- output_p($cfg_file, @cfg_list);
+ setVarsInSh($cfg_file, \%conf);
chmod(0600, $cfg_file);
}
@@ -210,10 +200,7 @@ ca::ctrlaltdel:/sbin/reboot -f
x:5:respawn:/usr/X11R6/bin/X -ac -query $server_ip\n";
my $inittab_file = "/etc/inittab$suffix";
- local *INITTAB;
- open(INITTAB, "> $inittab_file") or warn("Can't open $inittab_file!");
- print INITTAB $inittab;
- close INITTAB
+ output_p($inittab_file, $inittab);
}
sub cursor_wait() {
@@ -443,7 +430,7 @@ sub clear_buttons() {
sub client_type() {
my $check_allow_thin = new Gtk2::CheckButton(N("Use thin clients."));
- $check_allow_thin->set_active($thin_clients);
+ $check_allow_thin->set_active($conf{ALLOW_THIN});
text_view(N("Please select default client type.
'Thin' clients run everything off the server's CPU/RAM, using the client display.
'Fat' clients use their own CPU/RAM but the server's filesystem."), "wizard");
@@ -451,7 +438,7 @@ sub client_type() {
0, gtkpack_(new Gtk2::HBox(1,0),
1, Gtk2::VBox->new,
0, gtksignal_connect($check_allow_thin, clicked => sub {
- invbool \$thin_clients;
+ invbool \$conf{ALLOW_THIN};
client_set("all");
}),
0, Gtk2::VBox->new,
@@ -477,17 +464,17 @@ sub sync_users {
my $buff = N("Syncing server user list with client list, including root.");
my @active_users = cat_("/etc/shadow");
- local *SHADOW;
- open(SHADOW, '> /etc/shadow$$CLIENT$$');
-
+ my $shadow = '/etc/shadow$$CLIENT$$';
+ my @userlist;
+
#- only users with home dirs, and root
foreach my $user (@active_users) {
my @fields = split(/:/, $user);
if (-d "/home/" . $fields[0] || $fields[0] eq "root") {
- print SHADOW $user;
+ push @userlist, $user;
}
}
- close SHADOW;
+ output_p($shadow, @userlist);
$buff .= "\n\n\t" . N("Done!");
text_view($buff, "wizard") if !$cmd_line;
}
@@ -1075,11 +1062,11 @@ sub maintain_clients() {
),
);
- $check_allow_thin->set_active($thin_clients);
- $check_thin->set_sensitive($thin_clients);
+ $check_allow_thin->set_active($conf{ALLOW_THIN});
+ $check_thin->set_sensitive($conf{ALLOW_THIN});
gtksignal_connect($check_allow_thin, clicked =>
- sub { invbool \$thin_clients;
- $check_thin->set_sensitive($thin_clients);
+ sub { invbool \$conf{ALLOW_THIN};
+ $check_thin->set_sensitive($conf{ALLOW_THIN});
client_set("single");
$in->ask_warn(N("Warning"), N("Need to restart the Display Manager for full changes to take effect. \n(service dm restart - at the console)"));
}
@@ -1119,7 +1106,7 @@ sub client_set {
# we need to change some system files to allow the thin clients
# to access the server - enabling xdmcp and modify hosts.deny/hosts.allow for some security
# we also need to set runlevel to 5 and restart the display manager
- if ($thin_clients == 1) {
+ if ($conf{ALLOW_THIN} == 1) {
if (-f "/etc/sysconfig/autologin") {
my $answer = $in->ask_yesorno('', N("Thin clients won't work with autologin. Disable autologin?"));
if ($answer == 1) {
@@ -1385,15 +1372,14 @@ sub get_ip_from_sys() {
sub write_dhcpd_config {
my ($mode, $subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_;
+ my @dhcpd_config;
if ($mode eq "append") {
append_to_file("/etc/dhcpd.conf", qq(include "/etc/dhcpd.conf.terminal-server";\n));
- local *FHANDLE;
- open(FHANDLE, "> /etc/dhcpd.conf.terminal-server");
- print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
- print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n);
- print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- close FHANDLE;
+ push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
+ push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n);
+ push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
+ output_p("/etc/dhcpd.conf.terminal-server", @dhcpd_config);
$config_written = 1;
return;
}
@@ -1401,34 +1387,32 @@ sub write_dhcpd_config {
$nfs_subnet = $subnet;
$nfs_mask = $subnet_mask;
- local *FHANDLE;
- open(FHANDLE, "> /etc/dhcpd.conf");
- print FHANDLE "#dhcpd.conf - generated by drakTermServ\n\n";
- print FHANDLE "ddns-update-style none;\n\n";
- print FHANDLE "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n";
- print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
- print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n);
- print FHANDLE "# Network-specific section\n\n";
+ push @dhcpd_config, "#dhcpd.conf - generated by drakTermServ\n\n";
+ push @dhcpd_config, "ddns-update-style none;\n\n";
+ push @dhcpd_config, "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n";
+ push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n);
+ push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n);
+ push @dhcpd_config, "# Network-specific section\n\n";
- print FHANDLE "subnet $subnet netmask $netmask {\n";
- print FHANDLE "\toption routers $routers;\n" if $routers;
- print FHANDLE "\toption subnet-mask $subnet_mask;\n" if $subnet_mask;
- print FHANDLE "\toption broadcast-address $broadcast;\n" if $broadcast;
- print FHANDLE qq(\toption domain-name "$domain";\n) if $domain;
+ push @dhcpd_config, "subnet $subnet netmask $netmask {\n";
+ push @dhcpd_config, "\toption routers $routers;\n" if $routers;
+ push @dhcpd_config, "\toption subnet-mask $subnet_mask;\n" if $subnet_mask;
+ push @dhcpd_config, "\toption broadcast-address $broadcast;\n" if $broadcast;
+ push @dhcpd_config, qq(\toption domain-name "$domain";\n) if $domain;
my $pool_string = "\trange dynamic-bootp " . $pool_start . " " . $pool_end . ";\n" if $pool_start && $pool_end;
- print FHANDLE $pool_string if $pool_string;
+ push @dhcpd_config, $pool_string if $pool_string;
my $ns_string = "\toption domain-name-servers " . $ns1 if $ns1;
$ns_string = $ns_string . ", " . $ns2 if $ns2;
$ns_string = $ns_string . ", " . $ns3 if $ns3;
$ns_string = $ns_string . ";\n" if $ns_string;
- print FHANDLE $ns_string if $ns_string;
+ push @dhcpd_config, $ns_string if $ns_string;
- print FHANDLE "}\n\n";
+ push @dhcpd_config, "}\n\n";
- print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n);
- close FHANDLE;
+ push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n);
+ output_p("/etc/dhcpd.conf", @dhcpd_config);
$config_written = 1;
}
@@ -1564,14 +1548,11 @@ sub toggle_chkconfig {
sub service_change {
my ($service, $command, $buff_index) = @_;
system("BOOTUP=serial /sbin/service $service $command > /tmp/drakTSservice.status 2>&1");
- local *STATUS;
- open(STATUS, "/tmp/drakTSservice.status");
- local $_;
- while (<STATUS>) {
+ my @result = cat_("/tmp/drakTSservice.status");
+ foreach (@result) {
$buff[$buff_index] = "\t$_";
- $buff_index++;
+ $buff_index++;
}
- close STATUS;
unlink "/tmp/drakTSservice.status";
$buff_index;
}
@@ -1655,13 +1636,8 @@ sub adduser {
}
} else {
# new ts user
- local *FHANDLE;
- open(FHANDLE, '>> /etc/shadow$$CLIENT$$');
- print FHANDLE $shadow_entry[0] or $add_fail = 1;
- close FHANDLE;
- open(FHANDLE, '>> /etc/passwd$$CLIENT$$');
- print FHANDLE $passwd_entry[0] or $add_fail = 1;
- close FHANDLE;
+ append_to_file('/etc/shadow$$CLIENT$$', $shadow_entry[0]) or $add_fail = 1;
+ append_to_file('/etc/passwd$$CLIENT$$', $passwd_entry[0]) or $add_fail = 1;
$in_already = 0;
}
}
@@ -1700,10 +1676,7 @@ sub deluser {
}
$i++;
}
- local *FHANDLE;
- open(FHANDLE, '> /etc/shadow$$CLIENT$$');
- print FHANDLE $_ foreach @ts_users;
- close FHANDLE;
+ output_p('/etc/shadow$$CLIENT$$', @ts_users);
}
if ($is_passwd_user) {
@@ -1716,10 +1689,7 @@ sub deluser {
}
$i++;
}
- local *FHANDLE;
- open(FHANDLE, '> /etc/passwd$$CLIENT$$');
- print FHANDLE $_ foreach @passwd_users;
- close FHANDLE;
+ output_p('/etc/passwd$$CLIENT$$', @passwd_users);
}
if ($cmd_line == 1) {
@@ -1772,12 +1742,8 @@ sub addclient {
$ts_clients{$hostname}{hdw_config} = "false";
client_hdw_config($ip, 0);
}
- my $clients = $client_cfg;
- local *CLIENT;
- open(CLIENT, ">> $clients") or warn(N("Can't open %s!", $clients));
my $client_entry = format_client_entry($hostname, %ts_clients);
- print CLIENT $client_entry;
- close CLIENT;
+ append_to_file($client_cfg, $client_entry);
$changes_made = 1;
create_client_sysnetwork($hostname, $ip);
0;
@@ -1898,15 +1864,12 @@ qq(\tfilename\t\t"$ts_clients{$client}{filename}";),
sub write_dhcpd_conf {
my %ts_clients = @_;
- my $clients = $client_cfg;
-
- local *CLIENT;
- open(CLIENT, "> $clients") or warn("Can't open $clients!");
+ my @client_data;
foreach my $key (keys(%ts_clients)) {
my $client_entry = format_client_entry($key, %ts_clients);
- print CLIENT $client_entry;
+ push @client_data, $client_entry;
}
- close CLIENT
+ output_p($client_cfg, @client_data);
}
sub read_dhcpd_conf() {
@@ -1915,9 +1878,8 @@ sub read_dhcpd_conf() {
my $hostname;
#- read and parse current client entries
- local *CLIENTS;
- open(CLIENTS, $clients) or warn("Can't open $clients\n");
- while (<CLIENTS>) {
+ my @client_data = cat_($clients);
+ foreach (@client_data) {
my ($name, $val, $val2) = split ' ';
$val = $val2 if $name =~ /hardware/;
$val =~ s/[;"]//g;
@@ -1932,7 +1894,6 @@ sub read_dhcpd_conf() {
}
}
}
- close CLIENTS;
%ts_clients;
}
@@ -1960,11 +1921,15 @@ sub client_hdw_config {
cp_af('/etc/X11/XF86Config-4$$CLIENT$$', "/etc/X11/XF86Config-4$suffix") if -f '/etc/X11/XF86Config-4$$CLIENT$$';
cp_af("/dev/null", "/etc/modules.conf$suffix");
cp_af("/dev/null", "/etc/modules$suffix");
+ cp_af("/dev/null", "/etc/modprobe.conf$suffix");
+ cp_af("/dev/null", "/etc/modprobe.preload$suffix");
# create mount points so they can be edited by the client
my $mnt_access = "$client_ip(rw,no_root_squash)";
append_to_file("/etc/exports", "/etc/sysconfig/mouse$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/modules.conf$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/modules$suffix\t$mnt_access\n");
+ append_to_file("/etc/exports", "/etc/modprobe.conf$suffix\t$mnt_access\n");
+ append_to_file("/etc/exports", "/etc/modprobe.preload$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/X11/XF86Config$suffix\t$mnt_access\n");
append_to_file("/etc/exports", "/etc/X11/XF86Config-4$suffix\t$mnt_access\n");
} else {
@@ -1979,12 +1944,8 @@ sub create_client_sysnetwork {
my ($hostname, $ip) = @_;
log::explanations("Adding /etc/sysconfig/network for $ip");
my $network_file = "/etc/sysconfig/network\$\$IP=$ip\$\$";
- local *NETWORK;
- open(NETWORK, "> $network_file") or warn("Can't open $network_file!");
- print NETWORK "HOSTNAME=$hostname\n";
- print NETWORK "NETWORKING=yes\n";
- print NETWORK "FORWARD_IPV4=false\n";
- close NETWORK;
+ my %net_data = ("HOSTNAME=$hostname\n", "NETWORKING=yes\n", "FORWARD_IPV4=false\n");
+ output_p($network_file, %net_data);
}
sub restart_server() {
@@ -2005,6 +1966,8 @@ sub clean_client_config {
eval { rm_rf("/etc/sysconfig/mouse$suffix") };
eval { rm_rf("/etc/modules.conf$suffix") };
eval { rm_rf("/etc/modules$suffix") };
+ eval { rm_rf("/etc/modprobe.conf$suffix") };
+ eval { rm_rf("/etc/modprobe.preload$suffix") };
eval { rm_rf("/etc/X11/XF86Config$suffix") };
eval { rm_rf("/etc/X11/XF86Config-4$suffix") };
eval { rm_rf("/etc/sysconfig/network$suffix") };
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
index 351f363f3..00f3a3a15 100755
--- a/perl-install/standalone/drakbackup
+++ b/perl-install/standalone/drakbackup
@@ -225,14 +225,11 @@ sub get_tape_info() {
@tape_devices = ();
system("dmesg | grep 'st[0-9] at' > $info");
- local *INFO;
- open INFO, $info or warn("Can't open $info\n");
- local $_;
- while (<INFO>) {
+ my @info = cat_($info);
+ foreach (@info) {
@line_data = split(/[ \t,]+/, $_);
push @tape_devices, "/dev/" . $line_data[3];
}
- close INFO;
unlink($info);
}
@@ -1044,7 +1041,7 @@ sub build_backup_files() {
do_find(undef, $find_args_user, $list_file, $path_name);
do_tar($tar_cmd_user, "backup_$incr$user", undef, $path_name);
}
- push_list("$incr$user") if $incr =~ /_user/;
+ push_list("list_$incr$user") if $incr =~ /_user/;
files_to_results("$incr$user");
}
}
@@ -1254,7 +1251,7 @@ sub push_list {
my $filename = $conf{PATH_TO_SAVE} . "/" . $prefix . $the_time . ".";
$filename .= $conf{OPTION_COMP} if $prefix =~ /^backup/;
$filename .= "txt" if $prefix =~ /^list/;
- push @file_list_to_send_by_ftp, $filename;
+ push @file_list_to_send_by_ftp, $filename if -e $filename;
}
sub files_to_results {
@@ -2776,22 +2773,18 @@ sub restore_aff_result() {
button_box_ok_only();
$central_widget = \$do_restore;
$up_box->show_all;
-
}
sub return_path {
my ($username) = @_;
my $usr;
my $home_dir;
- my $passwdfile = "/etc/passwd";
- local *PASSWD;
- open(PASSWD, $passwdfile) or exit 1;
- while (defined(my $line = <PASSWD>)) {
+ my @passwords = cat_("/etc/passwd");
+ foreach my $line (@passwords) {
chomp($line);
($usr, $home_dir) = (split(/:/, $line))[0,5];
last if $usr eq $username;
}
- close(PASSWD);
return $home_dir;
}
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 7e323fb19..3863e0197 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -25,6 +25,7 @@ use lib qw(/usr/lib/libDrakX);
use strict;
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
+use c;
use interactive;
use ugtk2 qw(:helpers :wrappers :create);
use common;
@@ -281,12 +282,15 @@ sub get_val() {
$a =~ s/^.*?\n.*?\n//;
$a =~ s/^\s*lo:.*?\n//;
my @line = split(/\n/, $a);
+ my @interfaces = c::get_netdevices();
map {
s/\s*(\w*)://;
my $intf = $1;
- $monitor->{$intf}{val} = [split()];
- $monitor->{$intf}{intf} = $intf;
- $intf;
+ if (member($intf, @interfaces)) {
+ $monitor->{$intf}{val} = [ split() ];
+ $monitor->{$intf}{intf} = $intf;
+ $intf;
+ } else { () }
} @line;
}