control_install.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. if(!DEFINED('EGP'))
  3. exit(header('Refresh: 0; URL=http://'.$_SERVER['SERVER_NAME'].'/404'));
  4. class control_install extends cron
  5. {
  6. function __construct()
  7. {
  8. global $cfg, $sql, $argv;
  9. $sql->query('SELECT `id`, `address`, `passwd` FROM `control` WHERE `status`="install" AND `install`="0" LIMIT 1');
  10. if(!$sql->num())
  11. exit('not found');
  12. $unit = $sql->get();
  13. include(LIB.'ssh.php');
  14. // Проверка ssh соедниения пу с локацией
  15. if(!$ssh->auth($unit['passwd'], $unit['address']))
  16. exit('error connect');
  17. $ssh->set('apt-get update; apt-get install -y wget screen');
  18. sleep(20);
  19. $ssh->set('screen -dmS install bash -c "cd /tmp; rm script.sh; wget -O script.sh [home]autocontrol/action/script --no-check-certificate; chmod 500 script.sh;./script.sh"');
  20. $sql->query('UPDATE `control` set install="1" WHERE `id`="'.$unit['id'].'" LIMIT 1');
  21. exit('install');
  22. }
  23. }
  24. ?>