aethernal-agent 0.2.0 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +674 -0
  3. data/Gemfile.lock +31 -32
  4. data/README.md +3 -32
  5. data/Vagrantfile +10 -2
  6. data/aethernal-agent.gemspec +2 -1
  7. data/bin/install-aa +120 -0
  8. data/bin/run-aa-for-test +1 -1
  9. data/lib/aethernal_agent.rb +7 -0
  10. data/lib/aethernal_agent/apache/apache.rb +8 -5
  11. data/lib/aethernal_agent/apache/templates/aa-default.conf +2 -0
  12. data/lib/aethernal_agent/apache/templates/aa-user.conf.erb +2 -0
  13. data/lib/aethernal_agent/app.rb +87 -22
  14. data/lib/aethernal_agent/apt.rb +17 -6
  15. data/lib/aethernal_agent/docker/container_settings.rb +33 -0
  16. data/lib/aethernal_agent/docker/env.rb +33 -0
  17. data/lib/aethernal_agent/docker/port_binding.rb +32 -0
  18. data/lib/aethernal_agent/docker/volume.rb +28 -0
  19. data/lib/aethernal_agent/filesystem.rb +2 -1
  20. data/lib/aethernal_agent/loader.rb +3 -3
  21. data/lib/aethernal_agent/operation.rb +1 -1
  22. data/lib/aethernal_agent/plugins/bazarr/bazarr.rb +57 -0
  23. data/lib/aethernal_agent/plugins/bazarr/files/bazarr.service +16 -0
  24. data/lib/aethernal_agent/plugins/bazarr/manifest.yml +64 -0
  25. data/lib/aethernal_agent/plugins/bazarr/meta/bazarr.png +0 -0
  26. data/lib/aethernal_agent/plugins/bazarr/templates/bazarr.apache.conf.erb +5 -0
  27. data/lib/aethernal_agent/plugins/bazarr/templates/config.ini.erb +135 -0
  28. data/lib/aethernal_agent/plugins/cardigann/cardigann.rb +45 -0
  29. data/lib/aethernal_agent/plugins/cardigann/files/cardigann.service +13 -0
  30. data/lib/aethernal_agent/plugins/cardigann/manifest.yml +36 -0
  31. data/lib/aethernal_agent/plugins/cardigann/meta/cardigann.png +0 -0
  32. data/lib/aethernal_agent/plugins/cardigann/templates/cardigann.apache.conf.erb +6 -0
  33. data/lib/aethernal_agent/plugins/cardigann/templates/config.json.erb +7 -0
  34. data/lib/aethernal_agent/plugins/couchpotato/couchpotato.rb +45 -0
  35. data/lib/aethernal_agent/plugins/couchpotato/files/couchpotato.service +13 -0
  36. data/lib/aethernal_agent/plugins/couchpotato/manifest.yml +37 -0
  37. data/lib/aethernal_agent/plugins/couchpotato/meta/couchpotato.png +0 -0
  38. data/lib/aethernal_agent/plugins/couchpotato/templates/couchpotato.apache.conf.erb +4 -0
  39. data/lib/aethernal_agent/plugins/couchpotato/templates/settings.conf.erb +585 -0
  40. data/lib/aethernal_agent/plugins/deluge/manifest.yml +2 -2
  41. data/lib/aethernal_agent/plugins/deluge/templates/deluge.apache.conf.erb +0 -1
  42. data/lib/aethernal_agent/plugins/filebrowser/manifest.yml +1 -1
  43. data/lib/aethernal_agent/plugins/gitea/manifest.yml +1 -1
  44. data/lib/aethernal_agent/plugins/jackett/files/jackett.service +15 -0
  45. data/lib/aethernal_agent/plugins/jackett/jackett.rb +49 -0
  46. data/lib/aethernal_agent/plugins/jackett/manifest.yml +54 -0
  47. data/lib/aethernal_agent/plugins/jackett/meta/jackett.png +0 -0
  48. data/lib/aethernal_agent/plugins/jackett/templates/ServerConfig.json.erb +8 -0
  49. data/lib/aethernal_agent/plugins/jackett/templates/jackett.apache.conf.erb +5 -0
  50. data/lib/aethernal_agent/plugins/medusa/files/medusa.service +13 -0
  51. data/lib/aethernal_agent/plugins/medusa/manifest.yml +54 -0
  52. data/lib/aethernal_agent/plugins/medusa/medusa.rb +47 -0
  53. data/lib/aethernal_agent/plugins/medusa/meta/medusa.png +0 -0
  54. data/lib/aethernal_agent/plugins/medusa/templates/config.ini.erb +1308 -0
  55. data/lib/aethernal_agent/plugins/medusa/templates/medusa.apache.conf.erb +12 -0
  56. data/lib/aethernal_agent/plugins/nextcloud/manifest.yml +54 -0
  57. data/lib/aethernal_agent/plugins/nextcloud/meta/nextcloud.png +0 -0
  58. data/lib/aethernal_agent/plugins/nextcloud/nextcloud.rb +44 -0
  59. data/lib/aethernal_agent/plugins/nextcloud/templates/nextcloud.apache.conf.erb +4 -0
  60. data/lib/aethernal_agent/plugins/nzbget/files/nzbget.service +13 -0
  61. data/lib/aethernal_agent/plugins/nzbget/manifest.yml +54 -0
  62. data/lib/aethernal_agent/plugins/nzbget/meta/nzbget.png +0 -0
  63. data/lib/aethernal_agent/plugins/nzbget/nzbget.rb +44 -0
  64. data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.apache.conf.erb +5 -0
  65. data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.conf.erb +1508 -0
  66. data/lib/aethernal_agent/plugins/olaris/manifest.yml +1 -1
  67. data/lib/aethernal_agent/plugins/ombi/manifest.yml +5 -2
  68. data/lib/aethernal_agent/plugins/ombi/ombi.rb +59 -22
  69. data/lib/aethernal_agent/plugins/ombi/templates/ombi.apache.conf.erb +3 -4
  70. data/lib/aethernal_agent/plugins/ombi/templates/ombi.service.erb +1 -1
  71. data/lib/aethernal_agent/plugins/plex-docker/manifest.yml +74 -0
  72. data/lib/aethernal_agent/plugins/plex-docker/meta/plex.png +0 -0
  73. data/lib/aethernal_agent/plugins/plex-docker/plex_docker.rb +37 -0
  74. data/lib/aethernal_agent/plugins/plex-docker/templates/Preferences.xml.erb +2 -0
  75. data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.apache.conf.erb +21 -0
  76. data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.service.erb +10 -0
  77. data/lib/aethernal_agent/plugins/plex/manifest.yml +6 -5
  78. data/lib/aethernal_agent/plugins/plex/plex.rb +2 -4
  79. data/lib/aethernal_agent/plugins/plex/templates/Preferences.xml.erb +1 -1
  80. data/lib/aethernal_agent/plugins/plex/templates/plex.apache.conf.erb +21 -0
  81. data/lib/aethernal_agent/plugins/portainer/manifest.yml +50 -0
  82. data/lib/aethernal_agent/plugins/portainer/meta/portainer.png +0 -0
  83. data/lib/aethernal_agent/plugins/portainer/portainer.rb +51 -0
  84. data/lib/aethernal_agent/plugins/portainer/templates/portainer.apache.conf.erb +7 -0
  85. data/lib/aethernal_agent/plugins/portainer/templates/portainer.service.erb +10 -0
  86. data/lib/aethernal_agent/plugins/radarr/files/radarr.service +1 -1
  87. data/lib/aethernal_agent/plugins/radarr/manifest.yml +3 -13
  88. data/lib/aethernal_agent/plugins/radarr/radarr.rb +24 -18
  89. data/lib/aethernal_agent/plugins/radarr/templates/radarr.apache.conf.erb +3 -4
  90. data/lib/aethernal_agent/plugins/resilio_docker/files/resilio_docker.service.erb +10 -0
  91. data/lib/aethernal_agent/plugins/resilio_docker/manifest.yml +59 -0
  92. data/lib/aethernal_agent/plugins/resilio_docker/meta/resilio.png +0 -0
  93. data/lib/aethernal_agent/plugins/resilio_docker/resilio_docker.rb +28 -0
  94. data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.apache.conf.erb +11 -0
  95. data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.conf.erb +38 -0
  96. data/lib/aethernal_agent/plugins/rutorrent/manifest.yml +84 -0
  97. data/lib/aethernal_agent/plugins/rutorrent/meta/rtorrent.png +0 -0
  98. data/lib/aethernal_agent/plugins/rutorrent/rutorrent.rb +39 -0
  99. data/lib/aethernal_agent/plugins/rutorrent/templates/rtorrent.rc.erb +69 -0
  100. data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.apache.conf.erb +13 -0
  101. data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.service.erb +10 -0
  102. data/lib/aethernal_agent/plugins/sabnzbd/files/sabnzbd.service +13 -0
  103. data/lib/aethernal_agent/plugins/sabnzbd/manifest.yml +43 -0
  104. data/lib/aethernal_agent/plugins/sabnzbd/meta/sabnzbd.png +0 -0
  105. data/lib/aethernal_agent/plugins/sabnzbd/sabnzbd.rb +47 -0
  106. data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.apache.conf.erb +4 -0
  107. data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.ini.erb +188 -0
  108. data/lib/aethernal_agent/plugins/sickchill/files/sickchill.service +13 -0
  109. data/lib/aethernal_agent/plugins/sickchill/manifest.yml +58 -0
  110. data/lib/aethernal_agent/plugins/sickchill/meta/sickchill.png +0 -0
  111. data/lib/aethernal_agent/plugins/sickchill/sickchill.rb +49 -0
  112. data/lib/aethernal_agent/plugins/sickchill/templates/config.ini.erb +1078 -0
  113. data/lib/aethernal_agent/plugins/sickchill/templates/sickchill.apache.conf.erb +4 -0
  114. data/lib/aethernal_agent/plugins/sonarr/manifest.yml +2 -2
  115. data/lib/aethernal_agent/plugins/sonarr/templates/sonarr.apache.conf.erb +3 -4
  116. data/lib/aethernal_agent/plugins/syncthing/files/syncthing.service +18 -0
  117. data/lib/aethernal_agent/plugins/syncthing/manifest.yml +38 -0
  118. data/lib/aethernal_agent/plugins/syncthing/meta/syncthing.png +0 -0
  119. data/lib/aethernal_agent/plugins/syncthing/syncthing.rb +33 -0
  120. data/lib/aethernal_agent/plugins/syncthing/templates/config.xml.erb +56 -0
  121. data/lib/aethernal_agent/plugins/syncthing/templates/syncthing.apache.conf.erb +7 -0
  122. data/lib/aethernal_agent/plugins/tautulli/files/tautulli.service +13 -0
  123. data/lib/aethernal_agent/plugins/tautulli/manifest.yml +40 -0
  124. data/lib/aethernal_agent/plugins/tautulli/meta/tautulli.png +0 -0
  125. data/lib/aethernal_agent/plugins/tautulli/tautulli.rb +45 -0
  126. data/lib/aethernal_agent/plugins/tautulli/templates/config.ini.erb +222 -0
  127. data/lib/aethernal_agent/plugins/tautulli/templates/tautulli.apache.conf.erb +5 -0
  128. data/lib/aethernal_agent/plugins/vnc/manifest.yml +3 -2
  129. data/lib/aethernal_agent/systemd.rb +19 -13
  130. data/lib/aethernal_agent/utils.rb +69 -6
  131. data/lib/aethernal_agent/version.rb +1 -1
  132. data/lib/aethernal_agent/webserver/api.rb +1 -1
  133. data/lib/aethernal_agent/webserver/core.rb +1 -1
  134. metadata +115 -6
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aethernal-agent (0.2.0)
4
+ aethernal-agent (0.3.6)
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,38 +12,36 @@ PATH
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- activesupport (6.0.3)
15
+ activesupport (6.0.3.3)
15
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
17
  i18n (>= 0.7, < 2)
17
18
  minitest (~> 5.1)
18
19
  tzinfo (~> 1.1)
19
20
  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)
21
+ backports (3.18.2)
22
+ bcrypt (3.1.16)
23
+ coderay (1.1.3)
24
+ concurrent-ruby (1.1.7)
25
+ diff-lcs (1.4.4)
26
+ docker-api (1.34.2)
27
+ excon (>= 0.47.0)
28
+ multi_json
29
+ excon (0.76.0)
30
+ i18n (1.8.5)
28
31
  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)
32
+ method_source (1.0.0)
33
+ minitest (5.14.2)
34
+ multi_json (1.15.0)
36
35
  mustermann (1.1.1)
37
36
  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)
37
+ net-scp (3.0.0)
38
+ net-ssh (>= 2.6.5, < 7.0.0)
39
+ net-ssh (6.1.0)
41
40
  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)
41
+ pry (0.13.1)
42
+ coderay (~> 1.1)
43
+ method_source (~> 1.0)
44
+ rack (2.2.3)
46
45
  rack-protection (2.0.8.1)
47
46
  rack
48
47
  rake (10.5.0)
@@ -50,18 +49,18 @@ GEM
50
49
  rspec-core (~> 3.9.0)
51
50
  rspec-expectations (~> 3.9.0)
52
51
  rspec-mocks (~> 3.9.0)
53
- rspec-core (3.9.0)
54
- rspec-support (~> 3.9.0)
55
- rspec-expectations (3.9.0)
52
+ rspec-core (3.9.2)
53
+ rspec-support (~> 3.9.3)
54
+ rspec-expectations (3.9.2)
56
55
  diff-lcs (>= 1.2.0, < 2.0)
57
56
  rspec-support (~> 3.9.0)
58
57
  rspec-its (1.3.0)
59
58
  rspec-core (>= 3.0.0)
60
59
  rspec-expectations (>= 3.0.0)
61
- rspec-mocks (3.9.0)
60
+ rspec-mocks (3.9.1)
62
61
  diff-lcs (>= 1.2.0, < 2.0)
63
62
  rspec-support (~> 3.9.0)
64
- rspec-support (3.9.0)
63
+ rspec-support (3.9.3)
65
64
  ruby2_keywords (0.0.2)
66
65
  serverspec (2.41.5)
67
66
  multi_json
@@ -81,7 +80,7 @@ GEM
81
80
  rack-protection (= 2.0.8.1)
82
81
  sinatra (= 2.0.8.1)
83
82
  tilt (~> 2.0)
84
- specinfra (2.82.4)
83
+ specinfra (2.82.19)
85
84
  net-scp
86
85
  net-ssh (>= 2.7)
87
86
  net-telnet (= 0.1.1)
@@ -91,7 +90,7 @@ GEM
91
90
  tilt (2.0.10)
92
91
  tzinfo (1.2.7)
93
92
  thread_safe (~> 0.1)
94
- zeitwerk (2.3.0)
93
+ zeitwerk (2.4.0)
95
94
 
96
95
  PLATFORMS
97
96
  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,6 @@ 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"
45
46
  end
@@ -0,0 +1,120 @@
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 service aethernal-agent enable
46
+ run service aethernal-agent start
47
+ }
48
+ stop_aa(){
49
+ run service aethernal-agent stop
50
+ }
51
+ restart_aa(){
52
+ run service aethernal-agent restart
53
+ }
54
+ update_services(){
55
+ if ! curl -o /lib/systemd/system/aethernal-agent.service https://storage.googleapis.com/bysh-chef-files/aethernal-agent.service;then
56
+ fail "Failed to download systemd service file"
57
+ fi
58
+
59
+ run systemctl daemon-reload
60
+ }
61
+
62
+ install_deps(){
63
+ info "Ensuring dependencies are installed"
64
+ run apt update
65
+ 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
66
+ }
67
+
68
+ install_gem(){
69
+ info "Downloading latest Aethernal Agent gem release"
70
+ run gem install --no-doc aethernal-agent
71
+ restart_aa
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
+ restart_aa
84
+ }
85
+
86
+ main() {
87
+ if ! is_root; then
88
+ fail "this script must be executed as the root user"
89
+ fi
90
+
91
+ if ! is_ubuntu; then
92
+ fail "this script is only compatible with Ubuntu"
93
+ fi
94
+
95
+ local ubuntu_version=$(cat /etc/os-release | grep VERSION_ID| cut -d = -f2 | sed "s/\"//g")
96
+ local version_name=$(lsb_release -a | grep "Codename" | awk '{print $2}')
97
+
98
+ if [[ "${version_name}" = "" ]];then
99
+ fail "Sorry but an unsupported Ubuntu version was found $ubuntu_version - $version_name"
100
+ fi
101
+ info "Found Ubuntu version ${ubuntu_version}"
102
+
103
+ install_deps
104
+ PKG_OK=$(dpkg-query -W --showformat='${Status}\n' docker-ce|grep "install ok installed")
105
+ if [ "" = "$PKG_OK" ]; then
106
+ echo "Docker not installed, doing that now"
107
+ run curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
108
+ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
109
+ run apt-get install -y docker-ce
110
+ fi
111
+ update_services
112
+
113
+ if [[ "$1" = "from-ci" ]];then
114
+ install_ci
115
+ else
116
+ install_gem
117
+ fi
118
+ }
119
+
120
+ 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)
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'docker-api'
2
3
  require 'sqlite3'
3
4
  require 'active_support/core_ext/hash/indifferent_access'
4
5
  require 'active_support/core_ext/string'
@@ -7,9 +8,15 @@ require 'etc'
7
8
  require 'fileutils'
8
9
  require 'socket'
9
10
  require 'logger'
11
+ require 'bcrypt'
12
+ require 'net/http'
10
13
 
11
14
  require 'aethernal_agent/app'
12
15
  require 'aethernal_agent/loader'
16
+ require 'aethernal_agent/docker/volume'
17
+ require 'aethernal_agent/docker/port_binding'
18
+ require 'aethernal_agent/docker/container_settings'
19
+ require 'aethernal_agent/docker/env'
13
20
  require 'aethernal_agent/template'
14
21
  require 'aethernal_agent/operation'
15
22
  require 'aethernal_agent/operation_pool'
@@ -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,13 @@ 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
+ run_command("docker pull #{options['image']}")
88
95
  end
89
96
  end
90
97
  AethernalAgent.logger.info("Done Installing packages for #{self.manifest.name} - v#{self.manifest.version}")
@@ -100,10 +107,13 @@ module AethernalAgent
100
107
  self.manifest.package.each_key do |package_type|
101
108
  case package_type
102
109
  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
110
+ options = self.manifest.package['apt'][ubuntu_release]
111
+ AethernalAgent.logger.debug("Using apt for ubuntu #{ubuntu_release} - #{options}")
112
+ packages = options['packages']
113
+ if packages
114
+ AethernalAgent.logger.debug("Removing packages #{packages}")
115
+ apt_package(packages: packages, action: :remove)
116
+ end
107
117
  when "direct_download"
108
118
  directory(app_path, action: :delete)
109
119
  end
@@ -123,29 +133,65 @@ module AethernalAgent
123
133
  apache.write_app_config(template_path(self.manifest.apache_configuration), self.manifest.plain_name, opts[:port])
124
134
  end
125
135
 
136
+ if self.is_docker_install?
137
+ begin
138
+ docker_group = Etc.getgrnam('docker')
139
+ rescue ArgumentError
140
+ 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)
141
+ end
142
+
143
+ unless docker_group.mem.include?(self.user)
144
+ 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)
145
+ end
146
+ self.container_settings = AethernalAgent::Docker::ContainerSettings.build_from_options(self.manifest["actions"]["configure_app_user"], opts)
147
+ end
148
+
126
149
  AethernalAgent.logger.debug("Running custom plugin code.")
127
150
  yield opts if block_given?
128
151
  AethernalAgent.logger.debug("Done running custom plugin code.")
129
152
 
153
+ # This is probably not the best way to check if we need a docker image
154
+ if self.is_docker_install?
155
+ 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
+ begin
163
+ container = self.container_settings.create_container(self.docker_container_name, image)
164
+ AethernalAgent.logger.debug("Starting: #{container.start}")
165
+ rescue StandardError => e
166
+ self.add_errors(e)
167
+ return create_return_args(opts)
168
+ end
169
+ end
170
+
130
171
  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"
172
+ if self.manifest.services.present?
173
+ self.manifest.services.each do |s|
174
+ options = {service_name: "#{s}.service", user: self.user, vars: opts}
175
+ service_template = template_path("#{s}.service.erb")
176
+ if File.exists?(service_template)
177
+ AethernalAgent.logger.debug("Found service template: '#{service_template}'")
178
+ options[:template] = "#{s}.service.erb"
179
+ elsif File.exists?(files_path("#{s}.service"))
180
+ AethernalAgent.logger.debug("Found service file")
181
+ options[:file] = "#{s}.service"
182
+ end
183
+ create_service_file(options)
140
184
  end
141
185
 
142
- create_service_file(options)
186
+ AethernalAgent.logger.debug("Done with service generation.")
187
+ else
188
+ AethernalAgent.logger.debug("Skipping service generation, no service file defined.")
143
189
  end
144
- AethernalAgent.logger.debug("Done with service generation.")
145
190
 
191
+ AethernalAgent.logger.debug("Done with service generation.")
146
192
  directory(home_folder_path("apps"), owner: self.user)
147
-
148
193
  AethernalAgent.logger.debug("Done running configure_app_user")
194
+
149
195
  return create_return_args(opts)
150
196
  end
151
197
 
@@ -155,8 +201,10 @@ module AethernalAgent
155
201
 
156
202
  run_user_systemctl(:stop)
157
203
 
158
- self.manifest.services.each do |service|
159
- file(service_file_path("#{service}.service"), action: :delete)
204
+ if self.manifest.services.present?
205
+ self.manifest.services.each do |service|
206
+ file(service_file_path("#{service}.service"), action: :delete)
207
+ end
160
208
  end
161
209
 
162
210
  if self.manifest.apache_configuration
@@ -164,8 +212,17 @@ module AethernalAgent
164
212
  apache.remove_app_config(self.manifest.plain_name)
165
213
  end
166
214
 
167
- if self.is_local_install?
168
- self.uninstall_packages(opts)
215
+ # Jackett is removing necessary packages, for now dont uninstall a package ever in user_configure
216
+ #if self.is_local_install?
217
+ # self.uninstall_packages(opts)
218
+ #end
219
+ if self.is_docker_install?
220
+ begin
221
+ container = ::Docker::Container.get(self.docker_container_name)
222
+ container.delete(:force => true)
223
+ rescue ::Docker::Error::NotFoundError
224
+ AethernalAgent.logger.warn("Wanted to delete Docker container '#{self.docker_container_name}' but it did not exist.")
225
+ end
169
226
  end
170
227
 
171
228
  yield opts if block_given?
@@ -223,7 +280,7 @@ module AethernalAgent
223
280
  end
224
281
 
225
282
  # 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?)
283
+ if reqs.include?("auto_generate") && reqs["auto_generate"] == true && (!options.has_key?(opt) || options[opt].blank?)
227
284
  options[opt] = self.random_string
228
285
  end
229
286
 
@@ -289,6 +346,10 @@ module AethernalAgent
289
346
  case options[:extract_as].gsub('.', '')
290
347
  when "gz", "tar"
291
348
  run_command("tar -C #{extract_to} -xvf #{extract_from}")
349
+ when "tgz"
350
+ run_command("tar -C #{extract_to} -zxvf #{extract_from}")
351
+ when "bz2", "tar"
352
+ run_command("tar -C #{extract_to} -xvjf #{extract_from}")
292
353
  when "zip"
293
354
  run_command("unzip -od #{extract_to} #{extract_from}")
294
355
  else
@@ -306,6 +367,10 @@ module AethernalAgent
306
367
  self.manifest.installation_type == 'local_install'
307
368
  end
308
369
 
370
+ def is_docker_install?
371
+ self.manifest.installation_type == 'docker_image'
372
+ end
373
+
309
374
  def sha_1_hash(password, salt)
310
375
  sha = Digest::SHA1.new
311
376
  sha.update(salt)