OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use App\Facades\Install;
  6. /**
  7. * Install Nodejs
  8. *
  9. * @author Björn Hase, Tentakelfabrik
  10. * @license http://opensource.org/licenses/MIT The MIT License
  11. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
  12. *
  13. */
  14. class NodejsInstallCommand extends Command
  15. {
  16. /**
  17. * The signature of the command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'nodejs:install {version}';
  22. /**
  23. * The description of the command.
  24. *
  25. * @var string
  26. */
  27. protected $description = 'Install Nodejs';
  28. /**
  29. * Execute the console command.
  30. *
  31. * @return mixed
  32. */
  33. public function handle()
  34. {
  35. // getting configuration
  36. $version = $this->argument('version');
  37. $this->info('Nodejs installing...');
  38. system('curl -sL https://deb.nodesource.com/setup_'.$version.'.x | sudo -E bash -');
  39. // @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
  40. exec('apt-get install -y nodejs 2>&1', $output);
  41. $this->line(implode("\n", Install::filterAptMessages($output)));
  42. $this->info('Nodejs add user...');
  43. system('useradd -d /home/nodejs -m nodejs');
  44. system('sudo -Hu nodejs mkdir /home/nodejs/.npm');
  45. system('sudo -Hu nodejs npm config set prefix /home/nodejs/.npm');
  46. system('echo -e "export PATH=/home/nodejs/.npm/bin:\$PATH" >> /home/nodejs/.bashrc');
  47. $this->info('Nodejs install npm & pm2...');
  48. system('npm install -g npm && npm install -g pm2');
  49. // check if nginx is ready and installed
  50. if (Install::isReady('nodejs')) {
  51. $this->info('Nginx installing...Success! \o/');
  52. } else {
  53. $this->error('Failed! Please check log-file!');
  54. }
  55. }
  56. }