[Piuparts-commits] [SCM] piatti.debian.org configuration files branch, master, updated. 148332ef45997ba3aaf38cc2c9a28441083bad49
Andreas Beckmann
debian at abeckmann.de
Fri Dec 23 10:24:21 UTC 2011
The following commit has been merged in the master branch:
commit 6f91a5c4f5575f4bbc9cf13b8a1dc6b6d2471701
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Wed Nov 30 14:59:13 2011 +0100
use new style config parsing
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/home/piupartsm/bin/archive_old_logs b/home/piupartsm/bin/archive_old_logs
index 3380d87..e91deb9 100755
--- a/home/piupartsm/bin/archive_old_logs
+++ b/home/piupartsm/bin/archive_old_logs
@@ -16,18 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# archive old log files
diff --git a/home/piupartsm/bin/detect_archive_issues b/home/piupartsm/bin/detect_archive_issues
index 884baef..72bd0a8 100755
--- a/home/piupartsm/bin/detect_archive_issues
+++ b/home/piupartsm/bin/detect_archive_issues
@@ -16,19 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-[ -e /etc/piuparts/piuparts.conf ] || exit 0
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# detect packages which are/were untestable due to archive issue and mark them as such
diff --git a/home/piupartsm/bin/detect_network_issues b/home/piupartsm/bin/detect_network_issues
index 37f4f7e..f19905a 100755
--- a/home/piupartsm/bin/detect_network_issues
+++ b/home/piupartsm/bin/detect_network_issues
@@ -16,19 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-[ -e /etc/piuparts/piuparts.conf ] || exit 0
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# detect network/mirror problems
diff --git a/home/piupartsm/bin/detect_piuparts_issues b/home/piupartsm/bin/detect_piuparts_issues
index 1341c34..92fe8d9 100755
--- a/home/piupartsm/bin/detect_piuparts_issues
+++ b/home/piupartsm/bin/detect_piuparts_issues
@@ -16,19 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-[ -e /etc/piuparts/piuparts.conf ] || exit 0
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# detect piuparts problems
@@ -41,6 +51,7 @@ for SECTION in $SECTIONS ; do
rgrep -l -e "^RuntimeError: maximum recursion depth exceeded while calling a Python object" $MASTER/$SECTION/fail >> $FILE
rgrep -l -e "^Traceback" $MASTER/$SECTION/fail >> $FILE
rgrep -l -e "^OSError:" $MASTER/$SECTION/fail >> $FILE
+ # Python errors from maintainer scripts etc. would be indented by 2 spaces, so don't match here.
done
if [ -s $FILE ] ; then
echo "piuparts problem detected!"
diff --git a/home/piupartsm/bin/detect_slave_problems b/home/piupartsm/bin/detect_slave_problems
index 17b136a..527a46e 100755
--- a/home/piupartsm/bin/detect_slave_problems
+++ b/home/piupartsm/bin/detect_slave_problems
@@ -21,19 +21,29 @@ if [ "$HOSTNAME" != "piatti" ] ; then
exit 0
fi
-#
-# parse config file
-#
-[ -e /etc/piuparts/piuparts.conf ] || exit 0
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# this scripts monitors the output of piuparts-slave
diff --git a/home/piupartsm/bin/detect_stale_mounts b/home/piupartsm/bin/detect_stale_mounts
index 720a4dd..e35e9b5 100755
--- a/home/piupartsm/bin/detect_stale_mounts
+++ b/home/piupartsm/bin/detect_stale_mounts
@@ -16,6 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+
+
FILE=`mktemp`
cp /proc/mounts $FILE
diff --git a/home/piupartsm/bin/detect_tmp_cruft b/home/piupartsm/bin/detect_tmp_cruft
index d047c2b..8f3c4b6 100755
--- a/home/piupartsm/bin/detect_tmp_cruft
+++ b/home/piupartsm/bin/detect_tmp_cruft
@@ -16,6 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+
+
LS_TMP=$(ls --color=never -l /org/piuparts.debian.org/tmp)
if [ "$(echo "$LS_TMP" | wc -l)" -gt 12 ] ; then
echo "More than ten directories in /org/piuparts.debian.org/tmp detected!"
diff --git a/home/piupartsm/bin/detect_well_known_errors b/home/piupartsm/bin/detect_well_known_errors
index 555a870..acd949a 100755
--- a/home/piupartsm/bin/detect_well_known_errors
+++ b/home/piupartsm/bin/detect_well_known_errors
@@ -16,19 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-[ -e /etc/piuparts/piuparts.conf ] || exit 0
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# loop through all known problems
diff --git a/home/piupartsm/bin/prepare_backup b/home/piupartsm/bin/prepare_backup
index 135f885..df7af54 100755
--- a/home/piupartsm/bin/prepare_backup
+++ b/home/piupartsm/bin/prepare_backup
@@ -16,17 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# backup statistiscs files to a single directory for DSA to backup
diff --git a/home/piupartsm/bin/report_stale_reserved_packages b/home/piupartsm/bin/report_stale_reserved_packages
index 190ec47..da2f0de 100755
--- a/home/piupartsm/bin/report_stale_reserved_packages
+++ b/home/piupartsm/bin/report_stale_reserved_packages
@@ -16,18 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# find packages which have been reserved for more than 2 days and unschedule them
diff --git a/home/piupartsm/bin/report_untestable_packages b/home/piupartsm/bin/report_untestable_packages
index 3def3ac..e165b9f 100755
--- a/home/piupartsm/bin/report_untestable_packages
+++ b/home/piupartsm/bin/report_untestable_packages
@@ -16,18 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
#
# find packages which have been in untestable for more than $DAYS days and reschedule them for testing
diff --git a/home/piupartsm/bin/reschedule_oldest_logs b/home/piupartsm/bin/reschedule_oldest_logs
index fe217fb..789f194 100755
--- a/home/piupartsm/bin/reschedule_oldest_logs
+++ b/home/piupartsm/bin/reschedule_oldest_logs
@@ -16,18 +16,29 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# parse config file
-#
-TEMPFILE=`mktemp`
-egrep "(^sections|^master-directory)" /etc/piuparts/piuparts.conf| sed -e "s# =#=#g" -e "s#= #=#g" -e 's#=#="#' -e 's#$#"#' -e "s#sections#SECTIONS#" -e "s#master-directory#MASTER#" > $TEMPFILE
-. $TEMPFILE
-rm $TEMPFILE
-if [ -z "$MASTER" ] || [ -z "$SECTIONS" ] ; then
- echo "sections and/or master-directory not set in /etc/piuparts/piuparts.conf, exiting."
- exit 1
-fi
+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"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
+ if [ -z "$value" ]; then
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
+ exit 1
+ fi
+ eval "$1"='"$value"'
+}
+
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+
AGE=180
COUNT=200
--
piatti.debian.org configuration files
More information about the Piuparts-commits
mailing list