Add tasks/config/install.rake

This commit is contained in:
0x1eef 2023-03-21 03:03:05 -03:00
parent 12b798a6bc
commit ad48f02b11
4 changed files with 18 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
build/
tmp/
node_modules/
.bundle/
*.log
.env
.idea

View file

@ -1,10 +1,11 @@
# frozen_string_literal: true
require "bundler/setup"
require "ryo"
require "listen"
require_relative "lib/tasks"
load "tasks/config.rake"
load "tasks/config/build.rake"
load "tasks/config/install.rake"
namespace :nanoc do
desc "Compile the website"

View file

@ -5,7 +5,7 @@ require "bundler/setup"
require "erb"
require "ryo"
require "yaml"
require_relative "../tasks.lib/erb_context"
require_relative "../../tasks.lib/erb_context"
read_options = ->(env:) do
path = File.join(Dir.getwd, "config", "#{env}.yml")
@ -34,6 +34,7 @@ build_files = -> (env:, base:, glob:) do
end
end
desc "Build configuration files"
task "config:build", :env do |task, args|
env = args[:env]
case env
@ -46,6 +47,7 @@ task "config:build", :env do |task, args|
Rake::Task["config:build:nginx"].invoke(env)
end
desc "Build /etc configuration files"
task "config:build:etc", :env do |task, args|
env = args[:env]
build_files.call(
@ -55,6 +57,7 @@ task "config:build:etc", :env do |task, args|
)
end
desc "Build nginx configuration files"
task "config:build:nginx", :env do |task, args|
env = args[:env]
build_files.call(

10
tasks/config/install.rake Normal file
View file

@ -0,0 +1,10 @@
desc "Install configuration files"
task "config:install", :env do |tasks, args|
env = args[:env]
if Process.euid != 0
sh "doas -u root bundle exec rake config:install[#{env}]"
exit $?.exitstatus
end
copy_entry File.join(Dir.getwd, "build", env, "usr.local.etc"),
"/usr/local/etc"
end