User Contributions: Difference between revisions

From Davical
Jump to navigationJump to search
mNo edit summary
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Languages|User Contributions}}
{{Languages|User Contributions}}


* [[Synology|Installing DAViCal on a Synology NAS]]
* [[Web Display of Calendars]]
 
* [[DAViCal_Web_Client]]
===Code or Examples Relating to DAViCal===
* [[DAViCal-cli]]
 
====Web Display of Calendars====
 
I wrote this to pull calendars from DAViCal to our website.  It is a re-write of some classes that pulled data from a Drupal database, so it currently doesn't display all possible text. 
 
I'd love to see this rolled into DAViCal on the user collections page or as a way of displaying groups of collections in read-only mode. 
 
To install, you'll need to update the following line in caldav_display.classes.php with your information, and then adjust the calendars you'd like to display in sample_display.php. Put sample_display.php and calendar.css in a web accessible folder and place the classes file in your path.
 
$calendar_db = pg_connect("host=hostname port=5432 dbname=rscds user=general password=password_for_general"
 
Place calendar_notifier on a server with cli php and call it with cron to send out nightly agenda emails.  Something like:
 
0 4 * * * php /usr/local/sbin/calendar/calendar_notifier.php
 
You'll also need to install [http://pear.php.net/package/Date Pear's Date] class and a relatively recent version of [http://jquery.com JQuery].
 
[http://marlboro.edu/davical/caldav_display.tar.gz Download]
 
====Web client for DAViCal====
 
Information has been moved [[DAViCal_Web_Client | here]]
 
====Install davical on a server where you can find an another version of Postgresql====
 
Newly, i have been confronted to install davical on my server, but i had a old version of postgresql (8.0.23) already installed.
Unfortunately for me, davical requires a PostgreSQL: 8.1 or greater.
 
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 )'''.
 
For to do this, you can modify file <tt>'''[my new db datastore 8.4.2]/postgresql.conf'''</tt>
 
  ...
  #------------------------------------------------------------------------------
  # CONNECTIONS AND AUTHENTICATION
  #------------------------------------------------------------------------------
 
  # - Connection Settings -
 
  listen_addresses = '*'          # what IP address(es) to listen on;
                                          # comma-separated list of addresses;
                                          # defaults to 'localhost', '*' = all
                                          # (change requires restart)
  #port = 5432                            # (change requires restart)
  '''port = 5433'''                            # (change requires restart)
  max_connections = 100                  # (change requires restart)
  # Note:  Increasing max_connections costs ~400 bytes of shared memory per
  # connection slot, plus lock space (see max_locks_per_transaction).
  ...
 
After do that, i have modify the create-database.sh file for it be able to found my new instance of postgresql.
 
I have added some variables :
 
  PGINSTALL=/opt/postgresql-8.4.2/bin  ''the path where my new postgresql is''
  export PGPORT=5433                    ''this variable is read by all postgres commands for to know where postgresql server listen''
 
After i modify all lines where i have found a command postgresql in following way :
 
ex :
  export DBVERSION="`psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"
 
  by
 
  export DBVERSION="`'''${PGINSTALL}/'''psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"
 
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 ;-).
 
 
----
 
  #!/bin/sh
  #
  # Build the DAViCal database
  #
 
  '''PGINSTALL=/opt/postgresql-8.4.2/bin'''
  DBNAME="${1:-davical}"
  '''export PGPORT=5433'''
  ADMINPW="${2}"
 
  DBADIR="`dirname \"$0\"`"
 
  INSTALL_NOTE_FN="`mktemp -t tmp.XXXXXXXXXX`"
 
 
  testawldir() {
    [ -f "${1}/dba/awl-tables.sql" ]
  }
 
  #
  # Attempt to locate the AWL directory
  '''AWLDIR="/opt/lib/awl"'''
  if ! testawldir "${AWLDIR}"; then
    AWLDIR="/usr/share/awl"
    if ! testawldir "${AWLDIR}"; then
      AWLDIR="/usr/local/share/awl"
      if ! testawldir "${AWLDIR}"; then
        echo "Unable to find AWL libraries"
        exit 1
      fi
    fi
  fi
 
  export AWL_DBAUSER=davical_dba
  export AWL_APPUSER=davical_app
 
  # Get the major version for PostgreSQL
  export DBVERSION="`'''${PGINSTALL}/'''psql -qAt -c "SELECT version();" template1 | cut -f2 -d' ' | cut -f1-2 -d'.'`"
 
  install_note() {
    cat >>"${INSTALL_NOTE_FN}"
  }
 
  db_users() {
    '''${PGINSTALL}/'''psql -qAt -c "SELECT usename FROM pg_user;" template1
  }
 
  create_db_user() {
    if ! db_users | grep "^${1}$" >/dev/null ; then
      '''${PGINSTALL}/'''psql -qAt -c "CREATE USER ${1} NOCREATEDB NOCREATEROLE;" template1
      cat <<EONOTE | install_note
  *  You will need to edit the PostgreSQL pg_hba.conf to allow the
    '${1}' database user access to the 'davical' database.
 
  EONOTE
    fi
  }
 
  create_plpgsql_language() {
    if ! '''${PGINSTALL}/'''psql ${DBA} -qAt -c "SELECT lanname FROM pg_language;" "${DBNAME}" | grep "^plpgsql$" >/dev/null; then
      '''${PGINSTALL}/'''createlang plpgsql "${DBNAME}"
    fi
  }
 
  try_db_user() {
    [ "XtestX`'''${PGINSTALL}/'''psql -U "${1}" -qAt -c \"SELECT usename FROM pg_user;\" \"${DBNAME}\" 2>/dev/null`" != "XtestX" ]
  }
 
  create_db_user "${AWL_DBAUSER}"
  create_db_user "${AWL_APPUSER}"
 
  # FIXME: Need to check that the database was actually created.
  if ! '''${PGINSTALL}/'''createdb --encoding UTF8 --template template0 --owner "${AWL_DBAUSER}" "${DBNAME}" ; then
    echo "Unable to create database"
    exit 1
  fi
 
  #
  # Try a few alternatives for a database user or give up...
  if try_db_user "${AWL_DBAUSER}" ; then
    export DBA="-U ${AWL_DBAUSER}"
  else
    if try_db_user "postgres" ; then
      export DBA="-U postgres"
    else
      if try_db_user "${USER}" ; then
        export DBA=""
      else
        if try_db_user "${PGUSER}" ; then
          export DBA=""
        else
          cat <<EOFAILURE
  * * * * ERROR * * * *
  I cannot find a usable database user to construct the DAViCal database with, but
  may have successfully created the davical_app and davical_dba users (I tried :-).
 
  You should edit your pg_hba.conf file to give permissions to the davical_app and
  davical_dba users to access the database and run this script again.  If you still
  continue to see this message then you will need to make sure you run the script
  as a user with full permissions to access the local PostgreSQL database.
 
  If your PostgreSQL database is non-standard then you will need to set the PGHOST,
  PGPORT and/or PGCLUSTER environment variables before running this script again.
 
  See:  http://wiki.davical.org/w/Install_Errors/No_Database_Rights
 
  EOFAILURE
          exit 1
        fi
      fi
    fi
  fi
 
  create_plpgsql_language
 
  #
  # Load the AWL base tables and schema management tables
  '''${PGINSTALL}/'''psql -qAt ${DBA} -f "${AWLDIR}/dba/awl-tables.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT|
  NOTICE: )"
  '''${PGINSTALL}/'''psql -qAt ${DBA} -f "${AWLDIR}/dba/schema-management.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT| NOTICE: |^t$)"
 
  #
  # Load the DAViCal tables
  '''${PGINSTALL}/'''psql -qAt ${DBA} -f "${DBADIR}/davical.sql" "${DBNAME}" 2>&1 | egrep -v "(^CREATE |^GRANT|^BEGIN|^COMMIT| NOTICE: |^t$)"
 
  #
  # Set permissions for the application DB user on the database
  if ! ${DBADIR}/update-davical-database --dbname "${DBNAME}" --appuser "${AWL_APPUSER}" --nopatch --owner "${AWL_DBAUSER}" ; then
          cat <<EOFAILURE
  * * * * ERROR * * * *
  The database administration utility failed.  This is usually due to the Perl YAML
  or the Perl DBD::Pg libraries not being available.
 
  See:  http://wiki.davical.org/w/Install_Errors/No_Perl_YAML
 
  EOFAILURE
  fi
  #
  # Load the required base data
  '''${PGINSTALL}/'''psql -qAt ${DBA} -f "${DBADIR}/base-data.sql" "${DBNAME}" | egrep -v '^10'
 
  #
  # We can override the admin password generation for regression testing predictability
  if [ "${ADMINPW}" = "" ] ; then
    #
    # Generate a random administrative password.  If pwgen is available we'll use that,
    # otherwise try and hack something up using a few standard utilities
    ADMINPW="`pwgen -Bcny 2>/dev/null | tr \"\\\\\'\" '^='`"
  fi
 
  if [ "$ADMINPW" = "" ] ; then
    # OK.  They didn't supply one, and pwgen didn't work, so we hack something
    # together from /dev/random ...
    export LC_ALL=C
    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`"
  fi
 
  if [ "$ADMINPW" = "" ] ; then
    # Right.  We're getting desperate now.  We'll have to use a default password
    # and hope that they change it to something more sensible.
    ADMINPW="please change this password"
  fi
 
  '''${PGINSTALL}/'''psql -q -c "UPDATE usr SET password = '**${ADMINPW}' WHERE user_no = 1;" "${DBNAME}"
 
  echo "NOTE"
  echo "===="
  cat "${INSTALL_NOTE_FN}"
  rm "${INSTALL_NOTE_FN}"
 
  cat <<FRIENDLY
  *  The password for the 'admin' user has been set to '${ADMINPW}'"
 
  Thanks for trying DAViCal!  Check in /usr/share/doc/davical/examples/ for
  some configuration examples.  For help, visit #davical on irc.oftc.net.
 
  FRIENDLY
 
I hope this howto can help someone who is in same case ;-)
 
ps : thanks to davical developpers for your soft...
 
Vic

Latest revision as of 19:13, 11 June 2016