Skip to content

Whmapi1 Commands

WhmApi commands

  • enable ssh
    whmapi1 --output=jsonpretty modifyacct user='vladmincp' HASSHELL=0
    
  • get feature list

    whmapi1 get_featurelist_data featurelist='custom_feature'
    
  • change cpanel hostname

    whmapi1 --output=jsonpretty \
      sethostname \
      hostname='hostname.example.com'
    

exclude domain from auto_ssl

uapi --user=$username SSL add_autossl_excluded_domains domains='$domain.tld'

API DOC

Change Server hostname

DOC

whmapi1 --output=jsonpretty sethostname  hostname='hostname.example.com'

Display mysqlusers

 whmapi1 --output=jsonpretty   list_mysql_databases_and_users   user='cpanel_user'

 ```


 ## Create bulk parked domains for cpuser
 [DOCS](https://api.docs.cpanel.net/openapi/whm/operation/create_parked_domain_for_user/)

 ```bash
 for domain in $(cat list_parked);do whmapi1 create_parked_domain_for_user domain=$domain username=vmin web_vhost_domain=python.vladmin-dev.top;done

 ```

 - File Content creation

 ```bash
 for i in {1..100};do echo parked$i.python.vladmin-dev.top >> list_parked;done

 ```


 - File format

 ```
parked94.python.vladmin-dev.top
parked95.python.vladmin-dev.top
parked96.python.vladmin-dev.top
parked97.python.vladmin-dev.top
parked98.python.vladmin-dev.top
parked99.python.vladmin-dev.top
parked100.python.vladmin-dev.top

Account Summary whm

whmapi1 --output=jsonpretty \
  accountsummary \
  user='cpanel-user'

Create sub domains

DOCS

  • With the same format file
    for i in {1..100};do echo sub$i.python.vladmin-dev.top >> list_subdomains;done
    
for sub in $(cat list_subdomains);do whmapi1 create_subdomain domain="$sub" document_root="public_html/$sub";done
  • Print all sub domains from the main file
grep -A1000 sub_domains: main | awk -F'-' '{print $2}' | wc -l
  • Print all parked domains with -B before for grep
grep -B1000 sub_domains: main | awk -F'-' '{print $2}'
  • Create login with the IP and preferred domain
whmapi1 create_user_session user=root service=whostmgrd preferred_domain=10.2.35.64

reset dns zones

for i in $(ls -1 /var/named/*.db | awk -F '\/' '{print $NF}');do whmapi1 --output=jsonpretty resetzone zone=$i;done

mass edit dns zone

  • Add a Recird
    whmapi1 mass_edit_dns_zone zone=cpanel-test.net serial=2025040404 add='{"dname":"cpanel-test.net","ttl":"14400","record_type":"MX","data":["30","mx4.cpanel-test.net"]}'
    

Dump DNS zone to get Serial

whmapi1 --output=jsonpretty dumpzone domain='vladmin-dev.top' | jq -r '.data.zone[0].record[] | select(.type=="SOA") | .serial'
- Enable monitoring plugin - https://api.docs.cpanel.net/openapi/whm/operation/local_enable/
whmapi1 --output=jsonpretty EcosystemFeatures/local_enable plugin='cpanel-monitoring-plugin'
  • Files
    /usr/local/cpanel/scripts/agent360.sh
    /var/cpanel/plugins/monitoring-agent/install.sh
    
  • Disable

    whmapi1 EcosystemFeatures/local_disable plugin=cpanel-sitejet-plugin
    
  • Test WHM API Tokens

    curl -H'Authorization: whm root:token' 'https://192.168.1.8:2087/json-api/applist?api.version=1'
    
  • Veryfu cluster reverse trust.

        whmapi1 --output=jsonpretty   cluster_member_has_trust_with   host='38.242.244.231'
    

Linux Boot Process

  1. BIOS - Basic Input/Output System
  2. MBR=Master boot record the first sector on the Hard Drive
  3. GRUB2 - Grand Unified Boot Loader v2- Loads Linux /boot/grub2/grub.cfg
  4. Kernel - Core of the Operating System - Starts the systemd
  5. SystemD initialization- Reads /etc/systemd/system/default.target file

  6. Selecting Targer (Run Level)

  7. Graphical Target ( UI Login for multiple users)

  8. multi-user.targer (multiple users only text based login)
  9. rescue.targer sulogin porompt, bashrc system initialization completed.
  10. Emergency.target sulogin prompt, initramfs, dracut,etc
  11. Check default target
systemctl get-default
systemctl list-dependencies multi-user.target
ls -l /lib/systemd/system/runlevel*
lrwxrwxrwx. 1 root root 15 Mar 10 02:00 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Mar 10 02:00 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Mar 10 02:00 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Mar 10 02:00 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Mar 10 02:00 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Mar 10 02:00 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Mar 10 02:00 /lib/systemd/system/runlevel6.target -> reboot.target
  • Recover root password

    rw init=/sysroot/bin/sh
    
  • Then chroot to mount the filesystem

chroot /sysroot
  • Change root password

    passwd root
    
  • For Selinux. Upate info before rebooting

touch ./autolabel

Repair filesystem corruption

Eclude domain from auto_ssl

whmapi1 --output=jsonpretty set_autossl_user_excluded_domains username='cpuser' domain='domain.com'
  • Tweak settings set/get. The keys are in /var/cpanel/cpanel.config. Set works with value=$val
     whmapi1 --output=jsonpretty   get_tweaksetting   key='php_upload_max_filesize'
    {
       "data" : {
          "tweaksetting" : {
             "key" : "php_upload_max_filesize",
             "value" : "100"
          }
       },
       "metadata" : {
          "command" : "get_tweaksetting",
          "reason" : "OK",
          "result" : 1,
          "version" : 1
       }
    }
    
 whmapi1 --output=jsonpretty   set_tweaksetting   key='php_upload_max_filesize' value=200
{
   "metadata" : {
      "command" : "set_tweaksetting",
      "reason" : "OK",
      "result" : 1,
      "version" : 1
   }
}
proxy_ssl_server_name on; 
proxy_ssl_name $host;

Cpapi2

  • Create Subdomain
    cpapi2 AddonDomain addaddondomain newdomain=test.vladmin-dev.top subdomain=test.vladmin-dev.top dir=/public_html/vdevtop
    

Package management

whmapi1 addpkg name='SuperHosting'
- Change user package
whmapi1 changepackage user=vtools pkg='SuperHosting'
  • Create Account

     whmapi1 createacct --output=jsonpretty username='vtools' domain='vladmin-tools.top'
    
  • Destination backup list

    whmapi1 backup_destination_list
    
  • List backup dates

    whmapi1 backup_date_list
    
  • Destination validate

    whmapi1 --output=jsonpretty \
      backup_destination_validate \
      id='0W1ei2rd3A4lI5sT6he7Be8st' \
      disableonfail='1'
    
  • Cphulk config

whmapi1 --output=jsonpretty load_cphulk_config > /root/cphulk_config.$(date +%Y%m%d-%H%M%S).json
  • get public and private ip
    whmapi1 listips --output=jsonpretty | jq -r '.data.ip[].ip'
    192.168.1.8
    
 whmapi1 listips --output=jsonpretty | jq -r '.data.ip[].public_ip'