196610da2STomoki Sekiyama#!/bin/sh 296610da2STomoki Sekiyama 396610da2STomoki Sekiyama# This script is executed when a guest agent receives fsfreeze-freeze and 496610da2STomoki Sekiyama# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F) 596610da2STomoki Sekiyama# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook). 696610da2STomoki Sekiyama# When the agent receives fsfreeze-freeze request, this script is issued with 796610da2STomoki Sekiyama# "freeze" argument before the filesystem is frozen. And for fsfreeze-thaw 896610da2STomoki Sekiyama# request, it is issued with "thaw" argument after filesystem is thawed. 996610da2STomoki Sekiyama 1096610da2STomoki SekiyamaLOGFILE=/var/log/qga-fsfreeze-hook.log 1196610da2STomoki SekiyamaFSFREEZE_D=$(dirname -- "$0")/fsfreeze-hook.d 1296610da2STomoki Sekiyama 1396610da2STomoki Sekiyama# Check whether file $1 is a backup or rpm-generated file and should be ignored 1496610da2STomoki Sekiyamais_ignored_file() { 1596610da2STomoki Sekiyama case "$1" in 16*7294e600SChristian Ehrhardt *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave | *.sample | *.dpkg-old | *.dpkg-new | *.dpkg-tmp | *.dpkg-dist | *.dpkg-bak | *.dpkg-backup | *.dpkg-remove) 1796610da2STomoki Sekiyama return 0 ;; 1896610da2STomoki Sekiyama esac 1996610da2STomoki Sekiyama return 1 2096610da2STomoki Sekiyama} 2196610da2STomoki Sekiyama 2296610da2STomoki Sekiyama# Iterate executables in directory "fsfreeze-hook.d" with the specified args 2396610da2STomoki Sekiyama[ ! -d "$FSFREEZE_D" ] && exit 0 2496610da2STomoki Sekiyamafor file in "$FSFREEZE_D"/* ; do 2596610da2STomoki Sekiyama is_ignored_file "$file" && continue 2696610da2STomoki Sekiyama [ -x "$file" ] || continue 2796610da2STomoki Sekiyama printf "$(date): execute $file $@\n" >>$LOGFILE 2896610da2STomoki Sekiyama "$file" "$@" >>$LOGFILE 2>&1 2996610da2STomoki Sekiyama STATUS=$? 3096610da2STomoki Sekiyama printf "$(date): $file finished with status=$STATUS\n" >>$LOGFILE 3196610da2STomoki Sekiyamadone 3296610da2STomoki Sekiyama 3396610da2STomoki Sekiyamaexit 0 34