D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
dedrads
/
provision
/
Filename :
cpanel
back
Copy
#!/bin/bash set -euo pipefail; RED='\033[0;31m'; GREEN='\033[1;32m'; NC='\033[0m'; function catch_exit() { rc=$? if [ $rc -ne 0 ]; then echo -e "${RED}ERROR: Script hit an error and has halted with exit code $rc. Please review /root/cpanel_setup.log${NC}"; else echo -e "${GREEN}Script finished successfully.${NC}"; fi exit $rc; } license_check() { lic_check=$(curl -s "https://verify.cpanel.net/api/ipaddrs"); cur_license=$(echo "${lic_check}" | jq -r '.current'); ipaddr=$(echo "${lic_check}" | jq -r '.ip'); if [ -z "${cur_license}" ] || [ "${cur_license}" == "null" ]; then echo -e "License check: ${RED}FAIL - Server is unlicensed. Please license ${ipaddr}${NC}"; exit 1; else echo -e "License check: ${GREEN}OK${NC}"; fi } install_cpanel() { # Prep Install cPanel /usr/bin/wget -O /home/latest https://securedownloads.cpanel.net/latest; # Cpanel Install auto logs to /var/log/cpanel-install.log the rest to /root/cpanel-setup.log /usr/bin/sh /home/latest; # Check if cPanel install is OK if [ ! -e /usr/local/cpanel/version ]; then echo -e "${RED}ERROR: cPanel Install Failed${NC}"; exit 1; fi } main_script() { trap catch_exit SIGINT; trap catch_exit EXIT; echo "New cPanel Provision Beginning: $(date)"; license_check; install_cpanel; } if [ $# -eq 1 ]; then echo "/opt/dedrads/provision/cpanel"; echo; echo "Run without any args to do full installation process."; else main_script | tee -a /root/cpanel_setup.log fi