192 |
- |
1 |
#!/bin/sh
|
|
|
2 |
|
|
|
3 |
# This script is executed when a guest agent receives fsfreeze-freeze and
|
|
|
4 |
# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
|
|
|
5 |
# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook).
|
|
|
6 |
# When the agent receives fsfreeze-freeze request, this script is issued with
|
|
|
7 |
# "freeze" argument before the filesystem is frozen. And for fsfreeze-thaw
|
|
|
8 |
# request, it is issued with "thaw" argument after filesystem is thawed.
|
|
|
9 |
|
|
|
10 |
LOGFILE=/var/log/qga-fsfreeze-hook.log
|
|
|
11 |
FSFREEZE_D=$(dirname -- "$0")/fsfreeze-hook.d
|
|
|
12 |
|
|
|
13 |
# Check whether file $1 is a backup or rpm-generated file and should be ignored
|
|
|
14 |
is_ignored_file() {
|
|
|
15 |
case "$1" in
|
|
|
16 |
*~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave | *.sample | *.dpkg-old | *.dpkg-new | *.dpkg-tmp | *.dpkg-dist | *.dpkg-bak | *.dpkg-backup | *.dpkg-remove)
|
|
|
17 |
return 0 ;;
|
|
|
18 |
esac
|
|
|
19 |
return 1
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
# Iterate executables in directory "fsfreeze-hook.d" with the specified args
|
|
|
23 |
[ ! -d "$FSFREEZE_D" ] && exit 0
|
|
|
24 |
for file in "$FSFREEZE_D"/* ; do
|
|
|
25 |
is_ignored_file "$file" && continue
|
|
|
26 |
[ -x "$file" ] || continue
|
|
|
27 |
printf "$(date): execute $file $@\n" >>$LOGFILE
|
|
|
28 |
"$file" "$@" >>$LOGFILE 2>&1
|
|
|
29 |
STATUS=$?
|
|
|
30 |
printf "$(date): $file finished with status=$STATUS\n" >>$LOGFILE
|
|
|
31 |
done
|
|
|
32 |
|
|
|
33 |
exit 0
|