aethernal-agent 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e121aa44ebced63bde59f1a7b9522dace4bc8d3c72f203900ae8cb22fb12f3c
4
- data.tar.gz: 77e7e31e5d372af0518583bb747a9f0e61e8125bb766935d44ffecb238613fcf
3
+ metadata.gz: 0f64b513fb0eb9a86d74289efec2c7e9434f289abbfcf64f1431c011c09b7bc3
4
+ data.tar.gz: 36c7972cc224a9afedd8c3e44fb3aa2f2fb7ad96d7c1572c1a57293dc67f9991
5
5
  SHA512:
6
- metadata.gz: 6c38eeecfa82b00825727db492412f2f53c737b8ab69178eab9d34d4c159c1ca682ccc2850d831e993e1f17c309d91a6320bf3ce1e6aeabba3d091ca72e50392
7
- data.tar.gz: e5e80f5b7dd3dbeff09be5731018e94c1b367f21fa3a815a1021603f25cd38e0791fa10cce74501f70cb81ec2bcf7fee7d0743b977b86f79241acdf5be115c91
6
+ metadata.gz: 268aeb60c33f57f8eab3b9fafff11ac281963aa2b02a9ac9681c5f334f4fc768a615d0be2622fc388f80152c1b382fc2d109eff5f262c40ad244e8effb154ff2
7
+ data.tar.gz: 1d99191e44b70103627c91979840e4784b680e4176ef6d75d5c42bb31a10f1f9e7195e77fda3502bdb5ebfa1fe26baa76046d182307795dcbdea589f79d21ae4
@@ -1,18 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aethernal-agent (0.3.6)
4
+ aethernal-agent (0.4.0)
5
5
  activesupport
6
6
  bcrypt
7
7
  docker-api (~> 1.34.2)
8
8
  sinatra (~> 2.0.7)
9
9
  sinatra-contrib
10
10
  sqlite3
11
+ terminal-table
12
+ thor
11
13
 
12
14
  GEM
13
15
  remote: https://rubygems.org/
14
16
  specs:
15
- activesupport (6.0.3.3)
17
+ activesupport (6.0.3.4)
16
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
19
  i18n (>= 0.7, < 2)
18
20
  minitest (~> 5.1)
@@ -26,7 +28,7 @@ GEM
26
28
  docker-api (1.34.2)
27
29
  excon (>= 0.47.0)
28
30
  multi_json
29
- excon (0.76.0)
31
+ excon (0.78.0)
30
32
  i18n (1.8.5)
31
33
  concurrent-ruby (~> 1.0)
32
34
  method_source (1.0.0)
@@ -86,11 +88,15 @@ GEM
86
88
  net-telnet (= 0.1.1)
87
89
  sfl
88
90
  sqlite3 (1.4.2)
91
+ terminal-table (2.0.0)
92
+ unicode-display_width (~> 1.1, >= 1.1.1)
93
+ thor (1.0.1)
89
94
  thread_safe (0.3.6)
90
95
  tilt (2.0.10)
91
- tzinfo (1.2.7)
96
+ tzinfo (1.2.8)
92
97
  thread_safe (~> 0.1)
93
- zeitwerk (2.4.0)
98
+ unicode-display_width (1.7.0)
99
+ zeitwerk (2.4.2)
94
100
 
95
101
  PLATFORMS
96
102
  ruby
@@ -43,4 +43,6 @@ Gem::Specification.new do |spec|
43
43
  spec.add_dependency "sqlite3"
44
44
  spec.add_dependency "bcrypt"
45
45
  spec.add_dependency "docker-api", "~> 1.34.2"
46
+ spec.add_dependency "thor"
47
+ spec.add_dependency "terminal-table"
46
48
  end
@@ -42,14 +42,15 @@ aethernal_exists(){
42
42
  [ -e "" ]
43
43
  }
44
44
  start_aa(){
45
- run service aethernal-agent enable
46
- run service aethernal-agent start
45
+ run systemctl enable aethernal-agent
46
+ run systemctl start aethernal-agent
47
47
  }
48
48
  stop_aa(){
49
- run service aethernal-agent stop
49
+ run systemctl stop aethernal-agent
50
50
  }
51
51
  restart_aa(){
52
- run service aethernal-agent restart
52
+ stop_aa
53
+ start_aa
53
54
  }
54
55
  update_services(){
55
56
  if ! curl -o /lib/systemd/system/aethernal-agent.service https://storage.googleapis.com/bysh-chef-files/aethernal-agent.service;then
@@ -68,7 +69,6 @@ install_deps(){
68
69
  install_gem(){
69
70
  info "Downloading latest Aethernal Agent gem release"
70
71
  run gem install --no-doc aethernal-agent
71
- restart_aa
72
72
  }
73
73
 
74
74
  install_ci(){
@@ -80,7 +80,6 @@ install_ci(){
80
80
 
81
81
  run unzip -o /tmp/aa.zip -d /tmp/
82
82
  run gem install --no-document /tmp/pkg/aethernal-agent*.gem
83
- restart_aa
84
83
  }
85
84
 
86
85
  main() {
@@ -108,13 +107,15 @@ main() {
108
107
  add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
109
108
  run apt-get install -y docker-ce
110
109
  fi
111
- update_services
112
110
 
113
111
  if [[ "$1" = "from-ci" ]];then
114
112
  install_ci
115
113
  else
116
114
  install_gem
117
115
  fi
116
+
117
+ update_services
118
+ restart_aa
118
119
  }
119
120
 
120
121
  main $@
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "aethernal_agent"
6
+
7
+ AethernalAgent::Cli::Core.start
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'thor'
2
3
  require 'docker-api'
3
4
  require 'sqlite3'
4
5
  require 'active_support/core_ext/hash/indifferent_access'
@@ -10,6 +11,7 @@ require 'socket'
10
11
  require 'logger'
11
12
  require 'bcrypt'
12
13
  require 'net/http'
14
+ require 'terminal-table'
13
15
 
14
16
  require 'aethernal_agent/app'
15
17
  require 'aethernal_agent/loader'
@@ -21,6 +23,7 @@ require 'aethernal_agent/template'
21
23
  require 'aethernal_agent/operation'
22
24
  require 'aethernal_agent/operation_pool'
23
25
  require 'aethernal_agent/version'
26
+ require 'aethernal_agent/cli/core'
24
27
 
25
28
  module AethernalAgent
26
29
 
@@ -91,6 +91,7 @@ module AethernalAgent
91
91
  run_command("git clone #{self.manifest['package']['git']['url']} #{File.join(app_path)}")
92
92
  when 'docker'
93
93
  options = self.manifest.package['docker']
94
+ AethernalAgent.logger.info("Pulling Docker image #{options['image']}")
94
95
  run_command("docker pull #{options['image']}")
95
96
  end
96
97
  end
@@ -150,15 +151,9 @@ module AethernalAgent
150
151
  yield opts if block_given?
151
152
  AethernalAgent.logger.debug("Done running custom plugin code.")
152
153
 
153
- # This is probably not the best way to check if we need a docker image
154
154
  if self.is_docker_install?
155
+ # We expect the image to be installed here by the install method
155
156
  image = self.manifest.package['docker']['image']
156
- AethernalAgent.logger.debug("Docker image information found")
157
-
158
- # Pull the image
159
- AethernalAgent.logger.debug("Pulling image #{image}")
160
- ::Docker::Image.create('fromImage' => image)
161
-
162
157
  begin
163
158
  container = self.container_settings.create_container(self.docker_container_name, image)
164
159
  AethernalAgent.logger.debug("Starting: #{container.start}")
@@ -0,0 +1,11 @@
1
+ require 'aethernal_agent/cli/services'
2
+
3
+ module AethernalAgent
4
+ module Cli
5
+
6
+ class Core < Thor
7
+ desc "services [SUBCOMMAND]", "Get Application status"
8
+ subcommand "services", AethernalAgent::Cli::Services
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ require 'pathname'
2
+
3
+ module AethernalAgent
4
+ module Cli
5
+ class Services < Thor
6
+ attr_accessor :user
7
+ include AethernalAgent::Utils
8
+
9
+ desc "start APP", "start the supplied application via systemd"
10
+ def start(app)
11
+ run_systemd_plain("start", app)
12
+ end
13
+
14
+ desc "stop APP", "stop the supplied application via systemd"
15
+ def stop(app)
16
+ run_systemd_plain("stop", app)
17
+ end
18
+
19
+ desc "restart APP", "restart the supplied application via systemd"
20
+ def restart(app)
21
+ run_systemd_plain("restart", app)
22
+ end
23
+
24
+ desc "status APP", "get the status of the supplied application via systemd"
25
+ def status(app)
26
+ result = run_systemd_plain("status", app)
27
+ puts result
28
+ end
29
+
30
+ desc "start-all", "Start all systemd managed applications"
31
+ def start_all
32
+ puts "Starting all known services"
33
+ service_files = `ls ~/.config/systemd/user/*.service`.split("\n")
34
+ result = service_files.collect do |s|
35
+ pn = Pathname.new(s)
36
+ app_name = pn.basename
37
+ puts "Starting #{app_name}"
38
+ run_systemd_plain("start", app_name)
39
+ end
40
+ end
41
+
42
+ desc "list", "Lists all available user services and their status."
43
+ def list
44
+ service_files = `ls ~/.config/systemd/user/*.service`.split("\n")
45
+ result = service_files.collect do |s|
46
+ pn = Pathname.new(s)
47
+ app_name = pn.basename
48
+ status = systemd_text_for_service(app_name).split("\n")[2].strip
49
+ [app_name, status]
50
+ end
51
+ table = Terminal::Table.new :headings => ['Service', 'Status'], :rows => result
52
+ puts table
53
+ end
54
+ end
55
+ end
56
+ end
@@ -8,6 +8,8 @@ class AethernalAgent::PlexDocker < AethernalAgent::App
8
8
  end
9
9
 
10
10
  def configure_app_user(options = {})
11
+ install_packages(options)
12
+
11
13
  super do |opts|
12
14
  self.container_settings.env << "ADVERTISE_IP=http://#{self.container_domain}:#{opts[:host_port]}"
13
15
 
@@ -3,12 +3,8 @@ class AethernalAgent::Portainer < AethernalAgent::App
3
3
  super(options)
4
4
  end
5
5
 
6
- def install_packages(options = {})
7
- super(options)
8
-
9
- end
10
-
11
6
  def configure_app_user(options = {})
7
+ install_packages(options)
12
8
  res = super(options) do |opts|
13
9
  @opts = opts
14
10
  end
@@ -39,13 +35,4 @@ class AethernalAgent::Portainer < AethernalAgent::App
39
35
 
40
36
  return create_return_args(@opts)
41
37
  end
42
-
43
- def uninstall_packages(options = {})
44
- super(options)
45
- end
46
-
47
- def remove_app_user(options = {})
48
- uninstall_packages(options)
49
- super(options)
50
- end
51
38
  end
@@ -51,6 +51,10 @@ actions:
51
51
  estimated_size_mb: 23
52
52
  package:
53
53
  folder_name: Radarr
54
+ apt:
55
+ "1804":
56
+ packages:
57
+ - mediainfo
54
58
  direct_download:
55
59
  url: https://radarr.servarr.com/v1/update/nightly/updatefile?os=linux&runtime=netcore&arch=x64
56
60
  target_name: Radarr.nightly.linux.tar.gz
@@ -8,6 +8,7 @@ class AethernalAgent::ResilioDocker < AethernalAgent::App
8
8
  end
9
9
 
10
10
  def configure_app_user(options = {})
11
+ install_packages(options)
11
12
  super(options) do |opts|
12
13
  write_template(template_path('resilio_docker.conf.erb'),
13
14
  File.join(opts[:data_volume], ('sync.conf')),
@@ -8,6 +8,8 @@ class AethernalAgent::Rutorrent < AethernalAgent::App
8
8
  end
9
9
 
10
10
  def configure_app_user(options = {})
11
+ install_packages(options)
12
+
11
13
  super do |opts|
12
14
 
13
15
  # Setup rc for custom port
@@ -64,3 +64,4 @@ package:
64
64
  key_id: "3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
65
65
  packages:
66
66
  - mono-devel
67
+ - mediainfo
@@ -166,5 +166,21 @@ module AethernalAgent
166
166
  def container_domain
167
167
  "#{get_global_config(:container_name)}.#{get_global_config(:hostname)}"
168
168
  end
169
+
170
+ def current_xdg_runtime_dir
171
+ "export XDG_RUNTIME_DIR=/run/user/#{get_current_uid}"
172
+ end
173
+
174
+ def get_current_uid
175
+ `id`.split("(")[0].split("=")[1]
176
+ end
177
+
178
+ def systemd_text_for_service(service_name)
179
+ run_systemd_plain("status", service_name)
180
+ end
181
+
182
+ def run_systemd_plain(action, service_name)
183
+ `#{current_xdg_runtime_dir} && systemctl --user #{action} #{service_name}`
184
+ end
169
185
  end
170
186
  end
@@ -1,3 +1,3 @@
1
1
  module AethernalAgent
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aethernal-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-10 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,10 +150,39 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.34.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: thor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: terminal-table
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description: Install and configure apps on the go.
154
182
  email:
155
183
  - maran@bytesized-hosting.com
156
184
  executables:
185
+ - aa-cli
157
186
  - aa-web
158
187
  extensions: []
159
188
  extra_rdoc_files: []
@@ -174,6 +203,7 @@ files:
174
203
  - bin/install-aa
175
204
  - bin/run-aa-for-test
176
205
  - bin/setup
206
+ - exe/aa-cli
177
207
  - exe/aa-web
178
208
  - lib/aethernal_agent.rb
179
209
  - lib/aethernal_agent/apache/apache.rb
@@ -181,6 +211,8 @@ files:
181
211
  - lib/aethernal_agent/apache/templates/aa-user.conf.erb
182
212
  - lib/aethernal_agent/app.rb
183
213
  - lib/aethernal_agent/apt.rb
214
+ - lib/aethernal_agent/cli/core.rb
215
+ - lib/aethernal_agent/cli/services.rb
184
216
  - lib/aethernal_agent/docker/container_settings.rb
185
217
  - lib/aethernal_agent/docker/env.rb
186
218
  - lib/aethernal_agent/docker/port_binding.rb
@@ -285,12 +317,12 @@ files:
285
317
  - lib/aethernal_agent/plugins/radarr/radarr.rb
286
318
  - lib/aethernal_agent/plugins/radarr/templates/config.xml.erb
287
319
  - lib/aethernal_agent/plugins/radarr/templates/radarr.apache.conf.erb
288
- - lib/aethernal_agent/plugins/resilio_docker/files/resilio_docker.service.erb
289
320
  - lib/aethernal_agent/plugins/resilio_docker/manifest.yml
290
321
  - lib/aethernal_agent/plugins/resilio_docker/meta/resilio.png
291
322
  - lib/aethernal_agent/plugins/resilio_docker/resilio_docker.rb
292
323
  - lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.apache.conf.erb
293
324
  - lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.conf.erb
325
+ - lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.service.erb
294
326
  - lib/aethernal_agent/plugins/rutorrent/manifest.yml
295
327
  - lib/aethernal_agent/plugins/rutorrent/meta/rtorrent.png
296
328
  - lib/aethernal_agent/plugins/rutorrent/rutorrent.rb