You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.4 KiB

#!/usr/bin/env bash
set -eu
FORCE=0
synopsis() {
cat << EOF
Usage : `basename $0` [-h] [-f] system
EOF
}
help() {
cat << EOF
`basename $0` supprime les modifications d'un système.
`synopsis`
-h : affiche cette aide
-f : pas de demande de confirmation
Remarque : Les fichiers seront regénérés (vides) au prochain
demarrage de la machine.
EOF
}
usage() {
synopsis
exit 1
}
args() {
local opt
while getopts "hf" opt; do
case $opt in
h) help; exit 0;;
f) FORCE=1;;
?) usage;;
esac
done
shift $(($OPTIND - 1))
GUEST_NAMES="$@"
[ -z "$GUEST_NAMES" ] && usage || :
}
# Programme principal
VDN_PATH=$(readlink -f $(dirname $0)/..); . $VDN_PATH/bin/functions.sh
args "$@"
SAVE_FILES=""
for i in $GUEST_NAMES; do
loadGuestVars $i
[ -n "$SAVE_FILE" ] && {
[ -e $SAVE_FILE ] && \
SAVE_FILES="$SAVE_FILES $SAVE_FILE" || :
} || :
[ -n "$HDB" ] && {
set +u
[ -z "$SAVE_DIR_HDB" ] && SAVE_DIR_HDB=$SAVE_DIR
set -u
[ -e $SAVE_DIR_HDB/$HDB ] && \
SAVE_FILES="$SAVE_FILES $SAVE_DIR_HDB/$HDB" || :
} || :
done
if [ -n "$SAVE_FILES" ]; then
if [ $FORCE = 0 ]; then
echo -e "Supprimer ? :"
for i in $SAVE_FILES; do
du -h $i
done
msg="Supprimer tous les fichiers ?"
request "$msg"
[ $? != 0 ] && exit || :
fi
echo
rm -f $SAVE_FILES
echo "rm -f $SAVE_FILES"
else
echo "No files to clean !" >&2
sleep 1
fi