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

<?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!");
}
}
}