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.
- checksums.yaml +4 -4
- data/COPYING +674 -0
- data/Gemfile.lock +38 -33
- data/README.md +3 -32
- data/Vagrantfile +10 -2
- data/aethernal-agent.gemspec +4 -1
- data/bin/install-aa +121 -0
- data/bin/run-aa-for-test +1 -1
- data/exe/aa-cli +7 -0
- data/lib/aethernal_agent.rb +10 -0
- data/lib/aethernal_agent/apache/apache.rb +8 -5
- data/lib/aethernal_agent/apache/templates/aa-default.conf +2 -0
- data/lib/aethernal_agent/apache/templates/aa-user.conf.erb +2 -0
- data/lib/aethernal_agent/app.rb +82 -22
- data/lib/aethernal_agent/apt.rb +17 -6
- data/lib/aethernal_agent/cli/core.rb +11 -0
- data/lib/aethernal_agent/cli/services.rb +56 -0
- data/lib/aethernal_agent/docker/container_settings.rb +33 -0
- data/lib/aethernal_agent/docker/env.rb +33 -0
- data/lib/aethernal_agent/docker/port_binding.rb +32 -0
- data/lib/aethernal_agent/docker/volume.rb +28 -0
- data/lib/aethernal_agent/filesystem.rb +2 -1
- data/lib/aethernal_agent/loader.rb +3 -3
- data/lib/aethernal_agent/operation.rb +1 -1
- data/lib/aethernal_agent/plugins/bazarr/bazarr.rb +57 -0
- data/lib/aethernal_agent/plugins/bazarr/files/bazarr.service +16 -0
- data/lib/aethernal_agent/plugins/bazarr/manifest.yml +64 -0
- data/lib/aethernal_agent/plugins/bazarr/meta/bazarr.png +0 -0
- data/lib/aethernal_agent/plugins/bazarr/templates/bazarr.apache.conf.erb +5 -0
- data/lib/aethernal_agent/plugins/bazarr/templates/config.ini.erb +135 -0
- data/lib/aethernal_agent/plugins/cardigann/cardigann.rb +45 -0
- data/lib/aethernal_agent/plugins/cardigann/files/cardigann.service +13 -0
- data/lib/aethernal_agent/plugins/cardigann/manifest.yml +36 -0
- data/lib/aethernal_agent/plugins/cardigann/meta/cardigann.png +0 -0
- data/lib/aethernal_agent/plugins/cardigann/templates/cardigann.apache.conf.erb +6 -0
- data/lib/aethernal_agent/plugins/cardigann/templates/config.json.erb +7 -0
- data/lib/aethernal_agent/plugins/couchpotato/couchpotato.rb +45 -0
- data/lib/aethernal_agent/plugins/couchpotato/files/couchpotato.service +13 -0
- data/lib/aethernal_agent/plugins/couchpotato/manifest.yml +37 -0
- data/lib/aethernal_agent/plugins/couchpotato/meta/couchpotato.png +0 -0
- data/lib/aethernal_agent/plugins/couchpotato/templates/couchpotato.apache.conf.erb +4 -0
- data/lib/aethernal_agent/plugins/couchpotato/templates/settings.conf.erb +585 -0
- data/lib/aethernal_agent/plugins/deluge/deluge.rb +5 -0
- data/lib/aethernal_agent/plugins/deluge/manifest.yml +2 -2
- data/lib/aethernal_agent/plugins/deluge/templates/core.conf.erb +1 -1
- data/lib/aethernal_agent/plugins/deluge/templates/deluge-web.service.erb +1 -1
- data/lib/aethernal_agent/plugins/deluge/templates/deluge.apache.conf.erb +0 -1
- data/lib/aethernal_agent/plugins/deluge/templates/deluged.service.erb +1 -1
- data/lib/aethernal_agent/plugins/deluge/templates/ltconfig.conf.erb +21 -0
- data/lib/aethernal_agent/plugins/filebrowser/manifest.yml +1 -1
- data/lib/aethernal_agent/plugins/gitea/manifest.yml +1 -1
- data/lib/aethernal_agent/plugins/jackett/files/jackett.service +15 -0
- data/lib/aethernal_agent/plugins/jackett/jackett.rb +49 -0
- data/lib/aethernal_agent/plugins/jackett/manifest.yml +54 -0
- data/lib/aethernal_agent/plugins/jackett/meta/jackett.png +0 -0
- data/lib/aethernal_agent/plugins/jackett/templates/ServerConfig.json.erb +8 -0
- data/lib/aethernal_agent/plugins/jackett/templates/jackett.apache.conf.erb +5 -0
- data/lib/aethernal_agent/plugins/jdownloader/files/jdownloader.service +13 -0
- data/lib/aethernal_agent/plugins/jdownloader/jdownloader.rb +38 -0
- data/lib/aethernal_agent/plugins/jdownloader/manifest.yml +53 -0
- data/lib/aethernal_agent/plugins/jdownloader/meta/jdownloader.png +0 -0
- data/lib/aethernal_agent/plugins/jdownloader/templates/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.erb +5 -0
- data/lib/aethernal_agent/plugins/medusa/files/medusa.service +13 -0
- data/lib/aethernal_agent/plugins/medusa/manifest.yml +54 -0
- data/lib/aethernal_agent/plugins/medusa/medusa.rb +47 -0
- data/lib/aethernal_agent/plugins/medusa/meta/medusa.png +0 -0
- data/lib/aethernal_agent/plugins/medusa/templates/config.ini.erb +1308 -0
- data/lib/aethernal_agent/plugins/medusa/templates/medusa.apache.conf.erb +12 -0
- data/lib/aethernal_agent/plugins/nextcloud/manifest.yml +54 -0
- data/lib/aethernal_agent/plugins/nextcloud/meta/nextcloud.png +0 -0
- data/lib/aethernal_agent/plugins/nextcloud/nextcloud.rb +44 -0
- data/lib/aethernal_agent/plugins/nextcloud/templates/nextcloud.apache.conf.erb +4 -0
- data/lib/aethernal_agent/plugins/nzbget/files/nzbget.service +13 -0
- data/lib/aethernal_agent/plugins/nzbget/manifest.yml +54 -0
- data/lib/aethernal_agent/plugins/nzbget/meta/nzbget.png +0 -0
- data/lib/aethernal_agent/plugins/nzbget/nzbget.rb +44 -0
- data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.apache.conf.erb +5 -0
- data/lib/aethernal_agent/plugins/nzbget/templates/nzbget.conf.erb +1508 -0
- data/lib/aethernal_agent/plugins/olaris/manifest.yml +1 -1
- data/lib/aethernal_agent/plugins/ombi/manifest.yml +5 -2
- data/lib/aethernal_agent/plugins/ombi/ombi.rb +59 -22
- data/lib/aethernal_agent/plugins/ombi/templates/ombi.apache.conf.erb +3 -4
- data/lib/aethernal_agent/plugins/ombi/templates/ombi.service.erb +2 -2
- data/lib/aethernal_agent/plugins/plex-docker/manifest.yml +74 -0
- data/lib/aethernal_agent/plugins/plex-docker/meta/plex.png +0 -0
- data/lib/aethernal_agent/plugins/plex-docker/plex_docker.rb +39 -0
- data/lib/aethernal_agent/plugins/plex-docker/templates/Preferences.xml.erb +2 -0
- data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.apache.conf.erb +21 -0
- data/lib/aethernal_agent/plugins/plex-docker/templates/plex_docker.service.erb +10 -0
- data/lib/aethernal_agent/plugins/plex/files/plex.service +1 -1
- data/lib/aethernal_agent/plugins/plex/manifest.yml +6 -5
- data/lib/aethernal_agent/plugins/plex/plex.rb +2 -4
- data/lib/aethernal_agent/plugins/plex/templates/Preferences.xml.erb +1 -1
- data/lib/aethernal_agent/plugins/plex/templates/plex.apache.conf.erb +21 -0
- data/lib/aethernal_agent/plugins/portainer/manifest.yml +50 -0
- data/lib/aethernal_agent/plugins/portainer/meta/portainer.png +0 -0
- data/lib/aethernal_agent/plugins/portainer/portainer.rb +38 -0
- data/lib/aethernal_agent/plugins/portainer/templates/portainer.apache.conf.erb +7 -0
- data/lib/aethernal_agent/plugins/portainer/templates/portainer.service.erb +10 -0
- data/lib/aethernal_agent/plugins/radarr/files/radarr.service +2 -2
- data/lib/aethernal_agent/plugins/radarr/manifest.yml +7 -13
- data/lib/aethernal_agent/plugins/radarr/radarr.rb +24 -18
- data/lib/aethernal_agent/plugins/radarr/templates/radarr.apache.conf.erb +3 -4
- data/lib/aethernal_agent/plugins/resilio_docker/manifest.yml +59 -0
- data/lib/aethernal_agent/plugins/resilio_docker/meta/resilio.png +0 -0
- data/lib/aethernal_agent/plugins/resilio_docker/resilio_docker.rb +29 -0
- data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.apache.conf.erb +11 -0
- data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.conf.erb +38 -0
- data/lib/aethernal_agent/plugins/resilio_docker/templates/resilio_docker.service.erb +10 -0
- data/lib/aethernal_agent/plugins/rutorrent/manifest.yml +84 -0
- data/lib/aethernal_agent/plugins/rutorrent/meta/rtorrent.png +0 -0
- data/lib/aethernal_agent/plugins/rutorrent/rutorrent.rb +41 -0
- data/lib/aethernal_agent/plugins/rutorrent/templates/rtorrent.rc.erb +69 -0
- data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.apache.conf.erb +13 -0
- data/lib/aethernal_agent/plugins/rutorrent/templates/rutorrent.service.erb +10 -0
- data/lib/aethernal_agent/plugins/sabnzbd/files/sabnzbd.service +13 -0
- data/lib/aethernal_agent/plugins/sabnzbd/manifest.yml +43 -0
- data/lib/aethernal_agent/plugins/sabnzbd/meta/sabnzbd.png +0 -0
- data/lib/aethernal_agent/plugins/sabnzbd/sabnzbd.rb +47 -0
- data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.apache.conf.erb +4 -0
- data/lib/aethernal_agent/plugins/sabnzbd/templates/sabnzbd.ini.erb +188 -0
- data/lib/aethernal_agent/plugins/sickchill/files/sickchill.service +13 -0
- data/lib/aethernal_agent/plugins/sickchill/manifest.yml +58 -0
- data/lib/aethernal_agent/plugins/sickchill/meta/sickchill.png +0 -0
- data/lib/aethernal_agent/plugins/sickchill/sickchill.rb +49 -0
- data/lib/aethernal_agent/plugins/sickchill/templates/config.ini.erb +1078 -0
- data/lib/aethernal_agent/plugins/sickchill/templates/sickchill.apache.conf.erb +4 -0
- data/lib/aethernal_agent/plugins/sonarr/files/sonarr.service +1 -1
- data/lib/aethernal_agent/plugins/sonarr/manifest.yml +3 -2
- data/lib/aethernal_agent/plugins/sonarr/templates/sonarr.apache.conf.erb +3 -4
- data/lib/aethernal_agent/plugins/syncthing/files/syncthing.service +18 -0
- data/lib/aethernal_agent/plugins/syncthing/manifest.yml +38 -0
- data/lib/aethernal_agent/plugins/syncthing/meta/syncthing.png +0 -0
- data/lib/aethernal_agent/plugins/syncthing/syncthing.rb +33 -0
- data/lib/aethernal_agent/plugins/syncthing/templates/config.xml.erb +56 -0
- data/lib/aethernal_agent/plugins/syncthing/templates/syncthing.apache.conf.erb +7 -0
- data/lib/aethernal_agent/plugins/tautulli/files/tautulli.service +13 -0
- data/lib/aethernal_agent/plugins/tautulli/manifest.yml +40 -0
- data/lib/aethernal_agent/plugins/tautulli/meta/tautulli.png +0 -0
- data/lib/aethernal_agent/plugins/tautulli/tautulli.rb +45 -0
- data/lib/aethernal_agent/plugins/tautulli/templates/config.ini.erb +222 -0
- data/lib/aethernal_agent/plugins/tautulli/templates/tautulli.apache.conf.erb +5 -0
- data/lib/aethernal_agent/plugins/vnc/manifest.yml +3 -2
- data/lib/aethernal_agent/systemd.rb +19 -13
- data/lib/aethernal_agent/utils.rb +85 -6
- data/lib/aethernal_agent/version.rb +1 -1
- data/lib/aethernal_agent/webserver/api.rb +1 -1
- data/lib/aethernal_agent/webserver/core.rb +1 -1
- metadata +154 -7
data/Gemfile.lock
CHANGED
@@ -1,48 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
aethernal-agent (0.2
|
4
|
+
aethernal-agent (0.4.2)
|
5
5
|
activesupport
|
6
|
-
|
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.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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.
|
30
|
-
|
31
|
-
|
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 (
|
39
|
-
net-ssh (>= 2.6.5, <
|
40
|
-
net-ssh (
|
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.
|
43
|
-
coderay (~> 1.1
|
44
|
-
method_source (~>
|
45
|
-
rack (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.
|
54
|
-
rspec-support (~> 3.9.
|
55
|
-
rspec-expectations (3.9.
|
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.
|
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.
|
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.
|
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.
|
96
|
+
tzinfo (1.2.8)
|
93
97
|
thread_safe (~> 0.1)
|
94
|
-
|
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
|
-
|
3
|
+
This is pre-production code, if you like to work on this please reach
|
4
|
+
out.
|
4
5
|
|
5
|
-
|
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.
|
data/Vagrantfile
CHANGED
@@ -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
|
-
|
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}
|
data/aethernal-agent.gemspec
CHANGED
@@ -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 "
|
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
|
data/bin/install-aa
ADDED
@@ -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 $@
|
data/bin/run-aa-for-test
CHANGED
@@ -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)
|
data/exe/aa-cli
ADDED
data/lib/aethernal_agent.rb
CHANGED
@@ -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
|
13
|
-
|
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
|
17
|
-
|
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)
|
@@ -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>
|
data/lib/aethernal_agent/app.rb
CHANGED
@@ -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
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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.
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
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.
|
159
|
-
|
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
|
-
|
168
|
-
|
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].
|
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)
|