|
|
- <?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');
-
- $this->info('Nodejs installing...');
-
- exec('curl -sL https://deb.nodesource.com/setup_'.$version.'.x | sudo -E bash -');
- exec('apt-get install -y nodejs 2>&1');
-
- // @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
- $this->line(implode("\n", Install::filterAptMessages($output)));
-
- $this->info('Nodejs add user...');
- exec('useradd -d /home/nodejs -m nodejs', $output);
-
- 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');
-
- $this->info('Nodejs install npm & pm2...');
- exec('npm install -g npm && npm install -g pm2');
-
- // check if nginx is ready and installed
- if (Install::isReady('nodejs')) {
- $this->info('Nginx installing...Success! \o/');
- } else {
- $this->error('Failed! Please check log-file!');
- }
- }
- }
|