Files
ofbiz-framework/debian/ofbiz.config
T
2008-08-28 17:32:40 +00:00

148 lines
3.8 KiB
Bash

#!/bin/sh
#Licensed to the Apache Software Foundation (ASF) under one
#or more contributor license agreements. See the NOTICE file
#distributed with this work for additional information
#regarding copyright ownership. The ASF licenses this file
#to you under the Apache License, Version 2.0 (the
#"License"); you may not use this file except in compliance
#with the License. You may obtain a copy of the License at
#
#http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing,
#software distributed under the License is distributed on an
#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#KIND, either express or implied. See the License for the
#specific language governing permissions and limitations
#under the License.
set -ex
. /usr/share/debconf/confmodule
db_version 2.0
db_capb backup
#DEBHELPER#
cat << _EOF_ > /dev/null
if [ "$1" = configure ]; then
db_fget ofbiz/database-type seen || true
if [ "$RET" != false ]; then
db_set ofbiz/database-type pgsql
db_fset ofbiz/database-type seen false
fi
for dbtype in pgsql mysql; do
db_fget ofbiz/$dbtype/method seen || true
if [ "$RET" != false ]; then
db_set ofbiz/$dbtype/method tcp/ip
db_fset ofbiz/$dbtype/method seen false
fi
done
fi
_EOF_
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
dbc_dbtype="derby"
dbc_dbtypes="pgsql, mysql, derby, hsql"
dbc_authmethod_user="password"
. /usr/share/dbconfig-common/dpkg/config
dbc_go ofbiz $@
fi
set -x
if [ -r "/etc/ofbiz/debconf.cfg" ]; then
. "/etc/ofbiz/debconf.cfg"
fi
set_if() {
if [ "$2" ]; then
db_set "$1" "$2"
return 0
fi
return 1;
}
ofbiz_readers="seed"
ofbiz_from_email="ofbiztest@yahoo.com"
ofbiz_admin_port="10523"
#env LANG=C LC_ALL=C sed -n -e 's/[^[:alnum:]]//g;p;q' < /dev/urandom | cut -b1-12
if set_if ofbiz/admin-password-encrypted "$ofbiz_admin_password_encrypted"; then
db_fset ofbiz/admin-password-encrypted seen true
fi
db_set ofbiz/admin-password ofbiz || true
set_if ofbiz/readers "$ofbiz_readers" || true
set_if ofbiz/from-email "$ofbiz_from_email" || true
set_if ofbiz/admin-port "$ofbiz_admin_port" || true
cmd="$1"
shift
case "$cmd" in
(configure)
import_question=ofbiz/import-additional-data
reader_choices="demo, ext"
;;
(reconfigure)
import_question=ofbiz/reimport-data
reader_choices="seed, demo, ext"
;;
(*)
echo "Invalid command($cmd)" 1>&2
exit 9
;;
esac
case "$cmd" in
(configure|reconfigure)
db_subst ofbiz/readers choices "$reader_choices"
STATE=0
while :; do
NEXT=$(($STATE + 1))
case "$STATE" in
(-1) exit 10
;;
(0) if db_input medium ofbiz/admin-password; then
db_set ofbiz/admin-password ''
db_set ofbiz/admin-password-encrypted ''
db_fset ofbiz/password-confirmation seen false
else
db_fset ofbiz/password-confirmation seen true
db_get ofbiz/admin-password || true
db_set ofbiz/password-confirmation "$RET"
fi
;;
(1) password=""
db_get ofbiz/admin-password && password="$RET"
if ! [ "$password" ]; then
db_input high ofbiz/empty-password-not-allowed || true
NEXT=0
fi
;;
(2) db_input high ofbiz/password-confirmation || true
;;
(3) confirm=""
db_get ofbiz/password-confirmation && confirm="$RET"
if [ "$password" != "$confirm" ]; then
db_input high ofbiz/mismatched-passwords || true
NEXT=0
db_fset ofbiz/admin-password seen false
fi
;;
(4) db_input medium $import_question || true
;;
(5) db_get $import_question && do_import="$RET"
if [ "$do_import" = "true" ]; then
db_input medium ofbiz/readers || true
fi
;;
(6) db_input medium ofbiz/from-email || true
;;
(7) db_input low ofbiz/admin-port || true
;;
(*) break
;;
esac
if db_go; then
STATE=$NEXT
else
STATE=$(($STATE - 1))
fi
done
;;
esac