Jump to content
Sign in to follow this  

Coordinated start/stop of VM/Docker thru User Scripts

1 post in this topic Last Reply

Recommended Posts

Would please somebody so kind and check these two script sniplets? I want to coordinate the Start and Stop of VMs and Dockers within a Start and Stop script. Is this how it should be done? Am I using the correct syntax and command options? Anything else I need to take into account?


I'm running additional Unraid arrays each in it's own VM. So the VMs need to be started first, I want to wait some time for them to complete. After that I want to create the required mount points and after that I want to start a docker.


Both scripts are User Scripts and applied to array start/stop.


May thanks in advance.



# Start both VMs first
virsh start TowerVM01
virsh start TowerVM02

# Wait some time
sleep 5m

# Create base Mount Point
mkdir -p /mnt/hawi

# Create Mount Points for first VM
mkdir -p /mnt/hawi/
# ...

# Create Mount Points for second VM
mkdir -p /mnt/hawi/
# ...

# Mount Shares of first VM
mount -t cifs -o rw,nounix,iocharset=utf8,_netdev,file_mode=0777,dir_mode=0777,vers=3.0,username=hawi,password=****** '//' '/mnt/hawi/'
# ...

# Mount Shares of second VM
# mount -t cifs -o rw,nounix,iocharset=utf8,_netdev,file_mode=0777,dir_mode=0777,vers=3.0,username=hawi,password=****** '//' '/mnt/hawi/'

# Start Docker
docker start plex

# Stop Docker
docker stop plex

# Unmount Shares of second VM
umount -l '/mnt/hawi/'
# ...

# Unmount Shares of first VM
umount -l '/mnt/hawi/'
# ...

# Remove Mount Points to second VM
rmdir '/mnt/hawi/'
# ...

# Remove Mount Points to first VM
rmdir '/mnt/hawi/'
# ...

# Remove base Mount Point
rmdir '/mnt/hawi'

# Stop VMs
virsh shutdown TowerVM02
virsh shutdown TowerVM01


Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this