Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #/bin/bash
  2. # Script for automating new account setups with WordPress installed
  3.  
  4. echo Lets setup a new WordPress dev site!
  5.  
  6. # Get user input
  7. # Us RegEx to check for valid domain
  8. read -p 'Enter the domain name: ' domain
  9. result=`echo $domain | grep -P '(?=^.{1,254}$)(^(?>(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)'`
  10. if [[ -z "$result" ]]
  11. then
  12. echo -e "\nNot a valid domain!"
  13. exit
  14. fi
  15. read -p 'Enter a username for the account (15 characters max): ' username
  16. read -sp 'Enter a password for the account: ' password
  17.  
  18. # Create cPanel account
  19. echo -e "\n\nCreating new cPanel account for $domain"
  20. whmapi1 createacct username=${username:0:15} domain=$domain plan=Unlimited featurelist=default quota=0 password=$password ip=n cgi=0 hasshell=1 contactemail=info@thisisvisceral.com cpmod=paper_lantern maxftp=unlimited maxsql=unlimited maxpop=unlimited maxlst=unlimited maxsub=unlimited maxpark=unlimited maxaddon=unlimited bwlimit=unlimited language=en useregns=1 hasuseregns=1 reseller=0 forcedns=1 mxcheck=local max_email_per_hour=500 max_defer_fail_percentage=80
  21.  
  22. # Create mySQL database
  23. dbname=${username:0:8}"_wordpress"
  24. dbuser=${username:0:8}"_dbuser"
  25. dbpassword=$password"sql"
  26. echo -e "\n\nCreating mySQL database ($dbname) in new cPanel account"
  27. uapi --user=$username Mysql create_database name=$dbname
  28. uapi --user=$username Mysql create_user name=$dbuser password=$dbpassword
  29. uapi --user=$username Mysql set_privileges_on_database user=$dbuser database=$dbname privileges=ALL%20PRIVILEGES
  30.  
  31. # Install WordPress
  32. wppassword=$password"wp"
  33. echo -e "\n\nInstalling WordPress"
  34. cd /home/${username:0:15}/public_html
  35. wp core download --allow-root
  36. chown -R ${username:0:15}:${username:0:15} *
  37. wp core config --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpassword --allow-root
  38. wp core install --url=$domain --title=$domain --admin_user=Visceral_Dev_Admin --admin_email=info@thisisvisceral.com --admin_password=$wppassword --allow-root
  39.  
  40. # Finish
  41. echo -e "\n\nSuccess!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement