davical/davical-setup.sh

Sat, 24 Mar 2012 21:40:49 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 24 Mar 2012 21:40:49 +0100
changeset 414
fd611cde817f
parent 298
e2eb036d448f
permissions
-rw-r--r--

Introduce many changes to the buildconf and source code including:
(01) clean up, update, and partially update default config files,
(02) seems that Melware is unable to perform release engineering so
update chan_capi to new daily snapshot to solve echo problems,
(03) correct Asterisk inadequate hard coded gmime version check,
(04) force postgresql pthreads linkage to solve build problem,
(05) remove buggy hard coded LibXML configure definitions,
(06) remove local architecture specification to allow GCC
internal logic to determine proper CPU type instead,
(07) remove vendor sound install target causing uncontrolled
downloads and non RPM managed file installation,
(08) solve long outstanding bug in tcptls causing Asterisk
to ignore any intermediate CA certificate signatures,
(09) back out Digium engineering team's bright idea of replacing the
very portable and pervasive POSIX rand(1) with ast_random(), and
then not even implementing it causing all references to fail in
platforms not providing the very new POSIX.1-2008 mkdtemp(3)
function only distributed by BSD and some Linux,
(10) withdraw advanced linker symbol manipulations from SVR5 builds
until either Binutils supports hybrid versioned and anonymous
linker scripts or GCC stops hard coding versioned linker scripts,
(11) correct missing library linkage, some tailored to a specific OS,
(12) remove outdated logic for the no longer distributed gmime-config(1),
(13) remove local gmime buildconf hacks now that Asterisk has corrected
their own build configuration to almost portably support gmime,
(14) solve build problems relating to undetected LibXML paths,
(15) correct erroneous out of tree include definitions,
(16) improve some variable and comment naming,
(17) simplify sound language path hierarchy creation,
and correct australian english installation logic.

michael@290 1 #!/bin/sh
michael@290 2 ##
michael@290 3 ## davical-setup
michael@290 4 ##
michael@290 5
michael@290 6 # command line argument sanity check
michael@290 7 prg="$0"
michael@290 8 if [ $# -eq 0 ]; then
michael@290 9 echo "$prg:ERROR: invalid command line" 1>&2
michael@290 10 echo "$prg:USAGE: $prg install [<admin-password>]" 1>&2
michael@290 11 echo "$prg:USAGE: $prg uninstall" 1>&2
michael@290 12 echo "$prg:USAGE: $prg edit" 1>&2
michael@290 13 exit 1
michael@290 14 fi
michael@290 15
michael@290 16 # database configuration
michael@290 17 db_dir="@l_prefix@/var/davical/db"
michael@290 18 db_name="davical"
michael@290 19 db_user="davical"
michael@290 20 db_pass="davical"
michael@290 21 db_sname=`grep "^superuser_database" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 22 sed -e 's;^ *superuser_database="\(.*\)".*;\1;'`
michael@290 23 db_suser=`grep "^superuser_username" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 24 sed -e 's;^ *superuser_username="\(.*\)".*;\1;'`
michael@290 25 db_spass=`grep "^superuser_password" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 26 sed -e 's;^ *superuser_password="\(.*\)".*;\1;'`
michael@290 27
michael@290 28 # dispatch operation
michael@290 29 cmd="${1:-"install"}"
michael@290 30 shift
michael@290 31 case "$cmd" in
michael@290 32 install )
michael@290 33 # determine admin password
michael@290 34 admin_password="$1"
michael@290 35 if [ ".$admin_password" = . ]; then
michael@290 36 admin_password="`@l_prefix@/bin/apg -Mncl -a1 -m12 -n1`"
michael@290 37 echo "ATTENTION: using generated \"admin\" password: \"$admin_password\"" 1>&2
michael@290 38 fi
michael@290 39
michael@290 40 # create database
michael@290 41 ( echo "CREATE ROLE $db_user LOGIN ENCRYPTED PASSWORD '$db_pass' NOCREATEDB NOCREATEUSER;"
michael@290 42 echo "CREATE TABLESPACE $db_name OWNER $db_user LOCATION '$db_dir';"
michael@396 43 echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name TEMPLATE template0 ENCODING 'UTF8';"
michael@290 44 ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
michael@396 45
michael@396 46 # ensure PL/PgSQL language is available
michael@290 47 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 48 -c "CREATE LANGUAGE plpgsql;"
michael@290 49
michael@290 50 # create schema 1/2 (from original "create_database" script)
michael@290 51 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 52 -f "@l_prefix@/lib/davical/awl/dba/awl-tables.sql" 2>&1 | grep -v NOTICE
michael@290 53 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 54 -f "@l_prefix@/lib/davical/awl/dba/schema-management.sql" 2>&1 | grep -v NOTICE
michael@290 55 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 56 -f "@l_prefix@/lib/davical/davical/dba/davical.sql" 2>&1 | grep -v NOTICE
michael@290 57 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 58 -f "@l_prefix@/lib/davical/davical/dba/base-data.sql" 2>&1 | grep -v NOTICE
michael@290 59
michael@396 60 # create schema 2/3 (from nowhere, but required by appuser_permissions.txt below)
michael@396 61 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@396 62 -f "@l_prefix@/lib/davical/davical/dba/views/dav_principal.sql" 2>&1 | grep -v NOTICE
michael@396 63
michael@396 64 # create schema 3/3 (from original "update-davical-database" script)
michael@290 65 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 66 -f "@l_prefix@/lib/davical/davical/dba/supported_locales.sql" 2>&1 | grep -v NOTICE
michael@290 67 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 68 -f "@l_prefix@/lib/davical/davical/dba/caldav_functions.sql" 2>&1 | egrep -v '(NOTICE|ERROR)'
michael@290 69 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 70 -f "@l_prefix@/lib/davical/davical/dba/rrule_functions.sql" 2>&1 | egrep -v '(NOTICE|ERROR)'
michael@290 71 PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_name" -A -t \
michael@290 72 -f "@l_prefix@/lib/davical/davical/dba/appuser_permissions.txt" 2>&1 | grep -v NOTICE
michael@290 73
michael@290 74 # set admin password
michael@290 75 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 76 -c "UPDATE usr SET password = '**$admin_password' WHERE user_no = 1;"
michael@290 77 ;;
michael@290 78
michael@290 79 uninstall )
michael@396 80 # destroy PL/PgSQL language
michael@290 81 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 82 -c "DROP LANGUAGE plpgsql CASCADE;" 2>&1 | grep -v NOTICE
michael@396 83
michael@396 84 # destroy database
michael@290 85 ( echo "DROP DATABASE $db_name;"
michael@290 86 echo "DROP TABLESPACE $db_name;"
michael@290 87 echo "DROP ROLE $db_user;"
michael@290 88 ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
michael@290 89 ;;
michael@290 90
michael@290 91 edit )
michael@396 92 # edit database
michael@290 93 PGPASSWORD="$db_spass" @l_prefix@/bin/psql -U "$db_suser" -d "$db_name"
michael@290 94 ;;
michael@290 95 esac
michael@290 96

mercurial