1

I have a bash script that installs and activates a theme like this:

wp theme install https://bitbucket.org/organization/theme/get/master.zip --activate

The problem is that it only works with public repositories, rather than private ones. If I make the repository private I get this error:

Unpacking the package...
Warning: The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

Is there a way I can install private repositories that I have ssh keys and passwords for?

2 Answers 2

2

I actually figured out a way to do this. First you use wget like this:

wget --user username --ask-password -O path/to/output.zip https://bitbucket.org/path/to/file.zip

the -O flag specifies output and output.zip is where you want it to download to.

Then you can run:

wp theme install path/to/output.zip --activate

Happy days

1

I like to run my grab from a php script. I happen to do git clone instead of wget, but the same principals will still apply. Try something like this:

git clone "https://bitBucketUsername:bit[email protected]/organization/theme/get/master.git"

In practice, you'll need to escape your username and password, like so.

$bitBucketUsername = "[email protected]";
$bitBucketPassword = 'ILikeTurtles';
$bitBucketCredentials = urlencode($bitBucketUsername).':'.urlencode($bitBucketPassword).'@';
$cmd = "git clone \"https://{$bitBucketCredentials}bitbucket.org/organization/theme/get/master.git\"";

exec($cmd, $output, $return);
if ($return != 0) {
    if (is_array($output)) {
            $output = var_export($output, true);
    }
    print "Yikes, got ($return).  output: $output";
} else {
    // seems to have worked
    // maybe activate the plugin?
}

For a more secure solution when using git, search on 'helper credentials'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.