„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"
|
done <<<"$web_state"
|
||||||
|
|
||||||
for vm in "${vms[@]}"; do
|
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
|
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]})"
|
echo "keine Änderung für $vm (web_state online: ${vm_states[$vm]} / web_state saved: ${vm_states_saved[$vm]})"
|
||||||
continue
|
continue
|
||||||
|
@ -71,14 +73,20 @@ inotify_start() {
|
||||||
# wenn Änderung gefunden wurde:
|
# wenn Änderung gefunden wurde:
|
||||||
case "${vm_states[$vm]}" in
|
case "${vm_states[$vm]}" in
|
||||||
on)
|
on)
|
||||||
echo "starte $vm ..."
|
if [ "$vm_host_status" = "shutdown" ]; then
|
||||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=poweron runner=admin guest_name="$vm" >/dev/null 2>&1
|
echo "starte $vm ..."
|
||||||
continue
|
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)
|
off)
|
||||||
echo "beende $vm ..."
|
if [ "$vm_host_status" = "running" ]; then
|
||||||
synowebapi --exec api=SYNO.Virtualization.API.Guest.Action version=1 method=shutdown runner=admin guest_name="$vm" >/dev/null 2>&1
|
echo "beende $vm ..."
|
||||||
continue
|
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
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue