Commit 97c411e

mo khan <mo@mokhan.ca>
2021-07-11 01:02:12
chore: generate key pair for development tls
1 parent 2217bcf
Changed files (3)
bin/server
@@ -1,3 +1,7 @@
 #!/bin/sh
 
+set -e
+
+cd "$(dirname "$0")/.."
+
 bundle exec rails server
bin/setup
@@ -1,36 +1,22 @@
-#!/usr/bin/env ruby
-require "fileutils"
+#!/bin/sh
 
-# path to your application root.
-APP_ROOT = File.expand_path('..', __dir__)
+set -e
 
-def system!(*args)
-  system(*args) || abort("\n== Command #{args} failed ==")
-end
+cd "$(dirname "$0")/.."
 
-FileUtils.chdir APP_ROOT do
-  # This script is a way to set up or update your development environment automatically.
-  # This script is idempotent, so that you can run it at any time and get an expectable outcome.
-  # Add necessary setup steps to this file.
+gem install bundler --conservative
+bundle install
+bin/yarn
 
-  puts '== Installing dependencies =='
-  system! 'gem install bundler --conservative'
-  system('bundle check') || system!('bundle install')
+bin/rails db:prepare
+bin/rails log:clear tmp:clear
+bin/rails restart
 
-  # Install JavaScript dependencies
-  system! 'bin/yarn'
-
-  # puts "\n== Copying sample files =="
-  # unless File.exist?('config/database.yml')
-  #   FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
-  # end
-
-  puts "\n== Preparing database =="
-  system! 'bin/rails db:prepare'
-
-  puts "\n== Removing old logs and tempfiles =="
-  system! 'bin/rails log:clear tmp:clear'
-
-  puts "\n== Restarting application server =="
-  system! 'bin/rails restart'
-end
+if [ ! -f config/key.pem ] && [ ! -f config/certificiate.pem ]; then
+  openssl req -x509 -newkey rsa:4096\
+    -days 999 \
+    -nodes \
+    -subj "/C=/ST=/L=/O=/OU=/CN=*.test" \
+    -keyout config/key.pem \
+    -out config/certificate.pem
+fi
bin/test
@@ -1,3 +1,7 @@
 #!/bin/sh
 
+set -e
+
+cd "$(dirname "$0")/.."
+
 bundle exec rails test "$@"