3 namespace Friendica\Core\Console;
8 * @brief Sets maintenance mode for this node
10 * @author Hypolite Petovan <hypolite@mrpetovan.com>
12 class Maintenance extends \Asika\SimpleConsole\Console
14 protected $helpOptions = ['h', 'help', '?'];
16 protected function getHelp()
19 console maintenance - Sets maintenance mode for this node
21 bin/console maintenance <enable> [<reason>] [-h|--help|-?] [-v]
24 <enable> cen be either 0 or 1 to disabled or enable the maintenance mode on this node.
26 <reason> is a quote-enclosed string with the optional reason for the maintenance mode.
29 bin/console maintenance 1
30 Enables the maintenance mode without setting a reason message
32 bin/console maintenance 1 "SSL certification update"
33 Enables the maintenance mode with setting a reason message
35 bin/console maintenance 0
36 Disables the maintenance mode
39 -h|--help|-? Show help information
40 -v Show more debug information.
45 protected function doExecute()
47 $a = \Friendica\BaseObject::getApp();
49 if ($this->getOption('v')) {
50 $this->out('Class: ' . __CLASS__);
51 $this->out('Arguments: ' . var_export($this->args, true));
52 $this->out('Options: ' . var_export($this->options, true));
55 if (count($this->args) == 0) {
56 $this->out($this->getHelp());
60 if (count($this->args) > 2) {
61 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
64 if ($a->getMode()->isInstall()) {
65 throw new \RuntimeException('Database isn\'t ready or populated yet');
68 $enabled = intval($this->getArgument(0));
70 Core\Config::set('system', 'maintenance', $enabled);
72 $reason = $this->getArgument(1);
74 if ($enabled && $this->getArgument(1)) {
75 Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));
77 Core\Config::set('system', 'maintenance_reason', '');
81 $mode_str = "maintenance mode";
83 $mode_str = "normal mode";
86 $this->out('System set in ' . $mode_str);
88 if ($enabled && $reason != '') {
89 $this->out('Maintenance reason: ' . $reason);