systemd: wait for shutdown-service to complete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi

i am trying to suspend / start my VMware-Workstation machines automatically
below my systemd-unit and the two shell-scripts
start works like a charme (yes i use a seperated user for VM's)

shutdown works on a machine with one small VM
on my homeserver i see that it is executed (script output)
but systemd does not wait until all machines are compleltly suspended
seeing boot-messages and partially fscheck in the guests

has anybody an idea how i can make sure that systemd waits to finish
"/scripts/vmware/vm-suspend-all.sh" before shutdown the next process
(in this case vmware.service)  and finally the system?

yes, the suspend script called directly works fine, adn yes it would be
possible to call the script manually before reboot/shtdown but i like
systems which works perfectly at boot/shutdown without manual interaction

[root@srv-rhsoft:~]$ cat /etc/systemd/system/vmware-default.service
[Unit]
Description=VMware-Default-Machines
After=vmware.service
[Service]
Type=oneshot
ExecStart=/bin/su -c "/scripts/vmware/vm-default-start.sh" vmware
ExecStop=/scripts/vmware/vm-suspend-all.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target


[root@srv-rhsoft:~]$ cat /scripts/vmware/vm-default-start.sh
#!/bin/bash
if [ "$HOSTNAME" == "srv-rhsoft.rhsoft.net" ]; then
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/arrakis/arrakis.vmx' nogui
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/testserver/config.vmx' nogui
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/Buildserver32/config.vmx' nogui
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/Buildserver64/config.vmx' nogui
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/centos/centos.vmx' nogui
fi
if [ "$HOSTNAME" == "rh.thelounge.net" ]; then
 /usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/backup-flow/config.vmx' nogui
fi


[root@srv-rhsoft:~]$ cat /scripts/vmware/vm-suspend-all.sh
#!/bin/bash
if [ -x /usr/bin/vmrun ] ; then
 for i in `pidof vmware-vmx` ; do
  VMX_PATH=`ps -p $i -f | sed -ne '/vmware/s/.* \(\/.*\.vmx\)/\1/p'`
  MY_DATE=$(/bin/date +%d-%m-%Y)
  MY_TIME=$(/bin/date +%H:%M:%S)
  echo "$MY_DATE $MY_TIME  SUSPEND: $VMX_PATH"
  /usr/bin/logger -t vmware "SUSPEND: $VMX_PATH"
  /usr/bin/vmrun suspend `ps -p $i -f | sed -ne '/vmware/s/.* \(\/.*\.vmx\)/\1/p'` 2> /dev/null
  MY_DATE=$(/bin/date +%d-%m-%Y)
  MY_TIME=$(/bin/date +%H:%M:%S)
  echo "$MY_DATE $MY_TIME  SUSPENDED: $VMX_PATH"
  /usr/bin/logger -t vmware "SUSPENDED: $VMX_PATH"
 done
fi

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux