public static function updateSonos() { log::remove('sonos_update'); $cmd = 'sudo /bin/bash ' . dirname(__FILE__) . '/../../ressources/install.sh'; $cmd .= ' >> ' . log::getPathToLog('sonos_update') . ' 2>&1 &'; exec($cmd); }
public static function updateporkfolio() { log::remove('porkfolio_update'); $clientid = config::byKey('clientid', 'porkfolio', 0); $clientsecret = config::byKey('clientsecret', 'porkfolio', 0); $username = config::byKey('username', 'porkfolio', 0); $password = config::byKey('password', 'porkfolio', 0); $cmd = '/usr/bin/python ' . dirname(__FILE__) . '/../../3rdparty/py-wink-adapt/login.py ' . $clientid . ' ' . $clientsecret . ' ' . $username . ' ' . $password; $cmd .= ' >> ' . log::getPathToLog('porkfolio_update') . ' 2>&1 &'; exec($cmd); }
public static function updateOpenzwave($_background = true) { try { self::stopDeamon(); } catch (Exception $e) { } log::remove('openzwave_update'); $cmd = 'sudo /bin/bash ' . dirname(__FILE__) . '/../../ressources/install.sh'; if ($_background) { $cmd .= ' >> ' . log::getPathToLog('openzwave_update') . ' 2>&1 &'; } exec($cmd); }
public static function updateSystem() { if (config::byKey('update::autoSystem') == 1 && jeedom::isCapable('systemUpdate') && jeedom::isCapable('sudo')) { $output = array(); $return_val = -1; log::remove('system_update'); exec('sudo apt-get -y update >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec de la mise à jour des dépot, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec de la mise à jour des paquets, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo apt-get -y autoremove >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec su nettoyage des paquets, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo service cron restart'); } }
public static function dns_start() { if (config::byKey('ngrok::addr') == '') { return; } network::dns_stop(); $config_file = '/tmp/ngrok_jeedom'; $logfile = log::getPathToLog('ngrok'); $uname = posix_uname(); if (strrpos($uname['machine'], 'arm') !== false) { $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-arm'; } else { if ($uname['machine'] == 'x86_64') { $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-x64'; } else { $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-x86'; } } exec('chmod +x ' . $cmd); $cmd .= ' -config=' . $config_file . ' start jeedom'; if (!self::dns_run()) { $replace = array('#server_addr#' => 'dns.jeedom.com:4443', '#name#' => 'jeedom', '#proto#' => 'https', '#port#' => 80, '#remote_port#' => '', '#token#' => config::byKey('ngrok::token'), '#auth#' => '', '#subdomain#' => 'subdomain : ' . config::byKey('ngrok::addr')); $config = template_replace($replace, file_get_contents(dirname(__FILE__) . '/../../script/ngrok/config')); if (file_exists($config_file)) { unlink($config_file); } file_put_contents($config_file, $config); log::remove('ngrok'); log::add('ngork', 'debug', 'Lancement de ngork : ' . $cmd); exec($cmd . ' >> /dev/null 2>&1 &'); } return true; }
public function start_openvpn() { $this->stop_openvpn(); $this->writeConfig(); $log_name = 'openvpn_' . str_replace(' ', '_', $this->getName()); log::remove($log_name); $cmd = 'sudo ' . $this->getCmdLine() . ' >> ' . log::getPathToLog($log_name) . ' 2>&1 &'; log::add($log_name, 'info', __('Lancement openvpn : ', __FILE__) . $cmd); shell_exec($cmd); $this->updateState(); }
public static function syncconfOpenzwave($_background = true) { log::remove('openzwave_syncconf'); $cmd = 'sudo /bin/bash ' . dirname(__FILE__) . '/../../ressources/syncconf.sh'; if ($_background) { $cmd .= ' >> ' . log::getPathToLog('openzwave_syncconf') . ' 2>&1 &'; } log::add('openzwave_syncconf', 'info', $cmd); shell_exec($cmd); }
if ($jsonrpc->getMethod() == 'jeeNetwork::backup') { jeedom::backup(true); $jsonrpc->makeSuccess('ok'); } /* * ************************Log*************************** */ if ($jsonrpc->getMethod() == 'log::get') { $jsonrpc->makeSuccess(log::get($params['log'], $params['start'], $params['nbLine'])); } if ($jsonrpc->getMethod() == 'log::list') { $jsonrpc->makeSuccess(log::liste()); } if ($jsonrpc->getMethod() == 'log::empty') { $jsonrpc->makeSuccess(log::clear($params['log'])); } if ($jsonrpc->getMethod() == 'log::remove') { $jsonrpc->makeSuccess(log::remove($params['log'])); } /* * ************************Messages*************************** */ if ($jsonrpc->getMethod() == 'message::removeAll') { message::removeAll(); $jsonrpc->makeSuccess('ok'); } if ($jsonrpc->getMethod() == 'message::all') { $jsonrpc->makeSuccess(utils::o2a(message::all())); } /* * ************************Interact*************************** */ if ($jsonrpc->getMethod() == 'interact::tryToReply') { $jsonrpc->makeSuccess(interactQuery::tryToReply($params['query'])); } /* * ************************USB mapping*************************** */ if ($jsonrpc->getMethod() == 'jeedom::getUsbMapping') {
public static function deamon_start($_debug = false) { self::deamon_stop(); $deamon_info = self::deamon_info(); if ($deamon_info['launchable'] != 'ok') { throw new Exception(__('Veuillez vérifier la configuration', __FILE__)); } log::remove('openzwavecmd'); $port = config::byKey('port', 'openzwave'); if ($port != 'auto') { $port = jeedom::getUsbMapping($port); } if (config::byKey('jeeNetwork::mode') == 'slave') { $serverId = config::byKey('jeeNetwork::slave::id'); $callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php'; $apikey = config::byKey('jeeNetwork::master::apikey'); } else { $serverId = 0; $callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php'; $apikey = config::byKey('api'); } $port_server = config::byKey('port_server', 'openzwave', 8083); $openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver'; $config_path = dirname(__FILE__) . '/../../ressources/openzwave/config'; $data_path = dirname(__FILE__) . '/../../data'; if (!file_exists($data_path)) { exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path); } $log = $_debug ? 'Debug' : 'Error'; $cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py '; $cmd .= ' --pidfile=/tmp/openzwave.pid'; $cmd .= ' --device=' . $port; $cmd .= ' --log=' . $log; $cmd .= ' --port=' . $port_server; $cmd .= ' --config_folder=' . $config_path; $cmd .= ' --data_folder=' . $data_path; $cmd .= ' --callback=' . $callback; $cmd .= ' --apikey=' . $apikey; $cmd .= ' --serverId=' . $serverId; log::add('openzwavecmd', 'info', 'Lancement démon openzwave : ' . $cmd); $result = exec($cmd . ' >> ' . log::getPathToLog('openzwavecmd') . ' 2>&1 &'); if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) { log::add('openzwavecmd', 'error', $result); return false; } $i = 0; while ($i < 30) { $deamon_info = self::deamon_info(); if ($deamon_info['state'] == 'ok') { break; } sleep(1); $i++; } if ($i >= 30) { log::add('openzwavecmd', 'error', 'Impossible de lancer le démon openzwave, relancer le démon en debug et vérifiez la log', 'unableStartDeamon'); return false; } message::removeAll('openzwave', 'unableStartDeamon'); log::add('openzwavecmd', 'info', 'Démon openzwave lancé'); }
public static function updateZwayServer($_version = '') { log::remove('zway_update'); if ($_version != '') { $cmd = 'sudo /bin/bash ' . dirname(__FILE__) . '/../../resources/zway_update.sh ' . $_version; } else { $cmd = 'sudo /bin/bash ' . dirname(__FILE__) . '/../../resources/zway_update.sh'; } $cmd .= ' >> ' . log::getPathToLog('zway_update') . ' 2>&1 &'; exec($cmd); }
* * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ try { require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if (init('action') == 'clear') { log::clear(init('logfile')); ajax::success(); } if (init('action') == 'remove') { log::remove(init('logfile')); ajax::success(); } if (init('action') == 'removeAll') { log::removeAll(); ajax::success(); } if (init('action') == 'get') { if (init('jeeNetwork_id') != '') { $jeeNetwork = jeeNetwork::byId(init('jeeNetwork_id')); if (is_object($jeeNetwork)) { $jeeNetwork->getLog(init('log'), init('start', 0), init('nbLine', 99999)); } } else { ajax::success(log::get(init('logfile'), init('start', 0), init('nbLine', 99999))); }
public static function dependancy_install() { log::add('arduidom', 'debug', 'Installation des dependances....'); config::save("ArduinoRequiredVersion", "124", "arduidom"); log::remove('arduidom_update'); chmod(dirname(__FILE__) . '/../../ressources/install.sh', 0775); $cmd = 'sudo ' . dirname(__FILE__) . '/../../ressources/install.sh'; if (substr(jeedom::version(), 0, 1) == 2) { $cmd .= ' >> ' . log::getPathToLog('arduidom_update') . ' 2>&1 &'; // & final retiré pour jeedom v1 } else { $cmd .= ' >> ' . log::getPathToLog('arduidom_update') . ' 2>&1'; // & final retiré pour jeedom v1 } log::add('arduidom', 'debug', 'Installation des dependances : ' . $cmd); exec($cmd); $ressource_path = realpath(dirname(__FILE__) . '/../../ressources'); if (file_exists($ressource_path . "/arduidom.py")) { unlink($ressource_path . "/arduidom.py"); } if (file_exists($ressource_path . "/arduidom1.py")) { unlink($ressource_path . "/arduidom1.py"); } if (file_exists($ressource_path . "/arduidom2.py")) { unlink($ressource_path . "/arduidom2.py"); } if (file_exists($ressource_path . "/arduidom3.py")) { unlink($ressource_path . "/arduidom3.py"); } if (file_exists($ressource_path . "/arduidom4.py")) { unlink($ressource_path . "/arduidom4.py"); } if (file_exists($ressource_path . "/arduidom5.py")) { unlink($ressource_path . "/arduidom5.py"); } if (file_exists($ressource_path . "/arduidom6.py")) { unlink($ressource_path . "/arduidom6.py"); } if (file_exists($ressource_path . "/arduidom7.py")) { unlink($ressource_path . "/arduidom7.py"); } if (file_exists($ressource_path . "/arduidom8.py")) { unlink($ressource_path . "/arduidom8.py"); } if (file_exists($ressource_path . "/arduidom1.pid")) { unlink($ressource_path . "/arduidom1.pid"); } if (file_exists($ressource_path . "/arduidom2.pid")) { unlink($ressource_path . "/arduidom2.pid"); } if (file_exists($ressource_path . "/arduidom3.pid")) { unlink($ressource_path . "/arduidom3.pid"); } if (file_exists($ressource_path . "/arduidom4.pid")) { unlink($ressource_path . "/arduidom4.pid"); } if (file_exists($ressource_path . "/arduidom5.pid")) { unlink($ressource_path . "/arduidom5.pid"); } if (file_exists($ressource_path . "/arduidom6.pid")) { unlink($ressource_path . "/arduidom6.pid"); } if (file_exists($ressource_path . "/arduidom7.pid")) { unlink($ressource_path . "/arduidom7.pid"); } if (file_exists($ressource_path . "/arduidom8.pid")) { unlink($ressource_path . "/arduidom8.pid"); } if (file_exists($ressource_path . "/arduidom.kill")) { unlink($ressource_path . "/arduidom.kill"); } if (file_exists($ressource_path . "/arduidom1.kill")) { unlink($ressource_path . "/arduidom1.kill"); } if (file_exists($ressource_path . "/arduidom2.kill")) { unlink($ressource_path . "/arduidom2.kill"); } if (file_exists($ressource_path . "/arduidom3.kill")) { unlink($ressource_path . "/arduidom3.kill"); } if (file_exists($ressource_path . "/arduidom4.kill")) { unlink($ressource_path . "/arduidom4.kill"); } if (file_exists($ressource_path . "/arduidom5.kill")) { unlink($ressource_path . "/arduidom5.kill"); } if (file_exists($ressource_path . "/arduidom6.kill")) { unlink($ressource_path . "/arduidom6.kill"); } if (file_exists($ressource_path . "/arduidom7.kill")) { unlink($ressource_path . "/arduidom7.kill"); } if (file_exists($ressource_path . "/arduidom8.kill")) { unlink($ressource_path . "/arduidom8.kill"); } }