These scripts belong in horde, not the packages
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Mar 2010 19:41:32 +0000 (13:41 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Mar 2010 20:37:47 +0000 (14:37 -0600)
framework/Memcache/package.xml
framework/Memcache/scripts/Horde/Memcache/stats.php [deleted file]
framework/Scheduler/package.xml
framework/Scheduler/scripts/Horde/Scheduler/horde-crond.php [deleted file]
framework/SessionHandler/package.xml
framework/SessionHandler/scripts/Horde/SessionHandler/horde-active-sessions.php [deleted file]
horde/bin/active_sessions [new file with mode: 0755]
horde/bin/crond [new file with mode: 0755]
horde/bin/memcache_stats [new file with mode: 0755]

index 87433be..9cac165 100644 (file)
@@ -25,18 +25,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.</notes>
+ <notes>* Remove Horde_Core dependency.
+ * Initial Horde 4 package.</notes>
  <contents>
   <dir name="/">
-   <dir name="scripts">
-    <dir name="Horde">
-     <dir name="Memcache">
-      <file name="stats.php" role="script">
-       <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/>
-      </file>
-     </dir> <!-- /scripts/Horde/Memcache -->
-    </dir> <!-- /scripts/Horde -->
-   </dir> <!-- /scripts -->
    <dir name="lib">
     <dir name="Horde">
      <file name="Memcache.php" role="php" />
@@ -53,10 +45,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <min>1.5.0</min>
    </pearinstaller>
    <package>
-    <name>Core</name>
-    <channel>pear.horde.org</channel>
-   </package>
-   <package>
     <name>Exception</name>
     <channel>pear.horde.org</channel>
    </package>
@@ -68,7 +56,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <phprelease>
   <filelist>
    <install name="lib/Horde/Memcache.php" as="Horde/Memcache.php" />
-   <install name="scripts/Horde/Memcache/stats.php" as="horde-memcache-stats" />
   </filelist>
  </phprelease>
  <changelog>
diff --git a/framework/Memcache/scripts/Horde/Memcache/stats.php b/framework/Memcache/scripts/Horde/Memcache/stats.php
deleted file mode 100755 (executable)
index 81887d9..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-#!@php_bin@
-<?php
-/**
- * This script outputs statistics on the current memcache pool.
- *
- * Usage: stats.php [--all] [--flush] [--lookup=key] [--raw] [--summary]
- *
- * By default, shows statistics for all servers.
- *
- * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Memcache
- */
-
-// The base file path of horde.
-$horde_base = '/path/to/horde';
-
-require_once $horde_base . '/lib/Application.php';
-Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-
-/* Make sure there's no compression. */
-@ob_end_clean();
-
-$c = new Console_Getopt();
-$argv = $c->readPHPArgv();
-array_shift($argv);
-$options = $c->getopt2($argv, '', array('all', 'flush', 'lookup=', 'raw', 'summary'));
-if (PEAR::isError($options)) {
-    $cli->writeln($cli->red("ERROR: Invalid arguments."));
-    exit;
-}
-
-$all = $raw = $summary = false;
-$memcache = $injector->getInstance('Horde_Memcache');
-
-foreach ($options[0] as $val) {
-    switch ($val[0]) {
-    case '--all':
-        $all = true;
-        break;
-
-    case '--flush':
-        if ($cli->prompt($cli->red('Are you sure you want to flush all data?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y') {
-            $memcache->flush();
-            $cli->writeln($cli->green('Done.'));
-        }
-        exit;
-
-    case '--lookup':
-        $data = $memcache->get($val[1]);
-        if (!empty($data)) {
-            $cli->writeln(print_r($data, true));
-        } else {
-            $cli->writeln('[Key not found.]');
-        }
-        exit;
-
-    case '--raw':
-        $raw = true;
-        break;
-
-    case '--summary':
-        $summary = true;
-        break;
-    }
-}
-
-$stats = $memcache->stats();
-
-if ($raw) {
-    $cli->writeln(print_r($stats, true));
-} elseif (!$summary) {
-    $all = true;
-}
-
-if ($all || $summary) {
-    if ($summary) {
-        $total = array();
-        $total_keys = array('bytes', 'limit_maxbytes', 'curr_items', 'total_items', 'get_hits', 'get_misses', 'curr_connections', 'bytes_read', 'bytes_written');
-        foreach ($total_keys as $key) {
-            $total[$key] = 0;
-        }
-    }
-
-    $i = $s_count = count($stats);
-
-    foreach ($stats as $key => $val) {
-        if ($summary) {
-            foreach ($total_keys as $k) {
-                $total[$k] += $val[$k];
-            }
-        }
-
-        if ($all) {
-            $cli->writeln($cli->green('Server: ' . $key . ' (Version: ' . $val['version'] . ' - ' . $val['threads'] . ' thread(s))'));
-            _outputInfo($val, $cli);
-            if (--$i || $summary) {
-                $cli->writeln();
-            }
-        }
-    }
-
-    if ($summary) {
-        $cli->writeln($cli->green('Memcache pool (' . $s_count . ' server(s))'));
-        _outputInfo($total, $cli);
-    }
-}
-
-function _outputInfo($val, $cli)
-{
-    $cli->writeln($cli->indent('Size:          ' . sprintf("%0.2f", $val['bytes'] / 1048576) . ' MB (Max: ' . sprintf("%0.2f", ($val['limit_maxbytes']) / 1048576) . ' MB - ' . ((!empty($val['limit_maxbytes']) ? round(($val['bytes'] / $val['limit_maxbytes']) * 100, 1) : 'N/A')) . '% used)'));
-    $cli->writeln($cli->indent('Items:         ' . $val['curr_items'] . ' (Total: ' . $val['total_items'] . ')'));
-    $cli->writeln($cli->indent('Cache Ratio:   ' . $val['get_hits'] . ' hits, ' . $val['get_misses'] . ' misses'));
-    $cli->writeln($cli->indent('Connections:   ' . $val['curr_connections']));
-    $cli->writeln($cli->indent('Traffic:       ' . sprintf("%0.2f", $val['bytes_read'] / 1048576) . ' MB in, ' . sprintf("%0.2f", $val['bytes_written'] / 1048576) . ' MB out'));
-}
index 0f7dad1..3a8e820 100644 (file)
@@ -24,19 +24,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.
+ <notes>* Removed Horde-specific command line script.
+ * Initial Horde 4 package.
  </notes>
  <contents>
   <dir name="/">
-   <dir name="scripts">
-    <dir name="Horde">
-     <dir name="Scheduler">
-      <file name="horde-crond.php" role="script">
-       <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/>
-      </file>
-     </dir> <!-- /scripts/Horde/Scheduler -->
-    </dir> <!-- /scripts/Horde -->
-   </dir> <!-- /scripts -->
    <dir name="lib">
     <dir name="Horde">
      <dir name="Scheduler">
@@ -74,7 +66,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
-   <install name="scripts/Horde/Scheduler/horde-crond.php" as="horde-crond" />
    <install name="lib/Horde/Scheduler/Cron/Date.php" as="Horde/Scheduler/Cron/Date.php" />
    <install name="lib/Horde/Scheduler/Cron.php" as="Horde/Scheduler/Cron.php" />
    <install name="lib/Horde/Scheduler.php" as="Horde/Scheduler.php" />
diff --git a/framework/Scheduler/scripts/Horde/Scheduler/horde-crond.php b/framework/Scheduler/scripts/Horde/Scheduler/horde-crond.php
deleted file mode 100755 (executable)
index e778799..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!@php_bin@
-<?php
-/**
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @package Horde_Scheduler
- */
-
-// The base file path of horde.
-$horde_base = '/path/to/horde';
-
-require_once $horde_base . '/lib/Application.php';
-Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-
-// Get an instance of the cron scheduler.
-$daemon = Horde_Scheduler::factory('Cron');
-
-// Now add some cron jobs to do, or add parsing to read a config file.
-// $daemon->addTask('ls', '0,5,10,15,20,30,40 * * * *');
-
-// Start the daemon going.
-$daemon->run();
index c180a12..5538256 100644 (file)
@@ -37,19 +37,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.
+ <notes>* Removed Horde-specific session counting script.
+ * Initial Horde 4 package.
  </notes>
  <contents>
   <dir name="/">
-   <dir name="scripts">
-    <dir name="Horde">
-     <dir name="SessionHandler">
-      <file name="horde-active-sessions.php" role="script">
-       <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/>
-      </file>
-     </dir> <!-- /scripts/Horde/SessionHandler -->
-    </dir> <!-- /scripts/Horde -->
-   </dir> <!-- /scripts -->
    <dir name="lib">
     <dir name="Horde">
      <dir name="SessionHandler">
@@ -77,11 +69,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
   </required>
   <optional>
    <package>
-    <name>Horde_Memcache</name>
+    <name>Memcache</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Horde_SQL</name>
+    <name>SQL</name>
     <channel>pear.horde.org</channel>
    </package>
   </optional>
@@ -95,7 +87,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/SessionHandler/Oci8.php" as="Horde/SessionHandler/Pgsql.php" />
    <install name="lib/Horde/SessionHandler/Sql.php" as="Horde/SessionHandler/Sql.php" />
    <install name="lib/Horde/SessionHandler.php" as="Horde/SessionHandler.php" />
-   <install name="scripts/Horde/SessionHandler/horde-active-sessions.php" as="scripts/horde-active-sessions.php" />
   </filelist>
  </phprelease>
  <changelog>
diff --git a/framework/SessionHandler/scripts/Horde/SessionHandler/horde-active-sessions.php b/framework/SessionHandler/scripts/Horde/SessionHandler/horde-active-sessions.php
deleted file mode 100755 (executable)
index a8ff63a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!@php_bin@
-<?php
-/**
- * This script counts the number of active authenticated user sessions.
- *
- * Command line options:
- *   '-l'   List the username of active authenticated users
- *   '-ll'  List the username and login time of active authenticated users
- *
- * @package Horde_SessionHandler
- */
-
-// Find the base file path of Horde.
-$horde_base = '/path/to/horde';
-
-require_once $horde_base . '/lib/Application.php';
-Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-
-/* Check for sessionhandler object. */
-$registry->setupSessionHandler();
-if (!$registry->sessionHandler) {
-    throw new Horde_Exception('Horde is unable to load the session handler');
-}
-
-$type = !empty($conf['sessionhandler']['type'])
-    ? $conf['sessionhandler']['type']
-    : 'builtin';
-
-if ($type == 'external') {
-    throw new Horde_Exception('Session counting is not supported in the \'external\' SessionHandler.');
-}
-
-$sessions = $registry->sessionHandler->getSessionsInfo();
-
-if (($argc < 2) || (($argv[1] != '-l') && ($argv[1] != '-ll'))) {
-    $cli->writeln(count($sessions));
-} else {
-    foreach ($sessions as $data) {
-        if ($argv[1] == '-ll') {
-            $cli->writeln($data['userid'] . ' [' . date('r', $data['timestamp']) . ']');
-        } else {
-            $cli->writeln($data['userid']);
-        }
-    }
-    $cli->writeln($cli->green('Total Sessions: ' . count($sessions)));
-}
diff --git a/horde/bin/active_sessions b/horde/bin/active_sessions
new file mode 100755 (executable)
index 0000000..a536192
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env php
+<?php
+/**
+ * This script counts the number of active authenticated user sessions.
+ *
+ * Command line options:
+ *   '-l'   List the username of active authenticated users
+ *   '-ll'  List the username and login time of active authenticated users
+ *
+ * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ */
+
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
+
+/* Check for sessionhandler object. */
+$registry->setupSessionHandler();
+if (!$registry->sessionHandler) {
+    throw new Horde_Exception('Horde is unable to load the session handler.');
+}
+
+$type = !empty($conf['sessionhandler']['type'])
+    ? $conf['sessionhandler']['type']
+    : 'builtin';
+
+if ($type == 'external') {
+    throw new Horde_Exception('Session counting is not supported in the \'external\' SessionHandler.');
+}
+
+$sessions = $registry->sessionHandler->getSessionsInfo();
+
+if (($argc < 2) || (($argv[1] != '-l') && ($argv[1] != '-ll'))) {
+    $cli->writeln(count($sessions));
+} else {
+    foreach ($sessions as $data) {
+        if ($argv[1] == '-ll') {
+            $cli->writeln($data['userid'] . ' [' . date('r', $data['timestamp']) . ']');
+        } else {
+            $cli->writeln($data['userid']);
+        }
+    }
+    $cli->writeln($cli->green('Total Sessions: ' . count($sessions)));
+}
diff --git a/horde/bin/crond b/horde/bin/crond
new file mode 100755 (executable)
index 0000000..6fe68f2
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env php
+<?php
+/**
+ * Horde cron daemon.  Cron
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ */
+
+// Configuration
+
+// Tasks configuration.
+// KEY: scriptname
+// VALUE: crontab definition
+$cron_tasks = array(
+    // Basic example: list files at xx:00, xx:05, xx:10, and xx:20
+    // '/bin/ls' => '0,5,10,15,20 * * * *'
+);
+
+// End Configuration
+
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
+
+// Get an instance of the cron scheduler.
+$daemon = Horde_Scheduler::factory('Cron');
+
+// Add cron tasks.
+foreach ($cron_tasks as $key => $val) {
+    $daemon->addTask($key, $val);
+}
+
+// Start the daemon going.
+$daemon->run();
diff --git a/horde/bin/memcache_stats b/horde/bin/memcache_stats
new file mode 100755 (executable)
index 0000000..bb8266b
--- /dev/null
@@ -0,0 +1,116 @@
+#!/usr/bin/env php
+<?php
+/**
+ * This script outputs statistics on the current memcache pool.
+ *
+ * Usage: stats.php [--all] [--flush] [--lookup=key] [--raw] [--summary]
+ *
+ * By default, shows statistics for all servers.
+ *
+ * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ */
+
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
+
+/* Make sure there's no compression. */
+@ob_end_clean();
+
+$c = new Console_Getopt();
+$argv = $c->readPHPArgv();
+array_shift($argv);
+$options = $c->getopt2($argv, '', array('all', 'flush', 'lookup=', 'raw', 'summary'));
+if (PEAR::isError($options)) {
+    $cli->writeln($cli->red("ERROR: Invalid arguments."));
+    exit;
+}
+
+$all = $raw = $summary = false;
+$memcache = $injector->getInstance('Horde_Memcache');
+
+foreach ($options[0] as $val) {
+    switch ($val[0]) {
+    case '--all':
+        $all = true;
+        break;
+
+    case '--flush':
+        if ($cli->prompt($cli->red('Are you sure you want to flush all data?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y') {
+            $memcache->flush();
+            $cli->writeln($cli->green('Done.'));
+        }
+        exit;
+
+    case '--lookup':
+        $data = $memcache->get($val[1]);
+        if (!empty($data)) {
+            $cli->writeln(print_r($data, true));
+        } else {
+            $cli->writeln('[Key not found.]');
+        }
+        exit;
+
+    case '--raw':
+        $raw = true;
+        break;
+
+    case '--summary':
+        $summary = true;
+        break;
+    }
+}
+
+$stats = $memcache->stats();
+
+if ($raw) {
+    $cli->writeln(print_r($stats, true));
+} elseif (!$summary) {
+    $all = true;
+}
+
+if ($all || $summary) {
+    if ($summary) {
+        $total = array();
+        $total_keys = array('bytes', 'limit_maxbytes', 'curr_items', 'total_items', 'get_hits', 'get_misses', 'curr_connections', 'bytes_read', 'bytes_written');
+        foreach ($total_keys as $key) {
+            $total[$key] = 0;
+        }
+    }
+
+    $i = $s_count = count($stats);
+
+    foreach ($stats as $key => $val) {
+        if ($summary) {
+            foreach ($total_keys as $k) {
+                $total[$k] += $val[$k];
+            }
+        }
+
+        if ($all) {
+            $cli->writeln($cli->green('Server: ' . $key . ' (Version: ' . $val['version'] . ' - ' . $val['threads'] . ' thread(s))'));
+            _outputInfo($val, $cli);
+            if (--$i || $summary) {
+                $cli->writeln();
+            }
+        }
+    }
+
+    if ($summary) {
+        $cli->writeln($cli->green('Memcache pool (' . $s_count . ' server(s))'));
+        _outputInfo($total, $cli);
+    }
+}
+
+function _outputInfo($val, $cli)
+{
+    $cli->writeln($cli->indent('Size:          ' . sprintf("%0.2f", $val['bytes'] / 1048576) . ' MB (Max: ' . sprintf("%0.2f", ($val['limit_maxbytes']) / 1048576) . ' MB - ' . ((!empty($val['limit_maxbytes']) ? round(($val['bytes'] / $val['limit_maxbytes']) * 100, 1) : 'N/A')) . '% used)'));
+    $cli->writeln($cli->indent('Items:         ' . $val['curr_items'] . ' (Total: ' . $val['total_items'] . ')'));
+    $cli->writeln($cli->indent('Cache Ratio:   ' . $val['get_hits'] . ' hits, ' . $val['get_misses'] . ' misses'));
+    $cli->writeln($cli->indent('Connections:   ' . $val['curr_connections']));
+    $cli->writeln($cli->indent('Traffic:       ' . sprintf("%0.2f", $val['bytes_read'] / 1048576) . ' MB in, ' . sprintf("%0.2f", $val['bytes_written'] / 1048576) . ' MB out'));
+}