summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/bin/partner-provision.sh')
-rwxr-xr-xplugins/jetpack/bin/partner-provision.sh46
1 files changed, 38 insertions, 8 deletions
diff --git a/plugins/jetpack/bin/partner-provision.sh b/plugins/jetpack/bin/partner-provision.sh
index 913ddb73..cfeca6d6 100755
--- a/plugins/jetpack/bin/partner-provision.sh
+++ b/plugins/jetpack/bin/partner-provision.sh
@@ -3,15 +3,12 @@
# accepts: partner client ID and secret key, and some site info
# executes wp-cli command to provision Jetpack site for given partner
-# TODO:
-# - allow user_email instead of user_id, automatically lookup/provision an admin on site (maybe rename user_id param to user?)
-
# change to script directory so that wp finds the wordpress install part for this Jetpack instance
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
cd "$SCRIPT_DIR" || exit
usage () {
- echo "Usage: partner-provision.sh --partner_id=partner_id --partner_secret=partner_secret --user_id=wp_user_id [--plan=plan_name] [--wpcom_user_id=1234] [--url=http://example.com]"
+ echo "Usage: partner-provision.sh --partner_id=partner_id --partner_secret=partner_secret [--user=wp_user_id] [--plan=plan_name] [--onboarding=1] [--wpcom_user_id=1234] [--url=http://example.com] [--force_connect=1] [--force_register=1]"
}
for i in "$@"; do
@@ -22,7 +19,7 @@ for i in "$@"; do
-s=* | --partner_secret=* ) CLIENT_SECRET="${i#*=}"
shift
;;
- -i=* | --user_id=* ) WP_USER_ID="${i#*=}"
+ -i=* | --user_id=* | --user=* ) WP_USER="${i#*=}"
shift
;;
-w=* | --wpcom_user_id=* ) WPCOM_USER_ID="${i#*=}"
@@ -31,6 +28,9 @@ for i in "$@"; do
-p=* | --plan=* ) PLAN_NAME="${i#*=}"
shift
;;
+ -o=* | --onboarding=* ) ONBOARDING="${i#*=}"
+ shift
+ ;;
-u=* | --url=* ) SITE_URL="${i#*=}"
shift
;;
@@ -42,7 +42,7 @@ for i in "$@"; do
esac
done
-if [ "$CLIENT_ID" = "" ] || [ "$CLIENT_SECRET" = "" ] || [ "$WP_USER_ID" = "" ]; then
+if [ "$CLIENT_ID" = "" ] || [ "$CLIENT_SECRET" = "" ]; then
usage
exit 1
fi
@@ -55,8 +55,38 @@ fi
# fetch an access token using our client ID/secret
ACCESS_TOKEN_JSON=$(curl https://$JETPACK_START_API_HOST/oauth2/token --silent --header "Host: public-api.wordpress.com" -d "grant_type=client_credentials&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&scope=jetpack-partner")
+# set URL arg for multisite compatibility
+if [ ! -z "$SITE_URL" ]; then
+ ADDITIONAL_ARGS="--url=$SITE_URL"
+fi
+
# silently ensure Jetpack is active
-wp plugin activate jetpack --url="$SITE_URL" >/dev/null 2>&1
+wp plugin activate jetpack $ADDITIONAL_ARGS >/dev/null 2>&1 --allow-root
+
+# add extra args if available
+if [ ! -z "$WP_USER" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --user=$WP_USER"
+fi
+
+if [ ! -z "$ONBOARDING" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --onboarding=$ONBOARDING"
+fi
+
+if [ ! -z "$PLAN_NAME" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --plan=$PLAN_NAME"
+fi
+
+if [ ! -z "$WPCOM_USER_ID" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --wpcom_user_id=$WPCOM_USER_ID"
+fi
+
+if [ ! -z "$FORCE_REGISTER" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --force_register=$FORCE_REGISTER"
+fi
+
+if [ ! -z "$FORCE_CONNECT" ]; then
+ ADDITIONAL_ARGS="$ADDITIONAL_ARGS --force_connect=$FORCE_CONNECT"
+fi
# provision the partner plan
-wp jetpack partner_provision "$ACCESS_TOKEN_JSON" --user_id="$WP_USER_ID" --plan="$PLAN_NAME" --wpcom_user_id="$WPCOM_USER_ID" --url="$SITE_URL"
+wp jetpack partner_provision "$ACCESS_TOKEN_JSON" $ADDITIONAL_ARGS --allow-root