Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 41508 | Differences between
and this patch

Collapse All | Expand All

(-)zope-config.original (-38 / +116 lines)
Lines 5-16 Link Here
5
# Originally written by Jason Shoemaker <kutsuya@gentoo.org>
5
# Originally written by Jason Shoemaker <kutsuya@gentoo.org>
6
# Portions by solution2u.net gmbh (Logging and some cleanups)
6
# Portions by solution2u.net gmbh (Logging and some cleanups)
7
# Portions by Robin Johnson <robbat2@gentoo.org> (Documentation and further cleanup)
7
# Portions by Robin Johnson <robbat2@gentoo.org> (Documentation and further cleanup)
8
# Portions by Carter Smithhart <derheld42@derheld.net> (2.7.0 stuff)
8
#
9
#
9
# Copyright 1999-2003 Gentoo Technologies, Inc.
10
# Copyright 1999-2003 Gentoo Technologies, Inc.
10
# Distributed under the terms of the GNU General Public License v2
11
# Distributed under the terms of the GNU General Public License v2
11
# $Header: /home/cvsroot/gentoo-x86/app-admin/zope-config/files/0.3/zope-config,v 1.2 2003/12/12 07:40:57 lanius Exp $
12
# $Header: /home/cvsroot/gentoo-x86/app-admin/zope-config/files/0.3/zope-config,v 1.2 2003/12/12 07:40:57 lanius Exp $
12
13
#
13
VERSION="0.2"
14
#
15
# Notes:
16
#  $ZI_DIR/.default holds name of default zope instance
17
#  $NEWZOPE is set to 1 if the zope server is 2.7.0 or newer
18
#
19
VERSION="0.3"
14
20
15
CONFIGFILE=/etc/zope-config.conf
21
CONFIGFILE=/etc/zope-config.conf
16
if [ -e ${CONFIGFILE} ]; then
22
if [ -e ${CONFIGFILE} ]; then
Lines 24-32 Link Here
24
E_SUCCESS=0
30
E_SUCCESS=0
25
E_FAILURE=1
31
E_FAILURE=1
26
32
27
#E_ZPLIST=20
28
E_ZILIST=22
33
E_ZILIST=22
29
#E_COMMAND=24
30
E_PARAM=26
34
E_PARAM=26
31
E_ZSLIST=28
35
E_ZSLIST=28
32
E_ZIDEFAULT=30
36
E_ZIDEFAULT=30
Lines 34-40 Link Here
34
#Parameters:
38
#Parameters:
35
# $1 = instance directory
39
# $1 = instance directory
36
# $2 = group
40
# $2 = group
37
38
zinst_security_setup()
41
zinst_security_setup()
39
{
42
{
40
	chown -R ${ZUID}:${2} ${1}
43
	chown -R ${ZUID}:${2} ${1}
Lines 44-61 Link Here
44
	chmod +t ${1}/var/
47
	chmod +t ${1}/var/
45
}
48
}
46
49
50
# params: $ZSERV_DIR
51
# returns 1 if $ZSERV_DIR is a 2.7 or newer Zope. Also sets NEWZOPE to 1.
52
zserv_is_2.7_or_newer()
53
{
54
    TEXT=$(echo $1 | grep ${ZS_DIR2})
55
    if [ "$TEXT" = "" ] ; then
56
        NEWZOPE=0
57
        return 0;
58
    fi
59
    NEWZOPE=1
60
    return 1;
61
}
62
47
#Params:
63
#Params:
48
#  $1 = zserv dir
64
#  $1 = zserv dir
49
#  $2 = zinst dir
65
#  $2 = zinst dir
50
51
zinst_fs_setup()
66
zinst_fs_setup()
52
{
67
{
53
	local RESULT=${E_FAILURE}
68
	local RESULT=${E_FAILURE}
69
        local USER=
70
        local PASS=
71
        local PASS2=
54
72
55
	if [ "${#}" -lt 2 ] ; then
73
	if [ "${#}" -lt 2 ] ; then
56
		# need a param
74
		# need a param
57
		RESULT=${E_PARAM}
75
		RESULT=${E_PARAM}
58
	else
76
	else
77
            if [ $NEWZOPE = 1 ] ; then
78
                while : ; do
79
                    USER=$(dialog --stdout \
80
                        --backtitle "Please choose a username and password for the initial user." \
81
                        --inputbox "Username:" 0 0 "admin")
82
                    RESULT=$?
83
                    if [ "$USER" != "" ] ; then
84
                        break
85
                    fi
86
                done
87
                while : ; do
88
                    PASS=$(dialog --stdout \
89
                        --backtitle "Please choose a username and password for the initial user." \
90
                        --passwordbox "Password:" 0 0 "")
91
                    RESULT=$?
92
                    if [ "$PASS" = "" ] ; then
93
                        continue
94
                    fi
95
                    PASS2=$(dialog --stdout \
96
                        --backtitle "Please choose a username and password for the initial user." \
97
                        --passwordbox "Reenter Password:" 0 0 "")
98
                    RESULT=$?
99
                    if [ "$PASS2" = "" ] ; then
100
                        continue
101
                    fi
102
                    if [ $PASS = $PASS2 ] ; then
103
                        break
104
                    else
105
                        dialog --msgbox "Passwords must be equal!" 0 0
106
                    fi
107
                done
108
                su zope -c "$1/bin/mkzopeinstance.py --dir $2 --user $USER:$PASS"
109
                RESULT=${E_SUCCESS}
110
            else
111
                # prior to 2.7
59
		mkdir -p $2 || exit 1
112
		mkdir -p $2 || exit 1
60
		if [ $(zinst_default_get >/dev/null)$? -ne 0 ] ; then
113
		if [ $(zinst_default_get >/dev/null)$? -ne 0 ] ; then
61
			echo $(basename ${ZINST_DIR}) >${ZI_DIR}/.default
114
			echo $(basename ${ZINST_DIR}) >${ZI_DIR}/.default
Lines 77-82 Link Here
77
		fi
130
		fi
78
131
79
		RESULT=$?
132
		RESULT=$?
133
            fi
80
	fi
134
	fi
81
135
82
	return ${RESULT}
136
	return ${RESULT}
Lines 86-92 Link Here
86
#  $1 = zserv dir
140
#  $1 = zserv dir
87
#  $2 = zinst dir
141
#  $2 = zinst dir
88
#  $3 = zinst name
142
#  $3 = zinst name
89
90
zinst_rc_setup()
143
zinst_rc_setup()
91
{
144
{
92
	local RESULT=${E_FAILURE}  
145
	local RESULT=${E_FAILURE}  
Lines 95-100 Link Here
95
		# need a param
148
		# need a param
96
		RESULT=${E_PARAM}
149
		RESULT=${E_PARAM}
97
	else
150
	else
151
            if [ $NEWZOPE = 1 ] ; then
152
                install $1/.templates/zope.initd ${INITD}/${3}
153
                sed -i \
154
                    -e "s|ZINST_DIR=|ZINST_DIR=${2}|" \
155
                    -e "s|EVENT_LOG_FILE=|EVENT_LOG_FILE=${EVENTLOGDIR}\/${3}|" \
156
                    ${INITD}/${3}
157
                RESULT=${E_SUCCESS}
158
            else
98
		install $1/.templates/zope.confd ${CONFD}/${3}
159
		install $1/.templates/zope.confd ${CONFD}/${3}
99
		install $1/.templates/zope.initd ${INITD}/${3}
160
		install $1/.templates/zope.initd ${INITD}/${3}
100
		sed -i \
161
		sed -i \
Lines 103-123 Link Here
103
			-e "/EVENT_LOG_FILE=/ c\\EVENT_LOG_FILE=${EVENTLOGDIR}\/${3}\\ " \
164
			-e "/EVENT_LOG_FILE=/ c\\EVENT_LOG_FILE=${EVENTLOGDIR}\/${3}\\ " \
104
			${CONFD}/${3}
165
			${CONFD}/${3}
105
		RESULT=$?
166
		RESULT=$?
106
		# make sure the directory exists
167
            fi
107
		mkdir -p ${EVENTLOGDIR} >/dev/null 2>&1
168
	    # make sure the directory exists
169
            mkdir -p ${EVENTLOGDIR} >/dev/null 2>&1
108
	fi
170
	fi
109
	return ${RESULT}
171
	return ${RESULT}
110
}
172
}
111
173
112
#
174
# Sets the variable: ZSERV_DIR and returns 0
113
175
#  or returns a non-zero error code
114
zserv_dir_get()
176
zserv_dir_get()
115
{
177
{
116
	local RESULT=${E_FAILURE}
178
	local RESULT=${E_FAILURE}
117
	local LIST=$(ls ${ZS_DIR})
179
	local LIST=$(ls -d ${ZS_DIR}* ; ls -d ${ZS_DIR2}*)
118
	local LIST_CNT=$(echo ${LIST} | wc -w)
180
	local LIST_CNT=$(echo ${LIST} | wc -w)
119
	local DLIST=
181
	local DLIST=
120
182
        
121
	# Assume that LIST_TMP contains valid zserver dirs.
183
	# Assume that LIST_TMP contains valid zserver dirs.
122
	if [ ${LIST_CNT} -eq 1 ] ; then
184
	if [ ${LIST_CNT} -eq 1 ] ; then
123
		ZSERV_DIR=${LIST}
185
		ZSERV_DIR=${LIST}
Lines 128-144 Link Here
128
		done
190
		done
129
		ZSERV_DIR=$(dialog --stdout \
191
		ZSERV_DIR=$(dialog --stdout \
130
			--title "Zope Server List" \
192
			--title "Zope Server List" \
131
			--menu "Select desired zserver: " 0 0 ${LIST_CNT} ${DLIST})
193
			--menu "Select desired zserver: " 0 40 ${LIST_CNT} ${DLIST})
132
		RESULT=$?
194
		RESULT=$?
133
	else
195
	else
134
		RESULT=${E_ZSLIST}    # There are no zservers
196
		RESULT=${E_ZSLIST}    # There are no zservers
135
	fi
197
	fi
136
	ZSERV_DIR="${ZS_DIR}${ZSERV_DIR}"
198
        
199
        # set NEWZOPE to 1 if we are dealing with a "newer" zope version
200
        zserv_is_2.7_or_newer ${ZERV_DIR}
201
137
	return ${RESULT}
202
	return ${RESULT}
138
}
203
}
139
  
204
  
140
#
205
# Sets the variable: ZINST_DIR and returns 0
141
206
#  or returns a non-zero error code
142
zinst_dir_set()
207
zinst_dir_set()
143
{
208
{
144
	local RESULT=
209
	local RESULT=
Lines 152-160 Link Here
152
			--backtitle "Need a uniqe name for zinstance directory.(Also the name of the rcscript.)" \
217
			--backtitle "Need a uniqe name for zinstance directory.(Also the name of the rcscript.)" \
153
			--inputbox "Enter a new zinstance name:" 0 0 ${DEFAULT_ZINSTANCENAME} )
218
			--inputbox "Enter a new zinstance name:" 0 0 ${DEFAULT_ZINSTANCENAME} )
154
		RESULT=$?
219
		RESULT=$?
155
		if [ ${RESULT} -ne 0 ] ; then
220
                if [ ${RESULT} -ne 0 ] ; then
156
			break
221
                        break
157
		elif [ -z ${ZINST_DIR} ] ; then
222
                elif [ -z ${ZINST_DIR} ] ; then
158
			dialog --msgbox "Error: need a name." 0 0
223
			dialog --msgbox "Error: need a name." 0 0
159
			continue
224
			continue
160
		elif echo ${ZINST_DIR} |grep "/" ; then
225
		elif echo ${ZINST_DIR} |grep "/" ; then
Lines 162-168 Link Here
162
			continue
227
			continue
163
		elif [[ -d "${ZI_DIR}${ZINST_DIR}" && \
228
		elif [[ -d "${ZI_DIR}${ZINST_DIR}" && \
164
			-f "${INITD}/${ZINST_DIR}" ]] ; then
229
			-f "${INITD}/${ZINST_DIR}" ]] ; then
165
			dialog --msgbox "Error: ${ZINST_DIR} zinstance already exists." 0 0
230
			dialog --msgbox "Error: ${ZINST_DIR} zinstance already exists. Delete ${INITD}/${ZINST_DIR} to replace instance." 0 0
166
			continue
231
			continue
167
		fi
232
		fi
168
		ZINST_DIR=${ZI_DIR}${ZINST_DIR}
233
		ZINST_DIR=${ZI_DIR}${ZINST_DIR}
Lines 171-178 Link Here
171
	return ${RESULT}
236
	return ${RESULT}
172
}
237
}
173
238
174
#
239
# sets the variable $ZINST_DIR and returns 0
175
240
#  or returns non-null error code
176
zinst_dir_get()
241
zinst_dir_get()
177
{
242
{
178
	local RESULT=1
243
	local RESULT=1
Lines 199-211 Link Here
199
	return ${RESULT}
264
	return ${RESULT}
200
}
265
}
201
266
202
#
267
# makes ZSERV_DIR the default zope version. if ZSERV_DIR
203
204
zinst_default_set()
268
zinst_default_set()
205
{
269
{
206
	local RESULT=
270
	local RESULT=
207
271
208
	zinst_dir_get
272
        if [ -z ${ZINST_DIR} ] ; then
273
            zinst_dir_get || { echo 'Canceled: zinst_dir_get' ; exit 1 ; }
274
        fi
209
	RESULT=$?
275
	RESULT=$?
210
	if [ ${RESULT} -eq 0 ] ; then
276
	if [ ${RESULT} -eq 0 ] ; then
211
		echo $(basename ${ZINST_DIR}) >${ZI_DIR}/.default
277
		echo $(basename ${ZINST_DIR}) >${ZI_DIR}/.default
Lines 216-222 Link Here
216
}
282
}
217
283
218
# Echos the default directory that this instance was created in
284
# Echos the default directory that this instance was created in
219
220
zinst_default_get()
285
zinst_default_get()
221
{
286
{
222
	local RESULT=${E_ZIDEFAULT}
287
	local RESULT=${E_ZIDEFAULT}
Lines 230-236 Link Here
230
295
231
# Gets a name for the group that owns the new zinstance and also creates the
296
# Gets a name for the group that owns the new zinstance and also creates the
232
# group if nessicary
297
# group if nessicary
233
234
zinst_zgid_set()
298
zinst_zgid_set()
235
{
299
{
236
	local RESULT=
300
	local RESULT=
Lines 256-262 Link Here
256
}
320
}
257
321
258
# Sets the inituser password for a given zinstance
322
# Sets the inituser password for a given zinstance
259
260
zinst_zpasswd_set()
323
zinst_zpasswd_set()
261
{
324
{
262
	if [ -z ${ZSERV_DIR} ] ; then
325
	if [ -z ${ZSERV_DIR} ] ; then
Lines 266-275 Link Here
266
		zinst_dir_get || exit $?
329
		zinst_dir_get || exit $?
267
	fi
330
	fi
268
331
269
	echo ">>> Create Zope inituser for \"$(basename ${ZINST_DIR})\"..."
332
        zserv_is_2.7_or_newer ${ZSERV_DIR}
270
	/usr/bin/python ${ZSERV_DIR}/zpasswd.py ${ZINST_DIR}/inituser
333
        if [ $NEWZOPE = 1 ] ; then
271
	# If zpasswd is aborted it creates a blank inituser
334
            echo ">>> Create Zope inituser for \"$(basename ${ZINST_DIR})\"..."
272
	chown ${ZUID} ${ZINST_DIR}/inituser
335
            /usr/bin/python ${ZSERV_DIR}/bin/zpasswd.py ${ZINST_DIR}/inituser
336
            # If zpasswd is aborted it creates a blank inituser
337
            chown ${ZUID} ${ZINST_DIR}/inituser
338
        else
339
            echo ">>> Create Zope inituser for \"$(basename ${ZINST_DIR})\"..."
340
            /usr/bin/python ${ZSERV_DIR}/zpasswd.py ${ZINST_DIR}/inituser
341
            # If zpasswd is aborted it creates a blank inituser
342
            chown ${ZUID} ${ZINST_DIR}/inituser
343
        fi
273
}
344
}
274
345
275
# help!
346
# help!
Lines 285-291 Link Here
285
	echo -e "\t$(basename $0) --[zserv=[dir] &| zinst=[dir] &| zgid=[name]]"
356
	echo -e "\t$(basename $0) --[zserv=[dir] &| zinst=[dir] &| zgid=[name]]"
286
	echo "Non-interactive usage:"
357
	echo "Non-interactive usage:"
287
	echo -e "\t$(basename $0) --[zidef-get | zidef-set | zpasswd | version | help]"
358
	echo -e "\t$(basename $0) --[zidef-get | zidef-set | zpasswd | version | help]"
288
	echo -e "\t$(basename $0) --[zserv=[dir] & zinst=[dir] & zgid=[name]]"
359
	echo -e "\t$(basename $0) --[zserv=[dir] & zinst=[di] & zgid=[name]]"
289
	exit ${E_SUCCESS}
360
	exit ${E_SUCCESS}
290
}
361
}
291
362
Lines 311-329 Link Here
311
	shift
382
	shift
312
done
383
done
313
384
385
# if ZSERV_DIR isn't set by command line, call zserv_dir_get to set it
314
if [ -z ${ZSERV_DIR} ] ; then
386
if [ -z ${ZSERV_DIR} ] ; then
315
	zserv_dir_get || { echo 'Canceled: zserv_dir_get' ; exit 1 ; }
387
	zserv_dir_get || { echo 'Canceled: zserv_dir_get' ; exit 1 ; }
316
fi
388
fi
317
389
390
# if ZINST_DIR passed by command line, call zinst_dir_set to set it
318
if [ -z ${ZINST_DIR} ] ; then
391
if [ -z ${ZINST_DIR} ] ; then
319
	zinst_dir_set || { echo 'Canceled: zinst_dir_set' ; exit 1 ; }
392
	zinst_dir_set || { echo 'Canceled: zinst_dir_set' ; exit 1 ; }
320
fi
393
fi
321
394
395
# if ZIRC_NAME isn't set then use the base of the ZINST_DIR for ZIRC_NAME
322
[ -z ${ZIRC_NAME} ] && ZIRC_NAME=$(basename ${ZINST_DIR})
396
[ -z ${ZIRC_NAME} ] && ZIRC_NAME=$(basename ${ZINST_DIR})
323
397
324
if [ -z ${ZGID_NAME} ] ; then
398
if [ -z ${ZGID_NAME} ] ; then
325
	zinst_zgid_set || { echo 'Canceled: zinst_zgid_set' ; exit 1 ; }
399
	zinst_zgid_set || { echo 'Canceled: zinst_zgid_set' ; exit 1 ; }
326
fi
400
fi
401
zserv_is_2.7_or_newer ${ZSERV_DIR}
327
402
328
zinst_fs_setup ${ZSERV_DIR} ${ZINST_DIR}
403
zinst_fs_setup ${ZSERV_DIR} ${ZINST_DIR}
329
zinst_rc_setup ${ZSERV_DIR} ${ZINST_DIR} ${ZIRC_NAME}
404
zinst_rc_setup ${ZSERV_DIR} ${ZINST_DIR} ${ZIRC_NAME}
Lines 332-340 Link Here
332
# add existing user zope to the new group
407
# add existing user zope to the new group
333
gpasswd -a zope ${ZGID_NAME}
408
gpasswd -a zope ${ZGID_NAME}
334
409
335
zinst_security_setup ${ZINST_DIR} ${ZGID_NAME}
336
337
# TODO: see about adding interactive configuration of ZOPE_OPTS
410
# TODO: see about adding interactive configuration of ZOPE_OPTS
338
echo "Note: Don\'t forget to edit ZOPE_OPTS in ${CONFD}${ZIRC_NAME}"
411
if [ $NEWZOPE != 1 ] ; then
339
echo "      (you might want to add -P 8{1,2,3,..}00 to set the zope ports offset)"
412
    zinst_security_setup ${ZINST_DIR} ${ZGID_NAME}
413
414
    echo "Note: Don't forget to edit ZOPE_OPTS in ${CONFD}${ZIRC_NAME}"
415
    echo "      (you might want to add -P 8{1,2,3,..}00 to set the zope ports offset)"
416
fi
417
340
418

Return to bug 41508