summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/drakTermServ151
-rwxr-xr-xperl-install/standalone/drakbackup15
2 files changed, 58 insertions, 108 deletions
diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ
index 7282680b7..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;
}
@@ -1983,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() {
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
index 351f363f3..08532c12f 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);
}
@@ -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;
}