source: trunk/debathena/scripts/clean-schroots @ 23048

Revision 23048, 750 bytes checked in by andersk, 16 years ago (diff)
Match temporary sbuild chroots with a more specific pattern.
  • Property svn:executable set to *
RevLine 
[22687]1#!/bin/sh
[22688]2
3# Usage: clean-schroots
4
5# Remove any LVM snapshots and chroots left behind by schroot.  Not
6# normally necessary as schroot should clean up after itself.
7
[22727]8: ${VG=/dev/dink}
[22687]9set -x
10for i in $(
[22727]11    for dir in "$VG" /var/lib/schroot/mount /var/lib/schroot/session; do
[22687]12        cd "$dir"
[23048]13        for i in *-sbuild-????????-????-????-????-????????????; do
[22687]14            echo "$i"
15        done
16    done | \
17    sort -u | grep -v "\*"
18); do
[23048]19    schroot -ec "$i"
[22687]20    if [ "$1" = "-f" ]; then
21        tac /proc/mounts | cut -d" " -f2 | fgrep "/var/lib/schroot/mount/$i" | xargs -rn1 umount -l
[22727]22        lvremove -f "$VG/$i"
[22687]23        rmdir /var/lib/schroot/mount/"$i" /var/lib/schroot/session/"$i"
[22727]24        if ! [ -e "$VG/$i" ]; then rm "$VG/$i"; fi
[22687]25    fi
26done
Note: See TracBrowser for help on using the repository browser.