diff --git a/core/class/luna.class.php b/core/class/luna.class.php index cefa925..1759b95 100644 --- a/core/class/luna.class.php +++ b/core/class/luna.class.php @@ -1093,6 +1093,36 @@ public static function waitLuna($_method, $_params = null) { return $result; } + public static function checkLunaLte() { + $waitFileExist = false; + $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); + if (trim($result) != "exists") { + $maxWaitTime = 180; + $startTime = time(); + $isLte = null; + while (time() - $startTime < $maxWaitTime) { + $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); + if(trim($result) == "exists"){ + log::add('luna', 'debug', 'Wait for jeedomLTE file'); + $waitFileExist = true; + break; + }else{ + usleep(500000); + } + } + } else { + $waitFileExist = true; + } + if($waitFileExist){ + $isLte = shell_exec('sudo cat /boot/jeedomLTE'); + if(trim($isLte) == "2"){ + config::save('isLte', 'NOLTE', 'luna'); + } else { + config::save('isLte', 'LTE', 'luna'); + } + } + } + //Todo a supprimer dans l'avenir // public static function cronHourly() { // // executer LTE si pas de ppp0 dans un ifconfig @@ -1184,6 +1214,14 @@ public static function sendSMS($number, $text) { } /* ----- FIN SMS ----- */ + /* ----- Outils d'aministration ----- */ + public static function reloadConfig() { + shell_exec('sudo rm /boot/jeedomLTE'); + shell_exec('sudo systemctl daemon-reload'); + shell_exec('sudo systemctl enable jeedomLTE.service'); + shell_exec('sudo systemctl start jeedomLTE.service'); + self::checkLunaLte(); + } public static function switchHost($activated = true) { //exec("sudo apt remove -y dnsmasq"); diff --git a/plugin_info/install.php b/plugin_info/install.php index 5f6799a..6b9b4ba 100644 --- a/plugin_info/install.php +++ b/plugin_info/install.php @@ -53,32 +53,7 @@ function luna_install() { luna::switchHost(); luna::installLora(); luna::onBattery(); - $waitFileExist = false; - $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); - if (trim($result) != "exists") { - $maxWaitTime = 180; - $startTime = time(); - $isLte = null; - while (time() - $startTime < $maxWaitTime) { - $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); - if(trim($result) == "exists"){ - $waitFileExist = true; - break; - }else{ - usleep(500000); - } - } - } else { - $waitFileExist = true; - } - if($waitFileExist){ - $isLte = shell_exec('sudo cat /boot/jeedomLTE'); - if(trim($isLte) == "2"){ - config::save('isLte', 'NOLTE', 'luna'); - } else { - config::save('isLte', 'LTE', 'luna'); - } - } + luna::checkLunaLte(); } function luna_update() { @@ -122,31 +97,5 @@ function luna_update() { luna::switchHost(); luna::installLora(); luna::onBattery(); - $waitFileExist = false; - $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); - if (trim($result) != "exists") { - $maxWaitTime = 180; - $startTime = time(); - $isLte = null; - while (time() - $startTime < $maxWaitTime) { - $result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"'); - if(trim($result) == "exists"){ - log::add('luna', 'debug', 'Wait for jeedomLTE file'); - $waitFileExist = true; - break; - }else{ - usleep(500000); - } - } - } else { - $waitFileExist = true; - } - if($waitFileExist){ - $isLte = shell_exec('sudo cat /boot/jeedomLTE'); - if(trim($isLte) == "2"){ - config::save('isLte', 'NOLTE', 'luna'); - } else { - config::save('isLte', 'LTE', 'luna'); - } - } + luna::checkLunaLte(); } \ No newline at end of file