https://wiki.davical.org/index.php?title=Installing_DAViCal_on_systems_running_multiple_versions_or_a_non-standard_port_for_PostgreSQL&feed=atom&action=historyInstalling DAViCal on systems running multiple versions or a non-standard port for PostgreSQL - Revision history2024-03-28T21:24:40ZRevision history for this page on the wikiMediaWiki 1.40.1https://wiki.davical.org/index.php?title=Installing_DAViCal_on_systems_running_multiple_versions_or_a_non-standard_port_for_PostgreSQL&diff=3502&oldid=prevGorka: moved user contribution into its own page2015-06-30T12:59:15Z<p>moved user contribution into its own page</p>
<p><b>New page</b></p><div>Newly, i have been confronted to install davical on my server, but i had a old version of postgresql (8.0.23) already installed.<br />
Unfortunately for me, davical requires a PostgreSQL: 8.1 or greater.<br />
<br />
To stay on davical installations rules, i have compiled and installed postgresql 8.4.2 on my system and i have start it on another TCP port '''( 5433 )'''.<br />
<br />
For to do this, you can modify file <tt>'''[my new db datastore 8.4.2]/postgresql.conf'''</tt><br />
<br />
...<br />
#------------------------------------------------------------------------------<br />
# CONNECTIONS AND AUTHENTICATION<br />
#------------------------------------------------------------------------------<br />
<br />
# - Connection Settings -<br />
<br />
listen_addresses = '*' # what IP address(es) to listen on;<br />
# comma-separated list of addresses;<br />
# defaults to 'localhost', '*' = all<br />
# (change requires restart)<br />
#port = 5432 # (change requires restart)<br />
'''port = 5433''' # (change requires restart)<br />
max_connections = 100 # (change requires restart)<br />
# Note: Increasing max_connections costs ~400 bytes of shared memory per<br />
# connection slot, plus lock space (see max_locks_per_transaction).<br />
...<br />
<br />
After do that, i have modify the create-database.sh file for it be able to found my new instance of postgresql.<br />
<br />
I have added some variables :<br />
<br />
PGINSTALL=/opt/postgresql-8.4.2/bin ''the path where my new postgresql is''<br />
export PGPORT=5433 ''this variable is read by all postgres commands for to know where postgresql server listen''<br />
<br />
After i modify all lines where i have found a command postgresql in following way :<br />
<br />
ex :<br />
export DBVERSION="`psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"<br />
<br />
by<br />
<br />
export DBVERSION="`'''${PGINSTALL}/'''psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"<br />
<br />
Below the new modified '''create-database.sh''' file. Sorry, i have not been able to upload this file on this wiki, perhaps the admin can change that ;-).<br />
<br />
<br />
----<br />
<br />
#!/bin/sh<br />
#<br />
# Build the DAViCal database<br />
#<br />
<br />
'''PGINSTALL=/opt/postgresql-8.4.2/bin'''<br />
DBNAME="${1:-davical}"<br />
'''export PGPORT=5433'''<br />
ADMINPW="${2}"<br />
<br />
DBADIR="`dirname \"$0\"`"<br />
<br />
INSTALL_NOTE_FN="`mktemp -t tmp.XXXXXXXXXX`"<br />
<br />
<br />
testawldir() {<br />
[ -f "${1}/dba/awl-tables.sql" ]<br />
}<br />
<br />
#<br />
# Attempt to locate the AWL directory<br />
'''AWLDIR="/opt/lib/awl"'''<br />
if ! testawldir "${AWLDIR}"; then<br />
AWLDIR="/usr/share/awl"<br />
if ! testawldir "${AWLDIR}"; then<br />
AWLDIR="/usr/local/share/awl"<br />
if ! testawldir "${AWLDIR}"; then<br />
echo "Unable to find AWL libraries"<br />
exit 1<br />
fi<br />
fi<br />
fi<br />
<br />
export AWL_DBAUSER=davical_dba<br />
export AWL_APPUSER=davical_app<br />
<br />
# Get the major version for PostgreSQL<br />
export DBVERSION="`'''${PGINSTALL}/'''psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"<br />
<br />
install_note() {<br />
cat >>"${INSTALL_NOTE_FN}"<br />
}<br />
<br />
db_users() {<br />
'''${PGINSTALL}/'''psql -qAt -c "SELECT usename FROM pg_user;" template1<br />
}<br />
<br />
create_db_user() {<br />
if ! db_users | grep "^${1}$" >/dev/null ; then<br />
'''${PGINSTALL}/'''psql -qAt -c "CREATE USER ${1} NOCREATEDB NOCREATEROLE;" template1<br />
cat <<EONOTE | install_note<br />
* You will need to edit the PostgreSQL pg_hba.conf to allow the<br />
'${1}' database user access to the 'davical' database.<br />
<br />
EONOTE<br />
fi<br />
}<br />
<br />
create_plpgsql_language() {<br />
if ! '''${PGINSTALL}/'''psql ${DBA} -qAt -c "SELECT lanname FROM pg_language;" "${DBNAME}" | grep "^plpgsql$" >/dev/null; then<br />
'''${PGINSTALL}/'''createlang plpgsql "${DBNAME}"<br />
fi<br />
}<br />
<br />
try_db_user() {<br />
[ "XtestX`'''${PGINSTALL}/'''psql -U "${1}" -qAt -c \"SELECT usename FROM pg_user;\" \"${DBNAME}\" 2>/dev/null`" != "XtestX" ]<br />
}<br />
<br />
create_db_user "${AWL_DBAUSER}"<br />
create_db_user "${AWL_APPUSER}"<br />
<br />
# FIXME: Need to check that the database was actually created.<br />
if ! '''${PGINSTALL}/'''createdb --encoding UTF8 --template template0 --owner "${AWL_DBAUSER}" "${DBNAME}" ; then<br />
echo "Unable to create database"<br />
exit 1<br />
fi<br />
<br />
#<br />
# Try a few alternatives for a database user or give up...<br />
if try_db_user "${AWL_DBAUSER}" ; then<br />
export DBA="-U ${AWL_DBAUSER}"<br />
else<br />
if try_db_user "postgres" ; then<br />
export DBA="-U postgres"<br />
else<br />
if try_db_user "${USER}" ; then<br />
export DBA=""<br />
else<br />
if try_db_user "${PGUSER}" ; then<br />
export DBA=""<br />
else<br />
cat <<EOFAILURE<br />
* * * * ERROR * * * *<br />
I cannot find a usable database user to construct the DAViCal database with, but<br />
may have successfully created the davical_app and davical_dba users (I tried :-).<br />
<br />
You should edit your pg_hba.conf file to give permissions to the davical_app and<br />
davical_dba users to access the database and run this script again. If you still<br />
continue to see this message then you will need to make sure you run the script<br />
as a user with full permissions to access the local PostgreSQL database.<br />
<br />
If your PostgreSQL database is non-standard then you will need to set the PGHOST,<br />
PGPORT and/or PGCLUSTER environment variables before running this script again.<br />
<br />
See: http://wiki.davical.org/w/Install_Errors/No_Database_Rights<br />
<br />
EOFAILURE<br />
exit 1<br />
fi<br />
fi<br />
fi<br />
fi<br />
<br />
create_plpgsql_language<br />
<br />
#<br />
# Load the AWL base tables and schema management tables<br />
'''${PGINSTALL}/'''psql -qAt ${DBA} -f "${AWLDIR}/dba/awl-tables.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT|<br />
NOTICE: )"<br />
'''${PGINSTALL}/'''psql -qAt ${DBA} -f "${AWLDIR}/dba/schema-management.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT| NOTICE: |^t$)"<br />
<br />
#<br />
# Load the DAViCal tables<br />
'''${PGINSTALL}/'''psql -qAt ${DBA} -f "${DBADIR}/davical.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT| NOTICE: |^t$)"<br />
<br />
#<br />
# Set permissions for the application DB user on the database<br />
if ! ${DBADIR}/update-davical-database --dbname "${DBNAME}" --appuser "${AWL_APPUSER}" --nopatch --owner "${AWL_DBAUSER}" ; then<br />
cat <<EOFAILURE<br />
* * * * ERROR * * * *<br />
The database administration utility failed. This is usually due to the Perl YAML<br />
or the Perl DBD::Pg libraries not being available.<br />
<br />
See: http://wiki.davical.org/w/Install_Errors/No_Perl_YAML<br />
<br />
EOFAILURE<br />
fi<br />
#<br />
# Load the required base data<br />
'''${PGINSTALL}/'''psql -qAt ${DBA} -f "${DBADIR}/base-data.sql" "${DBNAME}" | egrep -v '^10'<br />
<br />
#<br />
# We can override the admin password generation for regression testing predictability<br />
if [ "${ADMINPW}" = "" ] ; then<br />
#<br />
# Generate a random administrative password. If pwgen is available we'll use that,<br />
# otherwise try and hack something up using a few standard utilities<br />
ADMINPW="`pwgen -Bcny 2>/dev/null | tr \"\\\\\'\" '^='`"<br />
fi<br />
<br />
if [ "$ADMINPW" = "" ] ; then<br />
# OK. They didn't supply one, and pwgen didn't work, so we hack something<br />
# together from /dev/random ...<br />
export LC_ALL=C<br />
ADMINPW="`dd if=/dev/urandom bs=512 count=1 2>/dev/null | tr -c -d "a-km-zA-HJ-NP-Y0-9" | cut -c2-9`"<br />
fi<br />
<br />
if [ "$ADMINPW" = "" ] ; then<br />
# Right. We're getting desperate now. We'll have to use a default password<br />
# and hope that they change it to something more sensible.<br />
ADMINPW="please change this password"<br />
fi<br />
<br />
'''${PGINSTALL}/'''psql -q -c "UPDATE usr SET password = '**${ADMINPW}' WHERE user_no = 1;" "${DBNAME}"<br />
<br />
echo "NOTE"<br />
echo "===="<br />
cat "${INSTALL_NOTE_FN}"<br />
rm "${INSTALL_NOTE_FN}"<br />
<br />
cat <<FRIENDLY<br />
* The password for the 'admin' user has been set to '${ADMINPW}'"<br />
<br />
Thanks for trying DAViCal! Check in /usr/share/doc/davical/examples/ for<br />
some configuration examples. For help, visit #davical on irc.oftc.net.<br />
<br />
FRIENDLY<br />
<br />
I hope this howto can help someone who is in same case ;-)<br />
<br />
ps : thanks to davical developpers for your soft...<br />
<br />
Vic</div>Gorka