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
|
#! /usr/bin/perl
# post install script for the Debian GNU/Linux sendfile package
require DebianNet;
# First modify the services file
open(SERVICES, "/etc/services");
@services=<SERVICES>;
close(SERVICES);
if (! grep(/^saft.*/, @services)) {
push (@services, "saft 487/tcp # simple asynchronous file transfer\n");
open(SERVICES, ">/etc/services.new");
print SERVICES @services;
close (SERVICES);
system ("mv -f /etc/services.new /etc/services");
}
# Now modify the inetd.conf file
open(INETD, "/etc/inetd.conf");
@inetd=<INETD>;
close(INETD);
if (! grep(/.*sendfiled/, @inetd)) {
$newentry = 'saft stream tcp nowait root /usr/sbin/tcpd /usr/sbin/sendfiled';
$DebianNet::sep = "#<off># "; DebianNet::add_service($newentry, "OTHER");
}
undef(@inetd);
for $profile (('/etc/profile')) {
open(PROFILE, "$profile");
@profile=<PROFILE>;
close(PROFILE);
if (! grep(/^.*check-sendfile/, @profile)) {
open(PROFILE, ">>$profile");
print PROFILE "test -x /usr/bin/check-sendfile && /usr/bin/check-sendfile || /bin/true\n";
close (PROFILE);
}
}
for $profile (('/etc/csh.login')) {
open(PROFILE, "$profile");
@profile=<PROFILE>;
close(PROFILE);
if (grep(/^.*check-sendfile/, @profile)) {
open(PROFILE, ">$profile");
printf PROFILE "%s", join ('', grep (!/^.*check-sendfile/, @profile));
close(PROFILE);
}
}
system "/etc/init.d/netbase reload";
if ($ARGV[0] eq 'configure') {
if (defined $ARGV[1] && $ARGV[1] =~ /2\.1b(-[67]|\.20080311-|\.20080616-1)/) {
system "chmod 644 /etc/logrotate.d/sendfile";
}
}
|