GoAdmio

domain

Change the primary domain of a hosting account, with an automatic snapshot first

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/domain moves an existing hosting account to a new primary domain. It:

[!WARNING] The command has almost no safety checks. It does not validate its arguments, and it keeps going after errors. Read Before you run first.


Quick start

/go/domain old-example.com new-example.com

Syntax

/go/domain <current-domain> <new-domain> [--progress]
Form Behavior
/go/domain <current-domain> <new-domain> Moves the account and prints plain status messages.
/go/domain <current-domain> <new-domain> --progress Same, and also prints the progress numbers 10, 20, 30, 50, 70, and 100 on separate lines, for use by a progress bar.

--progress is detected anywhere in the argument list.

[!WARNING] Always pass both domains, written in full and in lowercase. An empty argument can turn a later rm -rf /home/<domain> into rm -rf /home/.

Before you run


Arguments

Argument Required Default Notes
<current-domain> Yes — The account's current primary domain, as stored in GoAdmio.
<new-domain> Yes — The new primary domain. Becomes the account's domain and its username.
--progress No Off Prints progress numbers.

Output

Outcome What you get
Start A snapshot of the current domain (<new-domain>) will be taken before changing the primary domain... (the message shows the new domain, although the snapshot is of the current one).
After the snapshot Changing primary domain started now...
New account created The single-line JSON result of create. It contains the new account's generated password in plain text.
Finished Primary domain name changed successfully...

The command always exits with code 0, including after errors, because it never calls exit and doesn't check the result of any step.

Progress numbers

With --progress, each number prints when that stage starts or finishes:

Number After
10 The snapshot announcement.
20 The snapshot finished, before the new account is created.
30 The folder is moved and ownership is fixed.
50 The database records are re-pointed.
70 The old system user, PHP-FPM pool, and Apache config are removed.
100 Everything is finished.

Logging

Every run is appended to /var/log/go/domain.log with a timestamp and the arguments.


Examples

# Change the primary domain
/go/domain old-example.com new-example.com
# Same, with progress numbers
/go/domain old-example.com new-example.com --progress
# Check the result
ls /home/new-example.com
tail /var/log/go/domain.log
# Recommended follow-up: set a known password and request SSL
/go/password new-example.com 'N3wS3cureP4ss'
/go/ssl new-example.com

Troubleshooting

There is no rollback. If something goes wrong, restore from the snapshot taken at the start with snapshot or recover.

Symptom Likely cause Fix
Another site's files or records disappeared The new domain was already hosted. create failed, but the script kept going and deleted that domain's folder and rows. Restore that account from its own snapshot or backup. Check the new domain before running.
Account named shop.com but folder and records use Shop or shop create normalizes the domain, the script doesn't. Pass the full, lowercase domain.
New account has default limits, email, and settings The script does not load the old account's settings before calling create. See Notes for maintainers. Reapply the limits and settings, for example with the panel or contact.
FTP or SSH password unknown create generated a random one and printed it in its JSON result. Run password with a known password.
Panel password is still the old one, but FTP/SSH has a new random one The panel hash is carried over; the system user is recreated. Run password to align them.
Old email addresses stop working Addresses were rewritten to the new domain, with no forwarding. Update mail clients and DNS MX records, and tell users the new addresses.
Website shows old URLs or errors Site settings (for example a CMS URL) still contain the old domain. Update them inside the site.
No SSL certificate for the new domain DNS doesn't point here yet, or the certificate is requested about a minute after creation. Fix DNS, then run ssl.
PostgreSQL databases missing for the new domain postgre.db rows are not moved. Re-register them with postgre.
Old vhost still served The web server was not reloaded after the old config files were deleted. Run restart.

Details

What it does

  1. Logs the call to /var/log/go/domain.log and reads the operating system name from /usr/local/goadmio/linux/os.db.
  2. Looks up the current account's username in /var/lib/sqlite/site.db.
  3. Takes a snapshot of the current domain with snapshot.
  4. Creates a new account for the new domain with create.
  5. Sets the account's username to the new domain.
  6. Deletes the new account's empty /home/<new-domain> and moves /home/<current-domain> there.
  7. Sets www group to nobody, www ownership to the new username, and /home/<new-domain> to 755.
  8. Runs phpmyadmin for the new domain.
  9. Deletes the placeholder rows create just made for the new domain in the Site, Alias, Subdomain, Directory, Mysql, Postgre, SQLite, Mail, and Ftp tables.
  10. Updates the current domain's rows to the new domain and username in the Site, SQLite, FTP, Httplog, Ftplog, Mysql, Mail, Subdomain, Directory, Github, Alias, and Block tables. In Mail, the old domain text inside each email address is replaced by the new one.
  11. Deletes the old PHP-FPM pool files and the old Apache virtual host files for the operating system in use (AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu).
  12. Deletes the old system user (userdel -f) and /home/<current-domain>.
  13. Deletes the old Nginx virtual host files.
  14. Deletes the old DNS zone with zone.
  15. Deletes /etc/vsftpd/permission/<current-domain> and /etc/opendkim/<current-domain>.
flowchart TD
    A["domain current new"] --> B["Snapshot current domain"]
    B --> C["create new account"]
    C --> D["Replace new home with old home"]
    D --> E["Fix ownership, run phpmyadmin"]
    E --> F["Delete placeholder rows, re-point old rows"]
    F --> G["Remove old user, PHP-FPM, Apache, Nginx"]
    G --> H["Remove old zone, FTP permissions, DKIM key"]
    H --> I["Done"]

What changes and what doesn't

Area Result
Site files, mail folders, SQLite files, logs Move with the home folder.
Panel records (sites, FTP, MySQL, mail, subdomains, directories, aliases, GitHub, blocks, HTTP and FTP logs) Re-pointed to the new domain and username.
System/FTP/SSH user New user named after the new domain; old user deleted.
Web server, PHP-FPM, DKIM, DNS zone, SSL request Created for the new domain by create; old ones deleted.
Email addresses Rewritten to the new domain. Old addresses stop working.
PostgreSQL records Not moved.
Databases and database users Not renamed by this script.
Cloudflare DNS records, MX/SPF/DKIM for the new domain Not changed. Update them yourself.
Old domain's Let's Encrypt certificate files Not removed by this script.
Content inside the site that contains the old domain Not changed.

Notes for maintainers

Issue Why it matters Suggested fix
Variables such as $Username, $Password, $DocumentRoot, $Email, $DiskSpace, and $PHPVersion are never set create receives empty values instead of the old account's settings. A block that loads the old Site row appears to be missing. Confirm that create treats empty options as unset. Read the old account's settings from the Site table before calling create.
No argument validation An empty or malformed domain makes rm -rf /home/$Domain or rm -rf /home/$CurrentDomain target /home/. Exit unless both arguments are non-empty, and normalize and validate them as create does.
Result of create is not checked After a failed create (for example, domain already hosted), the script deletes that domain's folder and rows. Exit unless the JSON contains "success": true.
Current domain is not checked If it doesn't exist, the new account is created, then removed again, leaving leftovers. Exit if $CurrentUsername is empty or /home/$CurrentDomain is missing.
Snapshot message prints $Domain Shows the new domain instead of the current one. Print $CurrentDomain.
Snapshot failure is not checked The change continues without a safety copy. Stop if snapshot fails.
postgre.db is deleted for the new domain but never updated for the old one PostgreSQL records are lost. Add an UPDATE Postgre ... line.
replace(Email, '<old>', '<new>') Replaces the old domain text anywhere in the address, including the local part. Replace only the part after @.
Domains are placed directly in SQL A quote in the value breaks the query and can be abused. Validate against ^[a-z0-9.-]+$.
Final rm -rf /home/$CurrentDomain Redundant after mv, and dangerous if the variable is empty. Remove it, or guard it.
Web server is not reloaded after the old vhosts are removed The old site can keep being served. Reload the web server at the end.
No rollback and always exits with 0 Failures are silent. Use set -e or check each step, and exit non-zero on failure.
Progress numbers skip 40, 60, and 80 The progress bar jumps. Optional: add more steps or use evenly spaced values.

See also

Command Description
create Create a GoAdmio account from the command line
snapshot Restic-based per-domain snapshot backup and restore
recover Restore a deleted account from its latest snapshot
password Change a GoAdmio account password from the command line
primary Convert an addon domain to a primary domain
username Change the GoAdmio account username
zone Create, update, or delete a DNS zone file and register it with BIND
ssl Install an SSL certificate for a domain in GoAdmio