/usr/sbin/dbconfig-load-include is in dbconfig-common 1.8.47+nmu3+deb8u1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | #!/bin/sh
# set some defaults
dbuser_varname="dbuser"
dbpass_varname="dbpass"
dbname_varname="dbname"
dbserver_varname="dbserver"
dbport_varname="dbport"
dbtype_varname="dbtype"
basepath_varname="basepath"
# the version will always be < the package version
VERSION="$Revision$"
version(){
prog=`basename $0`
cat << EOF
$prog v$VERSION
copyright (c) 2005 sean finney <seanius@debian.org>
EOF
}
usage(){
version
cat << EOF
usage: $prog [-hv] [-a] [-d[varname]] [-u[varname]] [-p[varname]] [-s[varname]] [-P[varname]] [-t[varname]] -f format infile
infile use the given dbconfig-common config file as input
-f|--format use the given output format (must be specified)
-a|--all include all information in output (default)
-b|--basepath include the basepath in the output
-d|--dbname include the dbname in the output
-p|--dbpass include the dbpass in the output
-s|--dbserver include the dbserver in the output
-P|--dbport include the dbport in the output
-u|--dbuser include the dbuser in the output
-t|--dbtype include the dbtype in the output
-h|--help display this helpful message
-v|--version output the version and exit
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
exec - run the file as a script and interpret its output.
EOF
}
TEMP=`getopt -o af:hb::d::p::u::s::t::P::v -l help,dbuser::,dbname::,dbpass::,dbport::,dbserver::,dbtype::,basepath::,format:,version -n $0 -- "$@"`
if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
eval set -- "$TEMP"
while true; do
case "$1" in
-a|--all)
use_all="yes"
shift
;;
-b|--basepath)
use_basepath="yes"
if [ ! -z "$2" ]; then
basepath_varname="$2"
fi
shift 2
;;
-d|--dbname)
use_dbname="yes"
if [ ! -z "$2" ]; then
dbname_varname="$2"
fi
shift 2
;;
-u|--dbuser)
use_dbuser="yes"
if [ ! -z "$2" ]; then
dbuser_varname="$2"
fi
shift 2
;;
-p|--dbpass)
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
;;
-P|--dbport)
use_dbport="yes"
if [ ! -z "$2" ]; then
dbport_varname="$2"
fi
shift 2
;;
-t|--dbtype)
use_dbtype="yes"
if [ ! -z "$2" ]; then
dbtype_varname="$2"
fi
shift 2
;;
-f|--format)
format="$2"
shift 2
;;
-h|--help)
usage
exit
;;
-v|--version)
version
exit
;;
--)
shift
break
;;
*)
echo "eh? $1" >&2
exit 1
;;
esac
done
# if they asked for all vars, or didn't ask for anything (which defaults to all)
if [ "$use_all" ] || [ ! "${use_dbuser}${use_dbpass}${use_basepath}${use_dbname}${use_dbserver}${use_dbtype}${use_dbport}" ]; then
use_dbuser="yes"
use_dbpass="yes"
use_basepath="yes"
use_dbname="yes"
use_dbserver="yes"
use_dbport="yes"
use_dbtype="yes"
fi
inputfile=$1
rv=0
if [ ! "$inputfile" ]; then
echo "error: you must specify an inputfile" >&2
usage >&2
exit 1
fi
if [ ! -f "$inputfile" ] || [ ! -r "$inputfile" ]; then
echo "unable to read input file $inputfile" >&2
exit 1
fi
if [ ! "$format" ]; then
echo "error: you must specify a format!" >&2
usage >&2
exit 1
fi
case $format in
sh)
cat << EOF | sh
. $inputfile
use_dbuser="$use_dbuser";
use_dbpass="$use_dbpass";
use_basepath="$use_basepath";
use_dbname="$use_dbname";
use_dbserver="$use_dbserver";
use_dbport="$use_dbport";
use_dbtype="$use_dbtype";
[ "$use_dbuser" ] && cat << FOO
dbc_dbuser='\$$dbuser_varname'
FOO
[ "$use_dbpass" ] && cat << FOO
dbc_dbpass='\$$dbpass_varname'
FOO
[ "$use_basepath" ] && echo "dbc_basepath='\$$basepath_varname'"
[ "$use_dbname" ] && echo "dbc_dbname='\$$dbname_varname'"
[ "$use_dbserver" ] && echo "dbc_dbserver='\$$dbserver_varname'"
[ "$use_dbport" ] && echo "dbc_dbport='\$$dbport_varname'"
[ "$use_dbtype" ] && echo "dbc_dbtype='\$$dbtype_varname'"
EOF
;;
php)
if ! which php > /dev/null; then
echo "error: php format but i can't find a php binary!" >&2
exit 1
fi
cat << EOF | php
<?php
require_once "$inputfile";
\$use_dbuser="$use_dbuser";
\$use_dbpass="$use_dbpass";
\$use_basepath="$use_basepath";
\$use_dbname="$use_dbname";
\$use_dbserver="$use_dbserver";
\$use_dbport="$use_dbport";
\$use_dbtype="$use_dbtype";
if(!empty(\$use_dbuser) && isset(\$$dbuser_varname))
echo "dbc_dbuser='\$$dbuser_varname';\n";
if(!empty(\$use_dbpass) && isset(\$$dbpass_varname))
echo "dbc_dbpass='\$$dbpass_varname';\n";
if(!empty(\$use_basepath) && isset(\$$basepath_varname))
echo "dbc_basepath='\$$basepath_varname';\n";
if(!empty(\$use_dbname) && isset(\$$dbname_varname))
echo "dbc_dbname='\$$dbname_varname';\n";
if(!empty(\$use_dbserver) && isset(\$$dbserver_varname))
echo "dbc_dbserver='\$$dbserver_varname';\n";
if(!empty(\$use_dbport) && isset(\$$dbport_varname))
echo "dbc_dbport='\$$dbport_varname';\n";
if(!empty(\$use_dbtype) && isset(\$$dbtype_varname))
echo "dbc_dbtype='\$$dbtype_varname';\n";
EOF
;;
perl)
( cat $inputfile; cat << EOF ) | perl
print "dbc_dbuser='\$$dbuser_varname'\n" if("$use_dbuser");
print "dbc_dbpass='\$$dbpass_varname'\n" if("$use_dbpass");
print "dbc_basepath='\$$basepath_varname'\n" if("$use_basepath");
print "dbc_dbname='\$$dbname_varname'\n" if("$use_dbname");
print "dbc_dbserver='\$$dbserver_varname'\n" if("$use_dbserver");
print "dbc_dbport='\$$dbport_varname'\n" if("$use_dbport");
print "dbc_dbtype='\$$dbtype_varname'\n" if("$use_dbtype");
EOF
;;
exec)
sh -c $inputfile
rv="$?"
;;
esac
exit $rv
|