ConfigLMM 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e1dcd8d8d61d199700f39e2298c45ffaedfcb12822a833ebd16423120c4526c
4
- data.tar.gz: ea7e2be4c9ea59a2babe325a8d63c1440aae67f147106d4b30e17839c0d6abda
3
+ metadata.gz: a8ee6e7ca0b1e3cf4dd9e1007aa696d763ab522c2c1cfc4a401e55ccdeefc4e3
4
+ data.tar.gz: 71c10651774b7c6ce347cf3fe9bc2df08ca388244ad8cf0cdbaa77c1f8beb1a7
5
5
  SHA512:
6
- metadata.gz: 32fcd1db26c56ce7787a4515ce1d653cf96cf9a812f56ac7bcaa94465bcad4fa0a3082f2420cf6bdea7ae7b8e6229c8d416b3be7e4157eb37d3ea11cd4c7a42c
7
- data.tar.gz: fcd652884fe0f191739e830315da87f066507fd719e38b60bdfeb35030116de97ac9eaabf913b9e75f2e33c95a85dafc77539eba985be6968a80f136d545c186
6
+ metadata.gz: 17cc1304b94186312fd2c25779234ba4c0354c8dfcc971eeff5d000ebdb1d29138f7decfa5f175f154cbc1174d6e3b5ef3f7077caa8013d53a493c8c2a7ccf7d
7
+ data.tar.gz: 50b169c6147cbd7b02da3e0fc3b264b09271bb83813330196a546da4d976c5071b2d53e534e47512fca85927ea5201e1f085b10601febcfaacf0d41ffec7c362
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
- ## [Unreleased]
1
+
2
+ ## [0.2.0] - 2024-07-19
3
+
4
+ - openSUSE - https://www.opensuse.org/
5
+ - libvirt - https://libvirt.org/
6
+ - More Linux configs (including SSH)
7
+ - postfix - https://www.postfix.org/
8
+ - PostgreSQL - https://www.postgresql.org/
2
9
 
3
10
  ## [0.1.0] - 2024-06-06
4
11
 
5
12
  - Initial release
13
+ - PorkbunDNS - https://porkbun.com/
14
+ - TonicDNS - https://www.tonic.to/
15
+ - PowerDNS - https://www.powerdns.com/
16
+ - GoDaddy - https://www.godaddy.com/
17
+ - Linux
18
+ - ArubaInstant - https://www.arubanetworks.com/
19
+ - ArchiSteamFarm - https://github.com/JustArchiNET/ArchiSteamFarm
20
+ - Bitmagnet - https://bitmagnet.io/
21
+ - Gollum - https://github.com/gollum/gollum
22
+ - Grafana - https://grafana.com/
23
+ - IPFS - https://ipfs.tech/
24
+ - InfluxDB - https://www.influxdata.com/
25
+ - Jackett - https://github.com/Jackett/Jackett/
26
+ - Jellyfin - https://jellyfin.org/
27
+ - Mastodon - https://github.com/mastodon/mastodon
28
+ - Matrix - https://matrix.org/
29
+ - Netdata - https://www.netdata.cloud/
30
+ - Nextcloud - https://nextcloud.com/
31
+ - Odoo - https://www.odoo.com/
32
+ - Pterodactyl - https://pterodactyl.io/
33
+ - qBittorrent - https://www.qbittorrent.org/
34
+ - Scrutiny - https://github.com/AnalogJ/scrutiny
35
+ - Sunshine - https://app.lizardbyte.dev/Sunshine/
36
+ - Vaultwarden - https://github.com/dani-garcia/vaultwarden
@@ -43,9 +43,32 @@ GoDaddy:
43
43
 
44
44
  Linux:
45
45
  Type: Linux
46
+ Location: qemu:///session
47
+ AlternativeLocation: ssh://example.org/
48
+ Distro: openSUSE Leap
49
+ CPU: 2
50
+ RAM: 4 GiB
51
+ Storage: 30 GiB
52
+ Domain: example.org
46
53
  Hosts:
47
54
  127.0.0.1:
48
55
  - example.org
56
+ Apps:
57
+ - sshd
58
+ - fish
59
+ - vim
60
+ Users:
61
+ root:
62
+ Shell: fish
63
+ AuthorizedKeys:
64
+ - ~/.ssh/id_ed25519.pub
65
+ SSH:
66
+ Config:
67
+ Example:
68
+ User: root
69
+ HostName: example.org
70
+ Sysctl:
71
+ vm.overcommit_memory: 1
49
72
 
50
73
  # https://www.arubanetworks.com/
51
74
  ArubaInstant:
@@ -63,6 +86,10 @@ Bitmagnet:
63
86
  Type: Bitmagnet
64
87
  Domain: bitmagnet.example.org
65
88
 
89
+ Dovecot:
90
+ Type: Dovecot
91
+ Location: ssh://example.org/
92
+
66
93
  # https://github.com/gollum/gollum
67
94
  Gollum:
68
95
  Type: Gollum
@@ -120,6 +147,20 @@ Odoo:
120
147
  Type: Odoo
121
148
  Domain: odoo.example.org
122
149
 
150
+ # https://www.postfix.org/
151
+ Postfix:
152
+ Type: Postfix
153
+ Location: ssh://example.org/
154
+ AlternativePort: 2525
155
+ ForwardAll: example.com
156
+ Settings:
157
+ inet_interfaces: $myhostname, localhost
158
+
159
+ PostgreSQL:
160
+ Type: PostgreSQL
161
+ Location: ssh://example.org/
162
+ ListenAll: yes
163
+
123
164
  # https://pterodactyl.io/
124
165
  Pterodactyl:
125
166
  Type: Pterodactyl
@@ -149,6 +190,11 @@ Sunshine:
149
190
  Type: Sunshine
150
191
  Domain: sunshine.example.org
151
192
 
193
+ # https://valkey.io/ (Redis fork)
194
+ Valkey:
195
+ Type: Valkey
196
+ Location: ssh://example.org/
197
+
152
198
  # https://github.com/dani-garcia/vaultwarden
153
199
  Vaultwarden:
154
200
  Type: Vaultwarden
data/Examples/Keys.ini CHANGED
@@ -1,6 +1,8 @@
1
1
  ARUBA_INSTANT_PASSWORD=
2
2
  GITHUB_TOKEN=
3
3
  GODADDY_SECRET=
4
+ LINUX_ROOT_PASSWORD=
5
+ LINUX_ROOT_PASSWORD_HASH=
4
6
  PORKBUN_API_KEY=
5
7
  PORKBUN_SECRET_API_KEY=
6
8
  POWERDNS_API_KEY=
@@ -1,16 +1,27 @@
1
1
  Linux:
2
- Type: ArchLinux
2
+ Type: Linux
3
+ Distro: ArchLinux
3
4
  Apps:
4
5
  - fish
5
6
  - vim
6
7
  Users:
7
- - user1:
8
+ user1:
8
9
  Admin: Yes
9
10
  Shell: fish
10
- - user2:
11
+ AuthorizedKeys:
12
+ - ~/.ssh/id_ed25519.pub
13
+ user2:
11
14
  Admin: Yes
12
15
  Shell: fish
13
16
  Comment: Other user
17
+ Domain: example.org
14
18
  Hosts:
15
19
  127.0.0.1:
16
20
  - example.org
21
+ SSH:
22
+ Config:
23
+ Example:
24
+ User: root
25
+ HostName: example.org
26
+ Sysctl:
27
+ vm.overcommit_memory: 1
Binary file
Binary file
@@ -0,0 +1,17 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class Dovecot < Framework::Plugin
5
+ PACKAGE_NAME = 'Dovecot'
6
+ SERVICE_NAME = 'dovecot'
7
+
8
+ def actionDovecotDeploy(id, target, activeState, context, options)
9
+ plugins[:Linux].ensurePackage(PACKAGE_NAME, target['Location'])
10
+ plugins[:Linux].ensureServiceAutoStart(SERVICE_NAME, target['Location'])
11
+ plugins[:Linux].startService(SERVICE_NAME, target['Location'])
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -21,7 +21,7 @@ error_page 521 /_errors_/HTTP521.$errorExtension;
21
21
  error_page 533 /_errors_/HTTP533.$errorExtension;
22
22
 
23
23
  location /_errors_/ {
24
- include config/public.conf;
24
+ include config-lmm/public.conf;
25
25
 
26
26
  alias /srv/http/errors/;
27
27
  internal;
@@ -0,0 +1,4 @@
1
+
2
+ # Security / XSS Mitigation Headers
3
+ add_header X-Frame-Options "DENY";
4
+ add_header X-Content-Type-Options "nosniff";
@@ -0,0 +1,76 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class Postfix < Framework::Plugin
5
+ PACKAGE_NAME = 'Postfix'
6
+ SERVICE_NAME = 'postfix'
7
+ MASTER_FILE = '/etc/postfix/master.cf'
8
+ MAIN_FILE = '/etc/postfix/main.cf'
9
+ TRANSPORT_FILE = '/etc/postfix/transport'
10
+
11
+ def actionPostfixDeploy(id, target, activeState, context, options)
12
+ plugins[:Linux].ensurePackage(PACKAGE_NAME, target['Location'])
13
+ plugins[:Linux].ensureServiceAutoStart(SERVICE_NAME, target['Location'])
14
+
15
+ deploySettings(target, target['Location'], options)
16
+
17
+ plugins[:Linux].startService(SERVICE_NAME, target['Location'])
18
+ end
19
+
20
+ def deploySettings(target, location, options)
21
+ if location && location != '@me'
22
+ if target['AlternativePort']
23
+ updateRemoteFile(location, MASTER_FILE, options, true) do |fileLines|
24
+ fileLines << "#{target['AlternativePort']} inet n - n - - smtpd\n"
25
+ end
26
+ end
27
+ self.class.sshStart(location) do |ssh|
28
+ domain = self.class.sshExec!(ssh, "hostname --fqdn").strip
29
+ command = "sed -i 's|^myhostname = .*|myhostname = #{domain}|' #{MAIN_FILE}"
30
+ command = "sed -i 's|^#myhostname = virtual.domain.tld|myhostname = #{domain}|' #{MAIN_FILE}"
31
+ self.class.sshExec!(ssh, command)
32
+ end
33
+ if target['Settings']
34
+ target['Settings'].each do |name, value|
35
+ self.class.sshStart(location) do |ssh|
36
+ command = "sed -i 's|^#{name} =.*|#{name} = #{value}|' #{MAIN_FILE}"
37
+ self.class.sshExec!(ssh, command)
38
+ end
39
+ end
40
+ end
41
+ if target['ForwardAll']
42
+ updateRemoteFile(location, TRANSPORT_FILE, options, true) do |fileLines|
43
+ hostname, port = target['ForwardAll'].split(':')
44
+ hostname = '[' + hostname + ']'
45
+ line = '* smtp:' + hostname
46
+ line += ':' + port if port
47
+ fileLines << line + "\n"
48
+ end
49
+ self.class.sshStart(location) do |ssh|
50
+ self.class.sshExec!(ssh, "postmap #{TRANSPORT_FILE}")
51
+ end
52
+ end
53
+ else
54
+ if target['AlternativePort']
55
+ updateLocalFile(MASTER_FILE, options, true) do |fileLines|
56
+ fileLines << "#{target['AlternativePort']} inet n - n - - smtpd\n"
57
+ end
58
+ end
59
+ if target['Settings']
60
+ target['Settings'].each do |name, value|
61
+ `sed -i 's|^#{name} =.*|#{name} = #{value}|' #{MAIN_FILE}`
62
+ end
63
+ end
64
+ if target['ForwardAll']
65
+ updateLocalFile(TRANSPORT_FILE, options, true) do |fileLines|
66
+ fileLines << '* smtp:[' + target['ForwardAll'] + "]\n"
67
+ end
68
+ `postmap #{TRANSPORT_FILE}`
69
+ end
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,76 @@
1
+
2
+ require_relative '../../OS/Linux/Linux.lmm.rb'
3
+
4
+ module ConfigLMM
5
+ module LMM
6
+ class PostgreSQL < Framework::LinuxApp
7
+ PACKAGE_NAME = 'PostgreSQL'
8
+ SERVICE_NAME = 'postgresql'
9
+ USER_NAME = 'postgres'
10
+
11
+ HBA_FILE = 'data/pg_hba.conf'
12
+ CONFIG_FILE = 'data/postgresql.conf'
13
+
14
+ def actionPostgreSQLDeploy(id, target, activeState, context, options)
15
+ self.ensurePackage(PACKAGE_NAME, target['Location'])
16
+ self.ensureServiceAutoStart(SERVICE_NAME, target['Location'])
17
+
18
+ if target['Location'] && target['Location'] != '@me'
19
+ uri = Addressable::URI.parse(target['Location'])
20
+ raise Framework::PluginProcessError.new("#{id}: Unknown Protocol: #{uri.scheme}!") if uri.scheme != 'ssh'
21
+ if target['ListenAll']
22
+ cmd = "sed -i 's|^host all all 127.0.0.1/32 ident|host all all 0.0.0.0/0 scram-sha-256|'"
23
+ dir = updateConfigOverSSH(uri, cmd)
24
+ updateRemoteFile(uri, dir + CONFIG_FILE, options, false) do |configLines|
25
+ configLines << "listen_addresses = '*'\n"
26
+ end
27
+ else
28
+ cmd = "sed -i 's|^host all all 127.0.0.1/32 ident|host all all 127.0.0.1/32 scram-sha-256|'"
29
+ updateConfigOverSSH(uri, cmd)
30
+ end
31
+ else
32
+ dir = pgsqlDir(self.class.distroID)
33
+ if target['ListenAll']
34
+ `sed -i 's|^host all all 127.0.0.1/32 ident|host all all 0.0.0.0/0 scram-sha-256|' #{dir + HBA_FILE}`
35
+ updateLocalFile(dir + CONFIG_FILE, options) do |configLines|
36
+ configLines << "listen_addresses = '*'"
37
+ end
38
+ else
39
+ `sed -i 's|^host all all 127.0.0.1/32 ident|host all all 127.0.0.1/32 scram-sha-256|' #{dir + HBA_FILE}`
40
+ end
41
+ end
42
+
43
+ self.startService(SERVICE_NAME, target['Location'])
44
+ end
45
+
46
+ def updateConfigOverSSH(uri, cmd)
47
+ dir = ''
48
+ self.class.sshStart(uri) do |ssh|
49
+ distroID = self.class.distroIDfromSSH(ssh)
50
+ dir = pgsqlDir(distroID)
51
+ self.class.sshExec!(ssh, cmd + ' ' + dir + HBA_FILE)
52
+ end
53
+ dir
54
+ end
55
+
56
+ def self.createUserAndDBOverSSH(user, password, ssh)
57
+ self.sshExec!(ssh, "su --login #{USER_NAME} --command 'createuser #{user}'", true)
58
+ self.sshExec!(ssh, "su --login #{USER_NAME} --command 'createdb --owner=#{user} #{user}'", true)
59
+ cmd = " su --login #{USER_NAME} --command ' psql -c \"ALTER USER #{user} WITH PASSWORD \\'#{password}\\';\"'"
60
+ self.sshExec!(ssh, cmd)
61
+ end
62
+
63
+ def pgsqlDir(distroID)
64
+ if distroID == 'opensuse-leap'
65
+ '/var/lib/pgsql/'
66
+ elsif distroID == 'arch'
67
+ '/var/lib/postgres/'
68
+ else
69
+ raise Framework::PluginProcessError.new("Unknown Linux Distro: #{distroID}!")
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,55 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class Valkey < Framework::LinuxApp
5
+ PACKAGE_NAME = 'Valkey'
6
+ CONFIG_FILE = '/etc/redis/redis.conf'
7
+ PID_FILE = '/run/redis/redis.pid'
8
+
9
+ def actionValkeyDeploy(id, target, activeState, context, options)
10
+ self.ensurePackage(PACKAGE_NAME, target['Location'])
11
+
12
+ serviceName = 'redis'
13
+
14
+ if target['Location'] && target['Location'] != '@me'
15
+ self.class.sshStart(target['Location']) do |ssh|
16
+ distroId = self.class.distroIDfromSSH(ssh)
17
+ if distroId == SUSE_ID
18
+ serviceName = 'redis@redis'
19
+ self.class.sshExec!(ssh, "touch #{CONFIG_FILE}")
20
+
21
+ target['Settings'] ||= {}
22
+ target['Settings']['pidfile'] = PID_FILE
23
+ target['Settings']['supervised'] = 'systemd'
24
+ target['Settings']['dir'] = '/var/lib/redis/default/'
25
+ end
26
+
27
+ if target['Settings']
28
+ updateRemoteFile(ssh, CONFIG_FILE, options, false) do |configLines|
29
+ target['Settings'].each do |name, value|
30
+ configLines << "#{name} #{value}\n"
31
+ end
32
+ configLines
33
+ end
34
+ end
35
+ end
36
+ else
37
+ if target['Settings']
38
+ `touch #{CONFIG_FILE}`
39
+ updateLocalFile(CONFIG_FILE, options) do |configLines|
40
+ target['Settings'].each do |name, value|
41
+ configLines << "#{name} #{value}\n"
42
+ end
43
+ configLines
44
+ end
45
+ end
46
+ end
47
+
48
+ self.ensureServiceAutoStart(serviceName, target['Location'])
49
+ self.startService(serviceName, target['Location'])
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+
2
+ opensuse-leap:
3
+ Name: openSUSE Leap
4
+ InstallPackage: zypper install --no-confirm
5
+ AutoStartService: systemctl enable
6
+ StartService: systemctl start