summaryrefslogtreecommitdiffstats
path: root/bin/schroot-create.sh
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2015-09-10 11:28:56 +0200
committerHolger Levsen <holger@layer-acht.org>2015-09-10 11:28:56 +0200
commit064e46b4a50e165b0046a51982dbb31617dc1389 (patch)
treef6ca56febdea1861990602b6b3b035bf3f864bde /bin/schroot-create.sh
parent95e01b859cc5aca85e847a2f755cce03ab61c4e6 (diff)
downloadjenkins.debian.net-064e46b4a50e165b0046a51982dbb31617dc1389.tar.xz
reproducible: cleanup schroot sessions before moving them away
Diffstat (limited to 'bin/schroot-create.sh')
-rwxr-xr-xbin/schroot-create.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh
index c3ffe469..51859325 100755
--- a/bin/schroot-create.sh
+++ b/bin/schroot-create.sh
@@ -181,6 +181,12 @@ bootstrap() {
fi
}
+cleanup_schroot_sessions() {
+ # FIXME: if this works well, move to _common.sh and use the same function from _maintenance.sh
+ ps fax|grep -v grep |grep schroot || for i in $(schroot --all-sessions -l ) ; do ps fax|grep -v grep |grep schroot || schroot -e -c $i ; done
+ schroot --all-sessions -l
+}
+
cleanup() {
if [ -d $CHROOT_TARGET ]; then
sudo rm -rf --one-file-system $CHROOT_TARGET || ( echo "Warning: $CHROOT_TARGET could not be fully removed on forced cleanup." ; ls $CHROOT_TARGET -la )
@@ -196,10 +202,12 @@ trap - INT TERM EXIT
rand=$RANDOM
if [ -d $SCHROOT_BASE/"$TARGET" ]
then
+ cleanup_schroot_sessions
echo "$(date -u ) - $SCHROOT_BASE/$TARGET exists, moving it away to $SCHROOT_BASE/$TARGET-$rand"
sudo mv $SCHROOT_BASE/"$TARGET" $SCHROOT_BASE/"$TARGET"-"$rand"
fi
+cleanup_schroot_sessions
echo "$(date -u ) - renaming $CHROOT_TARGET to $SCHROOT_BASE/$TARGET"
sudo mv $CHROOT_TARGET $SCHROOT_BASE/"$TARGET"