This file is indexed.

postinst is in slbackup 0.0.12-8.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
#!/usr/bin/perl -w
#
# slbackup postinst script using debconf
#
# Written by Morten Werner Olsen <werner@skolelinux.no>
#

use strict;
use Debconf::Client::ConfModule ":all";
use Config::General;
use File::Path qw(make_path);


## subsections
sub writeconfig {
    my ($datafilename, $data) = @_;
}

## start postinst

if ($ARGV[0] and $ARGV[0] eq "configure") {
    # fetch debconf-variables for slbackup
    my $enable = get("slbackup/enable");
    my $backuptime = get("slbackup/backuptime");
    my $client_name = get("slbackup/client_name");
    my $client_type = get("slbackup/client_type");
    my $client_address = get("slbackup/client_address");
    my $client_user = get("slbackup/client_user");
    my $client_location = get("slbackup/client_location");
    my $client_keep = get("slbackup/client_keep");
    my $server_type = get("slbackup/server_type");
    my $server_destdir = get("slbackup/server_destdir");
    my $server_address = get("slbackup/server_address");
    my $server_user = get("slbackup/server_user");

    # check if config-file (/etc/slbackup/slbackup.conf) exists, and
    # if it doesn't, we'll make one
    if  ( ! -e "/etc/slbackup/slbackup.conf" ) {
	# make config file
	my %confighash;
	my $config = \%confighash;
	$config->{client}->{$client_name}->{address} = $client_address;
	$config->{client}->{$client_name}->{type} = $client_type;
	$config->{client}->{$client_name}->{user} = $client_user;
	my @location = split(/ /, $client_location);
	if (scalar(@location) eq 1) {
	    $config->{client}->{$client_name}->{location} = $location[0];
	} elsif (scalar(@location) gt 1) {
	    @{$config->{client}->{$client_name}->{location}} = @location;
	}
	$config->{client}->{$client_name}->{keep} = $client_keep;
	$config->{server_type} = $server_type;
	$config->{server_destdir} = $server_destdir;
	if ( ! -e "$server_destdir" ) {
		make_path("$server_destdir", {
		                owner => 'root',
		                group => 'root',
		                mode => '0700',
		          }
		);
	}
	$config->{server_address} = $server_address;
	$config->{server_user} = $server_user;
	
	# write configuration file
	my $datafile = new Config::General();
	$datafile->save_file("/etc/slbackup/slbackup.conf", $config);
    }

    # check if file specifying cron-job exists and if the user wanted to
    # configure slbackup now, and make one the answers to both questions
    # are "yes"
    if ( ! -e "/etc/cron.d/slbackup" and $enable eq "true") {
	# make cron-job
	my $crontab = "# cron job for Skolelinux Backup (once a day)\n";
	if ($enable eq "false") { $crontab .= "#"; }
	my ($hour, $min) = split(/:/, $backuptime);
	$crontab .= "$min $hour * * * root if [ -x " .
	    "/usr/share/slbackup/slbackup-cron -a -f " .
	    "/etc/slbackup/slbackup.conf ]; then " . 
	    "/usr/share/slbackup/slbackup-cron ; fi\n";

	open(CRONFILE, ">/etc/cron.d/slbackup");
	print(CRONFILE "$crontab");
	close(CRONFILE);
    }

}

system("dpkg-maintscript-helper rm_conffile /etc/cron.daily/slbackup 0.0.12-3 -- \"".@ARGV."\"");

system('

');