Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add snapshot action to Status page

  • Loading branch information...
commit e7e8118629dda51bb9e82f300b543ef4b2c037ed 1 parent 4294dac
Shawn Webb authored

Showing 2 changed files with 25 additions and 0 deletions. Show diff stats Hide diff stats

  1. +10 0 jailadmin.module
  2. +15 0 jailstatus.inc
10 jailadmin.module
@@ -127,6 +127,16 @@ function jailadmin_menu() {
127 127 'type' => MENU_NORMAL_ITEM,
128 128 );
129 129
  130 + $items['jailadmin/%/snapshot'] = array(
  131 + 'title' => 'Snapshot Jail',
  132 + 'page callback' => 'drupal_get_form',
  133 + 'page arguments' => array('jail_snapshot', 1),
  134 + 'file' => 'jailstatus.inc',
  135 + 'access callback' => 'jail_config_access',
  136 + 'access arguments' => array(1),
  137 + 'type' => MENU_NORMAL_ITEM,
  138 + );
  139 +
130 140 return $items;
131 141 }
132 142
15 jailstatus.inc
@@ -24,6 +24,8 @@ function jailadmin_status($form, &$form_state) {
24 24 else
25 25 $action = l("Start", "jailadmin/{$jail->name}/start");
26 26
  27 + $action .= " | " . l("Snapshot", "jailadmin/{$jail->name}/snapshot");
  28 +
27 29 $rows[] = array($name, $jail->IsOnlineString(), $jail->NetworkStatus(), $action);
28 30 }
29 31
@@ -67,3 +69,16 @@ function jail_stop($form, &$form_state) {
67 69
68 70 return jailadmin_status($form, $form_state);
69 71 }
  72 +
  73 +function jail_snapshot($form, &$form_state) {
  74 + $jail = Jail::Load($form_state['build_info']['args'][0]);
  75 +
  76 + if ($jail->Snapshot())
  77 + drupal_set_message(t('Jail @jail snapshot successful', array('@jail' => $jail->name)));
  78 + else
  79 + drupal_set_message(t('Jail @jail snapshot unsuccessful', array('@jail' => $jail->name)));
  80 +
  81 + $form_state['rebuild'] = true;
  82 +
  83 + return jailadmin_status($form, $form_state);
  84 +}

0 comments on commit e7e8118

Please sign in to comment.
Something went wrong with that request. Please try again.