/
interchange.config
executable file
·194 lines (171 loc) · 4.74 KB
/
interchange.config
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#! /bin/sh -e
#
# Copyright 2000,2001,2002,2003,2004,2005,2007 by Stefan Hornburg (Racke) <racke@linuxia.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA.
# Source debconf library
. /usr/share/debconf/confmodule
if [ -e /etc/interchange/init.cfg ]; then
# Read current state from configuration file
. /etc/interchange/init.cfg || true
if [ "$MODE" = "--unix" ]; then
db_set interchange/mode "unix mode"
elif [ "$MODE" = "--inetmode" ]; then
db_set interchange/mode "internet mode"
else
db_set interchange/mode "both"
fi
db_set interchange/group $GROUP
db_set interchange/user $USER
if [ "$DOCROOT" ]; then
db_set interchange/docroot $DOCROOT
fi
if [ "$GPGHOME" ]; then
db_set interchange/gpghome $GPGHOME
fi
if [ "$WEBSERVER" ]; then
db_set interchange/webserver $WEBSERVER
fi
fi
# Which mode we should use ?
db_input medium interchange/mode || [ $? -eq 30 ]
db_go
# Remember old interchange user/group configuration
db_get interchange/user || [ $? -eq 30 ]
OLDUSER=$RET
db_set interchange/olduser $OLDUSER
# Which user should be choosed for the interchange server ?
HAVEUSER=0
while [ $HAVEUSER -eq 0 ]; do
db_input medium interchange/user || [ $? -eq 30 ]
db_go
db_get interchange/user
USER=$RET
if [ -z "$USER" ]; then
USER=interchange
fi
if [ "$USER" = root ]; then
db_input medium interchange/usernoroot || [ $? -eq 30 ]
db_go
elif grep -q ^$USER: /etc/passwd; then
HAVEUSER=1
else
db_subst interchange/createuser USER $USER
db_input medium interchange/createuser || [ $? -eq 30 ]
db_go
db_get interchange/createuser || [ $? -eq 30 ]
CREATEUSER=$RET
if [ "$CREATEUSER" = true ]; then
HAVEUSER=1
fi
fi
if [ $HAVEUSER -eq 0 ]; then
db_fset interchange/user isdefault true
db_reset interchange/user
db_fset interchange/createuser isdefault true
db_reset interchange/createuser
fi
done
# Which group should be choosed for the interchange server ?
HAVEGROUP=0
while [ $HAVEGROUP -eq 0 ]; do
db_input medium interchange/group || [ $? -eq 30 ]
db_go
db_get interchange/group
GROUP=$RET
if [ -z "$GROUP" ]; then
GROUP=interchange
fi
if [ "$GROUP" = root ]; then
db_input medium interchange/groupnoroot || [ $? -eq 30 ]
db_go
elif grep -q ^$GROUP: /etc/group; then
HAVEGROUP=1
else
db_subst interchange/creategroup GROUP $GROUP
db_input medium interchange/creategroup || [ $? -eq 30 ]
db_go
db_get interchange/creategroup || [ $? -eq 30 ]
CREATEGROUP=$RET
if [ "$CREATEGROUP" = true ]; then
HAVEGROUP=1
fi
fi
if [ $HAVEGROUP -eq 0 ]; then
# no appropriate group, reset and try again
db_fset interchange/group isdefault true
db_reset interchange/group
db_fset interchange/creategroup isdefault true
db_reset interchange/creategroup
fi
done
# Settings
if [ -f /etc/interchange/settings.cfg ]; then
exec 4</etc/interchange/settings.cfg
while read <&4 variable name value; do
if [ "$variable" = "Variable" ]; then
FLAG=false
if [ "$value" = "1" ]; then
FLAG=true
fi
if [ "$name" = "FULL_URL" ]; then
db_set interchange/full_url $FLAG
fi
if [ "$name" = "ROBOTS" ]; then
db_set interchange/robots $FLAG
fi
if [ "$name" = "SOAP" ]; then
db_set interchange/soap $FLAG
fi
if [ "$name" = "TRAFFIC" ]; then
db_set interchange/traffic $value
fi
fi
done
fi
# FullURL directive
db_input low interchange/full_url || [ $? -eq 30 ]
db_go
# SOAP server
if /usr/bin/perl -MSOAP::Lite -e '' 2>/dev/null; then
db_set interchange/cansoap true
db_input low interchange/soap || [ $? -eq 30 ]
else
db_input low interchange/cansoap || [ $? -eq 30 ]
fi
# Inclusion of robots directives
db_input low interchange/robots || [ $? -eq 30 ]
db_go
# Traffic mode
db_input medium interchange/traffic || [ $? -eq 30 ]
db_go
# GNUPG Home
db_input low interchange/gpghome || [ $? -eq 30 ]
db_go
# Webserver
if [ -x /usr/sbin/apache2ctl ]; then
if [ -x /usr/sbin/apachectl ]; then
db_input medium interchange/webserver || [ $? -eq 30 ]
db_go
else
db_set interchange/webserver Apache2
fi
else
db_set interchange/webserver Apache
fi
# Catalog configuration
db_input medium interchange/docroot || [ $? -eq 30 ]
db_go