/usr/share/piuparts/lib/read_config.sh is in piuparts-common 0.77.
This file is owned by root:root, with mode 0o644.
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 | # Copyright © 2011, 2013 Andreas Beckmann (anbe@debian.org)
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Helper function for getting values from piuparts.conf.
# Used by several master and slave scripts.
#
PIUPARTS_CONF=${PIUPARTS_CONF:-/etc/piuparts/piuparts.conf}
[ -f "$PIUPARTS_CONF" ] || exit 0
# usage: get_config_value VARIABLE section key [default]
get_config_value()
{
local section key value
test -n "$1" && test "$1" = "$(echo "$1" | tr -c -d '[:alnum:]_')" || exit 1
section="$2"
key="$3"
# First select the [$section] block (\#^\[$section\]#) (use # as
# marker because $section may contain slashes) up to the start of the
# next section (/^\[/). The select the $key=value, this may be wrapped
# with indented lines and comment lines embedded. The $key=value is
# over once we hit the next key (or any line not starting with # or
# whitespace. Throw away comments (/^#/d), the following key, remove
# our $key= part, trim the value, remove empty lines, and print it.
value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/,/^[^ \t#]/ {/^#/d; /^'"$key"'\s*=|^\s/!d; s/^'"$key"'\s*=\s*//; s/^\s*//; s/\s*$//; /^$/d; p}}' "$PIUPARTS_CONF")"
if [ -z "$value" ]; then
if [ -n "${4+set}" ]; then
value="$4"
else
echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
exit 1
fi
fi
eval "$1"='"$value"'
}
|