summaryrefslogtreecommitdiffstats
path: root/perl-install/services.pm
blob: 44a915adf27cd9c0d8e4465b897767dc31f006b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
package services; # $Id$

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use commands;
use run_program;
use my_gtk qw(:helpers :wrappers);

sub description {
    my %services = (
alsa => __("Launch the ALSA (Advanced Linux Sound Architecture) sound system"),
anacron => __("Anacron a periodic command scheduler."),
apmd => __("apmd is used for monitoring batery status and logging it via syslog.
It can also be used for shutting down the machine when the battery is low."),
atd => __("Runs commands scheduled by the at command at the time specified when
at was run, and runs batch commands when the load average is low enough."),
crond => __("cron is a standard UNIX program that runs user-specified programs
at periodic scheduled times. vixie cron adds a number of features to the basic
UNIX cron, including better security and more powerful configuration options."),
gpm => __("GPM adds mouse support to text-based Linux applications such the
Midnight Commander. It also allows mouse-based console cut-and-paste operations,
and includes support for pop-up menus on the console."),
harddrake => __("HardDrake runs a hardware probe, and optionally configures
new/changed hardware."),
httpd => __("Apache is a World Wide Web server.  It is used to serve HTML files
and CGI."),
inet => __("The internet superserver daemon (commonly called inetd) starts a
variety of other internet services as needed. It is responsible for starting
many services, including telnet, ftp, rsh, and rlogin. Disabling inetd disables
all of the services it is responsible for."),
ipchains => __("Launch packet filtering for Linux kernel 2.2 series, to set
up a firewall to protect your machine from network attacks."),
keytable => __("This package loads the selected keyboard map as set in
/etc/sysconfig/keyboard.  This can be selected using the kbdconfig utility.
You should leave this enabled for most machines."),
kheader => __("Automatic regeneration of kernel header in /boot for
/usr/include/linux/{autoconf,version}.h"),
kudzu => __("Automatic detection and configuration of hardware at boot."),
linuxconf => __("Linuxconf will sometimes arrange to perform various tasks
at boot-time to maintain the system configuration."),
lpd => __("lpd is the print daemon required for lpr to work properly. It is
basically a server that arbitrates print jobs to printer(s)."),
lvs => __("Linux Virtual Server, used to build a high-performance and highly
available server."),
named => __("named (BIND) is a Domain Name Server (DNS) that is used to resolve
host names to IP addresses."),
netfs => __("Mounts and unmounts all Network File System (NFS), SMB (Lan
Manager/Windows), and NCP (NetWare) mount points."),
network => __("Activates/Deactivates all network interfaces configured to start
at boot time."),
nfs => __("NFS is a popular protocol for file sharing across TCP/IP networks.
This service provides NFS server functionality, which is configured via the
/etc/exports file."),
nfslock => __("NFS is a popular protocol for file sharing across TCP/IP
networks. This service provides NFS file locking functionality."),
numlock => __("Automatically switch on numlock key locker under console
and XFree at boot."),
oki4daemon => __("Support the OKI 4w and compatible winprinters."),
pcmcia => __("PCMCIA support is usually to support things like ethernet and
modems in laptops.  It won't get started unless configured so it is safe to have
it installed on machines that don't need it."),
portmap => __("The portmapper manages RPC connections, which are used by
protocols such as NFS and NIS. The portmap server must be running on machines
which act as servers for protocols which make use of the RPC mechanism."),
postfix => __("Postfix is a Mail Transport Agent, which is the program that
moves mail from one machine to another."),
random => __("Saves and restores system entropy pool for higher quality random
number generation."),
rawdevices => __("Assign raw devices to block devices (such as hard drive
partitions), for the use of applications such as Oracle"),
routed => __("The routed daemon allows for automatic IP router table updated via
the RIP protocol. While RIP is widely used on small networks, more complex
routing protocols are needed for complex networks."),
rstatd => __("The rstat protocol allows users on a network to retrieve
performance metrics for any machine on that network."),
rusersd => __("The rusers protocol allows users on a network to identify who is
logged in on other responding machines."),
rwhod => __("The rwho protocol lets remote users get a list of all of the users
logged into a machine running the rwho daemon (similiar to finger)."),
sound => __("Launch the sound system on your machine"),
syslog => __("Syslog is the facility by which many daemons use to log messages
to various system log files.  It is a good idea to always run syslog."),
usb => __("Load the drivers for your usb devices."),
xfs => __("Starts the X Font Server (this is mandatory for XFree to run)."),
    );
    my ($name, $prefix) = @_;
    my $s = $services{$name};
    if ($s) {
	$s = translate($s);
    } else {
	$s = -e "$prefix/etc/rc.d/init.d/$name" && cat_("$prefix/etc/rc.d/init.d/$name");
	$s ||= -e "$prefix/etc/init.d/$name" && cat_("$prefix/etc/init.d/$name");
	$s ||= -e "$prefix/etc/xinetd.d/$name" && cat_("$prefix/etc/xinetd.d/$name");
	$s =~ s/\\\s*\n#\s*//mg;
	if ($s =~ /^# description:\s+\S/sm) {
	    ($s) = $s =~ /^# description:\s+(.*?)^(?:[^#]|# {0,2}\S)/sm;
	} else {
	    ($s) = $s =~ /^#\s*(.*?)^[^#]/sm;
	}
	$s =~ s/#\s*//mg;
    }
    $s =~ s/\n/ /gm; $s =~ s/\s+$//;
    $s;
}

sub ask_install_simple {
    my ($in, $prefix) = @_;
    my ($l, $on_services) = services($prefix);
    $in->ask_many_from_list("drakxservices",
			    _("Choose which services should be automatically started at boot time"),
			    {
			     list => $l,
			     help => sub { description($_, $prefix) },
			     values => $on_services,
			     sort => 1,
			    });
}

sub ask_install {
    my ($in, $prefix) = @_;
    my %root_services = (
			 _("Printing") => [ qw(cups lpr oki4daemon) ],
			 _("Internet") => [ qw(httpd ftp proftpd wuftpd) ],
			 _("File sharing") => [ qw(nfs nfslock smb nettalk) ],
			 _("System") => [ qw(usb usbd pcmcia irda xinetd inetd kudzu harddrake apmd sound network xfs) ],
			 _("Remote Administration") => [ qw(sshd telnetd webmin) ],
			 _("Database Server") => [ qw(mysql postgresql) ],
			);
    my %services_root;
    foreach my $root (keys %root_services) {
	$services_root{$_} = $root foreach @{$root_services{$root}};
    }
    my ($l, $on_services) = services($prefix);
    my %services;
    $services{$_} = 0 foreach @{$l || []};
    $services{$_} = 1 foreach @{$on_services || []};

    $in->ask_browse_tree_info('drakxservices', _("Choose which services should be automatically started at boot time"),
			      {
			       node_state => sub { $services{$_[0]} ? 'selected' : 'unselected' },
			       build_tree => sub {
				   my ($add_node, $flat) = @_;
				   $add_node->($_, !$flat && ($services_root{$_} || _("Other")))
				     foreach sort keys %services;
			       },
			       grep_unselected => sub { grep { !$services{$_} } @_ },
			       toggle_nodes => sub {
				   my ($set_state, @nodes) = @_;
				   my $new_state = !$services{$nodes[0]};
				   foreach (@nodes) {
				       $set_state->($_, $new_state ? 'selected' : 'unselected');
				       $services{$_} = $new_state;
				   }
			       },
			       get_status => sub {
				   _("Services: %d activated for %d registered", 
				     scalar(grep { $_ } values %services),
				     scalar(values %services));
			       },
			       get_info => sub { formatLines(description($_[0], $prefix)) },
			      }) or return ($l, $on_services); #- no change on cancel.
    ($l, [ grep { $services{$_} } @$l ]);
}

sub ask_standalone_gtk {
    my ($in, $prefix) = @_;
    my ($l, $on_services) = services($prefix);
    my $W = my_gtk->new(_("Services"));
    my ($x, $y, $w_popup);
    my $nopop = sub { $w_popup and $w_popup->destroy };
    my $display = sub { $nopop->(); $_[0] and gtkmove(gtkshow(gtkadd($w_popup=new Gtk::Window (-popup),
        				       gtksignal_connect(gtkadd(new Gtk::EventBox(),
        				           gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'),
        					   gtkset_justify(new Gtk::Label($_[0]), 0))),
        					   button_press_event => sub { $nopop->() }
		      ))), $x, $y) };
    my $update_service = sub {
		my $started = -e "/var/lock/subsys/$_[0]";
                my $action = $started ? "stop" : "start";
                $_[1]->set($started ? _("running") : _("stopped"));
                $started, $action;
    };
    my $strip = sub {
                my $infos_old = $_[0];
                my $infos;
		while ($infos_old =~ s/(.{40})//) {
                    $1 =~ /(.*) ([^ ]*)/;
		    $infos .= "$1\n$2";
                }
                $infos .= $infos_old;
    };
    my $b = new Gtk::EventBox();
    $b->set_events(["pointer_motion_mask"]);
    gtkadd($W->{window}, gtkadd($b, gtkpack_($W->create_box_with_title(_("Services and deamons")),
	1, gtkset_usize(createScrolledWindow(create_packtable({ col_spacings => 10, row_spacings => 3 },
	    map {
                my $service = $_;
        	my $infos = $strip->(description($_, $prefix));
                $infos ||= _("No additionnal information\nabout this service, sorry.");
		my $l = new Gtk::Label();
                my ($started, $action) = $update_service->($service, gtkset_justify($l, 0));
		[ gtkpack__(new Gtk::HBox(0,0), $_),
		  gtkpack__(new Gtk::HBox(0,0), $l),
		  gtkpack__(new Gtk::HBox(0,0), gtksignal_connect(new Gtk::Button("Infos"), clicked => sub { $display->($infos) })),
                  gtkpack__(new Gtk::HBox(0,0), gtkset_active(gtksignal_connect(
                          new Gtk::CheckButton(_("On boot")),
                          clicked => sub { if ($_[0]->active) {
                                               "@$on_services" =~ /$service/ or push(@$on_services,$service)
                                           } else {
                                               @$on_services = grep(!/$service/, @$on_services)
                                        }}), "@$on_services" =~ /$service/ )),
		  map { my $a = $_;
                      gtkpack__(new Gtk::HBox(0,0), gtksignal_connect(new Gtk::Button(_($a)),
                          clicked => sub { my $c = "service $service " . (lc($a) eq "start" ? "restart" : lc($a)) . " 2>&1"; local $_=`$c`; s/\033\[[^mG]*[mG]//g;
                                           ($started, $action) = $update_service->($service, $l);
                                           $display->($_);
                                         }
                      )) } ("Start", "Stop")
		]
	    }
            @$l)), 500, 400),
            0, gtkpack(gtkset_border_width(new Gtk::HBox(0,0),5), $W->create_okcancel)
            ))
	  );
    $b->signal_connect( motion_notify_event => sub { my ($w, $e) = @_;
                                                               my ($ox, $oy) = $w->window->get_deskrelative_origin;
                                                               $x = $e->{'x'}+$ox; $y = $e->{'y'}+$oy; });
    $b->signal_connect( button_press_event => sub { $nopop->()});
    $::isEmbedded and Gtk->main_iteration while Gtk->events_pending;
    $::isEmbedded and kill (12, $::CCPID);
    $W->main or return;
    ($l, $on_services);
}

sub ask {    
    my ($in, $prefix) = @_;
    !$::isInstall && ref($in) =~ /gtk/ ? &ask_standalone_gtk : &ask_install;
}

sub doit {
    my ($in, $on_services, $prefix) = @_;
    my ($l, $was_on_services) = services($prefix);

    foreach (@$l) {
	my $before = member($_, @$was_on_services);
	my $after = member($_, @$on_services);
	if ($before != $after) {
	    my $script = "/etc/rc.d/init.d/$_";
	    run_program::rooted($prefix, "chkconfig", $after ? "--add" : "--del", $_);
	    if ($after && cat_("$prefix$script") =~ /^#\s+chkconfig:\s+-/m) {
		run_program::rooted($prefix, "chkconfig", "--level", "35", $_, "on");
	    }
	    if (!$after && $::isStandalone) {
		run_program::rooted($prefix, $script, "stop");
	    }
	}
    }
}

#- returns: 
#--- the listref of installed services
#--- the listref of "on" services
sub services {
    my ($prefix) = @_;
    my $cmd = $prefix && !$::testing ? "chroot $prefix" : "";
    my @l = map { [ /([^\s:]+)/, /\bon\b/ ] } grep { !/:$/ } sort `LANGUAGE=C $cmd /sbin/chkconfig --list`;
    [ map { $_->[0] } @l ], [ map { $_->[0] } grep { $_->[1] } @l ];
}

sub mapgrep(&@) {
    my $f = shift;
    my @l;
    foreach (@_) {
	my ($b, $v) = $f->($_);
	push @l, $v if $b;
    }
    @l;
}

1;
gt;>>>>>> @*\n", rights($s[2]), getpwuid $s[4] || $s[4], getgrgid $s[5] || $s[5], displaySize($s[2]) ? $s[7] : join(", ", unmakedev($s[6])), scalar localtime $s[9], -l $_ ? "$_ -> " . readlink $_ : $_); print $^A; $^A = ''; } else { print "$_\n"; } } } sub cp { my ($force) = getopts(\@_, qw(f)); @_ >= 2 or die "usage: cp [-f] <sources> <dest>\n(this cp does -Rl by default)\n"; my $cp; $cp = sub { my $dest = pop @_; @_ or return; @_ == 1 || -d $dest or die "cp: copying multiple files, but last argument ($dest) is not a directory\n"; foreach my $src (@_) { my $dest = $dest; -d $dest and $dest .= "/" . basename($src); if (-e $dest) { $force ? unlink $dest : die "file $dest already exist\n"; } if (-d $src) { -d $dest or mkdir $dest, mode($src) or die "mkdir: can't create directory $dest: $!\n"; &$cp(glob_($src), $dest); } elsif (-l $src) { unless (symlink((readlink($src) || die "readlink failed: $!"), $dest)) { my $msg = "symlink: can't create symlink $dest: $!\n"; $force ? warn $msg : die $msg; } } else { local (*F, *G); open F, $src or die "can't open $src for reading: $!\n"; open G, "> $dest" or $force or die "can't create $dest : $!\n"; foreach (<F>) { print G $_ } chmod mode($src), $dest; } } }; &$cp(@_); } sub ps { @_ and die "usage: ps\n"; my ($pid, $rss, $cpu, $cmd); my ($uptime) = split ' ', first(cat_("/proc/uptime")); my $hertz = 100; require c; my $page = c::getpagesize() / 1024; open PS, ">&STDOUT"; format PS_TOP = PID RSS %CPU CMD . format PS = @>>>> @>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $pid, $rss, $cpu, $cmd . foreach $pid (sort {$a <=> $b} grep { /\d+/ } all('/proc')) { my @l = split(' ', cat_("/proc/$pid/stat")); $cpu = sprintf "%2.1f", max(0, min(99, ($l[13] + $l[14]) * 100 / $hertz / ($uptime - $l[21] / $hertz))); $rss = (split ' ', cat_("/proc/$pid/stat"))[23] * $page; (($cmd) = cat_("/proc/$pid/cmdline")) =~ s/\0/ /g; $cmd ||= (split ' ', (cat_("/proc/$pid/stat"))[0])[1]; write PS; } } sub dd { my $u = "usage: dd [-h] [-p] [if=<file>] [of=<file>] [bs=<number>] [count=<number>]\n"; my ($help, $percent) = getopts(\@_, qw(hp)); die $u if $help; my %h = (if => *STDIN, of => *STDOUT, bs => 512, count => undef); foreach (@_) { /(.*?)=(.*)/ && exists $h{$1} or die $u; $h{$1} = $2; } local (*IF, *OF); my ($tmp, $nb, $read); ref $h{if} eq 'GLOB' ? *IF = $h{if} : sysopen(IF, $h{if}, 0 ) || die "error: can't open file $h{if}\n"; ref $h{of} eq 'GLOB' ? *OF = $h{of} : sysopen(OF, $h{of}, 0x41) || die "error: can't open file $h{of}\n"; $h{bs} = removeXiBSuffix($h{bs}); for ($nb = 0; !$h{count} || $nb < $h{count}; $nb++) { printf "\r%02.1d%%", 100 * $nb / $h{count} if $h{count} && $percent; $read = sysread(IF, $tmp, $h{bs}) or $h{count} ? die "error: can't read block $nb\n" : last; syswrite(OF, $tmp) or die "error: can't write block $nb\n"; $read < $h{bs} and $read = 1, last; } print STDERR "\r$nb+$read records in\n"; print STDERR "$nb+$read records out\n"; } sub head_tail { my ($h, $n) = getopts(\@_, qw(hn)); $h || @_ > 1 + bool($n) and die "usage: $0 [-h] [-n lines] [<file>]\n"; $n = $n ? shift : 10; local *F; @_ ? open(F, $_[0]) || die "error: can't open file $_[0]\n" : (*F = *STDIN); if ($0 eq 'head') { foreach (<F>) { $n-- or return; print } } else { @_ = (); foreach (<F>) { push @_, $_; @_ > $n and shift; } print @_; } } sub head { $0 = 'head'; &head_tail } sub tail { $0 = 'tail'; &head_tail } sub strings { my ($h, $o, $n) = getopts(\@_, qw(hon)); $h and die "usage: strings [-o] [-n min-length] [<files>]\n"; $n = $n ? shift : 4; $/ = "\0"; @ARGV = @_; my $l = 0; while (<>) { while (/[$printable_chars]{$n,}/og) { printf "%07d ", ($l + length $') if $o; print "$&\n" ; } $l += length; } continue { $l = 0 if eof } } sub hexdump { my $i = 0; $/ = \16; @ARGV = @_; while (<>) { printf "%08lX ", $i; $i += 16; print join(" ", (map { sprintf "%02X", $_ } unpack("C*", $_)), ($_ =~ s/[^$printable_chars]/./og, $_)[1]), "\n"; } } sub more { @ARGV = @_; require devices; my $tty = devices::make('tty'); local *IN; open IN, "<$tty" or die "can't open $tty\n"; my $n = 0; while (<>) { ++$n == 25 and $n = <IN>, $n = 0; print } } sub pack_ { my $t; foreach (@_) { if (-d $_) { pack_(glob_($_)); } else { print -s $_, "\n"; print $_, "\n"; local *F; open F, $_ or die "can't read file $_: $!\n"; while (read F, $t, $BUFFER_SIZE) { print $t; } } } } sub unpack_ { my $t; @_ == 1 or die "give me one and only one file to unpack\n"; local *F; open F, $_[0] or die "can't open file $_: $!\n"; while (1) { my ($size) = chop_(scalar <F>); defined $size or last; $size =~ /^\d+$/ or die "bad format (can't find file size)\n"; my ($filename) = chop_(scalar <F>) or die "expecting filename\n"; print "$filename\n"; my $dir = dirname($filename); -d $dir or mkdir_('-p', $dir); local *G; open G, "> $filename" or die "can't write file $filename: $!\n"; while ($size) { $size -= read(F, $t, min($size, $BUFFER_SIZE)) || die "data for file $filename is missing\n"; print G $t or die "error writing to file $filename: $!\n"; } } } sub insmod { my ($h) = getopts(\@_, qw(h)); $h || @_ == 0 and die "usage: insmod <module> [options]\n"; my $f = local $_ = shift; require run_program; #- try to install the module if it exist else extract it from archive. #- needed for cardmgr. unless (-r $f) { $_ = $1 if m@.*/([^/]*)\.o@; unless (-r ($f = "/lib/modules/$_.o")) { $f = "/tmp/$_.o"; my $cz = "/lib/modules" . (arch() eq 'sparc64' && "64") . ".cz"; -e $cz or $cz .= "2"; if (-e $cz) { run_program::run("extract_archive $cz /tmp $_.o"); } elsif (-e "/lib/modules.cpio.bz2") { run_program::run("cd /tmp ; bzip2 -cd /lib/modules.cpio.bz2 | cpio -i $_.o"); } else { die "unable to find an archive for modules"; } } } -r $f or die "can't find module $_"; run_program::run(["insmod_", "insmod"], "-f", $f, @_) or die("insmod $_ failed"); unlink $f; } sub modprobe { my ($h) = getopts(\@_, qw(h)); $h || @_ == 0 and die "usage: modprobe <module> [options]\n"; my $name = shift; require modules; modules::load_deps("/modules/modules.dep"); modules::load($name, '', @_); } sub route { @_ == 0 or die "usage: route\nsorry, no modification handled\n"; my ($titles, @l) = cat_("/proc/net/route"); my @titles = split ' ', $titles; my %l; open ROUTE, ">&STDOUT"; format ROUTE_TOP = Destination Gateway Mask Iface . format ROUTE = @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<< $l{Destination}, $l{Gateway}, $l{Mask}, $l{Iface} . foreach (@l) { /^\s*$/ and next; @l{@titles} = split; $_ = join ".", reverse map { hex } unpack "a2a2a2a2", $_ foreach @l{qw(Destination Gateway Mask)}; $l{Destination} = 'default' if $l{Destination} eq "0.0.0.0"; $l{Gateway} = '*' if $l{Gateway} eq "0.0.0.0"; write ROUTE; } } sub df { my ($h) = getopts(\@_, qw(h)); my ($dev, $size, $free, $used, $use, $mntpoint); open DF, ">&STDOUT"; format DF_TOP = Filesystem Size Used Avail Use Mounted on . format DF = @<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>>> @>>>>>% @<<<<<<<<<<<<<<<<<<<<<<<<< $dev, $size, $used, $free, $use, $mntpoint . my %h; foreach (cat_("/proc/mounts"), cat_("/etc/mtab")) { ($dev, $mntpoint) = split; $h{$dev} = $mntpoint; } foreach $dev (sort keys %h) { ($size, $free) = common::df($mntpoint = $h{$dev}); $size or next; $use = int (100 * ($size - $free) / $size); $used = $size - $free; if ($h) { $used = int ($used / 1024) . "M"; $size = int ($size / 1024) . "M"; $free = int ($free / 1024) . "M"; } write DF if $size; } } sub kill { my $signal = 15; @_ or die "usage: kill [-<signal>] pids\n"; $signal = (shift, $1)[1] if $_[0] =~ /^-(.*)/; kill $signal, @_ or die "kill failed: $!\n"; } sub lspci { require detect_devices; print join "\n", detect_devices::stringlist(), ''; } *lssbus = *lspci; sub dmesg { print cat_("/tmp/syslog"); } sub sort { my ($n, $h) = getopts(\@_, qw(nh)); $h and die "usage: sort [-n] [<file>]\n"; local *F; @_ ? open(F, $_[0]) || die "error: can't open file $_[0]\n" : (*F = *STDIN); if ($n) { print sort { $a <=> $b } <F>; } else { print sort <F>; } } sub du { my ($s, $h) = getopts(\@_, qw(sh)); $h || !$s and die "usage: du -s [<directories>]\n"; my $f; $f = sub { my ($e) = @_; my $s = (lstat($e))[12]; $s += sum map { &$f($_) } glob_("$e/*") if !-l $e && -d $e; $s; }; print &$f($_) >> 1, "\t$_\n" foreach @_ ? @_ : glob_("*"); } sub install_cpio($$;@) { my ($dir, $name, @more) = @_; return "$dir/$name" if -e "$dir/$name"; my $cpio = "$dir.cpio.bz2"; -e $cpio or return; eval { rm("-r", $dir) }; mkdir $dir, 0755; require run_program; my $more = join " ", map { $_ && "$_ $_/*" } @more; run_program::run("cd $dir ; bzip2 -cd $cpio | cpio -id $name $name/* $more"); "$dir/$name"; } sub bug { my ($h) = getopts(\@_, "h"); $h and die "usage: bug\nput file report.bug on fat formatted floppy\n"; mount "/dev/fd0", "/fd0"; sub header { " ******************************************************************************** * $_[0] ********************************************************************************"; } require detect_devices; local $\ = "\n"; output "/fd0/report.bug", map { chomp; $_ } header("lspci"), detect_devices::stringlist(), header("pci_devices"), cat_("/proc/bus/pci/devices"), header("fdisk"), `fdisk -l`, header("scsi"), cat_("/proc/scsi/scsi"), header("lsmod"), cat_("/proc/modules"), header("cmdline"), cat_("/proc/cmdline"), header("cpuinfo"), cat_("/proc/cpuinfo"), header("syslog"), cat_("/tmp/syslog"), header("ddebug.log"), cat_("/tmp/ddebug.log"), header("install.log"), cat_("/mnt/root/install.log"), ; umount "/fd0"; sync; } #-###################################################################################### #- Wonderful perl :( #-###################################################################################### 1; #