aethernal-agent 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.gitlab-ci.yml +23 -0
  4. data/.rspec +2 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +107 -0
  9. data/README.md +35 -0
  10. data/Rakefile +31 -0
  11. data/Vagrantfile +32 -0
  12. data/aethernal-agent.gemspec +45 -0
  13. data/bin/console +14 -0
  14. data/bin/run-aa-for-test +35 -0
  15. data/bin/setup +8 -0
  16. data/exe/aa-web +7 -0
  17. data/lib/aethernal_agent.rb +34 -0
  18. data/lib/aethernal_agent/apache/apache.rb +70 -0
  19. data/lib/aethernal_agent/apache/templates/aa-user.conf.erb +21 -0
  20. data/lib/aethernal_agent/app.rb +317 -0
  21. data/lib/aethernal_agent/apt.rb +30 -0
  22. data/lib/aethernal_agent/errors.rb +17 -0
  23. data/lib/aethernal_agent/filesystem.rb +178 -0
  24. data/lib/aethernal_agent/loader.rb +56 -0
  25. data/lib/aethernal_agent/manifest.rb +6 -0
  26. data/lib/aethernal_agent/operation.rb +51 -0
  27. data/lib/aethernal_agent/operation_pool.rb +46 -0
  28. data/lib/aethernal_agent/plugins/deluge/deluge.rb +65 -0
  29. data/lib/aethernal_agent/plugins/deluge/manifest.yml +51 -0
  30. data/lib/aethernal_agent/plugins/deluge/meta/deluge.png +0 -0
  31. data/lib/aethernal_agent/plugins/deluge/templates/auth.erb +2 -0
  32. data/lib/aethernal_agent/plugins/deluge/templates/core.conf.erb +95 -0
  33. data/lib/aethernal_agent/plugins/deluge/templates/deluge-web.service.erb +12 -0
  34. data/lib/aethernal_agent/plugins/deluge/templates/deluge.apache.conf.erb +9 -0
  35. data/lib/aethernal_agent/plugins/deluge/templates/deluged.service.erb +12 -0
  36. data/lib/aethernal_agent/plugins/deluge/templates/hostlist.conf.erb +14 -0
  37. data/lib/aethernal_agent/plugins/deluge/templates/web.conf.erb +24 -0
  38. data/lib/aethernal_agent/plugins/filebrowser/filebrowser.rb +45 -0
  39. data/lib/aethernal_agent/plugins/filebrowser/files/filebrowser.service +12 -0
  40. data/lib/aethernal_agent/plugins/filebrowser/manifest.yml +51 -0
  41. data/lib/aethernal_agent/plugins/filebrowser/meta/filebrowser.png +0 -0
  42. data/lib/aethernal_agent/plugins/filebrowser/templates/filebrowser.apache.conf.erb +6 -0
  43. data/lib/aethernal_agent/plugins/gitea/files/gitea.service +12 -0
  44. data/lib/aethernal_agent/plugins/gitea/gitea.rb +64 -0
  45. data/lib/aethernal_agent/plugins/gitea/manifest.yml +53 -0
  46. data/lib/aethernal_agent/plugins/gitea/meta/gitea.png +0 -0
  47. data/lib/aethernal_agent/plugins/gitea/templates/app.ini.erb +68 -0
  48. data/lib/aethernal_agent/plugins/gitea/templates/gitea.apache.conf.erb +6 -0
  49. data/lib/aethernal_agent/plugins/olaris/manifest.yml +52 -0
  50. data/lib/aethernal_agent/plugins/olaris/meta/olaris.png +0 -0
  51. data/lib/aethernal_agent/plugins/olaris/olaris.rb +35 -0
  52. data/lib/aethernal_agent/plugins/olaris/templates/olaris.apache.conf.erb +6 -0
  53. data/lib/aethernal_agent/plugins/olaris/templates/olaris.service.erb +12 -0
  54. data/lib/aethernal_agent/plugins/ombi/manifest.yml +57 -0
  55. data/lib/aethernal_agent/plugins/ombi/meta/ombi.jpeg +0 -0
  56. data/lib/aethernal_agent/plugins/ombi/ombi.rb +81 -0
  57. data/lib/aethernal_agent/plugins/ombi/templates/ombi.apache.conf.erb +6 -0
  58. data/lib/aethernal_agent/plugins/ombi/templates/ombi.service.erb +14 -0
  59. data/lib/aethernal_agent/plugins/plex/files/plex.service +26 -0
  60. data/lib/aethernal_agent/plugins/plex/manifest.yml +49 -0
  61. data/lib/aethernal_agent/plugins/plex/meta/plex.png +0 -0
  62. data/lib/aethernal_agent/plugins/plex/plex.rb +65 -0
  63. data/lib/aethernal_agent/plugins/plex/templates/Preferences.xml.erb +2 -0
  64. data/lib/aethernal_agent/plugins/radarr/files/radarr.service +13 -0
  65. data/lib/aethernal_agent/plugins/radarr/manifest.yml +68 -0
  66. data/lib/aethernal_agent/plugins/radarr/meta/radarr.png +0 -0
  67. data/lib/aethernal_agent/plugins/radarr/radarr.rb +72 -0
  68. data/lib/aethernal_agent/plugins/radarr/templates/config.xml.erb +16 -0
  69. data/lib/aethernal_agent/plugins/radarr/templates/radarr.apache.conf.erb +6 -0
  70. data/lib/aethernal_agent/plugins/sonarr/files/sonarr.service +13 -0
  71. data/lib/aethernal_agent/plugins/sonarr/manifest.yml +66 -0
  72. data/lib/aethernal_agent/plugins/sonarr/meta/sonarr.jpeg +0 -0
  73. data/lib/aethernal_agent/plugins/sonarr/sonarr.rb +70 -0
  74. data/lib/aethernal_agent/plugins/sonarr/templates/config.xml.erb +16 -0
  75. data/lib/aethernal_agent/plugins/sonarr/templates/sonarr.apache.conf.erb +6 -0
  76. data/lib/aethernal_agent/plugins/vnc/files/xstartup +9 -0
  77. data/lib/aethernal_agent/plugins/vnc/manifest.yml +41 -0
  78. data/lib/aethernal_agent/plugins/vnc/meta/vnc.png +0 -0
  79. data/lib/aethernal_agent/plugins/vnc/templates/vnc.service.erb +14 -0
  80. data/lib/aethernal_agent/plugins/vnc/vnc.rb +41 -0
  81. data/lib/aethernal_agent/systemd.rb +123 -0
  82. data/lib/aethernal_agent/template.rb +57 -0
  83. data/lib/aethernal_agent/utils.rb +107 -0
  84. data/lib/aethernal_agent/version.rb +3 -0
  85. data/lib/aethernal_agent/webserver/api.rb +77 -0
  86. data/lib/aethernal_agent/webserver/core.rb +32 -0
  87. metadata +257 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8764791bb1e8b5cdcfd0794584eec9c68ceead16cbd38490e98a969c94ab9856
4
+ data.tar.gz: ef5f8a614fe5a596dc0d82547392f55baff4e062b7a6092b817026359e77d086
5
+ SHA512:
6
+ metadata.gz: a165f9b155ad4925f6e23ef7bfa55fa9aae554e5681b2fba7c17d459f6db036d79746ea04edaec351769dbd202810b74371dc9d8d2795182094b19894959f395
7
+ data.tar.gz: 0c2e0b11a8daf00024f91cbbc12e529067f7390564e29b3b99ecb5b032d12c9c98e69915c8d1eda6d95bef68a9e03cd5454792632e69cf5c4576087350363113
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.log
10
+ .vagrant
11
+ *.DS_Store
12
+ rspec_html_reports
@@ -0,0 +1,23 @@
1
+ image: "ruby:2.6"
2
+
3
+ before_script:
4
+ - gem install bundler --no-document
5
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
6
+
7
+ stages:
8
+ - test
9
+ - build
10
+
11
+ test:
12
+ stage: test
13
+ script:
14
+ - bundle exec rake
15
+
16
+ build:
17
+ stage: build
18
+ script:
19
+ - bundle exec rake build
20
+ artifacts:
21
+ paths:
22
+ - pkg/*.gem
23
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1 @@
1
+ aethernal_agent
@@ -0,0 +1 @@
1
+ 2.6.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in aethernal_agent.gemspec
6
+ gemspec
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aethernal-agent (0.1.10)
5
+ activesupport
6
+ httparty
7
+ sinatra (~> 2.0.7)
8
+ sinatra-contrib
9
+ sqlite3
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (6.0.3)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.2, >= 2.2.2)
20
+ backports (3.17.1)
21
+ coderay (1.1.2)
22
+ concurrent-ruby (1.1.6)
23
+ diff-lcs (1.3)
24
+ httparty (0.18.0)
25
+ mime-types (~> 3.0)
26
+ multi_xml (>= 0.5.2)
27
+ i18n (1.8.2)
28
+ concurrent-ruby (~> 1.0)
29
+ method_source (0.9.2)
30
+ mime-types (3.3.1)
31
+ mime-types-data (~> 3.2015)
32
+ mime-types-data (3.2020.0512)
33
+ minitest (5.14.0)
34
+ multi_json (1.14.1)
35
+ multi_xml (0.6.0)
36
+ mustermann (1.1.1)
37
+ ruby2_keywords (~> 0.0.1)
38
+ net-scp (2.0.0)
39
+ net-ssh (>= 2.6.5, < 6.0.0)
40
+ net-ssh (5.2.0)
41
+ net-telnet (0.1.1)
42
+ pry (0.12.2)
43
+ coderay (~> 1.1.0)
44
+ method_source (~> 0.9.0)
45
+ rack (2.2.2)
46
+ rack-protection (2.0.8.1)
47
+ rack
48
+ rake (10.5.0)
49
+ rspec (3.9.0)
50
+ rspec-core (~> 3.9.0)
51
+ rspec-expectations (~> 3.9.0)
52
+ rspec-mocks (~> 3.9.0)
53
+ rspec-core (3.9.0)
54
+ rspec-support (~> 3.9.0)
55
+ rspec-expectations (3.9.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.9.0)
58
+ rspec-its (1.3.0)
59
+ rspec-core (>= 3.0.0)
60
+ rspec-expectations (>= 3.0.0)
61
+ rspec-mocks (3.9.0)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.9.0)
64
+ rspec-support (3.9.0)
65
+ ruby2_keywords (0.0.2)
66
+ serverspec (2.41.5)
67
+ multi_json
68
+ rspec (~> 3.0)
69
+ rspec-its
70
+ specinfra (~> 2.72)
71
+ sfl (2.3)
72
+ sinatra (2.0.8.1)
73
+ mustermann (~> 1.0)
74
+ rack (~> 2.0)
75
+ rack-protection (= 2.0.8.1)
76
+ tilt (~> 2.0)
77
+ sinatra-contrib (2.0.8.1)
78
+ backports (>= 2.8.2)
79
+ multi_json
80
+ mustermann (~> 1.0)
81
+ rack-protection (= 2.0.8.1)
82
+ sinatra (= 2.0.8.1)
83
+ tilt (~> 2.0)
84
+ specinfra (2.82.4)
85
+ net-scp
86
+ net-ssh (>= 2.7)
87
+ net-telnet (= 0.1.1)
88
+ sfl
89
+ sqlite3 (1.4.2)
90
+ thread_safe (0.3.6)
91
+ tilt (2.0.10)
92
+ tzinfo (1.2.7)
93
+ thread_safe (~> 0.1)
94
+ zeitwerk (2.3.0)
95
+
96
+ PLATFORMS
97
+ ruby
98
+
99
+ DEPENDENCIES
100
+ aethernal-agent!
101
+ bundler (>= 2.0)
102
+ pry
103
+ rake (~> 10.5)
104
+ serverspec
105
+
106
+ BUNDLED WITH
107
+ 2.1.4
@@ -0,0 +1,35 @@
1
+ # AethernalAgent
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aethernal_agent`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'aethernal_agent'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install aethernal_agent
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aethernal_agent.
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ task :spec => 'spec:all'
7
+ namespace :spec do
8
+ targets = []
9
+ Dir.glob('./spec/*').each do |dir|
10
+ next unless File.directory?(dir)
11
+ target = File.basename(dir)
12
+ target = "_#{target}" if target == "default"
13
+ targets << target
14
+ end
15
+ task :all => targets
16
+ task :default => :all
17
+ targets.each do |target|
18
+ original_target = target == "_default" ? target[1..-1] : target
19
+ desc "Run serverspec tests to #{original_target}"
20
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
21
+ ENV['TARGET_HOST'] = original_target
22
+ t.pattern = "spec/#{original_target}/*_spec.rb"
23
+ end
24
+ end
25
+ end
26
+
27
+ Rake::TestTask.new do |t|
28
+ t.pattern = "test/minitest/test_*.rb"
29
+ end
30
+
31
+ task :default => :test
@@ -0,0 +1,32 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure(2) do |config|
5
+ config.vm.box = "ubuntu/bionic64"
6
+ config.vm.network "forwarded_port", guest: 22, host: 22
7
+ config.vm.network "forwarded_port", guest: 80, host: 80
8
+ config.vm.network "forwarded_port", guest: 4567, host: 4567
9
+ config.vm.network "private_network", ip: "10.0.0.123"
10
+
11
+ config.vm.provider "virtualbox" do |vb|
12
+ vb.memory = "2048"
13
+ disk_file = File.expand_path("../.vagrant/disks/c-disk1.vdi", __FILE__)
14
+
15
+ if ! File.exist?(disk_file)
16
+ vb.customize ['createhd', '--filename', disk_file, '--size', 1024 * 1024]
17
+ vb.customize ['storageattach', :id, '--storagectl', 'SATA controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk_file]
18
+ end
19
+ end
20
+
21
+ config.vm.provision :shell, privileged: true, inline: <<-SHELL
22
+ snap install ruby --classic
23
+ adduser --add_extra_groups --gecos '' --quiet --disabled-password testuser
24
+ apt update
25
+ apt install -y build-essential libsqlite3-dev
26
+ SHELL
27
+
28
+ config.trigger.after [:up, :reload] do |trigger|
29
+ trigger.info = "Doing bundle install"
30
+ trigger.run_remote = {inline: "cd /vagrant && /snap/bin/bundle install --system", privileged: true}
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "aethernal_agent/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aethernal-agent"
8
+ spec.version = AethernalAgent::VERSION
9
+ spec.authors = ["Maran"]
10
+ spec.email = ["maran@bytesized-hosting.com"]
11
+
12
+ spec.summary = %q{Aethernal Agent for Aethernal.host.}
13
+ spec.description = %q{Install and configure apps on the go.}
14
+ spec.homepage = "https://aethernal.host"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "http://gitlab.com/olaris/aethernal_agent"
21
+ spec.metadata["changelog_uri"] = "http://gitlab.com/olaris/aethernal_agent"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", ">= 2.0"
37
+ spec.add_development_dependency "rake", "~> 10.5"
38
+ spec.add_development_dependency "serverspec"
39
+ spec.add_development_dependency "pry"
40
+ spec.add_dependency "activesupport" # We leave this loose to not interfere with Rails projects
41
+ spec.add_dependency "sinatra", "~> 2.0.7"
42
+ spec.add_dependency "sinatra-contrib"
43
+ spec.add_dependency "sqlite3"
44
+ spec.add_dependency "httparty"
45
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "aethernal_agent"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # run-aethernal_agent-plugin plugin_name user options_in_json
4
+ require "bundler/setup"
5
+ require 'active_support/core_ext/hash/indifferent_access'
6
+
7
+ $:.unshift( File.expand_path("../../lib", __FILE__) )
8
+ require 'aethernal_agent'
9
+ include AethernalAgent::Utils
10
+
11
+ prepare_test_config
12
+ AethernalAgent::Loader.new
13
+
14
+ app = ARGV[0]
15
+ method = ARGV[1]
16
+ user = ARGV[2]
17
+ begin
18
+ options = JSON.parse(ARGV[3])
19
+ rescue Exception
20
+ puts "WARNING: Could not parse options from the command line, ignoring custom options"
21
+ options = {}
22
+ end
23
+
24
+ unless app && method && user && options
25
+ puts "Please supply at least three arguments: app, method, user and optionally options as json string" and return
26
+ return
27
+ end
28
+ options.reverse_merge!(user: user)
29
+ plugin = "AethernalAgent::#{app.titlecase}".constantize.new(options)
30
+
31
+ puts "Running BOSS #{AethernalAgent::VERSION} - AethernalAgent::#{app.titlecase}.#{method}(#{options})"
32
+ result = plugin.send(method, options)
33
+ puts "result: #{result}"
34
+ puts "Sleeping 10 seconds..."
35
+ sleep 10
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'aethernal_agent/webserver/core'
4
+ require 'active_support/core_ext/hash/indifferent_access'
5
+
6
+ core = AethernalAgent::Webserver::Core.new
7
+ core.start
@@ -0,0 +1,34 @@
1
+ require 'yaml'
2
+ require 'sqlite3'
3
+ require 'active_support/core_ext/hash/indifferent_access'
4
+ require 'active_support/core_ext/string'
5
+ require 'ostruct'
6
+ require 'etc'
7
+ require 'fileutils'
8
+ require 'socket'
9
+ require 'logger'
10
+
11
+ require 'aethernal_agent/app'
12
+ require 'aethernal_agent/loader'
13
+ require 'aethernal_agent/template'
14
+ require 'aethernal_agent/operation'
15
+ require 'aethernal_agent/operation_pool'
16
+ require 'aethernal_agent/version'
17
+
18
+ module AethernalAgent
19
+
20
+ class << self
21
+ attr_writer :logger
22
+
23
+ def logger
24
+ @logger ||= Logger.new($stdout)
25
+ end
26
+
27
+ def change_log_level(level = Logger::INFO)
28
+ AethernalAgent.logger.level = level
29
+ end
30
+ end
31
+
32
+
33
+ class Error < StandardError; end
34
+ end
@@ -0,0 +1,70 @@
1
+ require 'aethernal_agent/filesystem'
2
+ require 'aethernal_agent/utils'
3
+
4
+ module AethernalAgent
5
+ class Apache
6
+ include AethernalAgent::Filesystem
7
+ include AethernalAgent::Utils
8
+ include AethernalAgent::Errors
9
+
10
+ attr_accessor :user
11
+
12
+ def initialize(options = {})
13
+ self.user = options['user'] || 'root'
14
+ end
15
+
16
+ def ensure_mods
17
+ run_command("a2enmod proxy scgi headers proxy proxy_html proxy_http ssl xml2enc proxy_wstunnel")
18
+ self.restart
19
+ end
20
+
21
+ def write_app_config(template_path, app_name, port)
22
+ directory(apache_user_conf_path)
23
+ write_template(template_path, apache_user_conf_path(app_name), {port: port})
24
+
25
+ reload
26
+ end
27
+
28
+ def remove_app_config(app_name)
29
+ file(apache_user_conf_path(app_name), action: :delete)
30
+ end
31
+
32
+ def ensure_base_config(options = {})
33
+ config_file = File.join(File.expand_path(File.dirname(__FILE__)), "templates","aa-user.conf.erb")
34
+
35
+ container_name = get_global_config(:container_name)
36
+ host_name = get_global_config(:hostname)
37
+
38
+ add_errors("hostname not found in global config") unless host_name
39
+ add_errors("container_name not found in global config") unless container_name
40
+
41
+ write_template(config_file, "/etc/apache2/sites-available/aethernal_agent-#{self.user}.conf",{
42
+ home_folder: home_folder_path,
43
+ user: self.user,
44
+ container_name: container_name,
45
+ host_name: host_name,
46
+ custom_domains: options[:custom_domains]
47
+ })
48
+
49
+ directory(home_folder_path("www"), owner: self.user)
50
+
51
+ run_command("a2ensite aethernal_agent-#{self.user}")
52
+
53
+ return nil
54
+ end
55
+
56
+ def reload
57
+ run_command("systemctl reload apache2")
58
+ end
59
+
60
+ def restart
61
+ run_command("systemctl restart apache2")
62
+ end
63
+
64
+ def apache_user_conf_path(app_name = nil)
65
+ path = File.join("/etc/apache2/users", self.user)
66
+ path = File.join(path, "#{app_name}.conf") if app_name
67
+ path
68
+ end
69
+ end
70
+ end