reorganize script's functions

This commit is contained in:
cig
2022-09-16 08:06:47 +02:00
committed by root
parent fb3f38d77d
commit 5178dfd6e8

View File

@@ -2,6 +2,7 @@
set -e set -e
set -u set -u
set -o pipefail
statusfile=/var/run/zabbix/vmbackup.status statusfile=/var/run/zabbix/vmbackup.status
basedir=/mnt/backups/vms basedir=/mnt/backups/vms
@@ -17,6 +18,17 @@ _mail () {
echo "$@" | mail -s "$(hostname -f) : vm backup error" root echo "$@" | mail -s "$(hostname -f) : vm backup error" root
} }
function checkRunning {
local machine=$1
$vbm list runningvms | grep -q $machine
return $?
}
function _shutdown_vm {
net rpc shutdown -I 192.168.69.250 -U tom%123Soleil2022!
sleep 30
}
mount /mnt/backups &> /dev/null || _exit "mount failed" 2 mount /mnt/backups &> /dev/null || _exit "mount failed" 2
if [ ! -d $basedir ] ; then if [ ! -d $basedir ] ; then
@@ -32,17 +44,6 @@ if [ $# -ne 1 ] ; then
_exit "Usage" 42 _exit "Usage" 42
fi fi
function checkRunning {
local machine=$1
$vbm list runningvms | grep -q $machine
return $?
}
function _shutdown_vm {
net rpc shutdown -I 192.168.69.250 -U tom%123Soleil2022!
sleep 30
}
machine=$1 machine=$1
if ( checkRunning $machine ) ; then if ( checkRunning $machine ) ; then
mkdir -p ${outputdir} mkdir -p ${outputdir}