Created
April 20, 2023 04:54
-
-
Save cipulan/10fa3036a7b8d7c153df9c3c5045212e to your computer and use it in GitHub Desktop.
Automatic Install Wordpress On cPanel Account Creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMPFILE="$(mktemp -p /tmp wp-auto-install-XXXXXXXX)" | |
cat "${1:-/dev/stdin}" > $TMPFILE | |
DOMAIN=$(python2.7 -c "import sys, json; print json.load(open('$TMPFILE'))['data']['domain']") | |
CUSTOMEREMAIL=$(python2.7 -c "import sys, json; print json.load(open('$TMPFILE'))['data']['contactemail']") | |
## The following variable contains the name of the Package that was assigned to the account. | |
## It would be possible to add additional logic to this script so that WordPress is only installed for certain packages | |
PACKAGE=$(python2.7 -c "import sys, json; print json.load(open('$TMPFILE'))['data']['plan']") | |
rm -f $TMPFILE | |
if [ "$PACKAGE" == "A" ] || [ "$PACKAGE" == "B" ]; then | |
if [ ! -z $CUSTOMEREMAIL ]; then | |
wp-toolkit --install -domain-name $DOMAIN -admin-email $CUSTOMEREMAIL | |
else | |
# If a contact email address was not provided while creating the account, WP Toolkit will use the default of [email protected] as the WordPress Admin email | |
wp-toolkit --install -domain-name $DOMAIN | |
fi | |
else | |
echo "WordPress installation is only supported for A and B packages" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Automatic Install Wordpress On cPanel Account Creation
Create File /usr/local/cpanel/3rdparty/bin/wpAutoInstall.sh with content above
Setting permission & owner
Add to cPanel hook
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/wpAutoInstall.sh --manual --category Whostmgr --event Accounts::Create --stage=post
Test create cPanel account with selected package A or B