pkgsrc/devel/rt-mysql/files/rtconfig
atatat 47195b7a87 Initial import of a pkg for the RT ticketing system.
RT is an industrial-grade ticketing system. It lets a group of
people intelligently and efficiently manage requests submitted by
a community of users. RT is used by systems administrators, customer
support staffs, NOCs, developers and even marketing departments at
over a thousand sites around the world.

This version is backed by the mysql database.
2002-09-19 21:40:45 +00:00

192 lines
3.9 KiB
Bash

#!/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 <<EOF
WARNING: You cannot upgrade an RT installation from $ODB_TYPE to
WARNING: $DB_TYPE simply by installing a new pkg. Your data will
WARNING: need to be manually dumped and reloading from the database.
EOF
exit 1
fi
fi
query WEB_USER '@RT_WEB_USER@'
query WEB_GROUP '@RT_WEB_GROUP@'
MASON_DATA_PATH='@RT_DATA_PATH@'
MASON_SESSION_PATH='@RT_SESSION_PATH@'
# install -> 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 <<EOF
Congratulations. RT has been upgraded. You should now check-over
${RT_ETC_PATH}/config.pm for any necessary site customization.
EOF
}
#
rtinstall()
{
$upgrading && return 0
cat <<EOF
Congratulations. RT has been installed. From here on in, you
should refer to the users guide (aka README.rt).
EOF
echo "$DB_TYPE" > "${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