~ubuntu-branches/ubuntu/wily/calamaris/wily

« back to all changes in this revision

Viewing changes to debian/config

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Frauenfelder
  • Date: 2004-06-08 14:26:25 UTC
  • Revision ID: james.westby@ubuntu.com-20040608142625-5bqiw8figzmdpg8j
Tags: 2.59-1
New upstream release. Closes: #253093: New upstream version of Calamaris

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl -w
 
2
 
 
3
use strict;
 
4
use Debconf::Client::ConfModule ':all';
 
5
 
 
6
my $debug = 0;
 
7
 
 
8
version('2.0');
 
9
my $capb=capb('backup');
 
10
 
 
11
my @ret;
 
12
 
 
13
# Step 1: Put the current settings into the DebConf database
 
14
if (open(CONFIG, '/etc/calamaris.conf')) {
 
15
    while(<CONFIG>) {
 
16
        chomp;
 
17
        (/^daily:/) && do {
 
18
            my ($when, $mail, $web, $task, $title) = split(/:/);
 
19
            $title =~ s/^'(.*)'$/$1/;
 
20
            print STDERR "daily = ($when, $mail, $web, $task, $title)\n",
 
21
            if ($debug);
 
22
            set('calamaris/daily/mail', $mail);
 
23
            set('calamaris/daily/html', $web);
 
24
            set('calamaris/daily/title', $title);
 
25
            set('calamaris/daily/task', $task);
 
26
        };
 
27
        (/^weekly:/) && do {
 
28
            my ($when, $mail, $web, $task, $title) = split(/:/);
 
29
            $title =~ s/^'(.*)'$/$1/;
 
30
            print STDERR "weekly = ($when, $mail, $web, $task, $title)\n",
 
31
            if ($debug);
 
32
            set('calamaris/weekly/mail', $mail);
 
33
            set('calamaris/weekly/html', $web);
 
34
            set('calamaris/weekly/title', $title);
 
35
            set('calamaris/weekly/task', $task);
 
36
        };
 
37
        (/^monthly:/) && do {
 
38
            my ($when, $mail, $web, $task, $title) = split(/:/);
 
39
            $title =~ s/^'(.*)'$/$1/;
 
40
            print STDERR "monthly = ($when, $mail, $web, $task, $title)\n",
 
41
            if ($debug);
 
42
            set('calamaris/monthly/mail', $mail);
 
43
            set('calamaris/monthly/html', $web);
 
44
            set('calamaris/monthly/title', $title);
 
45
            set('calamaris/monthly/task', $task);
 
46
        };
 
47
        (/^cache=/) && do {
 
48
            s/^cache=//;
 
49
            set('calamaris/cache_type', $_);
 
50
        };
 
51
    }
 
52
}
 
53
close(CONFIG);
 
54
 
 
55
my $state = 0;
 
56
while (($state >= 0) && ($state <= 5)) {
 
57
    if ($state == 0) {
 
58
        input("high", "calamaris/transition");
 
59
        @ret = go();
 
60
    }
 
61
 
 
62
    if ($state == 1) {
 
63
        @ret = input("low", "calamaris/cache_type");
 
64
        print STDERR "ret = ", @ret, "\n", if ($debug);
 
65
        @ret = go();
 
66
    }
 
67
 
 
68
# select tasks block
 
69
    if ($state == 2) {
 
70
        beginblock();
 
71
        @ret = input("medium", "calamaris/daily/task");
 
72
        print STDERR "ret = ", @ret, "\n", if ($debug);
 
73
        @ret = input("medium", "calamaris/weekly/task");
 
74
        print STDERR "ret = ", @ret, "\n", if ($debug);
 
75
        @ret = input("medium", "calamaris/monthly/task");
 
76
        print STDERR "ret = ", @ret, "\n", if ($debug);
 
77
        endblock();
 
78
        @ret = go();
 
79
    }
 
80
 
 
81
# daily block
 
82
    if ($state == 3) {
 
83
        if (get('calamaris/daily/task') ne 'nothing') {
 
84
            beginblock();
 
85
            if (get('calamaris/daily/task') ne 'web') {
 
86
                @ret = input("medium", "calamaris/daily/mail");
 
87
                print STDERR "ret = ", @ret, "\n", if ($debug);
 
88
            }
 
89
            if (get('calamaris/daily/task') ne 'mail') {
 
90
                @ret = input("medium", "calamaris/daily/html");
 
91
                print STDERR "ret = ", @ret, "\n", if ($debug);
 
92
            }
 
93
            @ret = input("medium", "calamaris/daily/title");
 
94
            print STDERR "ret = ", @ret, "\n", if ($debug);
 
95
            endblock();
 
96
            @ret = go();
 
97
        }
 
98
    }
 
99
 
 
100
 
 
101
# weekly block
 
102
    if ($state == 4) {
 
103
        if (get('calamaris/weekly/task') ne 'nothing') {
 
104
            beginblock();
 
105
            if ( (get('calamaris/daily/task') eq 'mail') ||
 
106
                 (get('calamaris/daily/task') eq 'both')) {
 
107
                my $mail = get('calamaris/daily/mail');
 
108
                set('calamaris/weekly/mail', $mail);
 
109
            }
 
110
            if (get('calamaris/weekly/task') ne 'web') {
 
111
                input("medium", "calamaris/weekly/mail");
 
112
            }
 
113
            if (get('calamaris/weekly/task') ne 'mail') {
 
114
                input("medium", "calamaris/weekly/html");
 
115
            }
 
116
            input("medium", "calamaris/weekly/title");
 
117
            endblock();
 
118
            @ret = go();
 
119
        }
 
120
    }
 
121
 
 
122
# monthly block
 
123
    if ($state == 5) {
 
124
        if (get('calamaris/monthly/task') ne 'nothing') {
 
125
            beginblock();
 
126
            if ( (get('calamaris/daily/task') eq 'mail') ||
 
127
                 (get('calamaris/daily/task') eq 'both')) {
 
128
                my $mail = get('calamaris/daily/mail');
 
129
                set('calamaris/monthly/mail', $mail);
 
130
            }
 
131
            if ( (get('calamaris/weekly/task') eq 'mail') ||
 
132
                 (get('calamaris/weekly/task') eq 'both')) {
 
133
                my $mail = get('calamaris/weekly/mail');
 
134
                set('calamaris/monthly/mail', $mail);
 
135
            }
 
136
            if (get('calamaris/monthly/task') ne 'web') {
 
137
                input("medium", "calamaris/monthly/mail");
 
138
            }
 
139
            if (get('calamaris/monthly/task') ne 'mail') {
 
140
                input("medium", "calamaris/monthly/html");
 
141
            }
 
142
            input("medium", "calamaris/monthly/title");
 
143
            endblock();
 
144
            @ret = go();
 
145
        }
 
146
    }
 
147
 
 
148
    print STDERR "ret = ", @ret, "\n", if ($debug);
 
149
    if ($ret[0] == 0) {
 
150
        $state ++;
 
151
    } else {
 
152
        $state --;
 
153
    }
 
154
}
 
155
 
 
156
open(CONF, "> /etc/calamaris.conf");
 
157
print CONF <<'ENDOFTEXT'
 
158
# configuration file for calamaris
 
159
# by Philipp Frauenfelder <pfrauenf@debian.org>
 
160
# 1998-10-09
 
161
 
 
162
# There are three categories: daily, weekly and monthly. For each of these
 
163
# one line is responsible. There must be a line for each category but only 
 
164
# one.
 
165
 
 
166
# cat: [daily|weekly|monthly]
 
167
# mailto: mailaddress, eg. root
 
168
# webto: path incl. file name, eg. /var/www/calamaris/daily.html. 
 
169
#        The script does currently not check wether the directory 
 
170
#        exists and fails with a rather ugly error.
 
171
# todo: [nothing|mail|web|both]
 
172
# title: try it :-)
 
173
 
 
174
# cat:mailto:webto:todo:title
 
175
ENDOFTEXT
 
176
    ;
 
177
 
 
178
print CONF 'daily:' .
 
179
    get('calamaris/daily/mail') . ':' .
 
180
    get('calamaris/daily/html') . ':' .
 
181
    get('calamaris/daily/task') . ':' .
 
182
    "'" . get('calamaris/daily/title') . "'\n";
 
183
print CONF 'weekly:' .
 
184
    get('calamaris/weekly/mail') . ':' .
 
185
    get('calamaris/weekly/html') . ':' .
 
186
    get('calamaris/weekly/task') . ':' .
 
187
    "'" . get('calamaris/weekly/title') . "'\n";
 
188
print CONF 'monthly:' .
 
189
    get('calamaris/monthly/mail') . ':' .
 
190
    get('calamaris/monthly/html') . ':' .
 
191
    get('calamaris/monthly/task') . ':' .
 
192
    "'" . get('calamaris/monthly/title') . "'\n";
 
193
 
 
194
print CONF <<'ENDOFTEXT'
 
195
# what log files should be parsed: [auto|squid|oops]
 
196
#       auto: tries to find the log files in this order: squid, oops
 
197
#       squid: parses a squid log file if available
 
198
#       oops: parses a oops log file if available
 
199
ENDOFTEXT
 
200
    ;
 
201
 
 
202
print CONF 'cache=' . get('calamaris/cache_type') . "\n";