File: postinst

package info (click to toggle)
pdbv 2.0.10.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 436 kB
  • ctags: 52
  • sloc: perl: 1,004; sh: 291; makefile: 129
file content (46 lines) | stat: -rwxr-xr-x 1,007 bytes parent folder | download
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
#!/usr/bin/perl
# Postinst for pdbv

use Debconf::Client::ConfModule ':all';
version('2.0');

# Files
my $conffile = "/etc/pdbv/pdbvrc";
my $tmpfile = "/etc/pdbv/pdbvrc2.tmp";

# Settings
my @settings = ("listing", "output_dir", "cron", "cron_lang", "force");

# Read conffile and replace old values with old ones
open(OUT, ">$tmpfile");
open(IN, "<$conffile");
while (<IN>) {
    my $found;
    foreach my $setting (@settings) {
	if (/^(.*)$setting\=\"(.*)\"\;/) {
	    $$setting = get("pdbv/$setting");
	    if ($setting eq 'force') {
		if ($$setting eq 'true') { $$setting = "1"; } else { $$setting = "0"; }
	    }
	    print OUT "\$$setting=\"$$setting\"\;\n";
	    $found = 1;
	}
    }
    next if $found;
    print OUT $_;
}
close(OUT);
close(IN);

`mv -f $tmpfile $conffile`;

# Make sure that no old crontab file remains
`rm -f /etc/cron.d/pdbv2* /etc/cron.daily/pdbv`;


# Create output dir. Nobody as no write access in /var/www usually
`mkdir -p $output_dir`;
`chown nobody $output_dir`;


exit;