ConfigLMM 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -0
- data/CNAME +1 -0
- data/Examples/.lmm.state.yaml +159 -0
- data/Examples/ConfigLMM.mm.yaml +32 -0
- data/Examples/Implemented.mm.yaml +252 -4
- data/Examples/SmallBusiness.mm.yaml +492 -0
- data/Plugins/Apps/Answer/answer.lmm.rb +165 -0
- data/Plugins/Apps/Answer/answer@.service +40 -0
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.conf.erb +0 -3
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.lmm.rb +0 -1
- data/Plugins/Apps/Authentik/Authentik-ProxyOutpost.container +20 -0
- data/Plugins/Apps/Authentik/Authentik-Server.container +7 -1
- data/Plugins/Apps/Authentik/Authentik-Worker.container +7 -1
- data/Plugins/Apps/Authentik/Authentik.conf.erb +18 -6
- data/Plugins/Apps/Authentik/Authentik.lmm.rb +232 -45
- data/Plugins/Apps/BookStack/BookStack.conf.erb +38 -0
- data/Plugins/Apps/BookStack/BookStack.container +20 -0
- data/Plugins/Apps/BookStack/BookStack.lmm.rb +91 -0
- data/Plugins/Apps/Cassandra/Cassandra.lmm.rb +9 -19
- data/Plugins/Apps/ClickHouse/ClickHouse.container +28 -0
- data/Plugins/Apps/ClickHouse/ClickHouse.lmm.rb +113 -0
- data/Plugins/Apps/ClickHouse/Config/listen.yaml +2 -0
- data/Plugins/Apps/ClickHouse/Config/logger.yaml +8 -0
- data/Plugins/Apps/ClickHouse/Config/zookeepers.yaml +5 -0
- data/Plugins/Apps/ClickHouse/Connection.rb +96 -0
- data/Plugins/Apps/Discourse/Discourse-Sidekiq.container +22 -0
- data/Plugins/Apps/Discourse/Discourse.conf.erb +38 -0
- data/Plugins/Apps/Discourse/Discourse.container +21 -0
- data/Plugins/Apps/Discourse/Discourse.lmm.rb +156 -0
- data/Plugins/Apps/Dovecot/Dovecot.lmm.rb +87 -52
- data/Plugins/Apps/ERPNext/ERPNext-Frontend.container +24 -0
- data/Plugins/Apps/ERPNext/ERPNext-Queue.container +22 -0
- data/Plugins/Apps/ERPNext/ERPNext-Scheduler.container +22 -0
- data/Plugins/Apps/ERPNext/ERPNext-Websocket.container +24 -0
- data/Plugins/Apps/ERPNext/ERPNext.container +23 -0
- data/Plugins/Apps/ERPNext/ERPNext.lmm.rb +204 -0
- data/Plugins/Apps/ERPNext/ERPNext.network +12 -0
- data/Plugins/Apps/ERPNext/sites/apps.json +10 -0
- data/Plugins/Apps/ERPNext/sites/apps.txt +3 -0
- data/Plugins/Apps/ERPNext/sites/common_site_config.json +11 -0
- data/Plugins/Apps/GitLab/GitLab.container +9 -2
- data/Plugins/Apps/GitLab/GitLab.lmm.rb +52 -33
- data/Plugins/Apps/Homepage/Homepage.conf.erb +86 -0
- data/Plugins/Apps/Homepage/Homepage.container +19 -0
- data/Plugins/Apps/Homepage/Homepage.lmm.rb +54 -0
- data/Plugins/Apps/IPFS/IPFS.conf.erb +0 -3
- data/Plugins/Apps/IPFS/IPFS.lmm.rb +0 -1
- data/Plugins/Apps/InfluxDB/InfluxDB.conf.erb +0 -3
- data/Plugins/Apps/InfluxDB/InfluxDB.lmm.rb +0 -1
- data/Plugins/Apps/Jackett/Jackett.conf.erb +0 -3
- data/Plugins/Apps/Jackett/Jackett.lmm.rb +0 -1
- data/Plugins/Apps/Jellyfin/Jellyfin.conf.erb +0 -3
- data/Plugins/Apps/Jellyfin/Jellyfin.lmm.rb +0 -1
- data/Plugins/Apps/LetsEncrypt/LetsEncrypt.lmm.rb +78 -0
- data/Plugins/Apps/LetsEncrypt/hooks/dovecot.sh +2 -0
- data/Plugins/Apps/LetsEncrypt/hooks/nginx.sh +2 -0
- data/Plugins/Apps/LetsEncrypt/hooks/postfix.sh +2 -0
- data/Plugins/Apps/LetsEncrypt/renew-certificates.service +7 -0
- data/Plugins/Apps/LetsEncrypt/renew-certificates.timer +12 -0
- data/Plugins/Apps/LetsEncrypt/rfc2136.ini +11 -0
- data/Plugins/Apps/LibreTranslate/LibreTranslate.container +21 -0
- data/Plugins/Apps/LibreTranslate/LibreTranslate.lmm.rb +34 -0
- data/Plugins/Apps/Lobsters/Containerfile +81 -0
- data/Plugins/Apps/Lobsters/Lobsters-Tasks.container +26 -0
- data/Plugins/Apps/Lobsters/Lobsters.conf.erb +99 -0
- data/Plugins/Apps/Lobsters/Lobsters.container +27 -0
- data/Plugins/Apps/Lobsters/Lobsters.lmm.rb +196 -0
- data/Plugins/Apps/Lobsters/crontab +3 -0
- data/Plugins/Apps/Lobsters/database.yml +26 -0
- data/Plugins/Apps/Lobsters/entrypoint.sh +30 -0
- data/Plugins/Apps/Lobsters/generateCredentials.rb +19 -0
- data/Plugins/Apps/Lobsters/lobsters-cron.sh +25 -0
- data/Plugins/Apps/Lobsters/lobsters-daily.sh +23 -0
- data/Plugins/Apps/Lobsters/puma.rb +49 -0
- data/Plugins/Apps/MariaDB/Connection.rb +55 -0
- data/Plugins/Apps/MariaDB/MariaDB.lmm.rb +122 -0
- data/Plugins/Apps/Mastodon/Mastodon-Sidekiq.container +22 -0
- data/Plugins/Apps/Mastodon/Mastodon-Streaming.container +20 -0
- data/Plugins/Apps/Mastodon/Mastodon.conf.erb +34 -45
- data/Plugins/Apps/Mastodon/Mastodon.container +28 -0
- data/Plugins/Apps/Mastodon/Mastodon.lmm.rb +240 -5
- data/Plugins/Apps/Mastodon/configlmm.rake +30 -0
- data/Plugins/Apps/Mastodon/entrypoint.sh +16 -0
- data/Plugins/Apps/Matrix/Element.container +19 -0
- data/Plugins/Apps/Matrix/Matrix.conf.erb +47 -9
- data/Plugins/Apps/Matrix/Matrix.lmm.rb +119 -5
- data/Plugins/Apps/Matrix/Synapse.container +22 -0
- data/Plugins/Apps/Matrix/config.json +50 -0
- data/Plugins/Apps/Matrix/homeserver.yaml +70 -0
- data/Plugins/Apps/Matrix/log.config +30 -0
- data/Plugins/Apps/Netdata/Netdata.conf.erb +0 -3
- data/Plugins/Apps/Netdata/Netdata.lmm.rb +0 -1
- data/Plugins/Apps/Nextcloud/Nextcloud.conf.erb +3 -4
- data/Plugins/Apps/Nextcloud/Nextcloud.lmm.rb +155 -48
- data/Plugins/Apps/Nextcloud/autoconfig.php +13 -0
- data/Plugins/Apps/Nextcloud/config.php +10 -1
- data/Plugins/Apps/Nextcloud/nextcloudcron.service +8 -0
- data/Plugins/Apps/Nextcloud/nextcloudcron.timer +10 -0
- data/Plugins/Apps/Nginx/Connection.rb +93 -0
- data/Plugins/Apps/Nginx/conf.d/configlmm.conf +54 -4
- data/Plugins/Apps/Nginx/conf.d/languages.conf +21 -0
- data/Plugins/Apps/Nginx/config-lmm/errors.conf +33 -22
- data/Plugins/Apps/Nginx/config-lmm/gateway-errors.conf +20 -0
- data/Plugins/Apps/Nginx/config-lmm/proxy.conf +6 -2
- data/Plugins/Apps/Nginx/main.conf.erb +7 -3
- data/Plugins/Apps/Nginx/nginx.conf +2 -2
- data/Plugins/Apps/Nginx/nginx.lmm.rb +103 -81
- data/Plugins/Apps/Nginx/proxy.conf.erb +24 -6
- data/Plugins/Apps/Odoo/Odoo.conf.erb +0 -3
- data/Plugins/Apps/Odoo/Odoo.container +7 -1
- data/Plugins/Apps/Odoo/Odoo.lmm.rb +4 -5
- data/Plugins/Apps/Ollama/Ollama.container +26 -0
- data/Plugins/Apps/Ollama/Ollama.lmm.rb +73 -0
- data/Plugins/Apps/OpenTelemetry/Config/config.yaml +704 -0
- data/Plugins/Apps/OpenTelemetry/OpenTelemetry.lmm.rb +154 -0
- data/Plugins/Apps/OpenVidu/Ingress.container +23 -0
- data/Plugins/Apps/{GitLab/GitLab.conf.erb → OpenVidu/OpenVidu.conf.erb} +8 -3
- data/Plugins/Apps/OpenVidu/OpenVidu.container +21 -0
- data/Plugins/Apps/OpenVidu/OpenVidu.lmm.rb +94 -0
- data/Plugins/Apps/OpenVidu/OpenViduCall.conf.erb +32 -0
- data/Plugins/Apps/OpenVidu/OpenViduCall.container +20 -0
- data/Plugins/Apps/OpenVidu/ingress.yaml +10 -0
- data/Plugins/Apps/OpenVidu/livekit.yaml +13 -0
- data/Plugins/Apps/PHP-FPM/Connection.rb +91 -0
- data/Plugins/Apps/PHP-FPM/PHP-FPM.lmm.rb +31 -4
- data/Plugins/Apps/Peppermint/Peppermint.conf.erb +2 -9
- data/Plugins/Apps/Peppermint/Peppermint.container +7 -1
- data/Plugins/Apps/Peppermint/Peppermint.lmm.rb +29 -33
- data/Plugins/Apps/Perplexica/Perplexica.container +25 -0
- data/Plugins/Apps/Perplexica/Perplexica.lmm.rb +92 -0
- data/Plugins/Apps/Perplexica/config.toml +26 -0
- data/Plugins/Apps/Podman/Connection.rb +24 -0
- data/Plugins/Apps/Podman/Podman.lmm.rb +80 -0
- data/Plugins/Apps/Podman/storage.conf +6 -0
- data/Plugins/Apps/Postfix/Postfix.lmm.rb +249 -145
- data/Plugins/Apps/PostgreSQL/Connection.rb +97 -0
- data/Plugins/Apps/PostgreSQL/PostgreSQL.lmm.rb +204 -99
- data/Plugins/Apps/Pterodactyl/Pterodactyl.conf.erb +0 -3
- data/Plugins/Apps/Pterodactyl/Pterodactyl.lmm.rb +0 -2
- data/Plugins/Apps/Pterodactyl/Wings.conf.erb +0 -3
- data/Plugins/Apps/RVM/RVM.lmm.rb +57 -0
- data/Plugins/Apps/Roundcube/Roundcube.conf.erb +72 -0
- data/Plugins/Apps/Roundcube/Roundcube.lmm.rb +141 -0
- data/Plugins/Apps/SSH/SSH.lmm.rb +9 -15
- data/Plugins/Apps/SearXNG/SearXNG.container +22 -0
- data/Plugins/Apps/SearXNG/SearXNG.lmm.rb +79 -0
- data/Plugins/Apps/SearXNG/limiter.toml +40 -0
- data/Plugins/Apps/SearXNG/settings.yml +2 -0
- data/Plugins/Apps/SigNoz/Config/alerts.yml +11 -0
- data/Plugins/Apps/SigNoz/Config/otel-collector-config.yaml +110 -0
- data/Plugins/Apps/SigNoz/Config/otel-collector-opamp-config.yaml +1 -0
- data/Plugins/Apps/SigNoz/Config/prometheus.yml +18 -0
- data/Plugins/Apps/SigNoz/SigNoz-Collector.container +23 -0
- data/Plugins/Apps/SigNoz/SigNoz-Migrator.container +17 -0
- data/Plugins/Apps/SigNoz/SigNoz.conf.erb +61 -0
- data/Plugins/Apps/SigNoz/SigNoz.container +26 -0
- data/Plugins/Apps/SigNoz/SigNoz.lmm.rb +319 -0
- data/Plugins/Apps/Solr/log4j2.xml +89 -0
- data/Plugins/Apps/Solr/solr.lmm.rb +82 -0
- data/Plugins/Apps/Sunshine/Sunshine.conf.erb +0 -3
- data/Plugins/Apps/Sunshine/Sunshine.lmm.rb +0 -1
- data/Plugins/Apps/Tunnel/tunnel.lmm.rb +59 -0
- data/Plugins/Apps/Tunnel/tunnelTCP.service +9 -0
- data/Plugins/Apps/Tunnel/tunnelTCP.socket +9 -0
- data/Plugins/Apps/Tunnel/tunnelUDP.service +9 -0
- data/Plugins/Apps/Tunnel/tunnelUDP.socket +9 -0
- data/Plugins/Apps/UVdesk/UVdesk.conf.erb +0 -3
- data/Plugins/Apps/Umami/Umami.container +19 -0
- data/Plugins/Apps/Umami/Umami.lmm.rb +108 -0
- data/Plugins/Apps/Valkey/Valkey.lmm.rb +64 -20
- data/Plugins/Apps/Vaultwarden/Vaultwarden.conf.erb +9 -6
- data/Plugins/Apps/Vaultwarden/Vaultwarden.container +7 -1
- data/Plugins/Apps/Vaultwarden/Vaultwarden.lmm.rb +67 -28
- data/Plugins/Apps/Wiki.js/Wiki.js.conf.erb +39 -0
- data/Plugins/Apps/Wiki.js/Wiki.js.container +20 -0
- data/Plugins/Apps/Wiki.js/Wiki.js.lmm.rb +55 -0
- data/Plugins/Apps/YaCy/YaCy.conf.erb +93 -0
- data/Plugins/Apps/YaCy/YaCy.container +21 -0
- data/Plugins/Apps/YaCy/YaCy.lmm.rb +160 -0
- data/Plugins/Apps/ZooKeeper/ZooKeeper.container +24 -0
- data/Plugins/Apps/ZooKeeper/ZooKeeper.lmm.rb +68 -0
- data/Plugins/Apps/bitmagnet/bitmagnet.conf.erb +0 -3
- data/Plugins/Apps/bitmagnet/bitmagnet.lmm.rb +0 -1
- data/Plugins/Apps/gollum/gollum.conf.erb +40 -4
- data/Plugins/Apps/gollum/gollum.container +10 -1
- data/Plugins/Apps/gollum/gollum.lmm.rb +56 -47
- data/Plugins/Apps/llama.cpp/llama.cpp.container +28 -0
- data/Plugins/Apps/llama.cpp/llama.cpp.lmm.rb +90 -0
- data/Plugins/Apps/vLLM/vLLM.container +32 -0
- data/Plugins/Apps/vLLM/vLLM.lmm.rb +89 -0
- data/Plugins/OS/General/Utils.lmm.rb +26 -0
- data/Plugins/OS/Linux/Connection.rb +472 -0
- data/Plugins/OS/Linux/Debian/preseed.cfg.erb +81 -0
- data/Plugins/OS/Linux/Distributions.yaml +32 -0
- data/Plugins/OS/Linux/Flavours.yaml +24 -0
- data/Plugins/OS/Linux/Grub/grub.cfg +10 -0
- data/Plugins/OS/Linux/HTTP.rb +32 -0
- data/Plugins/OS/Linux/Linux.lmm.rb +708 -174
- data/Plugins/OS/Linux/Packages.yaml +67 -3
- data/Plugins/OS/Linux/Proxmox/answer.toml.erb +30 -0
- data/Plugins/OS/Linux/Services.yaml +8 -0
- data/Plugins/OS/Linux/Shell.rb +70 -0
- data/Plugins/OS/Linux/Syslinux/default +8 -0
- data/Plugins/OS/Linux/WireGuard/WireGuard.lmm.rb +93 -40
- data/Plugins/OS/Linux/WireGuard/wg0.conf.erb +3 -0
- data/Plugins/OS/Linux/openSUSE/autoinst.xml.erb +29 -3
- data/Plugins/OS/Linux/systemd/systemd.lmm.rb +13 -11
- data/Plugins/OS/Routers/Aruba/ArubaInstant.lmm.rb +6 -5
- data/Plugins/Platforms/GitHub.lmm.rb +73 -28
- data/Plugins/Platforms/GoDaddy/GoDaddy.lmm.rb +10 -7
- data/Plugins/Platforms/Proxmox/Proxmox.lmm.rb +402 -0
- data/Plugins/Platforms/Proxmox/XTerm.rb +321 -0
- data/Plugins/Platforms/libvirt/libvirt.lmm.rb +41 -15
- data/Plugins/Platforms/porkbun.lmm.rb +12 -2
- data/Plugins/Platforms/porkbun_spec.rb +2 -2
- data/Plugins/Services/DNS/AmberBit.lmm.rb +1 -1
- data/Plugins/Services/DNS/ArubaItDNS.lmm.rb +1 -1
- data/Plugins/Services/DNS/NICLV.lmm.rb +1 -1
- data/Plugins/Services/DNS/PowerDNS.lmm.rb +130 -41
- data/Plugins/Services/DNS/tonic.lmm.rb +22 -12
- data/bootstrap.sh +41 -3
- data/lib/ConfigLMM/Framework/plugins/dns.rb +4 -3
- data/lib/ConfigLMM/Framework/plugins/linuxApp.rb +187 -144
- data/lib/ConfigLMM/Framework/plugins/nginxApp.rb +54 -6
- data/lib/ConfigLMM/Framework/plugins/plugin.rb +68 -140
- data/lib/ConfigLMM/Framework/plugins/store.rb +4 -4
- data/lib/ConfigLMM/Framework/variables.rb +75 -0
- data/lib/ConfigLMM/Framework.rb +1 -0
- data/lib/ConfigLMM/cli.rb +13 -5
- data/lib/ConfigLMM/commands/cleanup.rb +1 -0
- data/lib/ConfigLMM/commands/configsCommand.rb +38 -5
- data/lib/ConfigLMM/commands/diff.rb +33 -9
- data/lib/ConfigLMM/context.rb +22 -3
- data/lib/ConfigLMM/io/configList.rb +85 -7
- data/lib/ConfigLMM/io/connection.rb +143 -0
- data/lib/ConfigLMM/io/dhcp.rb +330 -0
- data/lib/ConfigLMM/io/http.rb +78 -0
- data/lib/ConfigLMM/io/local.rb +207 -0
- data/lib/ConfigLMM/io/pxe.rb +92 -0
- data/lib/ConfigLMM/io/ssh.rb +156 -0
- data/lib/ConfigLMM/io/tftp.rb +105 -0
- data/lib/ConfigLMM/io.rb +2 -0
- data/lib/ConfigLMM/secrets/envStore.rb +39 -0
- data/lib/ConfigLMM/secrets/fileStore.rb +43 -0
- data/lib/ConfigLMM/state.rb +12 -3
- data/lib/ConfigLMM/version.rb +2 -1
- data/lib/ConfigLMM.rb +1 -0
- data/{Examples → scripts}/configlmmAuth.sh +7 -5
- metadata +257 -9
@@ -11,44 +11,40 @@ module ConfigLMM
|
|
11
11
|
raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
|
12
12
|
|
13
13
|
target['Database'] ||= {}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
path
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
self.class.prepareNginxConfig(target, ssh)
|
40
|
-
self.writeNginxConfig(__dir__, 'Peppermint', id, target, state, context, options)
|
41
|
-
self.deployNginxConfig(id, target, activeState, context, options)
|
42
|
-
Framework::LinuxApp.startServiceOverSSH(NGINX_PACKAGE, ssh)
|
14
|
+
self.withConnection(target['Location'], target) do |connection|
|
15
|
+
Linux.withConnection(connection) do |linuxConnection|
|
16
|
+
dbPassword = self.configurePostgreSQL(target['Database'], linuxConnection, options)
|
17
|
+
|
18
|
+
Podman.ensurePresent(linuxConnection, options)
|
19
|
+
Podman.createUser(USER, HOME_DIR, 'Peppermint Ticket Management', linuxConnection, options)
|
20
|
+
path = Podman.containersPath(HOME_DIR)
|
21
|
+
|
22
|
+
linuxConnection.fileWrite("#{path}/Peppermint.env", "DB_HOST=#{HOST_IP}", options)
|
23
|
+
linuxConnection.fileAppend("#{path}/Peppermint.env", "DB_USERNAME=#{USER}", options)
|
24
|
+
linuxConnection.fileAppend("#{path}/Peppermint.env", "DB_PASSWORD=#{dbPassword}", { **options, hide: true })
|
25
|
+
linuxConnection.fileAppend("#{path}/Peppermint.env", "SECRET=#{SecureRandom.urlsafe_base64(60)}", { **options, hide: true })
|
26
|
+
linuxConnection.fileAppend("#{path}/Peppermint.env", "API_URL=https://#{target['Domain']}/api", options)
|
27
|
+
|
28
|
+
linuxConnection.setUserGroup("#{path}/Peppermint.env", USER, USER, options)
|
29
|
+
linuxConnection.setPrivate("#{path}/Peppermint.env", options)
|
30
|
+
|
31
|
+
linuxConnection.upload(__dir__ + '/Peppermint.container', path, options)
|
32
|
+
|
33
|
+
linuxConnection.reloadUserServices(USER, options)
|
34
|
+
linuxConnection.restartUserService(USER, 'Peppermint', options)
|
35
|
+
|
36
|
+
Nginx.withConnection(linuxConnection) do |nginxConnection|
|
37
|
+
nginxConnection.provision(__dir__, 'Peppermint', target, activeState, context, options)
|
38
|
+
end
|
43
39
|
end
|
44
|
-
else
|
45
|
-
# TODO
|
46
40
|
end
|
47
41
|
end
|
48
42
|
|
49
|
-
def configurePostgreSQL(
|
43
|
+
def configurePostgreSQL(dbSettings, linuxConnection, options)
|
50
44
|
password = SecureRandom.alphanumeric(20)
|
51
|
-
PostgreSQL.
|
45
|
+
PostgreSQL.withConnection(dbSettings, linuxConnection) do |postgresConnection|
|
46
|
+
postgresConnection.createUserAndDB(USER, password, options)
|
47
|
+
end
|
52
48
|
password
|
53
49
|
end
|
54
50
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
[Unit]
|
3
|
+
Description=Perplexica container
|
4
|
+
After=local-fs.target
|
5
|
+
|
6
|
+
[Container]
|
7
|
+
ContainerName=Perplexica
|
8
|
+
Image=docker.io/itzcrazykns1337/perplexica:main
|
9
|
+
EnvironmentFile=/var/lib/perplexica/.config/containers/systemd/Perplexica.env
|
10
|
+
Network=slirp4netns:allow_host_loopback=true
|
11
|
+
PublishPort=127.0.0.1:13500:3000
|
12
|
+
UserNS=keep-id:uid=1000,gid=1000
|
13
|
+
Volume=/var/lib/perplexica/data:/home/perplexica/data
|
14
|
+
Volume=/var/lib/perplexica/uploads:/home/perplexica/uploads
|
15
|
+
Volume=/var/lib/perplexica/config.toml:/home/perplexica/config.toml
|
16
|
+
|
17
|
+
LogDriver=journald
|
18
|
+
AutoUpdate=registry
|
19
|
+
|
20
|
+
[Service]
|
21
|
+
TimeoutStartSec=6min
|
22
|
+
Restart=on-failure
|
23
|
+
|
24
|
+
[Install]
|
25
|
+
WantedBy=multi-user.target default.target
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
module ConfigLMM
|
3
|
+
module LMM
|
4
|
+
class Perplexica < Framework::Plugin
|
5
|
+
|
6
|
+
USER = 'perplexica'
|
7
|
+
HOME_DIR = '/var/lib/perplexica'
|
8
|
+
|
9
|
+
def actionPerplexicaDeploy(id, target, activeState, context, options)
|
10
|
+
|
11
|
+
self.withConnection(target['Location'], target) do |connection|
|
12
|
+
Linux.withConnection(connection) do |linuxConnection|
|
13
|
+
Podman.ensurePresent(linuxConnection, options)
|
14
|
+
Podman.createUser(USER, HOME_DIR, 'Perplexica', linuxConnection, options)
|
15
|
+
linuxConnection.withUserShell(USER) do |shell|
|
16
|
+
shell.createDirs(options, '~/data', '~/uploads')
|
17
|
+
end
|
18
|
+
|
19
|
+
linuxConnection.upload(__dir__ + '/config.toml', HOME_DIR, options)
|
20
|
+
|
21
|
+
grokKey = target['GrokSecretId'] ? context.secrets.load(target['GrokSecretId'], 'API_KEY') : nil
|
22
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$GROQ_KEY', grokKey, options)
|
23
|
+
|
24
|
+
anthropicKey = target['AnthropicSecretId'] ? context.secrets.load(target['AnthropicSecretId'], 'API_KEY') : nil
|
25
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$ANTHROPIC_KEY', anthropicKey, options)
|
26
|
+
|
27
|
+
geminiKey = target['GeminiSecretId'] ? context.secrets.load(target['GeminiSecretId'], 'API_KEY') : nil
|
28
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$GEMINI_KEY', geminiKey, options)
|
29
|
+
|
30
|
+
deepseekKey = target['DeepSeekSecretId'] ? context.secrets.load(target['DeepSeekSecretId'], 'API_KEY') : nil
|
31
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$DEEPSEEK_KEY', deepseekKey, options)
|
32
|
+
|
33
|
+
openaiKey = nil
|
34
|
+
openaiURL = nil
|
35
|
+
openaiModel = nil
|
36
|
+
if target['OpenAI'] && !target['OpenAI'].to_h.empty?
|
37
|
+
openaiKey = target['OpenAI']['SecretId'] ? context.secrets.load(target['OpenAI']['SecretId'], 'API_KEY') : nil
|
38
|
+
openaiURL = Podman.updateURL(target['OpenAI']['URL']) unless target['OpenAI']['URL'].to_s.empty?
|
39
|
+
openaiModel = target['OpenAI']['Model']
|
40
|
+
end
|
41
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$OPENAI_KEY', openaiKey, options)
|
42
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$OPENAI_URL', openaiURL, options)
|
43
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$OPENAI_MODEL', openaiModel, options)
|
44
|
+
|
45
|
+
ollamaURL = nil
|
46
|
+
if target['Ollama'] && !target['Ollama'].to_h.empty?
|
47
|
+
ollamaURL = Podman.updateURL(target['Ollama']['URL'], Ollama::PORT)
|
48
|
+
end
|
49
|
+
linuxConnection.fileReplace("#{HOME_DIR}/config.toml", '\$OLLAMA_URL', ollamaURL, options)
|
50
|
+
|
51
|
+
linuxConnection.setUserGroup("#{HOME_DIR}/config.toml", USER, USER, options)
|
52
|
+
|
53
|
+
path = Podman.containersPath(HOME_DIR)
|
54
|
+
|
55
|
+
searxng = Podman.updateURL(target['SearXNG'], SearXNG::PORT)
|
56
|
+
|
57
|
+
linuxConnection.fileWrite("#{path}/Perplexica.env", "SEARXNG_API_URL=#{searxng}", options)
|
58
|
+
|
59
|
+
linuxConnection.setUserGroup("#{path}/Perplexica.env", USER, USER, options)
|
60
|
+
linuxConnection.setPrivate("#{path}/Perplexica.env", options)
|
61
|
+
|
62
|
+
linuxConnection.upload(__dir__ + '/Perplexica.container', path, options)
|
63
|
+
|
64
|
+
linuxConnection.reloadUserServices(USER, options)
|
65
|
+
linuxConnection.restartUserService(USER, 'Perplexica', options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def cleanup(configs, state, context, options)
|
71
|
+
cleanupType(:Perplexica, configs, state, context, options) do |item, id, state, context, options, connection|
|
72
|
+
Linux.withConnection(connection) do |linuxConnection|
|
73
|
+
|
74
|
+
linuxConnection.stopUserService(USER, 'Perplexica', options)
|
75
|
+
|
76
|
+
path = Podman.containersPath(HOME_DIR)
|
77
|
+
linuxConnection.rm(path + '/Perplexica.container', options[:dry])
|
78
|
+
|
79
|
+
state.item(id)['Status'] = State::STATUS_DELETED unless options[:dry]
|
80
|
+
|
81
|
+
if options[:destroy]
|
82
|
+
linuxConnection.deleteUserAndGroup(USER, options)
|
83
|
+
state.item(id)['Status'] = State::STATUS_DESTROYED unless options[:dry]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
[GENERAL]
|
2
|
+
SIMILARITY_MEASURE = "cosine" # "cosine" or "dot"
|
3
|
+
KEEP_ALIVE = "5m" # How long to keep Ollama models loaded into memory. (Instead of using -1 use "-1m")
|
4
|
+
|
5
|
+
[MODELS.OPENAI]
|
6
|
+
API_KEY = "$OPENAI_KEY"
|
7
|
+
|
8
|
+
[MODELS.GROQ]
|
9
|
+
API_KEY = "$GROQ_KEY"
|
10
|
+
|
11
|
+
[MODELS.ANTHROPIC]
|
12
|
+
API_KEY = "$ANTHROPIC_KEY"
|
13
|
+
|
14
|
+
[MODELS.GEMINI]
|
15
|
+
API_KEY = "$GEMINI_KEY"
|
16
|
+
|
17
|
+
[MODELS.CUSTOM_OPENAI]
|
18
|
+
API_KEY = "$OPENAI_KEY"
|
19
|
+
API_URL = "$OPENAI_URL"
|
20
|
+
MODEL_NAME = "$OPENAI_MODEL"
|
21
|
+
|
22
|
+
[MODELS.OLLAMA]
|
23
|
+
API_URL = "$OLLAMA_URL" # Ollama API URL
|
24
|
+
|
25
|
+
[MODELS.DEEPSEEK]
|
26
|
+
API_KEY = "$DEEPSEEK_KEY"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module ConfigLMM
|
3
|
+
module LMM
|
4
|
+
class PodmanConnection
|
5
|
+
|
6
|
+
attr_reader :connection
|
7
|
+
|
8
|
+
def initialize(connection, container)
|
9
|
+
@connection = connection
|
10
|
+
@container = container
|
11
|
+
end
|
12
|
+
|
13
|
+
def exec(command, allowFailure = false, options = {})
|
14
|
+
workdir = ''
|
15
|
+
if options[:workdir]
|
16
|
+
workdir = "--workdir #{options[:workdir].shellescape}"
|
17
|
+
end
|
18
|
+
cmd = "podman exec #{workdir} #{@container['Id'].shellescape} sh -c '#{LinuxShell.escapeSingleQuotes(command)}'"
|
19
|
+
@connection.exec(cmd, allowFailure, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative 'Connection'
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module ConfigLMM
|
6
|
+
module LMM
|
7
|
+
class Podman < Framework::Plugin
|
8
|
+
|
9
|
+
PACKAGE_NAME = 'Podman'
|
10
|
+
SYSTEM_CONTAINERS_PATH = '/etc/containers/systemd'
|
11
|
+
USER_CONTAINERS_PATH = '~/.config/containers/systemd'
|
12
|
+
HOST_IP = '10.0.2.2'
|
13
|
+
|
14
|
+
def self.ensurePresent(linuxConnection, options = {})
|
15
|
+
linuxConnection.ensurePackage(PACKAGE_NAME, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.container(name, connection, options = {})
|
19
|
+
result = connection.exec("podman ps --format json --filter name='^#{name}$'", false, { **options, dry: false }).strip
|
20
|
+
containers = JSON.parse(result)
|
21
|
+
raise "Failed to find container #{name}!" if containers.empty?
|
22
|
+
containers.first
|
23
|
+
rescue JSON::ParserError => error
|
24
|
+
return { 'Id' => name } if options['dry']
|
25
|
+
raise error
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.withConnection(connection, container)
|
29
|
+
yield(PodmanConnection.new(connection, container))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.run(imageId, name, cmd, linuxConnection, options)
|
33
|
+
linuxConnection.exec("podman run --name #{name} --replace --rm -it #{imageId} #{cmd}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.createUser(user, homedir, userComment, linuxConnection, options)
|
37
|
+
linuxConnection.createServiceUser(user, homedir, userComment, options)
|
38
|
+
linuxConnection.createSubuids(user, options)
|
39
|
+
linuxConnection.enableLinger(user, options)
|
40
|
+
linuxConnection.withUserShell(user) do |shell|
|
41
|
+
shell.createDirs(options, USER_CONTAINERS_PATH)
|
42
|
+
end
|
43
|
+
# This is a workaround for performance issue with Podman --userns keep-id
|
44
|
+
# See https://github.com/containers/podman/issues/16541
|
45
|
+
linuxConnection.upload(__dir__ + '/storage.conf', homedir + '/.config/containers/', options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.loadImage(userShell, imageFile, options = {})
|
49
|
+
cmd = "podman image load --input '#{imageFile.shellescape}'"
|
50
|
+
userShell.exec(cmd, false, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.removeImage(userShell, imageFile, options = {})
|
54
|
+
cmd = "podman image rm --ignore '#{imageFile.shellescape}'"
|
55
|
+
userShell.exec(cmd, false, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.containersPath(homeDir = nil)
|
59
|
+
if homeDir.nil?
|
60
|
+
SYSTEM_CONTAINERS_PATH
|
61
|
+
else
|
62
|
+
USER_CONTAINERS_PATH.gsub('~', homeDir)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.updateHost(host)
|
67
|
+
host = HOST_IP if host.to_s.empty? || ['localhost', '127.0.0.1', '::1'].include?(host)
|
68
|
+
host
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.updateURL(url, defaultPort = nil)
|
72
|
+
uri = URI.parse(url.to_s)
|
73
|
+
uri.scheme = 'http' unless uri.scheme
|
74
|
+
uri.port = defaultPort if !uri.port && defaultPort
|
75
|
+
uri.host = self.updateHost(uri.host)
|
76
|
+
uri.to_s
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|