aethernal-agent 0.2.0 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +674 -0
  3. data/Gemfile.lock +38 -33
  4. data/README.md +3 -32
  5. data/Vagrantfile +10 -2
  6. data/aethernal-agent.gemspec +4 -1
  7. data/bin/install-aa +121 -0
  8. data/bin/run-aa-for-test +1 -1
  9. data/exe/aa-cli +7 -0
  10. data/lib/aethernal_agent.rb +10 -0
  11. data/lib/aethernal_agent/apache/apache.rb +8 -5
  12. data/lib/aethernal_agent/apache/templates/aa-default.conf +2 -0
  13. data/lib/aethernal_agent/apache/templates/aa-user.conf.erb +2 -0
  14. data/lib/aethernal_agent/app.rb +82 -22
  15. data/lib/aethernal_agent/apt.rb +17 -6
  16. data/lib/aethernal_agent/cli/core.rb +11 -0
  17. data/lib/aethernal_agent/cli/services.rb +56 -0
  18. data/lib/aethernal_agent/docker/container_settings.rb +33 -0
  19. data/lib/aethernal_agent/docker/env.rb +33 -0
  20. data/lib/aethernal_agent/docker/port_binding.rb +32 -0
  21. data/lib/aethernal_agent/docker/volume.rb +28 -0
  22. data/lib/aethernal_agent/filesystem.rb +2 -1
  23. data/lib/aethernal_agent/loader.rb +3 -3
  24. data/lib/aethernal_agent/operation.rb +1 -1
  25. data/lib/aethernal_agent/plugins/bazarr/bazarr.rb +57 -0
  26. data/lib/aethernal_agent/plugins/bazarr/files/bazarr.service +16 -0
  27. data/lib/aethernal_agent/plugins/bazarr/manifest.yml +64 -0
  28. data/lib/aethernal_agent/plugins/bazarr/meta/bazarr.png +0 -0
  29. data/lib/aethernal_agent/plugins/bazarr/templates/bazarr.apache.conf.erb +5 -0
  30. data/lib/aethernal_agent/plugins/bazarr/templates/config.ini.erb +135 -0
  31. data/lib/aethernal_agent/plugins/cardigann/cardigann.rb +45 -0
  32. data/lib/aethernal_agent/plugins/cardigann/files/cardigann.service +13 -0
  33. data/lib/aethernal_agent/plugins/cardigann/manifest.yml +36 -0
  34. data/lib/aethernal_agent/plugins/cardigann/meta/cardigann.png +0 -0
  35. data/lib/aethernal_agent/plugins/cardigann/templates/cardigann.apache.conf.erb +6 -0
  36. data/lib/aethernal_agent/plugins/cardigann/templates/config.json.erb +7 -0
  37. data/lib/aethernal_agent/plugins/couchpotato/couchpotato.rb +45 -0
  38. data/lib/aethernal_agent/plugins/couchpotato/files/couchpotato.service +13 -0
  39. data/lib/aethernal_agent/plugins/couchpotato/manifest.yml +37 -0
  40. data/lib/aethernal_agent/plugins/couchpotato/meta/couchpotato.png +0 -0
  41. data/lib/aethernal_agent/plugins/couchpotato/templates/couchpotato.apache.conf.erb +4 -0
  42. data/lib/aethernal_agent/plugins/couchpotato/templates/settings.conf.erb +585 -0
  43. data/lib/aethernal_agent/plugins/deluge/deluge.rb +5 -0
  44. data/lib/aethernal_agent/plugins/deluge/manifest.yml +2 -2
  45. data/lib/aethernal_agent/plugins/deluge/templates/core.conf.erb +1 -1
  46. data/lib/aethernal_agent/plugins/deluge/templates/deluge-web.service.erb +1 -1
  47. data/lib/aethernal_agent/plugins/deluge/templates/deluge.apache.conf.erb +0 -1
  48. data/lib/aethernal_agent/plugins/deluge/templates/deluged.service.erb +1 -1
  49. data/lib/aethernal_agent/plugins/deluge/templates/ltconfig.conf.erb +21 -0
  50. data/lib/aethernal_agent/plugins/filebrowser/manifest.yml +1 -1
  51. data/lib/aethernal_agent/plugins/gitea/manifest.yml +1 -1
  52. data/lib/aethernal_agent/plugins/jackett/files/jackett.service +15 -0
  53. data/lib/aethernal_agent/plugins/jackett/jackett.rb +49 -0
  54. data/lib/aethernal_agent/plugins/jackett/manifest.yml +54 -0
  55. data/lib/aethernal_agent/plugins/jackett/meta/jackett.png +0 -0
  56. data/lib/aethernal_agent/plugins/jackett/templates/ServerConfig.json.erb +8 -0
  57. data/lib/aethernal_agent/plugins/jackett/templates/jackett.apache.conf.erb +5 -0
  58. data/lib/aethernal_agent/plugins/jdownloader/files/jdownloader.service +13 -0
  59. data/lib/aethernal_agent/plugins/jdownloader/jdownloader.rb +38 -0
  60. data/lib/aethernal_agent/plugins/jdownloader/manifest.yml +53 -0
  61. data/lib/aethernal_agent/plugins/jdownloader/meta/jdownloader.png +0 -0
  62. data/lib/aethernal_agent/plugins/jdownloader/templates/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.erb +5 -0
  63. data/lib/aethernal_agent/plugins/medusa/files/medusa.service +13 -0
  64. data/lib/aethernal_agent/plugins/medusa/manifest.yml +54 -0
  65. data/lib/aethernal_agent/plugins/medusa/medusa.rb +47 -0
  66. data/lib/aethernal_agent/plugins/medusa/meta/medusa.png +0 -0
  67. data/lib/aethernal_agent/plugins/medusa/templates/config.ini.erb +1308 -0
  68. data/lib/aethernal_agent/plugins/medusa/templates/medusa.apache.conf.erb +12 -0
  69. data/lib/aethernal_agent/plugins/nextcloud/manifest.yml +54 -0
  70. data/lib/aethernal_agent/plugins/nextcloud/meta/nextcloud.png +0 -0
  71. data/lib/aethernal_agent/plugins/nextcloud/nextcloud.rb +44 -0
  72. data/lib/aethernal_agent/plugins/nextcloud/templates/nextcloud.apache.conf.erb +4 -0
  73. data/lib/aethernal_agent/plugins/nzbget/files/nzbget.service +13 -0
  74. data/lib/aethernal_agent/plugins/nzbget/manifest.yml +54 -0
  75. data/lib/aethernal_agent/plugins/nzbget/meta/nzbget.png +0 -0
  76. data/lib/aethernal_agent/plugins/nzbget/nzbget.rb +44 -0
  77. data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.apache.conf.erb +5 -0
  78. data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.conf.erb +1508 -0
  79. data/lib/aethernal_agent/plugins/olaris/manifest.yml +1 -1
  80. data/lib/aethernal_agent/plugins/ombi/manifest.yml +5 -2
  81. data/lib/aethernal_agent/plugins/ombi/ombi.rb +59 -22
  82. data/lib/aethernal_agent/plugins/ombi/templates/ombi.apache.conf.erb +3 -4
  83. data/lib/aethernal_agent/plugins/ombi/templates/ombi.service.erb +2 -2
  84. data/lib/aethernal_agent/plugins/plex-docker/manifest.yml +74 -0
  85. data/lib/aethernal_agent/plugins/plex-docker/meta/plex.png +0 -0
  86. data/lib/aethernal_agent/plugins/plex-docker/plex_docker.rb +39 -0
  87. data/lib/aethernal_agent/plugins/plex-docker/templates/Preferences.xml.erb +2 -0
  88. data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.apache.conf.erb +21 -0
  89. data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.service.erb +10 -0
  90. data/lib/aethernal_agent/plugins/plex/files/plex.service +1 -1
  91. data/lib/aethernal_agent/plugins/plex/manifest.yml +6 -5
  92. data/lib/aethernal_agent/plugins/plex/plex.rb +2 -4
  93. data/lib/aethernal_agent/plugins/plex/templates/Preferences.xml.erb +1 -1
  94. data/lib/aethernal_agent/plugins/plex/templates/plex.apache.conf.erb +21 -0
  95. data/lib/aethernal_agent/plugins/portainer/manifest.yml +50 -0
  96. data/lib/aethernal_agent/plugins/portainer/meta/portainer.png +0 -0
  97. data/lib/aethernal_agent/plugins/portainer/portainer.rb +38 -0
  98. data/lib/aethernal_agent/plugins/portainer/templates/portainer.apache.conf.erb +7 -0
  99. data/lib/aethernal_agent/plugins/portainer/templates/portainer.service.erb +10 -0
  100. data/lib/aethernal_agent/plugins/radarr/files/radarr.service +2 -2
  101. data/lib/aethernal_agent/plugins/radarr/manifest.yml +7 -13
  102. data/lib/aethernal_agent/plugins/radarr/radarr.rb +24 -18
  103. data/lib/aethernal_agent/plugins/radarr/templates/radarr.apache.conf.erb +3 -4
  104. data/lib/aethernal_agent/plugins/resilio_docker/manifest.yml +59 -0
  105. data/lib/aethernal_agent/plugins/resilio_docker/meta/resilio.png +0 -0
  106. data/lib/aethernal_agent/plugins/resilio_docker/resilio_docker.rb +29 -0
  107. data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.apache.conf.erb +11 -0
  108. data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.conf.erb +38 -0
  109. data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.service.erb +10 -0
  110. data/lib/aethernal_agent/plugins/rutorrent/manifest.yml +84 -0
  111. data/lib/aethernal_agent/plugins/rutorrent/meta/rtorrent.png +0 -0
  112. data/lib/aethernal_agent/plugins/rutorrent/rutorrent.rb +41 -0
  113. data/lib/aethernal_agent/plugins/rutorrent/templates/rtorrent.rc.erb +69 -0
  114. data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.apache.conf.erb +13 -0
  115. data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.service.erb +10 -0
  116. data/lib/aethernal_agent/plugins/sabnzbd/files/sabnzbd.service +13 -0
  117. data/lib/aethernal_agent/plugins/sabnzbd/manifest.yml +43 -0
  118. data/lib/aethernal_agent/plugins/sabnzbd/meta/sabnzbd.png +0 -0
  119. data/lib/aethernal_agent/plugins/sabnzbd/sabnzbd.rb +47 -0
  120. data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.apache.conf.erb +4 -0
  121. data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.ini.erb +188 -0
  122. data/lib/aethernal_agent/plugins/sickchill/files/sickchill.service +13 -0
  123. data/lib/aethernal_agent/plugins/sickchill/manifest.yml +58 -0
  124. data/lib/aethernal_agent/plugins/sickchill/meta/sickchill.png +0 -0
  125. data/lib/aethernal_agent/plugins/sickchill/sickchill.rb +49 -0
  126. data/lib/aethernal_agent/plugins/sickchill/templates/config.ini.erb +1078 -0
  127. data/lib/aethernal_agent/plugins/sickchill/templates/sickchill.apache.conf.erb +4 -0
  128. data/lib/aethernal_agent/plugins/sonarr/files/sonarr.service +1 -1
  129. data/lib/aethernal_agent/plugins/sonarr/manifest.yml +3 -2
  130. data/lib/aethernal_agent/plugins/sonarr/templates/sonarr.apache.conf.erb +3 -4
  131. data/lib/aethernal_agent/plugins/syncthing/files/syncthing.service +18 -0
  132. data/lib/aethernal_agent/plugins/syncthing/manifest.yml +38 -0
  133. data/lib/aethernal_agent/plugins/syncthing/meta/syncthing.png +0 -0
  134. data/lib/aethernal_agent/plugins/syncthing/syncthing.rb +33 -0
  135. data/lib/aethernal_agent/plugins/syncthing/templates/config.xml.erb +56 -0
  136. data/lib/aethernal_agent/plugins/syncthing/templates/syncthing.apache.conf.erb +7 -0
  137. data/lib/aethernal_agent/plugins/tautulli/files/tautulli.service +13 -0
  138. data/lib/aethernal_agent/plugins/tautulli/manifest.yml +40 -0
  139. data/lib/aethernal_agent/plugins/tautulli/meta/tautulli.png +0 -0
  140. data/lib/aethernal_agent/plugins/tautulli/tautulli.rb +45 -0
  141. data/lib/aethernal_agent/plugins/tautulli/templates/config.ini.erb +222 -0
  142. data/lib/aethernal_agent/plugins/tautulli/templates/tautulli.apache.conf.erb +5 -0
  143. data/lib/aethernal_agent/plugins/vnc/manifest.yml +3 -2
  144. data/lib/aethernal_agent/systemd.rb +19 -13
  145. data/lib/aethernal_agent/utils.rb +85 -6
  146. data/lib/aethernal_agent/version.rb +1 -1
  147. data/lib/aethernal_agent/webserver/api.rb +1 -1
  148. data/lib/aethernal_agent/webserver/core.rb +1 -1
  149. metadata +154 -7
@@ -1,48 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aethernal-agent (0.2.0)
4
+ aethernal-agent (0.4.2)
5
5
  activesupport
6
- httparty
6
+ bcrypt
7
+ docker-api (~> 1.34.2)
7
8
  sinatra (~> 2.0.7)
8
9
  sinatra-contrib
9
10
  sqlite3
11
+ terminal-table
12
+ thor
10
13
 
11
14
  GEM
12
15
  remote: https://rubygems.org/
13
16
  specs:
14
- activesupport (6.0.3)
17
+ activesupport (6.0.3.4)
15
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
19
  i18n (>= 0.7, < 2)
17
20
  minitest (~> 5.1)
18
21
  tzinfo (~> 1.1)
19
22
  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)
23
+ backports (3.18.2)
24
+ bcrypt (3.1.16)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.1.7)
27
+ diff-lcs (1.4.4)
28
+ docker-api (1.34.2)
29
+ excon (>= 0.47.0)
30
+ multi_json
31
+ excon (0.78.0)
32
+ i18n (1.8.5)
28
33
  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)
34
+ method_source (1.0.0)
35
+ minitest (5.14.2)
36
+ multi_json (1.15.0)
36
37
  mustermann (1.1.1)
37
38
  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)
39
+ net-scp (3.0.0)
40
+ net-ssh (>= 2.6.5, < 7.0.0)
41
+ net-ssh (6.1.0)
41
42
  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)
43
+ pry (0.13.1)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ rack (2.2.3)
46
47
  rack-protection (2.0.8.1)
47
48
  rack
48
49
  rake (10.5.0)
@@ -50,18 +51,18 @@ GEM
50
51
  rspec-core (~> 3.9.0)
51
52
  rspec-expectations (~> 3.9.0)
52
53
  rspec-mocks (~> 3.9.0)
53
- rspec-core (3.9.0)
54
- rspec-support (~> 3.9.0)
55
- rspec-expectations (3.9.0)
54
+ rspec-core (3.9.2)
55
+ rspec-support (~> 3.9.3)
56
+ rspec-expectations (3.9.2)
56
57
  diff-lcs (>= 1.2.0, < 2.0)
57
58
  rspec-support (~> 3.9.0)
58
59
  rspec-its (1.3.0)
59
60
  rspec-core (>= 3.0.0)
60
61
  rspec-expectations (>= 3.0.0)
61
- rspec-mocks (3.9.0)
62
+ rspec-mocks (3.9.1)
62
63
  diff-lcs (>= 1.2.0, < 2.0)
63
64
  rspec-support (~> 3.9.0)
64
- rspec-support (3.9.0)
65
+ rspec-support (3.9.3)
65
66
  ruby2_keywords (0.0.2)
66
67
  serverspec (2.41.5)
67
68
  multi_json
@@ -81,17 +82,21 @@ GEM
81
82
  rack-protection (= 2.0.8.1)
82
83
  sinatra (= 2.0.8.1)
83
84
  tilt (~> 2.0)
84
- specinfra (2.82.4)
85
+ specinfra (2.82.19)
85
86
  net-scp
86
87
  net-ssh (>= 2.7)
87
88
  net-telnet (= 0.1.1)
88
89
  sfl
89
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)
90
94
  thread_safe (0.3.6)
91
95
  tilt (2.0.10)
92
- tzinfo (1.2.7)
96
+ tzinfo (1.2.8)
93
97
  thread_safe (~> 0.1)
94
- zeitwerk (2.3.0)
98
+ unicode-display_width (1.7.0)
99
+ zeitwerk (2.4.2)
95
100
 
96
101
  PLATFORMS
97
102
  ruby
data/README.md CHANGED
@@ -1,35 +1,6 @@
1
1
  # AethernalAgent
2
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.
3
+ This is pre-production code, if you like to work on this please reach
4
+ out.
4
5
 
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.
6
+ This file will be updated as soon as we reach Alpha state.
@@ -10,6 +10,7 @@ Vagrant.configure(2) do |config|
10
10
 
11
11
  config.vm.provider "virtualbox" do |vb|
12
12
  vb.memory = "2048"
13
+ vb.cpus = 4
13
14
  disk_file = File.expand_path("../.vagrant/disks/c-disk1.vdi", __FILE__)
14
15
 
15
16
  if ! File.exist?(disk_file)
@@ -19,12 +20,19 @@ Vagrant.configure(2) do |config|
19
20
  end
20
21
 
21
22
  config.vm.provision :shell, privileged: true, inline: <<-SHELL
23
+ apt update
24
+ apt install -y build-essential libsqlite3-dev snapd apt-transport-https ca-certificates curl gnupg-agent software-properties-common
22
25
  snap install ruby --classic
26
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg > gpg
27
+ apt-key add gpg
28
+ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
29
+ apt install -y docker-ce docker-ce-cli containerd.io libssl-dev
23
30
  adduser --add_extra_groups --gecos '' --quiet --disabled-password testuser
24
- apt update
25
- apt install -y build-essential libsqlite3-dev
31
+ usermod -a -G docker testuser
26
32
  SHELL
27
33
 
34
+ config.vm.provision :reload
35
+
28
36
  config.trigger.after [:up, :reload] do |trigger|
29
37
  trigger.info = "Doing bundle install"
30
38
  trigger.run_remote = {inline: "cd /vagrant && /snap/bin/bundle install --system", privileged: true}
@@ -41,5 +41,8 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "sinatra", "~> 2.0.7"
42
42
  spec.add_dependency "sinatra-contrib"
43
43
  spec.add_dependency "sqlite3"
44
- spec.add_dependency "httparty"
44
+ spec.add_dependency "bcrypt"
45
+ spec.add_dependency "docker-api", "~> 1.34.2"
46
+ spec.add_dependency "thor"
47
+ spec.add_dependency "terminal-table"
45
48
  end
@@ -0,0 +1,121 @@
1
+ #!/bin/bash
2
+
3
+ is_root() {
4
+ [[ $(id -u) -eq 0 ]]
5
+ }
6
+
7
+ is_ubuntu() {
8
+ grep "Ubuntu" "/etc/os-release" &>/dev/null
9
+ }
10
+
11
+ run() {
12
+ local cmd=$@
13
+ info "running \"${cmd}\""
14
+ $cmd
15
+
16
+ local status=$?
17
+ if [[ $status -ne 0 ]]; then
18
+ fail "failed to run \"${cmd}\", exit status ${status}"
19
+ fi
20
+ }
21
+ timestamp() {
22
+ date "+%H:%M:%S.%3N"
23
+ }
24
+
25
+ info() {
26
+ local msg=$1
27
+ echo -e "\e[1;32m===> $(timestamp) ${msg}\e[0m"
28
+ }
29
+
30
+ warn() {
31
+ local msg=$1
32
+ echo -e "\e[1;33m===> $(timestamp) ${msg}\e[0m"
33
+ }
34
+
35
+ fail() {
36
+ local msg=$1
37
+ echo -e "\e[1;31m===> $(timestamp) ERROR: ${msg}\e[0m"
38
+ exit 1
39
+ }
40
+
41
+ aethernal_exists(){
42
+ [ -e "" ]
43
+ }
44
+ start_aa(){
45
+ run systemctl enable aethernal-agent
46
+ run systemctl start aethernal-agent
47
+ }
48
+ stop_aa(){
49
+ run systemctl stop aethernal-agent
50
+ }
51
+ restart_aa(){
52
+ stop_aa
53
+ start_aa
54
+ }
55
+ update_services(){
56
+ if ! curl -o /lib/systemd/system/aethernal-agent.service https://storage.googleapis.com/bysh-chef-files/aethernal-agent.service;then
57
+ fail "Failed to download systemd service file"
58
+ fi
59
+
60
+ run systemctl daemon-reload
61
+ }
62
+
63
+ install_deps(){
64
+ info "Ensuring dependencies are installed"
65
+ run apt update
66
+ run apt install -y apache2 unzip wget curl ruby2.5 build-essential libsqlite3-dev sqlite3 ruby-dev apt-transport-https ca-certificates curl software-properties-common
67
+ }
68
+
69
+ install_gem(){
70
+ info "Downloading latest Aethernal Agent gem release"
71
+ run gem install --no-doc aethernal-agent
72
+ }
73
+
74
+ install_ci(){
75
+ info "Downloading latest Aethernal Agent release from CI build"
76
+ run gem install bundler --no-document
77
+ if ! wget https://gitlab.com/bytesized/aethernal-agent/-/jobs/artifacts/master/download?job=build -O /tmp/aa.zip;then
78
+ fail "Failed to download gem from CI"
79
+ fi
80
+
81
+ run unzip -o /tmp/aa.zip -d /tmp/
82
+ run gem install --no-document /tmp/pkg/aethernal-agent*.gem
83
+ }
84
+
85
+ main() {
86
+ if ! is_root; then
87
+ fail "this script must be executed as the root user"
88
+ fi
89
+
90
+ if ! is_ubuntu; then
91
+ fail "this script is only compatible with Ubuntu"
92
+ fi
93
+
94
+ local ubuntu_version=$(cat /etc/os-release | grep VERSION_ID| cut -d = -f2 | sed "s/\"//g")
95
+ local version_name=$(lsb_release -a | grep "Codename" | awk '{print $2}')
96
+
97
+ if [[ "${version_name}" = "" ]];then
98
+ fail "Sorry but an unsupported Ubuntu version was found $ubuntu_version - $version_name"
99
+ fi
100
+ info "Found Ubuntu version ${ubuntu_version}"
101
+
102
+ install_deps
103
+ PKG_OK=$(dpkg-query -W --showformat='${Status}\n' docker-ce|grep "install ok installed")
104
+ if [ "" = "$PKG_OK" ]; then
105
+ echo "Docker not installed, doing that now"
106
+ run curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
107
+ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
108
+ run apt-get install -y docker-ce
109
+ fi
110
+
111
+ if [[ "$1" = "from-ci" ]];then
112
+ install_ci
113
+ else
114
+ install_gem
115
+ fi
116
+
117
+ update_services
118
+ restart_aa
119
+ }
120
+
121
+ main $@
@@ -26,7 +26,7 @@ unless app && method && user && options
26
26
  return
27
27
  end
28
28
  options.reverse_merge!(user: user)
29
- plugin = "AethernalAgent::#{app.titlecase}".constantize.new(options)
29
+ plugin = "AethernalAgent::#{app.titlecase.gsub(' ','')}".constantize.new(options)
30
30
 
31
31
  puts "Running BOSS #{AethernalAgent::VERSION} - AethernalAgent::#{app.titlecase}.#{method}(#{options})"
32
32
  result = plugin.send(method, options)
@@ -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,6 @@
1
1
  require 'yaml'
2
+ require 'thor'
3
+ require 'docker-api'
2
4
  require 'sqlite3'
3
5
  require 'active_support/core_ext/hash/indifferent_access'
4
6
  require 'active_support/core_ext/string'
@@ -7,13 +9,21 @@ require 'etc'
7
9
  require 'fileutils'
8
10
  require 'socket'
9
11
  require 'logger'
12
+ require 'bcrypt'
13
+ require 'net/http'
14
+ require 'terminal-table'
10
15
 
11
16
  require 'aethernal_agent/app'
12
17
  require 'aethernal_agent/loader'
18
+ require 'aethernal_agent/docker/volume'
19
+ require 'aethernal_agent/docker/port_binding'
20
+ require 'aethernal_agent/docker/container_settings'
21
+ require 'aethernal_agent/docker/env'
13
22
  require 'aethernal_agent/template'
14
23
  require 'aethernal_agent/operation'
15
24
  require 'aethernal_agent/operation_pool'
16
25
  require 'aethernal_agent/version'
26
+ require 'aethernal_agent/cli/core'
17
27
 
18
28
  module AethernalAgent
19
29
 
@@ -6,16 +6,19 @@ module AethernalAgent
6
6
  include AethernalAgent::Filesystem
7
7
  include AethernalAgent::Utils
8
8
  include AethernalAgent::Errors
9
+ extend AethernalAgent::Utils
9
10
 
10
11
  attr_accessor :user
11
12
 
12
- def initialize(options = {})
13
- self.user = options['user'] || 'root'
13
+ def self.ensure_default_config
14
+ run_command("a2enmod rewrite proxy scgi headers proxy proxy_html proxy_http ssl xml2enc proxy_wstunnel mpm_itk")
15
+ run_command("echo 'ProxyPass /aethernal http://127.0.0.1:4567/' > /etc/apache2/sites-available/aa-default.conf")
16
+ run_command("a2ensite aa-default")
17
+ run_command("systemctl restart apache2")
14
18
  end
15
19
 
16
- def ensure_mods
17
- run_command("a2enmod proxy scgi headers proxy proxy_html proxy_http ssl xml2enc proxy_wstunnel")
18
- self.restart
20
+ def initialize(options = {})
21
+ self.user = options['user'] || 'root'
19
22
  end
20
23
 
21
24
  def write_app_config(template_path, app_name, port)
@@ -0,0 +1,2 @@
1
+ # Default pass should show up on all routes for maximum compatibility
2
+ ProxyPass /aethernal http://127.0.0.1:4567/
@@ -9,6 +9,7 @@
9
9
  <% end %>
10
10
 
11
11
  DocumentRoot <%= @home_folder %>/www
12
+ AssignUserId <%= @user %> aethernal
12
13
  CustomLog /var/log/apache2/<%= @user %>.base-access.log combined
13
14
  ErrorLog /var/log/apache2/<%= @user %>.base-error.log
14
15
  IncludeOptional users/<%= @user %>/*.conf
@@ -18,4 +19,5 @@
18
19
  Require all granted
19
20
  </Directory>
20
21
 
22
+ ProxyPass /aethernal http://127.0.0.1:4567/
21
23
  </VirtualHost>
@@ -17,7 +17,7 @@ module AethernalAgent
17
17
  include AethernalAgent::Utils
18
18
  include AethernalAgent::Errors
19
19
 
20
- attr_accessor :manifest, :user, :plugin_path, :global_options
20
+ attr_accessor :manifest, :user, :plugin_path, :global_options, :container_settings
21
21
 
22
22
  def initialize(options = {})
23
23
  options = HashWithIndifferentAccess.new(options)
@@ -85,6 +85,14 @@ module AethernalAgent
85
85
  elsif opts["auto_extract"]
86
86
  extract(opts["target_name"], delete_after: true)
87
87
  end
88
+ when 'git'
89
+ run_command("mkdir #{home_folder_path(File.join('apps'))}")
90
+ run_command("mkdir #{app_path}")
91
+ run_command("git clone #{self.manifest['package']['git']['url']} #{File.join(app_path)}")
92
+ when 'docker'
93
+ options = self.manifest.package['docker']
94
+ AethernalAgent.logger.info("Pulling Docker image #{options['image']}")
95
+ run_command("docker pull #{options['image']}")
88
96
  end
89
97
  end
90
98
  AethernalAgent.logger.info("Done Installing packages for #{self.manifest.name} - v#{self.manifest.version}")
@@ -100,10 +108,13 @@ module AethernalAgent
100
108
  self.manifest.package.each_key do |package_type|
101
109
  case package_type
102
110
  when "apt"
103
- AethernalAgent.logger.debug("Using apt for ubuntu #{ubuntu_release}")
104
- packages = self.manifest.package[package_type][ubuntu_release]
105
- AethernalAgent.logger.debug("Removing packages #{packages}")
106
- apt_package(packages: packages, action: :remove) if packages
111
+ options = self.manifest.package['apt'][ubuntu_release]
112
+ AethernalAgent.logger.debug("Using apt for ubuntu #{ubuntu_release} - #{options}")
113
+ packages = options['packages']
114
+ if packages
115
+ AethernalAgent.logger.debug("Removing packages #{packages}")
116
+ apt_package(packages: packages, action: :remove)
117
+ end
107
118
  when "direct_download"
108
119
  directory(app_path, action: :delete)
109
120
  end
@@ -123,29 +134,59 @@ module AethernalAgent
123
134
  apache.write_app_config(template_path(self.manifest.apache_configuration), self.manifest.plain_name, opts[:port])
124
135
  end
125
136
 
137
+ if self.is_docker_install?
138
+ begin
139
+ docker_group = Etc.getgrnam('docker')
140
+ rescue ArgumentError
141
+ self.add_errors("Docker group not found, please install Docker (https://docs.docker.com/engine/install/ubuntu/). If Docker is already installed make sure the docker group exists.") and return create_return_args(opts)
142
+ end
143
+
144
+ unless docker_group.mem.include?(self.user)
145
+ self.add_errors("#{self.user} is not a member of the Docker group. Because of the implied security implications aethernal-agent does not do this by default. Please use `usermod -aG docker #{self.user}` if you want to give this user Docker access and restart your Capsule so SystemD has access as well.") and return create_return_args(opts)
146
+ end
147
+ self.container_settings = AethernalAgent::Docker::ContainerSettings.build_from_options(self.manifest["actions"]["configure_app_user"], opts)
148
+ end
149
+
126
150
  AethernalAgent.logger.debug("Running custom plugin code.")
127
151
  yield opts if block_given?
128
152
  AethernalAgent.logger.debug("Done running custom plugin code.")
129
153
 
154
+ if self.is_docker_install?
155
+ # We expect the image to be installed here by the install method
156
+ image = self.manifest.package['docker']['image']
157
+ begin
158
+ container = self.container_settings.create_container(self.docker_container_name, image)
159
+ AethernalAgent.logger.debug("Starting: #{container.start}")
160
+ rescue StandardError => e
161
+ self.add_errors(e)
162
+ return create_return_args(opts)
163
+ end
164
+ end
165
+
130
166
  AethernalAgent.logger.debug("Starting service generation.")
131
- self.manifest.services.each do |s|
132
- options = {service_name: "#{s}.service", user: self.user, vars: opts}
133
- service_template = template_path("#{s}.service.erb")
134
- if File.exists?(service_template)
135
- AethernalAgent.logger.debug("Found service template")
136
- options[:template] = "#{s}.service.erb"
137
- elsif File.exists?(files_path("#{s}.service"))
138
- AethernalAgent.logger.debug("Found service file")
139
- options[:file] = "#{s}.service"
167
+ if self.manifest.services.present?
168
+ self.manifest.services.each do |s|
169
+ options = {service_name: "#{s}.service", user: self.user, vars: opts}
170
+ service_template = template_path("#{s}.service.erb")
171
+ if File.exists?(service_template)
172
+ AethernalAgent.logger.debug("Found service template: '#{service_template}'")
173
+ options[:template] = "#{s}.service.erb"
174
+ elsif File.exists?(files_path("#{s}.service"))
175
+ AethernalAgent.logger.debug("Found service file")
176
+ options[:file] = "#{s}.service"
177
+ end
178
+ create_service_file(options)
140
179
  end
141
180
 
142
- create_service_file(options)
181
+ AethernalAgent.logger.debug("Done with service generation.")
182
+ else
183
+ AethernalAgent.logger.debug("Skipping service generation, no service file defined.")
143
184
  end
144
- AethernalAgent.logger.debug("Done with service generation.")
145
185
 
186
+ AethernalAgent.logger.debug("Done with service generation.")
146
187
  directory(home_folder_path("apps"), owner: self.user)
147
-
148
188
  AethernalAgent.logger.debug("Done running configure_app_user")
189
+
149
190
  return create_return_args(opts)
150
191
  end
151
192
 
@@ -155,8 +196,10 @@ module AethernalAgent
155
196
 
156
197
  run_user_systemctl(:stop)
157
198
 
158
- self.manifest.services.each do |service|
159
- file(service_file_path("#{service}.service"), action: :delete)
199
+ if self.manifest.services.present?
200
+ self.manifest.services.each do |service|
201
+ file(service_file_path("#{service}.service"), action: :delete)
202
+ end
160
203
  end
161
204
 
162
205
  if self.manifest.apache_configuration
@@ -164,8 +207,17 @@ module AethernalAgent
164
207
  apache.remove_app_config(self.manifest.plain_name)
165
208
  end
166
209
 
167
- if self.is_local_install?
168
- self.uninstall_packages(opts)
210
+ # Jackett is removing necessary packages, for now dont uninstall a package ever in user_configure
211
+ #if self.is_local_install?
212
+ # self.uninstall_packages(opts)
213
+ #end
214
+ if self.is_docker_install?
215
+ begin
216
+ container = ::Docker::Container.get(self.docker_container_name)
217
+ container.delete(:force => true)
218
+ rescue ::Docker::Error::NotFoundError
219
+ AethernalAgent.logger.warn("Wanted to delete Docker container '#{self.docker_container_name}' but it did not exist.")
220
+ end
169
221
  end
170
222
 
171
223
  yield opts if block_given?
@@ -223,7 +275,7 @@ module AethernalAgent
223
275
  end
224
276
 
225
277
  # This option should be an autogenerated string (passwords)
226
- if reqs.include?("auto_generate") && reqs["auto_generate"] == true && (!options.has_key?(opt) || options[opt].empty?)
278
+ if reqs.include?("auto_generate") && reqs["auto_generate"] == true && (!options.has_key?(opt) || options[opt].blank?)
227
279
  options[opt] = self.random_string
228
280
  end
229
281
 
@@ -289,6 +341,10 @@ module AethernalAgent
289
341
  case options[:extract_as].gsub('.', '')
290
342
  when "gz", "tar"
291
343
  run_command("tar -C #{extract_to} -xvf #{extract_from}")
344
+ when "tgz"
345
+ run_command("tar -C #{extract_to} -zxvf #{extract_from}")
346
+ when "bz2", "tar"
347
+ run_command("tar -C #{extract_to} -xvjf #{extract_from}")
292
348
  when "zip"
293
349
  run_command("unzip -od #{extract_to} #{extract_from}")
294
350
  else
@@ -306,6 +362,10 @@ module AethernalAgent
306
362
  self.manifest.installation_type == 'local_install'
307
363
  end
308
364
 
365
+ def is_docker_install?
366
+ self.manifest.installation_type == 'docker_image'
367
+ end
368
+
309
369
  def sha_1_hash(password, salt)
310
370
  sha = Digest::SHA1.new
311
371
  sha.update(salt)