david/scripts-archive
david
/
scripts-archive
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-archive/kvm-tools/kvm-tools.sh

123 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
#########################################
## ##
## kvm-tools ##
## ##
#########################################
# **** configuration section ****
# do not touch as long as you are not me
version="0.2_beta1"
author="david@socialnerds.org"
giturl="git://git.aec.at/kvm-tools.git"
functionfile="kvm-tools.func"
configfile="/etc/kvm-tools.conf"
logwhat="kvm-tools"
# **** bash trap initialisation ****
trap bashtrap INT
# **** read config file ****
if [ -r $configfile ]; then
source $configfile
else
echo "ERROR: configuration file not found."
exit 1
fi
# **** read function definitions ****
if [ -r $repopath/$functionfile ]; then
source $repopath/$functionfile
else
echo "ERROR: functionfile not found."
exit 1
fi
# **** load bashlib ****
if [ -d $bashlibpath ]; then
source $bashlibpath/main
source $bashlibpath/update
source $bashlibpath/logengine
log debug "preflight - bashlib loaded"
else
echo "ERROR: bashlib not found"
exit 1
fi
# **** option handler ****
while getopts "h,c:,e:,i,a:,b:,u,v,f" OPTION; do
case $OPTION in
h)
usage
log debug "option handler - usage message printed"
exit 0
;;
c)
log debug "option handler - server deployment process for $OPTARG started"
mkjeos "$OPTARG"
errorcode=$?
log debug "option handler - server deployment for $OPTARG finished"
exit $errorcode
;;
e)
edit "$OPTARG"
errorcode=$?
exit $errorcode
;;
i)
newids
exit $?
;;
a)
addimage "$OPTARG"
exit $?
;;
b)
log info "option handler - starting backup process"
backup "$OPTARG"
errorcode=$?
if [ $errorcode = "0" ]; then
log info "option handler - backup process successfully finished"
else
log error "option handler - an error occured during backup process"
fi
exit $errorcode
;;
u)
update
exit $?
;;
v)
version
exit $?
;;
f)
fix
exit $?
;;
?)
usage
exit 1
;;
esac
done
# **** print usage message if no option is given ****
if [ -z $1 ]; then
usage
exit 1
fi
# **** end of script ****
exit 0