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.

58 lines
1.3 KiB

  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. *
  8. *
  9. *
  10. */
  11. class NodejsInstallCommand extends Command
  12. {
  13. /**
  14. * The signature of the command.
  15. *
  16. * @var string
  17. */
  18. protected $signature = 'nodejs:install {version}';
  19. /**
  20. * The description of the command.
  21. *
  22. * @var string
  23. */
  24. protected $description = 'Install Nodejs';
  25. /**
  26. * Execute the console command.
  27. *
  28. * @return mixed
  29. */
  30. public function handle()
  31. {
  32. // getting configuration
  33. $version = $this->argument('version');
  34. exec('useradd -d /home/nodejs -m nodejs');
  35. exec('curl -sL https://deb.nodesource.com/setup_'.$version.'.x | sudo -E bash -');
  36. exec('apt-get install -y nodejs -qq');
  37. exec('sudo -Hu nodejs mkdir /home/nodejs/.npm');
  38. exec('sudo -Hu nodejs npm config set prefix /home/nodejs/.npm');
  39. exec('echo -e "export PATH=/home/nodejs/.npm/bin:\$PATH" >> /home/nodejs/.bashrc');
  40. exec('npm install -g npm && npm install -g pm2');
  41. // check if nginx is ready and installed
  42. if (Install::isReady('nodejs')) {
  43. $this->info("Success!");
  44. } else {
  45. $this->error("Failed! Please check log-file!");
  46. }
  47. }
  48. }