Skip to content
Newer
Older
100755 202 lines (152 sloc) 4.74 KB
2d38b94 @racke Default traffic setting is low now.
racke authored Jan 14, 2003
1 #! /usr/bin/perl
dc79e7d @racke copyleft added
racke authored Aug 6, 2001
2 #
b0b9e0e @racke add description on FULL_URL setting to interchangeconfig's POD
racke authored Apr 29, 2010
3 # Copyright 2001,2003,2004,2005,2009,2010 by Stefan Hornburg (Racke) <racke@linuxia.de>
dc79e7d @racke copyleft added
racke authored Aug 6, 2001
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public
16 # License along with this program; if not, write to the Free
07f71a7 @pajamian New Free Software Foundation Address in headers of various files
pajamian authored Mar 30, 2007
17 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 # MA 02110-1301 USA.
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored Jul 18, 2001
19
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
20 use strict;
2d38b94 @racke Default traffic setting is low now.
racke authored Jan 14, 2003
21 use warnings;
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored Jul 18, 2001
22
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
23 # constants we use
24 my $lock_ex = 2;
25 my $lock_un = 8;
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored Jul 18, 2001
26
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
27 # configuration files which we modify
28 my $featconf = '/etc/interchange/features.cfg';
29 my $settingsconf = '/etc/interchange/settings.cfg';
30
31 # Interchange variables
ece4ce5 @racke default for robots should be 1
racke authored Apr 12, 2003
32 my %setvars = (DEBUG => 0, FULL_URL => 0, ROBOTS => 1, SOAP => 0,
ec1a293 @racke Swish setting added
racke authored Sep 22, 2005
33 SWISH => 0, TRAFFIC => 'low', UI_LOCALE => 'en_US');
b7db2a6 @racke robots and soap debconf options added
racke authored Apr 10, 2003
34 my %requires = (SOAP => ['SOAP::Lite']);
059e10b @racke initial effort to replacing foundation with standard catalog in Debia…
racke authored Aug 3, 2004
35 my %featvars = (UI => '', USE_FOUNDATION => '', USE_STANDARD => '',
36 MV_GETPPID_BROKEN => 0);
31ad03e @racke don't override command line settings
racke authored Aug 6, 2001
37 my %skipvars;
38
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
39 # other variables
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
40 my (@tokens, $varref);
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
41
42 # parse commandline
43 for (@ARGV) {
44 unless (/\S+=/) {
45 die "$0: invalid parameter '$_'\n";
46 }
47 @tokens = split(/=/);
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
48 if (exists($setvars{$tokens[0]})) {
49 $varref = \%setvars;
50 } elsif (exists($featvars{$tokens[0]})) {
51 $varref = \%featvars;
52 } else {
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
53 die "$0: no such variable $tokens[0]\n";
54 }
55 if (defined $tokens[1]) {
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
56 $varref->{$tokens[0]} = $tokens[1];
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
57 } else {
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
58 $varref->{$tokens[0]} = '';
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
59 }
31ad03e @racke don't override command line settings
racke authored Aug 6, 2001
60 # don't override these settings
61 $skipvars{$tokens[0]} = 1;
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
62 }
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored Jul 18, 2001
63
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
64 # modify features configuration
65 &update_configfile($featconf, 0, \%featvars);
66
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
67 # modify settings configuration
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
68 &update_configfile($settingsconf, 1, \%setvars);
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored Jul 18, 2001
69
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
70 sub update_configfile {
71 my ($configfile, $modsallowed, $varref) = @_;
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
72
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
73 if (-f $configfile) {
74 open (SCONF, "+<$configfile")
75 || die ("$0: Couldn't open $configfile: $!\n");
76 flock (SCONF, $lock_ex);
77 while (<SCONF>) {
78 # strip leading/trailing whitespace
79 s/^\s+//; s/^\s+$//;
80 # skip comment lines/blank lines
81 next if /^\#/; next unless /\S/;
82 # check for "Variable"'s
83 @tokens = split (/\s+/, $_, 3);
84 next if $tokens[0] ne 'Variable';
85 next if exists $skipvars{$tokens[1]};
86 # record values found
87 if (exists $varref->{$tokens[1]}) {
88 if (defined $tokens[2]) {
89 $varref->{$tokens[1]} = $tokens[2];
90 } else {
91 $varref->{$tokens[1]} = '';
92 }
93 }
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
94 }
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
95 truncate (SCONF, 0)
96 || die ("$0: Couldn't truncate $configfile: $!\n");
97 seek (SCONF, 0, 0)
98 || die ("$0: Seek failed on $configfile: $!\n");
99 } else {
100 open (SCONF, ">$configfile")
101 || die ("$0: Couldn't open $configfile: $!\n");
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
102 }
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
103
104 if ($modsallowed) {
105 print SCONF <<EOF;
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
106 # This file is automatically generated by $0.
107 # You may modify this file, but this is NOT recommended.
108
109 EOF
17cf6d5 @racke handle features.cfg too now
racke authored Aug 12, 2001
110 } else {
111 print SCONF <<EOF;
112 # This file is automatically generated by $0.
113 # You may NOT modify this file, because it reflects the
114 # installation state of the Interchange packages.
115
116 EOF
117 }
118
119 for (sort (keys %$varref)) {
120 print SCONF "Variable $_ $varref->{$_}\n";
121 }
122 flock (SCONF, $lock_un);
123 close (SCONF)
124 || die ("$0: Couldn't close $configfile: $!\n");
be8d23b @racke complete rewrite started
racke authored Aug 6, 2001
125 }
1646c9d @racke POD documentation introduced
racke authored Aug 12, 2001
126
127
128 =head1 NAME
129
130 interchangeconfig - Updates Debian specific Interchange configuration files
131
132 =head1 DESCRIPTION
133
134 interchangeconfig reads and writes the Interchange configuration files
135 /etc/interchange/features.cfg and /etc/interchange/settings.cfg.
136
baa99da @racke added selection of configuration options to POD
racke authored Feb 13, 2004
137 The following settings can be changed with C<interchangeconfig>:
138
139 =over 4
140
141 =item C<DEBUG>
142
143 Whether to enable debug mode or not.
144
145 =back
146
147 =over 4
148
b0b9e0e @racke add description on FULL_URL setting to interchangeconfig's POD
racke authored Apr 29, 2010
149 =item C<FULL_URL>
150
151 Whether to enable FullUrl configuration directive or not.
152
153 =back
154
155 =over 4
156
baa99da @racke added selection of configuration options to POD
racke authored Feb 13, 2004
157 =item C<ROBOTS>
158
159 The Interchange Debian package uses a separate configuration file
160 C</etc/interchange/robots.cfg> for the directives C<RobotUA>, C<RobotIP>
161 and C<RobotHost>. It is recommended to include these settings so
162 Interchange can distinguish between robots and ordinary users.
163
164 =back
165
166 =over 4
167
ec1a293 @racke Swish setting added
racke authored Sep 22, 2005
168 =item C<SWISH>
169
170 Whether to enable Swish search or not.
171
64a97e8 @racke Fix misplaced =back in interchangeconfig's POD.
racke authored Apr 29, 2010
172 =back
173
ec1a293 @racke Swish setting added
racke authored Sep 22, 2005
174 =over 4
175
baa99da @racke added selection of configuration options to POD
racke authored Feb 13, 2004
176 =item C<SOAP>
177
178 This setting determines if Interchange starts the SOAP server as well.
179 This is only available if the Perl module SOAP::Lite is installed.
180
181 =back
182
183 =over 4
184
185 =item C<TRAFFIC>
186
187 You can choose different sets of server parameters (C<low>, C<high> and
188 C<rpc>). Any store based on the foundation demo will change its behaviour too.
189 If C<rpc> is selected, the Interchange server will run in PreFork mode.
190
191 =back
192
1646c9d @racke POD documentation introduced
racke authored Aug 12, 2001
193 =head1 AUTHOR
194
195 Stefan Hornburg (Racke), racke@linuxia.de
196
197 =head1 SEE ALSO
198
199 interchange(1p)
200
57c434e @racke fix POD errors and remove extraneous whitespace
racke authored Oct 29, 2009
201 =cut
Something went wrong with that request. Please try again.