diff --git a/app/Commands/NodejsInstallCommand.php b/app/Commands/NodejsInstallCommand.php new file mode 100644 index 0000000..2accdf2 --- /dev/null +++ b/app/Commands/NodejsInstallCommand.php @@ -0,0 +1,58 @@ +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!"); + } + } +}