[Piuparts-commits] [SCM] piatti.debian.org configuration files branch, piatti, updated. 0.43-15-g9510d05
Andreas Beckmann
debian at abeckmann.de
Tue Jan 31 07:59:56 UTC 2012
The following commit has been merged in the piatti branch:
commit ea3cc172cd9cede42c09510bc23d03e858ad0f6a
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Tue Jan 24 11:14:36 2012 +0100
read piuparts.conf instead of using hardcoded values
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/home/piupartss/bin/detect_leftover_processes b/home/piupartss/bin/detect_leftover_processes
index 4fda80e..ca97325 100755
--- a/home/piupartss/bin/detect_leftover_processes
+++ b/home/piupartss/bin/detect_leftover_processes
@@ -16,30 +16,40 @@
# 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 PIUPARTS_TEMPDIR global tempdir /org/piuparts.debian.org/tmp
#
# find processes running in deleted chroots
#
-
+# FIXME: is this script still needed?
+# FIXME: why does this need access to the $MASTER directory?
MONITORDIR=$MASTER/monitor-slave
LOCKFILE="$MONITORDIR/leftover_processes"
-OUTPUT=$(sudo ls --color=never -lad /proc/*/root 2>/dev/null|grep "/org/piuparts.debian.org/tmp" | grep "(deleted)")
+OUTPUT=$(sudo ls --color=never -lad /proc/*/root 2>/dev/null|grep "$PIUPARTS_TEMPDIR" | grep "(deleted)")
if [ "$OUTPUT" != "" ] && [ "$(cat $LOCKFILE)" != "$OUTPUT" ] ; then
- echo "Found processes running with a deleted chroot in /org/piuparts.debian.org/tmp/"
+ echo "Found processes running with a deleted chroot in $PIUPARTS_TEMPDIR"
echo "This is usually because of 'FAIL: Processes are running inside chroot' which usually"
echo "means the packages violates 'must use invoke-rc.d (policy 9.3.3.2)'."
echo
@@ -48,7 +58,7 @@ if [ "$OUTPUT" != "" ] && [ "$(cat $LOCKFILE)" != "$OUTPUT" ] ; then
echo "Please cleanup manually."
echo "#522918 has been filed to make this manual operation unneeded."
mkdir -p $MONITORDIR
- sudo chown piupartsm.piuparts $MONITORDIR
+ sudo chown piupartsm:piuparts $MONITORDIR
sudo chmod 775 $MONITORDIR
echo $OUTPUT > $LOCKFILE
chmod 664 $LOCKFILE
diff --git a/home/piupartss/bin/slave_cleanup b/home/piupartss/bin/slave_cleanup
index 382d753..606a53b 100755
--- a/home/piupartss/bin/slave_cleanup
+++ b/home/piupartss/bin/slave_cleanup
@@ -28,12 +28,36 @@ if [ "$(ps fax|grep piuparts-slave|grep -v grep)" != "" ] ; then
exit 0
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 PIUPARTS_TEMPDIR global tempdir /org/piuparts.debian.org/tmp
+
+
# umount all mount points (should be none on boot, but this script can also be called at other times)
-for MOUNTPOINT in $(cat /proc/mounts|cut -d " " -f 2|grep /org/piuparts.debian.org/tmp/) ; do
+for MOUNTPOINT in $(tac /proc/mounts | cut -d " " -f 2 | grep $PIUPARTS_TEMPDIR/)
+do
sudo umount $MOUNTPOINT
done
# cleanup tmp
-sudo rm /org/piuparts.debian.org/tmp -Rf
-mkdir /org/piuparts.debian.org/tmp
+sudo rm -rf --one-file-system $PIUPARTS_TEMPDIR
+mkdir -p $PIUPARTS_TEMPDIR
--
piatti.debian.org configuration files
More information about the Piuparts-commits
mailing list