Skip to content

Instantly share code, notes, and snippets.

@adamgoucher
Created January 13, 2017 02:56
Show Gist options
  • Save adamgoucher/2db848f0147b836dfeeb3af039cdd118 to your computer and use it in GitHub Desktop.
Save adamgoucher/2db848f0147b836dfeeb3af039cdd118 to your computer and use it in GitHub Desktop.
We are seeding Laravel Passport personal access tokens for intra-service communication. But, Laravel expects you to login to the box and run an artisan command. Of course, in today's infrastructure-as-code and thou-shalt-not-login-to-a-box approaches to servers creates a bit of a headache. Never fear! A quick artisan command wrapped in a shell s…
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use \Laravel\Passport\Client;
class CheckForPassportClient extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mxco:check';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Checks for presence of "Foo Personal Access Client"';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$client = Client::where('name', 'Foo Personal Access Client')->first();
return count($client);;
}
}
%w(tether).each { |service|
$client = <<SCRIPT
cd /var/www/#{service}
php artisan mxco:check
if [ $? = 0 ]
then
php artisan passport:install
fi
SCRIPT
config.vm.provision "shell",
inline: $client
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment