Virtualizor

Use Virtualizor recipes to run scripts on new VPSs

Automate VPS setup with Virtualizor recipes: write a shell script, add it as a recipe, let customers or plans apply it on build, and keep recipes safe and idempotent.

IntermediateVirtualizor admin2 min read

Virtualizor recipes are shell scripts that run inside a VPS after it is created or reinstalled. Use them to install a web stack, add monitoring agents, set the timezone or apply your standard security settings without logging in to every server.

Before you start

  • Virtualizor admin access.
  • A tested shell script for the target OS (Debian/Ubuntu and RHEL-family systems need different package commands).
  • A test VPS you can rebuild freely.

Write a good recipe script

  • Start with #!/bin/bash and use non-interactive commands, for example apt-get install -y or dnf install -y.
  • Make it idempotent: running it twice should not break anything.
  • Log output to a file such as /root/recipe.log so you can debug.
  • Never put passwords, API keys or licence keys in recipes customers can see.

Example recipe that updates the system and installs basic tools on Debian/Ubuntu:

#!/bin/bash
exec > /root/recipe.log 2>&1
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y upgrade
apt-get -y install curl htop fail2ban ufw
ufw allow OpenSSH
ufw --force enable

Add a Virtualizor recipe

  1. In the admin panel open Recipes (or Configuration → Recipes, depending on version) and choose Add Recipe.
  2. Give it a clear name and description, for example Ubuntu – base security.
  3. Paste the script, choose whether it is active and visible to end users, and save.

Warning: Recipes run as root inside the customer's VPS. Review every line, and test on your own VPS before making a recipe available to customers.

Apply recipes

  • On build or rebuild: select the recipe when creating or reinstalling a VPS.
  • By customers: if you make a recipe visible, customers can choose it when they reinstall from their panel (reinstall OS).
  • Recipes usually run on the first boot after the build; give the VPS a few minutes before testing.

Check afterwards

  • Log in and read /root/recipe.log.
  • Confirm the packages and settings are in place.

Troubleshooting

  • Recipe did not run: the template may not support recipes, or the VPS has no network on first boot.
  • Script stops halfway: a command asked for input; add non-interactive flags.
  • Works on Ubuntu but not AlmaLinux: create separate recipes per OS family.

Frequently asked questions

Can a recipe install a control panel?

Yes, if the panel's installer runs non-interactively, but large installs take time (install a control panel).

Do recipes run on Windows?

Recipes are aimed at Linux templates; check your version's support for Windows.

Can I run a recipe on an existing VPS?

Usually only during build or reinstall; otherwise run the script over SSH.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.