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

Revision 23048, 750 bytes checked in by andersk, 13 years ago (diff)
Match temporary sbuild chroots with a more specific pattern.
  • Property svn:executable set to *
Line 
1#!/bin/sh
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
8: ${VG=/dev/dink}
9set -x
10for i in $(
11    for dir in "$VG" /var/lib/schroot/mount /var/lib/schroot/session; do
12        cd "$dir"
13        for i in *-sbuild-????????-????-????-????-????????????; do
14            echo "$i"
15        done
16    done | \
17    sort -u | grep -v "\*"
18); do
19    schroot -ec "$i"
20    if [ "$1" = "-f" ]; then
21        tac /proc/mounts | cut -d" " -f2 | fgrep "/var/lib/schroot/mount/$i" | xargs -rn1 umount -l
22        lvremove -f "$VG/$i"
23        rmdir /var/lib/schroot/mount/"$i" /var/lib/schroot/session/"$i"
24        if ! [ -e "$VG/$i" ]; then rm "$VG/$i"; fi
25    fi
26done
Note: See TracBrowser for help on using the repository browser.