Browse Source

adding install nodejs

release/0.1
Björn 4 years ago
parent
commit
3e68a6e1d9
1 changed files with 58 additions and 0 deletions
  1. +58
    -0
      app/Commands/NodejsInstallCommand.php

+ 58
- 0
app/Commands/NodejsInstallCommand.php View File

@ -0,0 +1,58 @@
<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use App\Facades\Install;
/**
*
*
*
*/
class NodejsInstallCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'nodejs:install {version}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Install Nodejs';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// getting configuration
$version = $this->argument('version');
exec('useradd -d /home/nodejs -m nodejs');
exec('curl -sL https://deb.nodesource.com/setup_'.$version.'.x | sudo -E bash -');
exec('apt-get install -y nodejs -qq');
exec('sudo -Hu nodejs mkdir /home/nodejs/.npm');
exec('sudo -Hu nodejs npm config set prefix /home/nodejs/.npm');
exec('echo -e "export PATH=/home/nodejs/.npm/bin:\$PATH" >> /home/nodejs/.bashrc');
exec('npm install -g npm && npm install -g pm2');
// check if nginx is ready and installed
if (Install::isReady('nodejs')) {
$this->info("Success!");
} else {
$this->error("Failed! Please check log-file!");
}
}
}

Loading…
Cancel
Save