„vm_control.sh“ ändern
This commit is contained in:
parent
ac853942ad
commit
bb6b99530b
1 changed files with 14 additions and 6 deletions
|
@ -61,6 +61,8 @@ inotify_start() {
|
|||
done <<<"$web_state"
|
||||
|
||||
for vm in "${vms[@]}"; do
|
||||
vm_host_status=$(synowebapi --exec api=SYNO.Virtualization.API.Guest version=1 method=get runner=admin guest_name="$vm" 2>/dev/null | jq -r .data.status )
|
||||
|
||||
if [ "${vm_states[$vm]}" = "${vm_states_saved[$vm]}" ]; then
|
||||
echo "keine Änderung für $vm (web_state online: ${vm_states[$vm]} / web_state saved: ${vm_states_saved[$vm]})"
|
||||
continue
|
||||
|
@ -71,14 +73,20 @@ inotify_start() {
|
|||
# wenn Änderung gefunden wurde:
|
||||
case "${vm_states[$vm]}" in
|
||||
on)
|
||||
echo "starte $vm ..."
|
||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=poweron runner=admin guest_name="$vm" >/dev/null 2>&1
|
||||
continue
|
||||
if [ "$vm_host_status" = "shutdown" ]; then
|
||||
echo "starte $vm ..."
|
||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=poweron runner=admin guest_name="$vm" 2>/dev/null
|
||||
else
|
||||
echo "VM $vm hat folgenden Status und kann nicht gestartet werden: $vm_host_status"
|
||||
fi
|
||||
;;
|
||||
off)
|
||||
echo "beende $vm ..."
|
||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=shutdown runner=admin guest_name="$vm" >/dev/null 2>&1
|
||||
continue
|
||||
if [ "$vm_host_status" = "running" ]; then
|
||||
echo "beende $vm ..."
|
||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=shutdown runner=admin guest_name="$vm" 2>/dev/null
|
||||
else
|
||||
echo "VM $vm hat folgenden Status und kann nicht beendet werden: $vm_host_status"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue