Commit 8db1d936 authored by Holger Levsen's avatar Holger Levsen

refactor: move cleanup_schroot_sessions() to common_functions.sh

parent 659b2aa7
......@@ -127,3 +127,24 @@ publish_changes_to_userContent(){
fi
}
cleanup_schroot_sessions() {
echo
local RESULT=""
for loop in $(seq 0 40) ; do
# first, check if no process using "schroot" is running, if thats the case, loop through all schroot sessions:
pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do
# then, check that schroot is still not run, and then delete the session
pgrep -f "schroot --directory" || schroot -e -c $i
done
RESULT=$(schroot --all-sessions -l)
if [ -z "$RESULT" ] ; then
echo "No schroot sessions in use atm..."
echo
break
fi
echo "$(date -u) - schroot session cleanup loop $loop"
sleep 15
done
echo
}
......@@ -114,12 +114,7 @@ fi
# remove old and unused schroot sessions
echo "$(date -u) - Removing unused schroot sessions."
pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do pgrep -f "schroot --directory" || schroot -e -c $i ; done
# to explain this:
# first, check if no process using "schroot" is running...
# then loop through all schroot sessions
# for each session
# check that schroot is still not run, and then, delete the session
cleanup_schroot_sessions
# find old schroots
echo "$(date -u) - Removing old schroots."
......
......@@ -182,24 +182,6 @@ bootstrap() {
fi
}
cleanup_schroot_sessions() {
echo
# FIXME: if this works well, move to _common.sh and use the same function from _maintenance.sh
local RESULT=""
for loop in $(seq 0 40) ; do
pgrep -f "schroot --directory" || for i in $(schroot --all-sessions -l ) ; do pgrep -f "schroot --directory" || schroot -e -c $i ; done
RESULT=$(schroot --all-sessions -l)
if [ -z "$RESULT" ] ; then
echo "No schroot sessions in use atm..."
echo
break
fi
echo "$(date -u) - schroot session cleanup loop $loop"
sleep 15
done
echo
}
cleanup() {
if [ -d $SCHROOT_TARGET ]; then
sudo rm -rf --one-file-system $SCHROOT_TARGET || ( echo "Warning: $SCHROOT_TARGET could not be fully removed on forced cleanup." ; ls $SCHROOT_TARGET -la )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment