[Dbconfig-common-devel] dbconfig-common README.pgsql,1.1,1.2 dbconfig-generate-include,1.2,1.3
seanius@haydn.debian.org
seanius@haydn.debian.org
- Previous message: [Dbconfig-common-devel] dbconfig-common/doc dbapp-policy.html,1.4,1.5 dbconfig-common-design.html,1.3,1.4 dbconfig-common-using.html,1.4,1.5 dbconfig-common.html,1.4,1.5
- Next message: [Dbconfig-common-devel] dbconfig-common/debian TODO,1.7,1.8 changelog,1.9,1.10 dbconfig-common.templates,1.8,1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/dbconfig-common/dbconfig-common
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv26326
Modified Files:
README.pgsql dbconfig-generate-include
Log Message:
the next version is underway. i there's a bit more that needs to be
done, but there's been enough done that i want to get it into cvs
before i accidentally rm -rf something important.
as soon as i finish the support for include file generation, and give
everything a final go-through with testing, i'll make another upload
to experimental and an announcement to d-d.
Index: README.pgsql
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/README.pgsql,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- README.pgsql 4 Feb 2005 06:29:07 -0000 1.1
+++ README.pgsql 23 Feb 2005 05:39:56 -0000 1.2
@@ -25,6 +25,9 @@
USING SSL
-the postgres command-line client has no way of enforcing that connections
-use ssl, this is something you must configure on your server.
+you must also configure your server to use SSL, which is beyond the
+scope of this document. see:
+http://developer.postgresql.org/docs/postgres/ssl-tcp.html
+
+for directions on how to do that.
Index: dbconfig-generate-include
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dbconfig-generate-include,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbconfig-generate-include 4 Feb 2005 06:26:06 -0000 1.2
+++ dbconfig-generate-include 23 Feb 2005 05:39:56 -0000 1.3
@@ -1,6 +1,7 @@
#!/bin/sh
# set some defaults
+format="sh"
dbuser_varname="dbuser"
dbpass_varname="dbpass"
dbname_varname="dbname"
@@ -8,11 +9,40 @@
dbport_varname="dbport"
dsn_varname="dsn"
-format="sh"
+usage(){
+ prog=`basename $0`
+ cat << EOF
-TEMP=`getopt -o f:d:u:D:P: --long dbuser::,dbpass::,dbport::,dbserver::,output:,format: -n 'foo.sh' -- "$@"`
+$prog - copyright (c) 2005 sean finney <seanius@debian.org>
-if [ $? != 0 ] ; then echo "terminating..." >&2 ; exit 1 ; fi
+usage: $prog [-h] [-f format] [-a] [-d [varname]] [-u [varname]] [-p [varname]] [-D [varname]] [-O owner[:group]] [-M perms] [-U] infile [outfile]
+
+ infile use the given dbconfig-common config file as input
+ outfile use the given file as input (default: stdout)
+ -f|--format use the given output format (default: sh)
+ -a|--all include all information in output (default)
+ -d|--dbname include the dbname in the output
+ -u|--dbuser include the dbuser in the output
+ -p|--dbpass include the dbpass in the output
+ -s|--dbserver include the dbserver in the output
+ -n|--dsn include all information as a URI-like resource file
+ -O|--owner set the owner:group of the output file
+ -M|--mask set the permissions on the output file
+ -U|--ucf register the outputfile with ucf
+
+ format is one of a list of include-file style formats for various
+ programming languages. the current list includes:
+ sh - /bin/sh style include file
+ perl - perl parseable include file
+ php - php parseable include file
+ cpp - c-style header file, using #define'd constants
+
+EOF
+}
+
+TEMP=`getopt -o af:hd::p::u::s::O:M:U --long help,dsn::,dbuser::,dbpass::,dbport::,dbserver::,output:,format:,owner:,mask:,ucf -n $0 -- "$@"`
+
+if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
eval set -- "$TEMP"
@@ -20,9 +50,21 @@
case "$1" in
-a|--all)
use_all="yes"
+ use_dsn="yes"
+ use_dbuser="yes"
+ use_dbpass="yes"
+ use_dbname="yes"
+ use_dbserver="yes"
shift
;;
- -d|--dsn)
+ -d|--dbname)
+ use_dbname="yes"
+ if [ ! -z "$2" ]; then
+ dbname_varname="$2"
+ fi
+ shift 2
+ ;;
+ -n|--dsn)
use_dsn="yes"
if [ ! -z "$2" ]; then
dsn_varname="$2"
@@ -37,13 +79,39 @@
shift 2
;;
-p|--dbpass)
- dbpass_varname="$2"
+ use_dbpass="yes"
+ if [ ! -z "$2" ]; then
+ dbpass_varname="$2"
+ fi
+ shift 2
+ ;;
+ -s|--dbserver)
+ use_dbserver="yes"
+ if [ ! -z "$2" ]; then
+ dbserver_varname="$2"
+ fi
shift 2
;;
-f|--format)
format="$2"
shift 2
;;
+ -O|--owner)
+ owner="$2"
+ shift 2
+ ;;
+ -M|--mask)
+ perms="$2"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit
+ ;;
+ -U|--ucf)
+ do_ucf=1
+ exit
+ ;;
--)
shift
break
@@ -55,17 +123,27 @@
esac
done
-usage(){
- echo "$0 - "
-}
-if [ ! $# = 1 ]; then
- echo "$@ usage:" >&2
+
+inputfile=$1
+outputfile=$2
+
+if [ ! "$inputfile" ]; then
+ echo "you must specify an inputfile" >&2
+ usage >&2
exit 1
fi
-inputfile="$1"
-if [ ! -f $inputfile -o ! -r $inputfile ]; then
+if [ "$outputfile" ]; then
+ tmpout=`mktemp -t dbconfig-generate-include.XXXXXX`
+ if [ ! -f "$tmpout" ]; then
+ echo "unable to create temporary file $tmpout" >&2
+ exit 1
+ fi
+ exec > $tmpout
+fi
+
+if [ ! -f "$inputfile" -o ! -r "$inputfile" ]; then
echo "unable to read input file $inputfile" >&2
exit 1
fi
@@ -75,21 +153,31 @@
exit 1
fi
+if [ "$use_dsn" ]; then
+ dbc_dsn="$dbc_dbtype://${dbc_dbuser}"
+ [ "$dbc_dbpass" ] && dbc_dsn="$dbc_dsn:$dbc_dbpass"
+ [ "$dbc_dbserver" ] && dbc_dsn="$dbc_dsn@$dbc_dbserver"
+ dbc_dsn=$dbc_dsn/$dbc_dbname
+fi
+
case $format in
sh)
-cat << EOF
+ cat << EOF
##
## database access settings in /bin/sh format
## automatically generated from $inputfile
## by $0
## `date -R`
-##
-$dbuser_varname="$dbuser";
-$dbpass_varname="$dbpass";
EOF
+ [ "$use_dbuser" ] && echo "$dbuser_varname='$dbc_dbuser'"
+ [ "$use_dbpass" ] && echo "$dbpass_varname='$dbc_dbpass'"
+ [ "$use_dbname" ] && echo "$dbname_varname='$dbc_dbname'"
+ [ "$use_dbserver" ] && echo "$dbserver_varname='$dbc_dbserver'"
+ [ "$use_dsn" ] && echo "$dsn_varname='$dbc_dsn'"
;;
+
php)
-cat << EOF
+ cat << EOF
<?php
##
## database access settings in php format
@@ -97,42 +185,62 @@
## by $0
## `date -R`
##
-\$$dbuser_varname="$dbuser";
-\$$dbpass_varname="$dbpass";
+EOF
+ [ "$use_dbuser" ] && echo "\$$dbuser_varname='$dbc_dbuser';"
+ [ "$use_dbpass" ] && echo "\$$dbpass_varname='$dbc_dbpass';"
+ [ "$use_dbname" ] && echo "\$$dbname_varname='$dbc_dbname';"
+ [ "$use_dbserver" ] && echo "\$$dbserver_varname='$dbc_dbserver';"
+ [ "$use_dsn" ] && echo "\$$dsn_varname='$dbc_dsn';"
+ cat << EOF
?>
EOF
;;
+
perl)
-cat << EOF
+ cat << EOF
##
## database access settings in perl format
## automatically generated from $inputfile
## by $0
## `date -R`
##
-our \$$dbuser_varname="$dbuser";
-our \$$dbpass_varname="$dbpass";
-our \$$dbadmin_varname="$dbadmin";
-our \$$dbadmpass_varname="$dbadmpass";
+EOF
+ [ "$use_dbuser" ] && echo "our \$$dbuser_varname='$dbc_dbuser';"
+ [ "$use_dbpass" ] && echo "our \$$dbpass_varname='$dbc_dbpass';"
+ [ "$use_dbname" ] && echo "our \$$dbname_varname='$dbc_dbname';"
+ [ "$use_dbserver" ] && echo "our \$$dbserver_varname='$dbc_dbserver';"
+ [ "$use_dsn" ] && echo "our \$$dsn_varname='$dbc_dsn';"
+ cat << EOF
1;
EOF
;;
-c)
-cat << EOF
+cpp)
+ cat << EOF
/*
- * database access settings in c header format
+ * database access settings in cpp header format
+ * why you would ever need this, who knows? :)
* automatically generated from $inputfile
* by $0
* `date -R`
*/
#ifndef _DBCONFIG_COMMON_CONFIG_
- #define _DBCONFIG_COMMON_CONFIG_ 1
- #define $dbuser_varname="$dbuser";
- #define $dbpass_varname="$dbpass";
- #define $dbadmin_varname="$dbadmin";
- #define $dbadmpass_varname="$dbadmpass";
+ #define _DBCONFIG_COMMON_CONFIG_
+EOF
+ [ "$use_dbuser" ] && echo " #define $dbuser_varname \"$dbc_dbuser\";"
+ [ "$use_dbpass" ] && echo " #define $dbpass_varname \"$dbc_dbpass\";"
+ [ "$use_dbname" ] && echo " #define $dbname_varname \"$dbc_dbname\";"
+ [ "$use_dbserver" ] && echo " #define $dbserver_varname \"$dbc_dbserver\";"
+ [ "$use_dsn" ] && echo " #define $dsn_varname \"$dbc_dsn\";"
+ cat << EOF
#endif /* _DBCONFIG_COMMON_CONFIG_ */
EOF
;;
esac
+if [ "$outputfile" ]; then
+ if [ "$do_ucf" ]; then
+ ucf "$tmpout" "$outputfile"
+ else
+ mv "$tmpout" "$outputfile"
+ fi
+fi
- Previous message: [Dbconfig-common-devel] dbconfig-common/doc dbapp-policy.html,1.4,1.5 dbconfig-common-design.html,1.3,1.4 dbconfig-common-using.html,1.4,1.5 dbconfig-common.html,1.4,1.5
- Next message: [Dbconfig-common-devel] dbconfig-common/debian TODO,1.7,1.8 changelog,1.9,1.10 dbconfig-common.templates,1.8,1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]