11 error_reporting(E_ALL);
12 if ((php_sapi_name() !=
'cli')) {
13 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
16 require_once
'Console/Getopt.php';
19 $longopt = Array(
'enable',
'disable',
'forget',
'status',
'disable_force');
21 $args = Console_Getopt::readPHPArgv();
23 $options = Console_Getopt::getopt($args, $shortopt, $longopt);
25 if ($options instanceof PEAR_Error) {
29 if (empty($options[0])) usage();
34 foreach ($options[0] as $option) {
37 if (empty($option[1])) usage();
38 if (!is_dir($option[1])) usage();
39 $SYSTEM_ROOT = $option[1];
48 if (empty($SYSTEM_ROOT)) {
49 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
53 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
54 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
58 if($ACTION ===
'--disable_force') {
60 file_put_contents($SYSTEM_ROOT.
'/data/private/conf/.dejavu',
'0');
61 echo
"Deja Vu is forcibly disabled.\n";
65 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
66 require_once $SYSTEM_ROOT.
'/core/include/deja_vu.inc';
71 if ($deja_vu->enabled() == FALSE) {
72 echo
"Deja Vu is currently disabled.\n";
74 echo
"Deja Vu is currently enabled.\n";
78 if ($deja_vu->enabled() == TRUE) {
79 echo
"Deja Vu is already enabled.\n";
82 assert_true(extension_loaded(
'memcache'),
'Cannot use Deja Vu; it requires the memcache PECL extension installed within , which is not installed');
83 assert_true(is_file(SQ_DATA_PATH.
'/private/conf/memcache.inc'),
'Cannot use Deja Vu; the Memcache configuration file is not set');
85 $memcache_conf = require(SQ_DATA_PATH.
'/private/conf/memcache.inc');
86 $hosts =& $memcache_conf[
'hosts'];
87 $services =& $memcache_conf[
'services'];
89 assert_true(count($hosts) > 0,
'Cannot use Deja Vu; no hosts are defined in the Memcache configuration file');
90 assert_true(array_key_exists(
'deja_vu', $services) === TRUE,
'Cannot use Deja Vu; no Memcache hosts are assigned');
91 assert_true(count($services[
'deja_vu']) > 0,
'Cannot use Deja Vu; no Memcache hosts are assigned');
93 echo
"Enabling Deja Vu...\n";
94 if ($deja_vu->enable()) {
97 echo
"Forgetting everything previously remembered...\n";
98 if ($d_vu->forgetAll()) {
110 if ($deja_vu->enabled() == FALSE) {
111 echo
"Deja Vu is already disabled.\n";
113 echo
"Disabling Deja Vu...\n";
114 if ($deja_vu->disable()) {
122 if ($deja_vu->enabled() == FALSE) {
123 echo
"Deja Vu is currently disabled.\n";
125 echo
"Forgetting everything in Deja Vu...\n";
126 if ($deja_vu->forgetAll()) {
147 echo
"\nUSAGE: dejavu_management.php -s <system_root> [--enable] [--disable] [--forget]\n".
148 "--enable Enables Deja Vu in MySource Matrix\n".
149 "--disable Disables Deja Vu in MySource Matrix\n".
150 "--disable_force Forcibly disables Deja Vu by editing control file\n".
151 "--forget Forgets all Deja Vu data in MySource Matrix\n".
152 "--status Checks the current Deja Vu status\n".
153 "\nNOTE: only one of [--enable --disable --forget] option is allowed to be specified\n";