48 lines
969 B
Bash
Executable File
48 lines
969 B
Bash
Executable File
#!/bin/bash
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
STATUS="$1"
|
|
BCKDIR="${2:-/backup}"
|
|
VGNAME="$3"
|
|
LVNAME="$4"
|
|
|
|
###############################################################################
|
|
# Ne pas modifier à partir d'ici
|
|
|
|
function die() {
|
|
[ -n "$*" ] && echo "$*"
|
|
exit 1
|
|
}
|
|
|
|
# vérifier le status
|
|
[ "$STATUS" == "OK" ] || die "ERR status"
|
|
shift
|
|
|
|
# sauter les argument (BCKDIR, VGNAME, LVNAME)
|
|
shift; shift; shift
|
|
|
|
mountro=
|
|
umount=
|
|
umountvg=
|
|
|
|
while [ -n "$1" ]; do
|
|
case "$1" in
|
|
mounted_rw) mountro=1;;
|
|
mounted) umount=1;;
|
|
mounted_vg) umountvg=1;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -n "$mountro" ]; then
|
|
mount -o remount,ro "$BCKDIR" >&/dev/null || die "ERR cannot remount $BCKDIR as R/O"
|
|
fi
|
|
if [ -n "$umount" ]; then
|
|
umount "$BCKDIR" >&/dev/null || die "ERR cannot umount $BCKDIR"
|
|
fi
|
|
if [ -n "$umountvg" ]; then
|
|
vgchange -an "$VGNAME" >&/dev/null || die "ERR cannot deactivate $VGNAME"
|
|
fi
|
|
|
|
echo OK
|