App templates
An app template is a base image plus an install script plus a few input fields. When an admin, the API or a customer picks the app, NexoVirt creates the server, waits until it runs and then runs your script inside it with the values from the fields. It works for VMs (QEMU) and containers (LXC). Windows is not supported, because the script needs a POSIX shell.
The ready-made catalog apps (Docker, Nextcloud and so on) are described under One-click apps. They keep working as before. App templates are your own.
Create a template
Section titled “Create a template”Open Provisioning > App templates and click New app template. You need the permission
Manage app templates (apps.manage).
General tab:
- Name, Slug (lowercase letters, digits and dashes, used in the API), Description, Category.
- Base: VM (QEMU) or Container (LXC), then Base OS template or Base container template. The app always installs on this image.
- Minimum vCPU, Minimum RAM (MB), Minimum disk (GB). A server smaller than this is refused.
- Logo (PNG, JPG, WEBP or SVG, 512 KB at most).
- Available for installs: switch an app off without deleting it.
- Pass the customer’s email to the script (
NX_CUSTOMER_EMAIL).
Fields tab: what the customer is asked. Click Add field. Each field has a key, a label, a type,
Required, a default and a help text. Up to 30 fields. The key (lowercase, starts with a letter, 32
characters at most) reaches the script as NX_<KEY>.
| Type | What it accepts |
|---|---|
| text | Free text, 200 characters by default, optional pattern |
| An email address | |
| domain | A host name such as cloud.example.com |
| username | [a-z_][a-z0-9_-], 32 characters at most |
| password | 12 characters at least by default. Never stored and never shown again |
| number | A whole number with optional minimum and maximum |
| select | One of the listed options (Options, one per line: value or `value |
| yesno | 1 or 0 |
Every value is at most 1000 bytes and contains no control characters.
Script tab: a read-only preview of the latest version’s install script with Open editor. The script runs as root inside the server (60000 bytes at most). The Install timeout (minutes) on the General tab covers the whole install.
The Price per month field (empty = free), Sort order and the switch Show in the shop are described under Sell apps in the shop.
Notes tab: Notes for the customer, shown on the server page after the install.
Click Save as new draft and describe the change in the box next to it.
Script editor and sandbox
Section titled “Script editor and sandbox”Click Script editor (or Open editor on the Script tab) to edit the script on its own page: the editor on the left, a card with three tabs on the right. Save as new draft asks what changed and saves only the script; fields, notes and the timeout stay as in the latest version. Leaving the page with unsaved changes asks first.
- Variables: your saved fields and the built-in values. Click one to write
"$NX_KEY"at the cursor. - Check: enter test values for your fields and click Check script. Nothing runs: the panel checks the
syntax with
bash -n, runs ShellCheck when it is installed on the panel server, and adds its own checks (unknownNX_variables,${$NAME}, an optional field used without${NX_KEY:-}underset -u, printed passwords, a missing#!line, Windows line endings, the size limit). Click a problem to jump to its line. The list below shows every value the script gets, passwords as********. - Sandbox: Run in sandbox saves unsaved changes, then runs the latest draft with the Check tab’s test values on the sandbox server of the template’s base image, and shows its log and the result (exit code). Starting a run needs both Manage app templates and Manage guests. Test passwords travel with the run job until the script starts and are then removed: use throwaway values.
Sandbox servers
Section titled “Sandbox servers”There is one warm sandbox server per base image. The first run for a base image builds it (a few minutes, once):
the panel creates a server of at least 1 vCPU, 1024 MB RAM and 10 GB disk (more when the template’s minimums are
higher), waits for its first boot (for VMs until the guest agent answers and cloud-init is done) and takes the
snapshot nx-clean (VMs with their memory, so a run starts in seconds). Every run first restores nx-clean,
then runs the script. Afterwards the server stays as the script left it: Open server to look inside. The next
run restores the clean state again. While a run uses the server, other runs on the same base image wait their
turn (“Waiting for the sandbox server”). One run per template at a time.
- A template that needs more than the server has rebuilds it with more resources.
- When restoring fails (for example the snapshot is gone), the server is marked broken: click Rebuild the sandbox server. Delete removes it; the next run builds a new one.
- Sandbox servers belong to the admin who built them, never raise alerts and send no server mails or webhooks.
The panel only rolls back or deletes a server that is still its sandbox server (same owner, name starting
with
sandbox-pool-); anything else is marked broken and left alone. - Servers unused for 7 days are deleted. Turning sandbox runs off, moving the target to another node, or deleting the base image deletes them too.
Choose where sandbox servers run in the Sandbox servers card on the app templates page: a node and storage (or Automatic), the bridge, and DHCP or an IP zone. The Warm sandbox servers card below it lists every server with its base image, node, VMID, status and last use.
What the script receives
Section titled “What the script receives”Your fields arrive as environment variables. These built-in values are always there:
| Variable | Value |
|---|---|
NX_IP | The server’s IP address |
NX_PUBLIC_IP | The NAT WAN address when the server sits behind NexoVirt NAT, else NX_IP |
NX_HOSTNAME | The server’s host name |
NX_SERVER_NAME | The server’s name |
NX_VMID | The VMID |
NX_APP | The template slug |
NX_APP_VERSION | The version number |
NX_CUSTOMER_EMAIL | Only when Pass the customer’s email to the script is on |
Values are passed in a protected file, never pasted into the script text.
Notes placeholders
Section titled “Notes placeholders”In Notes for the customer these placeholders are filled in: {ip}, {public_ip}, {hostname} and
{input.<key>} for any non-password field, for example {input.domain}. Passwords are never available
in notes.
Versions and approval
Section titled “Versions and approval”Every save creates a new draft version. Only an approved version is installed on new servers; a template without one is not offered anywhere. Open Versions on a template to see every version with its state (draft, approved, retired), author, approver and change note, and Compare two versions.
Approve a draft with the permission Approve app template versions (apps.approve). It asks for
step-up confirmation. When more than one admin can approve, a different admin than the author has to do it
(“Another admin has to approve this version.”); a panel with a single admin approves its own drafts. The
previous approved version becomes retired. Servers remember the version they were installed with.
Test install
Section titled “Test install”Before approving, click Test install on a draft. It opens the create wizard with the draft preselected.
A test install only runs from the panel, by an admin with apps.manage, on a server that has no
customer owner. The API and customers can never run a draft.
Create a server from an app
Section titled “Create a server from an app”Admin wizard: in the operating system step open the Apps tab, pick the app under App, fill in the fields and create the server. The app sets the base image and the minimum size.
API: list the apps with GET /api/v1/app-templates, then send app_template (id or slug) and inputs
with the normal create call:
curl -s -X POST https://panel.example.com/api/v1/guests \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"type":"qemu","node":"auto","name":"panel-01","cores":2,"memory_mb":2048,"disk_gb":20, "app_template":"pterodactyl","password":"a-root-password",The same two fields work on POST /api/v1/hosts/{id}/guests. Mistakes answer 422 with the field, for
example "field": "inputs.admin_email", or app_template (unknown app), os_template (another operating
system named), cores, memory_mb or disk_gb (below the minimum) and type (wrong base type).
Install, failures and retries
Section titled “Install, failures and retries”The install runs after the server is created and running, and you follow it on the provisioning page.
- Containers run the script through the node agent (agent 0.25.0 or newer).
- VMs need the QEMU guest agent inside the server. The panel waits up to 15 minutes for it, and for cloud-init to finish, then runs the script.
- Passwords exist only until they are delivered to the server. They are not kept in the panel, the audit log, the notes or the API answers.
- Only admins see the install log (provisioning page and the server’s activity). A customer sees “The app could not be installed.” and Try again.
- A customer can try again twice. After the third failure the server shows “We are looking into it. A support ticket is open for this.”, admins get an alert and an email, and a support ticket is opened for the customer without the log. Admins can always use Retry on the server’s app card.
- The server is kept in every case.
Sell apps in the shop
Section titled “Sell apps in the shop”Selling needs the shop to be on (see Shop). Three steps:
- On the app template, set Price per month (empty = free) and switch on Show in the shop. Sort order sets the order on the order page. The app also needs an approved version and Available for installs.
- On the product, open the Apps part of the product form. Under Apps customers can install choose No apps (default), All apps in the shop or Only these and tick the apps (each shows its price or “Free”). Apps are offered only when they are approved, active and shown in the shop, and match the product type (virtual machine or container). The setting is copied to the product’s other billing periods.
- Customers see the apps on the order page under Operating system or app. The app brings its own system and installs itself after the server is created.
How it is billed:
- The app price is added to the product price for the same period (a longer billing period scales it like add-ons) and is reduced by the customer’s group discount. Coupons apply to the total.
- It renews with the server: balance renewals, low-balance and unpaid mails and gateway subscriptions all use the total.
- Invoices show a separate line App: <name>.
- Delete now refunds the unused time of the app together with the server (when unused time is refunded in the shop settings), based on what the customer actually paid for the app.
- A free product sells only free apps. Priced apps are not available on hourly billing (products that offer hourly billing hide priced apps) and not on products with manual provisioning, because those orders are priced by hand. A running gateway subscription blocks changing to an app with another price: “Stop the automatic payment first: the app price is part of it.”
- Customers never run drafts. Only approved versions are installed. If an app is not offered on the product the order is refused with “This app is not available for this product.”
Reinstall as an app
Section titled “Reinstall as an app”A server can be reinstalled as an app, the same way it can be reinstalled with another operating system.
- Admin panel: the reinstall dialog has the tabs Operating systems and an apps tab.
- Customer portal: the reinstall page has the same two tabs, if the product allows apps. The server’s size must meet the app’s minimums, otherwise the reinstall is refused.
- API:
POST /api/v1/hosts/{hostId}/guests/{type}/{vmid}/reinstallacceptsapp_templateandinputsinstead ofos_template.
The app’s base image replaces the system, everything on the server is wiped as with any reinstall, and the install script runs afterwards. Reinstalls always use the approved version, never a draft (use Test install on a new server to try a draft).
Price changes on a shop server, shown to the customer before they confirm:
- A dearer app: “This costs X now.” The difference for the rest of the paid time is booked at once from the balance (“Not enough balance for this app change. Please top up your balance first.” if it does not cover it).
- A cheaper app or a plain operating system: “You get X back.” The refund is booked when the reinstall has succeeded.
- Same price per period: “No charge now; the new price applies from the next renewal.”
- If the reinstall fails the charge is refunded once.
Only one reinstall can run per server (“A reinstall is already running for this server.”). Resellers cannot change a customer’s app; the customer does it in their portal. Hourly servers and servers without a paid date cannot change to a priced app.
Copy from the catalog
Section titled “Copy from the catalog”On Provisioning > App templates the Catalog apps card lists the ready-made catalog apps. Copy to my templates creates your own draft template from one, with its script and fields, which you can change and sell. The base template of the catalog app must already be on the panel, otherwise the panel asks you to download it first.
Export and import
Section titled “Export and import”Export on a template downloads it as a .json file (script, fields, notes, minimums; no customer data and
no secrets). Import on the same page adds such a file (200 KB at most) as a draft with the change note
“Imported from <slug>.json.”; the base image is matched by name and must exist on the panel. An imported
template is never approved automatically: review the script, then approve it. Use it to share templates between
panels or with other operators.
NexoVirt is developed and designed by Nucez Software, your partner for custom software and web design.