Permalink
Browse files

Add basic Drush module

  • Loading branch information...
lattera committed May 10, 2013
1 parent 3237804 commit 11ec68bdb1fb245b4422ffbc114510ff7afdd2c2
Showing with 71 additions and 0 deletions.
  1. +71 −0 jailadmin.drush.inc
View
@@ -0,0 +1,71 @@
+<?php
+
+require_once('jailadmin.helpers.inc');
+require_once('classes/Mount.php');
+require_once('classes/Service.php');
+require_once('classes/Network.php');
+require_once('classes/NetworkDevice.php');
+require_once('classes/Jail.php');
+
+function jailadmin_drush_command() {
+ return array(
+ 'start' => array(
+ 'description' => 'Boot up a jail',
+ 'arguments' => array(
+ 'jailname' => 'Name of the jail to boot up',
+ ),
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
+ ),
+ 'stop' => array(
+ 'description' => 'Shutdown a jail',
+ 'arguments' => array(
+ 'jailname' => 'Name of the jail to shutdown',
+ ),
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
+ ),
+ 'autoboot' => array(
+ 'description' => 'Autoboot the jails',
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
+ ),
+ );
+}
+
+function drush_jailadmin_autoboot() {
+ $jails = Jail::LoadAll();
+
+ foreach ($jails as $jail) {
+ if ($jail->autoboot) {
+ $jail->Start();
+ }
+ }
+}
+
+drush_jailadmin_start($jailname='') {
+ if ($jailname == '') {
+ drush_print("Please provide a jail name");
+ return;
+ }
+
+ $jail = Jail::Load($jailname);
+ if ($jail === FALSE) {
+ drush_print("Jail not found");
+ return;
+ }
+
+ $jail->Start();
+}
+
+drush_jailadmin_stop($jailname='') {
+ if ($jailname == '') {
+ drush_print("Please provide a jail name");
+ return;
+ }
+
+ $jail = Jail::Load($jailname);
+ if ($jail === FALSE) {
+ drush_print("Jail not found");
+ return;
+ }
+
+ $jail->Stop();
+}

0 comments on commit 11ec68b

Please sign in to comment.