Skip to content

Commit

Permalink
Update for Terminux 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rvtraveller committed Feb 25, 2017
1 parent 1d3e4f1 commit 37c779c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 65 deletions.
62 changes: 0 additions & 62 deletions Commands/OmniscientCommand.php

This file was deleted.

16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Omniscient

[![Terminus v1.x Compatible](https://img.shields.io/badge/terminus-v1.x-green.svg)](https://github.com/terminus-plugin-project/terminus-omniscient/tree/1.x)
[![Terminus v0.x Compatible](https://img.shields.io/badge/terminus-v0.x-green.svg)](https://github.com/terminus-plugin-project/terminus-omniscient/tree/0.x)

Terminus Plugin to enable [New Relic Pro](https://pantheon.io/docs/new-relic/) on all [Pantheon](https://www.pantheon.io) sites.

Adds a sub-command to 'sites' which is called 'omniscient'. This enables New Relic Pro for all sites your account has access to.

## Examples
* `terminus sites omniscient`
* `terminus omniscient`

## Installation
For help installing, see [Terminus's Wiki](https://github.com/pantheon-systems/terminus/wiki/Plugins)
To install this plugin place it in `~/.terminus/plugins/`.

On Mac OS/Linux:
```
mkdir -p ~/.terminus/plugins
composer create-project -d ~/.terminus/plugins terminus-plugin-project/terminus-omniscient:~1
```
For additional help installing, see [Terminus' Plugins](https://pantheon.io/docs/terminus/plugins/).

## Help
Run `terminus help sites omniscient` for help.
Run `terminus help omniscient` for help.
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"description": "Omniscient - A Terminus plugin for enabling New Relic Pro on all sites",
"homepage": "https://github.com/rvtraveller/terminus-omniscient",
"license": "MIT",
"type": "terminus-plugin",
"require": {
"php": ">=5.4"
},
"autoload": {
"psr-4": { "rvtraveller\\Omniscient\\": "src" }
},
"extra": {
"terminus": {
"compatible-version": "1.*"
}
}
}
51 changes: 51 additions & 0 deletions src/Commands/OmniscientCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace rvtraveller\Omniscient\Commands;

use Pantheon\Terminus\Commands\TerminusCommand;
use Pantheon\Terminus\Site\SiteAwareInterface;
use Pantheon\Terminus\Site\SiteAwareTrait;

class OmniscientCommand extends TerminusCommand implements SiteAwareInterface
{
use SiteAwareTrait;

/**
* Enables New Relic Pro on all sites/environments a user has access
* to.
*
* @authorize
*
* @command sites:omniscient
* @alias omniscient
*
* @usage terminus sites:omniscient
*/
public function omniscient() {
$this->sites()->fetch();

$sites = $this->sites()->serialize();

foreach ($sites as $site) {
$site = $this->getSite($site['name']);
$site_name = $site->getName();
$new_relic_info = $site->getNewRelic();
$new_relic_info->fetch();
$new_relic_data = $new_relic_info->serialize();
if (empty($new_relic_data)) {
// New Relic is disabled.
if ((boolean)$site->get('frozen')) {
$this->log()->notice("Skipping $site_name because site is frozen.");
}
else {
$new_relic_info->enable();
$this->log()->notice("Enabled New Relic Pro for $site_name");
}
}
else {
$this->log()->notice("Skipping $site_name because New Relic Pro is already enabled.");
}
}
}

}

0 comments on commit 37c779c

Please sign in to comment.