#!/bin/sh # # $NetBSD: rtconfig,v 1.1.1.1 2002/09/19 21:40:45 atatat Exp $ # nonemessage="Enter \"none\" for an empty reponse or hit enter for the default." query() { _var="$1" _default="$2" _value="" [ -n "$nonemessage" ] && echo "$nonemessage" nonemessage="" while [ -z "$_value" ]; do echo -n "Enter $_var [$_default]: " read _value if [ -z "$_value" ]; then _value="$_default" break elif [ "$_value" = "none" ]; then _value="" break fi done eval $_var="$_value" } PERL='@PREFIX@/bin/perl' RT_PATH='@RT_PATH@' RT_ETC_PATH="${RT_PATH}/etc" RT_LOG_PATH='@RT_LOG_PATH@' RT_DATA_PATH='@RT_DATA_PATH@' DB_TYPE='@RT_DB_TYPE@' DB_HOME='@RT_DB_HOME@' query DB_HOST '@RT_DB_HOST@' DB_PORT='@RT_DB_PORT@' DB_RT_USER='@RT_DB_USER@' DB_RT_PASS='@RT_DB_PASS@' DB_DATABASE='@RT_DB_DATABASE@' query DB_DBA '@RT_DB_DBA@' query DB_DBA_PASSWORD '@RT_DB_DBA_PASSWORD@' if [ ! -f "${RT_DATA_PATH}/installed" ]; then upgrading=false else ODB_TYPE=`cat "${RT_DATA_PATH}/installed"` if [ "$DB_TYPE" = "$ODB_TYPE" ]; then upgrading=true else cat < initialize.${DB_TYPE} -> createdb createdb() { $upgrading && return 0 ${PERL} ${RT_PATH}/etc/initdb "${DB_TYPE}" "${DB_HOME}" \ "${DB_HOST}" "${DB_PORT}" \ "${DB_DBA}" "${DB_DATABASE}" \ create } # install -> initialize.${DB_TYPE} -> acls acls() { $upgrading && return 0 echo "Note: make sure this is the same as listed in your config.pm" query DB_RT_PASS "${DB_RT_PASS}" sed < "${RT_ETC_PATH}/acl.${DB_TYPE}" > "${RT_ETC_PATH}/acl" \ -e "s/identified by [^ ]*$/identified by ${DB_RT_PASS}/" \ -e "s/with password '[^']*'/with password '${DB_RT_PASS}'/" \ -e "s/IDENTIFIED BY '[^']*'/IDENTIFIED BY '${DB_RT_PASS}'/" ${RT_ETC_PATH}/initacls.${DB_TYPE} "${DB_HOME}" \ "${DB_HOST}" "${DB_PORT}" "${DB_DBA}" \ "${DB_DBA_PASSWORD}" "${DB_DATABASE}" \ "${RT_ETC_PATH}/acl" rm "${RT_ETC_PATH}/acl" } # install -> initialize.mysql -> initdb.rtuser initdb_rtuser() { $upgrading && return 0 ${PERL} ${RT_ETC_PATH}/initdb "${DB_TYPE}" "${DB_HOME}" \ "${DB_HOST}" "${DB_PORT}" \ "${DB_RT_USER}" "${DB_DATABASE}" \ insert } # install -> initialize.Pg -> initdb.dba initdb_dba() { $upgrading && return 0 ${PERL} ${RT_ETC_PATH}/initdb "${DB_TYPE}" "${DB_HOME}" \ "${DB_HOST}" "${DB_PORT}" \ "${DB_DBA}" "${DB_DATABASE}" \ insert } # install -> upgrade -> upgrade-noclobber -> nondestruct -> fixperms fixperms() { chmod 770 ${RT_LOG_PATH} \ ${MASON_DATA_PATH} \ ${MASON_SESSION_PATH} chown -R ${WEB_USER} ${RT_LOG_PATH} \ ${MASON_DATA_PATH} \ ${MASON_SESSION_PATH} chgrp -R ${WEB_GROUP} ${RT_LOG_PATH} \ ${MASON_DATA_PATH} \ ${MASON_SESSION_PATH} } # install -> insert insert() { $upgrading && return 0 ${PERL} ${RT_ETC_PATH}/insertdata } # rt upgrade "instructions" rtupgrade() { $upgrading || return 0 cat < "${RT_DATA_PATH}/installed" } cd "${RT_PATH}" case "${DB_TYPE}" in mysql) createdb # not on upgrade acls # not on upgrade initdb_rtuser # not on upgrade fixperms insert # not on upgrade ;; Pg) createdb # not on upgrade initdb_dba # not on upgrade acls # not on upgrade fixperms insert # not on upgrade ;; *) echo "what database type is ${DB_TYPE}?" >&2 exit 1 ;; esac rtupgrade rtinstall