Merge branch 'main' of ssh://gurgul.pro/artur/environment

This commit is contained in:
Artur Gurgul 2025-08-04 19:43:37 +02:00
commit 8d6eb57fe0
3 changed files with 62 additions and 10 deletions

View file

@ -22,4 +22,6 @@ function cdd {
. $DAT_ROOT/bin/zshrc/prompt
. $DAT_ROOT/bin/zshrc/utils
bindkey '^e' edit-command-line
bindkey '^e' edit-command-line
export PATH="$HOME/.local/bin:$PATH"

View file

@ -28,7 +28,7 @@ module Make
class Context
attr_accessor :name, :use_cache, :environment, :steps, :packages, :repository
attr_accessor :target
attr_accessor :target, :archive, :source_type
def initialize(options: OpenStruct.new)
@target = options.target || :user
@ -52,7 +52,21 @@ module Make
# puts makefile
@packages = makefile["packages"] || []
project_sources = {
repository: makefile["repository"] != nil,
archive: makefile["archive"] != nil
}.select { |_, v| v }
if project_sources.size == 1
@source_type = project_sources.keys.first
else
raise "Exactly one type of source: 'repository' or 'archive'"
end
puts @source_type
@repository = Make.rostruct(makefile["repository"] || OpenStruct.new)
@archive = Make.rostruct(makefile["archive"] || OpenStruct.new)
@steps = makefile["steps"] || []
@environment = ENV.to_h.merge(
@ -147,7 +161,14 @@ module Make
install
@context.rpd do | path |
@cwd = path
checkout
case @context.source_type
when :repository
checkout
when :archive
download_and_extract
end
puts "path: #{path}"
Dir.chdir(path)
@ -160,6 +181,13 @@ module Make
end
end
end
def download_and_extract
archive = @context.archive
puts archive
exit -1
end
def checkout
repo_path = @context.local_repo
@ -195,4 +223,4 @@ module Make
builder = Builder.new(context)
builder.build
end
end
end

View file

@ -3,27 +3,47 @@ require 'erb'
class NGINXProxy
class << self
attr_accessor :domain, :port, :service
attr_accessor :domain, :port, :service, :user
def domain(value = nil)
@domain = value unless value.nil?
@domain
end
def user(value = nil)
@user = value unless value.nil?
@user
end
def port(value = nil)
@port = value unless value.nil?
@port
end
# This is name of the daemon that will be installed
# This is also master name user as user if not provided
def service(value = nil)
@service = value unless value.nil?
@service
end
def generate
template = File.read("proxy.erb")
template = ERB.new(template)
template.result(binding)
template = File.read("proxy.erb")
template = ERB.new(template)
template.result(binding)
end
def available_path
"/etc/nginx/sites-available/#{service}.#{domain}"
end
def enabled_path
"/etc/nginx/sites-available/#{service}.#{domain}"
end
def install
config = generate
File.write
end
end
end
@ -31,7 +51,9 @@ end
class ExampleProxy < NGINXProxy
domain "gurgul.org"
service "forgejo"
user "git"
port 3000
end
puts ExampleProxy.generate
puts ExampleProxy.generate
puts ExampleProxy.path