Compare commits
192 commits
oldstable/
...
master
Author | SHA1 | Date | |
---|---|---|---|
59a0b086ff | |||
df4882c57d | |||
e41472b1c3 | |||
10b80ae3fd | |||
d2e1f428db | |||
001c5433ab | |||
0f72484966 | |||
b9565754ad | |||
6d8f0a8082 | |||
cb3e6a0d81 | |||
41d0cfb79e | |||
6178d31613 | |||
69d293eb11 | |||
61dc8203ac | |||
5ec693114f | |||
c71ab09614 | |||
91145dade2 | |||
e427bbbdaa | |||
70887e076c | |||
95d8935d6a | |||
da1c001330 | |||
7f1dc9e842 | |||
c530a5a36d | |||
b2c1b81262 | |||
9043b01d3a | |||
713c1800ec | |||
bb1c9f29eb | |||
4cd211da63 | |||
bd07e76d36 | |||
c64e5bcdcc | |||
a54d81fce7 | |||
2b1c1cd89e | |||
45a2c3e465 | |||
e50b94f6a5 | |||
0fff902b20 | |||
3fe9fa7886 | |||
2c574ef2c5 | |||
9bc36a0db9 | |||
560e82903b | |||
72dc7fed8d | |||
2c76821ff4 | |||
d8d2a5f7ef | |||
700a4ecf14 | |||
4b0cee8e84 | |||
1ca17e65e9 | |||
4d3385e1af | |||
057e93d8bf | |||
0706e73f28 | |||
5972218cc7 | |||
1fcb1fd13f | |||
82667c0c86 | |||
0d22ea8397 | |||
4ddca813a2 | |||
169c969b46 | |||
18e0454807 | |||
43c18520be | |||
596ecf346f | |||
fbfc842125 | |||
c19eac0344 | |||
81b5fffe51 | |||
4c163468f9 | |||
ce499f3d3b | |||
33d564268f | |||
ce02589fe2 | |||
5be819b1e0 | |||
|
fb821f8b68 | ||
|
cf623b3261 | ||
|
d575e98493 | ||
|
ad7c12712a | ||
|
6464bc170b | ||
|
1d83a8c9e7 | ||
|
6e020a8333 | ||
|
ed36fb8041 | ||
|
850d7a23eb | ||
|
eb9c52a19b | ||
|
f9748745dd | ||
|
4faa7f0541 | ||
|
b0ac9dc850 | ||
|
552908f0b9 | ||
|
84e8b6565e | ||
|
1dfa1991aa | ||
|
038932520f | ||
|
e4e98cd246 | ||
|
ce01fd7deb | ||
|
b495f8ffd5 | ||
|
77ccd7a161 | ||
|
5c9b6bd8eb | ||
|
013d209a5d | ||
|
97e033a6ca | ||
|
df84e679a1 | ||
|
1942b50e92 | ||
|
eb5197eb1c | ||
|
49e4b3a9d0 | ||
|
5dafb934d8 | ||
|
fd2cbc8d1d | ||
|
9fe2253e2d | ||
|
3fed00c6d2 | ||
|
6028bfad05 | ||
|
c88b9d6e3b | ||
|
1ee398f327 | ||
|
0bef59f023 | ||
|
a680351797 | ||
|
5dfb28dfd8 | ||
|
c1d1403ea3 | ||
|
c832e1ea81 | ||
|
e219ede7eb | ||
|
8d5bc2f8f2 | ||
|
20fe7f5b99 | ||
|
f1cc7be542 | ||
|
57e7f057c6 | ||
|
2dc09181ac | ||
|
6aa86cbd73 | ||
|
5f432e16c9 | ||
|
35da420376 | ||
|
51ac687063 | ||
|
3ff3f06683 | ||
|
bc08431e91 | ||
|
ec632c9e90 | ||
|
45478a247f | ||
|
11c0a1dfe6 | ||
|
2096e36845 | ||
|
459130293c | ||
|
3e3b4287db | ||
|
627400942b | ||
|
132ba0aee1 | ||
|
218910bb39 | ||
|
c26e6f8441 | ||
|
1e53d3b81c | ||
|
154249141b | ||
|
317f327b51 | ||
|
364f477f7d | ||
|
c8c08e774a | ||
|
0d35bc4902 | ||
|
6bdf4119c9 | ||
|
176e5bbb8a | ||
|
681e515d47 | ||
|
2da1116e9d | ||
|
600732234b | ||
|
5f1a9e63ba | ||
|
4e78606061 | ||
|
8978fea0b3 | ||
|
8046479308 | ||
|
1de665cd14 | ||
|
ab0306ba90 | ||
|
0a860df1bd | ||
|
aec4020088 | ||
|
7033162e4b | ||
|
e8e6ff3596 | ||
|
8b2f421084 | ||
|
ccf97b505c | ||
|
084ba2e892 | ||
|
a21f795f24 | ||
|
c34599d749 | ||
|
7acfbf8def | ||
|
970c6cc4a4 | ||
|
cc004b176c | ||
|
a6b88e120e | ||
|
76313c8eb8 | ||
|
eccd75219d | ||
|
0eb57aea9d | ||
|
df040cbc03 | ||
|
1816659ace | ||
|
cc2eea5338 | ||
|
52f3ed9546 | ||
|
d23e62b728 | ||
|
5dbb44b071 | ||
|
30fb007f67 | ||
|
6b990c0c13 | ||
|
62f44a1467 | ||
|
4fa3f90b3c | ||
|
dbb821ebec | ||
|
496dbfa78d | ||
|
e134269eb4 | ||
|
5e0a60b670 | ||
|
d2b5bb8c80 | ||
|
bb9bff45d2 | ||
|
e1e2b0cb77 | ||
|
c723fb437b | ||
|
481ba3610e | ||
|
d348e66c11 | ||
|
0c7bc4b9aa | ||
|
eecb262bb0 | ||
|
b2059ab35e | ||
|
a517390dd6 | ||
|
ac8223fd28 | ||
|
00ef89f319 | ||
|
d4e2253ea3 | ||
|
dedc587d54 | ||
|
43c5e34ab6 | ||
|
290bd13b97 | ||
|
3e954ef23b | ||
|
63872a229f |
65 changed files with 1231 additions and 150 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
serverspecific.sls
|
||||
system/files/systemupdate.sh
|
|
@ -1,9 +0,0 @@
|
|||
# Noveria Salt-State
|
||||
|
||||

|
||||
|
||||
This repository is for the master-less salt-statetree for the noveria host, running Fedora Server (insert latest version here).
|
||||
|
||||
It managed the complete system using the saltproject.
|
||||
|
||||
For further instructions, head to the official salt docs: https://docs.saltproject.io/en/latest/contents.html
|
25
apps/generate-motd/init.sls
Normal file
25
apps/generate-motd/init.sls
Normal file
|
@ -0,0 +1,25 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
|
||||
apps_generate-motd_git:
|
||||
git.latest:
|
||||
- name: https://git.noveria.org/Tools/generate_motd.git
|
||||
- target: {{ noveria.app_dir }}/generate_motd
|
||||
- user: root
|
||||
- force_reset: True
|
||||
- require:
|
||||
- directories_apps_dir
|
||||
|
||||
apps_generate-motd_link:
|
||||
file.symlink:
|
||||
- name: {{ noveria.bin_dir }}/generate_motd
|
||||
- target: {{ noveria.app_dir }}/generate_motd/generate_motd
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- apps_generate-motd_git
|
||||
- directories_bin_dir
|
||||
- directories_apps_dir
|
3
apps/init.sls
Normal file
3
apps/init.sls
Normal file
|
@ -0,0 +1,3 @@
|
|||
include:
|
||||
- .noveriablcgen
|
||||
- .generate-motd
|
7
apps/noveriablcgen/files/noveriablcgen_config.json.jinja
Normal file
7
apps/noveriablcgen/files/noveriablcgen_config.json.jinja
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"be_env_dir": "{{ BTRFS_ROOT }}",
|
||||
"grub_conf_dir": "{{ GRUB_CONFD }}",
|
||||
"filename": "{{ GRUB_CONFIG_FILENAME }}",
|
||||
"root_uuid": "{{ ROOT_UUID }}",
|
||||
"grub_cfg": "{{ GRUB_CONFIG }}"
|
||||
}
|
44
apps/noveriablcgen/init.sls
Normal file
44
apps/noveriablcgen/init.sls
Normal file
|
@ -0,0 +1,44 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
|
||||
apps_noveriablcgen_git:
|
||||
git.latest:
|
||||
- name: https://git.noveria.org/Tools/noveriablcgen.git
|
||||
- target: {{ noveria.app_dir }}/noveriablcgen
|
||||
- user: root
|
||||
- force_reset: True
|
||||
- require:
|
||||
- directories_apps_dir
|
||||
|
||||
apps_noveriablcgen_link:
|
||||
file.symlink:
|
||||
- name: {{ noveria.bin_dir }}/noveriablcgen
|
||||
- target: {{ noveria.app_dir }}/noveriablcgen/noveriablcgen
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- apps_noveriablcgen_git
|
||||
- directories_bin_dir
|
||||
- directories_apps_dir
|
||||
|
||||
apps_noveriablcgen_config:
|
||||
file.managed:
|
||||
- name: {{ noveria.etc_dir }}/noveriablcgen/noveriablcgen.json
|
||||
- source: salt://{{ tpldir }}/files/noveriablcgen_config.json.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
BTRFS_ROOT: "/btrfs"
|
||||
GRUB_CONFD: "/etc/grub.d"
|
||||
GRUB_CONFIG_FILENAME: "10_noveria"
|
||||
ROOT_UUID: {{ salt['cmd.shell']('lsblk -o LABEL,UUID | grep ROOT | awk \'{print $2}\'') }}
|
||||
GRUB_CONFIG: "/boot/grub/grub.cfg"
|
||||
- mode: '0644'
|
||||
- makedirs: True
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- apps_noveriablcgen_git
|
||||
- directories_etc_dir
|
39
directories.sls
Normal file
39
directories.sls
Normal file
|
@ -0,0 +1,39 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
directories_dir:
|
||||
file.directory:
|
||||
- name: {{ noveria.dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- file_mode: '0644'
|
||||
- dir_mode: '0755'
|
||||
|
||||
directories_bin_dir:
|
||||
file.directory:
|
||||
- name: {{ noveria.bin_dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- file_mode: '0644'
|
||||
- dir_mode: '0755'
|
||||
- require:
|
||||
- directories_dir
|
||||
|
||||
directories_etc_dir:
|
||||
file.directory:
|
||||
- name: {{ noveria.etc_dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- file_mode: '0644'
|
||||
- dir_mode: '0755'
|
||||
- require:
|
||||
- directories_dir
|
||||
|
||||
directories_apps_dir:
|
||||
file.directory:
|
||||
- name: {{ noveria.app_dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- file_mode: '0644'
|
||||
- dir_mode: '0755'
|
||||
- require:
|
||||
- directories_dir
|
40
haproxy/files/haproxy_config.jinja
Normal file
40
haproxy/files/haproxy_config.jinja
Normal file
|
@ -0,0 +1,40 @@
|
|||
global
|
||||
log 127.0.0.1 local2
|
||||
|
||||
maxconn 4000
|
||||
user haproxy
|
||||
group haproxy
|
||||
daemon
|
||||
|
||||
stats socket /var/lib/haproxy/stats
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
timeout queue 1m
|
||||
timeout connect 10s
|
||||
timeout client 5m
|
||||
timeout server 5m
|
||||
maxconn 3000
|
||||
|
||||
frontend ssh
|
||||
mode tcp
|
||||
|
||||
bind {{ ipv4 }}:22
|
||||
|
||||
default_backend host-ssh
|
||||
|
||||
frontend http
|
||||
mode tcp
|
||||
bind {{ ipv4 }}:80
|
||||
|
||||
default_backend host-http
|
||||
|
||||
backend host-ssh
|
||||
mode tcp
|
||||
|
||||
server localhost 127.0.0.1
|
||||
|
||||
backend host-http
|
||||
mode tcp
|
||||
server localhost 127.0.0.1
|
56
haproxy/files/haproxy_rcscript.initd.jinja
Normal file
56
haproxy/files/haproxy_rcscript.initd.jinja
Normal file
|
@ -0,0 +1,56 @@
|
|||
#!/sbin/openrc-run
|
||||
# Copyright 1999-2011 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/net-proxy/haproxy/files/haproxy.initd-r1,v 1.2 2011/12/04 10:32:32 swegener Exp $
|
||||
|
||||
# This is file is managed by salt (state: {{ sls }})
|
||||
|
||||
extra_commands="checkconfig"
|
||||
extra_started_commands="reload"
|
||||
command=/usr/sbin/haproxy
|
||||
|
||||
CONF=${HAPROXY_CONF:-/etc/haproxy/${SVCNAME}.cfg}
|
||||
CONF_DIR=${HAPROXY_CONF_DIR:-{{ conf_dir }}}
|
||||
PIDFILE=/var/run/${SVCNAME}.pid
|
||||
|
||||
depend() {
|
||||
need net
|
||||
after firewall
|
||||
use dns logger
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
if [ ! -f "${CONF}" ] && [ ! -d "${CONF}" ]; then
|
||||
eerror "${CONF} does not exist!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ebegin "Checking ${CONF}"
|
||||
$command -q -c -f "${CONF}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting ${SVCNAME}"
|
||||
start-stop-daemon --pidfile "${PIDFILE}" --exec $command \
|
||||
--start -- -D -p "${PIDFILE}" -f "${CONF}" -f "${CONF_DIR}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping ${SVCNAME}"
|
||||
|
||||
if [ "${RC_CMD}" = "restart" ]; then
|
||||
checkconfig || return 1
|
||||
fi
|
||||
|
||||
start-stop-daemon --stop --pidfile "${PIDFILE}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
reload() {
|
||||
ebegin "Reloading ${SVCNAME}"
|
||||
checkconfig || { eerror "Reloading failed, please fix your ${CONF} first"; return 1; }
|
||||
$command -D -p "${PIDFILE}" -f "${CONF}" -f "${CONF_DIR}" -sf $(cat "${PIDFILE}")
|
||||
eend $?
|
||||
}
|
3
haproxy/init.sls
Normal file
3
haproxy/init.sls
Normal file
|
@ -0,0 +1,3 @@
|
|||
include:
|
||||
- .pkg
|
||||
- .service
|
5
haproxy/map.jinja
Normal file
5
haproxy/map.jinja
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% set dir = '/etc/haproxy' %}
|
||||
|
||||
{% set haproxy = {
|
||||
'conf_dir': '%s/conf.d' % dir,
|
||||
}%}
|
45
haproxy/pkg.sls
Normal file
45
haproxy/pkg.sls
Normal file
|
@ -0,0 +1,45 @@
|
|||
{% from tpldir+"/map.jinja" import haproxy with context %}
|
||||
{% set ipv4 = grains['ip4_interfaces']['eth0'][0] %}
|
||||
|
||||
haproxy_pkg_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- haproxy
|
||||
|
||||
haproxy_pkg_conf_dir:
|
||||
file.directory:
|
||||
- name: /etc/haproxy/conf.d
|
||||
- user: root
|
||||
- group: root
|
||||
- file_mode: '0644'
|
||||
- dir_mode: '0755'
|
||||
- require:
|
||||
- haproxy_pkg_pkgs
|
||||
|
||||
haproxy_pkg_config:
|
||||
file.managed:
|
||||
- name: /etc/haproxy/haproxy.cfg
|
||||
- source: salt://{{ tpldir }}/files/haproxy_config.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
ipv4: {{ ipv4 }}
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
- require:
|
||||
- haproxy_pkg_pkgs
|
||||
|
||||
haproxy_pkg_rc_script:
|
||||
file.managed:
|
||||
- name: /etc/init.d/haproxy
|
||||
- source: salt://{{ tpldir }}/files/haproxy_rcscript.initd.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
sls: {{ sls }}
|
||||
conf_dir: {{ haproxy.conf_dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- haproxy_pkg_conf_dir
|
||||
- haproxy_pkg_config
|
9
haproxy/service.sls
Normal file
9
haproxy/service.sls
Normal file
|
@ -0,0 +1,9 @@
|
|||
include:
|
||||
- .pkg
|
||||
|
||||
haproxy_service_running:
|
||||
service.running:
|
||||
- name: haproxy
|
||||
- enable: True
|
||||
- require:
|
||||
- haproxy_pkg_rc_script
|
8
map.jinja
Normal file
8
map.jinja
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% set dir = '/usr/local/noveria' %}
|
||||
|
||||
{% set noveria = {
|
||||
'dir': '%s' % dir,
|
||||
'bin_dir': '%s/bin' % dir,
|
||||
'etc_dir': '%s/etc' % dir,
|
||||
'app_dir': '%s/apps' % dir
|
||||
} %}
|
15
mysql/directory.sls
Normal file
15
mysql/directory.sls
Normal file
|
@ -0,0 +1,15 @@
|
|||
include:
|
||||
- .pkg
|
||||
|
||||
mysql_directory:
|
||||
file.directory:
|
||||
- name: /var/lib/mysql
|
||||
- create: False
|
||||
- replace: False
|
||||
- user: mysql
|
||||
- group: mysql
|
||||
- recurse:
|
||||
- user
|
||||
- group
|
||||
- require:
|
||||
- mysql_pkg
|
4
mysql/init.sls
Normal file
4
mysql/init.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
include:
|
||||
- .pkg
|
||||
- .directory
|
||||
- .service
|
6
mysql/pkg.sls
Normal file
6
mysql/pkg.sls
Normal file
|
@ -0,0 +1,6 @@
|
|||
mysql_pkg:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- mariadb
|
||||
- mariadb-client
|
||||
- mariadb-openrc
|
18
mysql/service.sls
Normal file
18
mysql/service.sls
Normal file
|
@ -0,0 +1,18 @@
|
|||
include:
|
||||
- .directory
|
||||
|
||||
{% if not salt['file.directory_exists']('/var/lib/mysql/mysql') %}
|
||||
mysql_service_setup:
|
||||
cmd.run:
|
||||
- name: /etc/init.d/mariadb setup
|
||||
- runas: root
|
||||
- shell: /bin/ash
|
||||
- require:
|
||||
- mysql_directory
|
||||
|
||||
mysql_service_enable:
|
||||
service.enabled:
|
||||
- name: mariadb
|
||||
- require:
|
||||
- mysql_service_setup
|
||||
{% endif %}
|
11
network/files/firewall_rules.nft.jinja
Normal file
11
network/files/firewall_rules.nft.jinja
Normal file
|
@ -0,0 +1,11 @@
|
|||
## This file is managed by Saltstack. (state: {{ sls }})
|
||||
#!/usr/sbin/nft
|
||||
|
||||
table inet filter {
|
||||
chain input {
|
||||
tcp dport 22 accept
|
||||
{%- for port in ALLOWED_PORTS %}
|
||||
tcp dport {{ port }} accept
|
||||
{%- endfor %}
|
||||
}
|
||||
}
|
8
network/files/network_interfaces
Normal file
8
network/files/network_interfaces
Normal file
|
@ -0,0 +1,8 @@
|
|||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
iface lo inet static
|
||||
address 127.0.0.2/8
|
||||
broadcast 0.0.0.0
|
29
network/firewall.sls
Normal file
29
network/firewall.sls
Normal file
|
@ -0,0 +1,29 @@
|
|||
network_firewall_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- nftables
|
||||
|
||||
network_firewall_rules:
|
||||
file.managed:
|
||||
- name: /etc/nftables.d/noveria.nft
|
||||
- source: salt://{{ tpldir }}/files/firewall_rules.nft.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
sls: {{ sls }}
|
||||
ALLOWED_PORTS: [80, 443, 25565, 51871]
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0600'
|
||||
- makedirs: True
|
||||
- require:
|
||||
- network_firewall_pkgs
|
||||
|
||||
network_firewall_service_reload:
|
||||
service.running:
|
||||
- name: nftables
|
||||
- enable: True
|
||||
- watch:
|
||||
- network_firewall_rules
|
||||
- require:
|
||||
- network_firewall_pkgs
|
||||
|
20
network/init.sls
Normal file
20
network/init.sls
Normal file
|
@ -0,0 +1,20 @@
|
|||
include:
|
||||
- system.base
|
||||
- .firewall
|
||||
|
||||
network_interfaces:
|
||||
file.managed:
|
||||
- name: /etc/network/interfaces
|
||||
- source: salt://{{ tpldir }}/files/network_interfaces
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
- require:
|
||||
- system_base_pkgs
|
||||
|
||||
network_service_reload:
|
||||
service.running:
|
||||
- name: networking
|
||||
- enable: True
|
||||
- watch:
|
||||
- network_interfaces
|
17
openssh/config.sls
Normal file
17
openssh/config.sls
Normal file
|
@ -0,0 +1,17 @@
|
|||
include:
|
||||
- .pkg
|
||||
|
||||
openssh_config_configuration:
|
||||
file.managed:
|
||||
- name: /etc/ssh/sshd_config
|
||||
- source: salt://{{ tpldir }}/files/openssh_sshd_config
|
||||
|
||||
openssh_config_keys:
|
||||
file.managed:
|
||||
- name: /root/.ssh/authorized_keys
|
||||
- source: salt://{{ tpldir }}/files/openssh_authorized_keys
|
||||
- makedirs: True
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- openssh_pkg
|
|
@ -18,9 +18,9 @@ Include /etc/ssh/sshd_config.d/*.conf
|
|||
# SELinux about this change.
|
||||
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
|
||||
#
|
||||
#Port 22
|
||||
Port 22
|
||||
#AddressFamily any
|
||||
#ListenAddress 0.0.0.0
|
||||
ListenAddress 127.0.0.1
|
||||
#ListenAddress ::
|
||||
|
||||
#HostKey /etc/ssh/ssh_host_rsa_key
|
4
openssh/init.sls
Normal file
4
openssh/init.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
include:
|
||||
- .pkg
|
||||
- .config
|
||||
- .service
|
4
openssh/pkg.sls
Normal file
4
openssh/pkg.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
openssh_pkg:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- openssh-server
|
13
openssh/service.sls
Normal file
13
openssh/service.sls
Normal file
|
@ -0,0 +1,13 @@
|
|||
include:
|
||||
- .config
|
||||
|
||||
openssh_service_enable:
|
||||
service.running:
|
||||
- name: sshd
|
||||
- enable: True
|
||||
- watch:
|
||||
- openssh_config_configuration
|
||||
- openssh_config_keys
|
||||
- require:
|
||||
- openssh_config_configuration
|
||||
- openssh_config_keys
|
4
podman/apps/certpod/init.sls
Normal file
4
podman/apps/certpod/init.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
3
podman/apps/init.sls
Normal file
3
podman/apps/init.sls
Normal file
|
@ -0,0 +1,3 @@
|
|||
include:
|
||||
- .poddoc
|
||||
- .pms-cli
|
11
podman/apps/pms-cli/files/pms-cli_config.json.jinja
Normal file
11
podman/apps/pms-cli/files/pms-cli_config.json.jinja
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"PODMAN_DIRECTORY": "{{ PODMAN_DIR }}",
|
||||
"SERVERRUNNERS": {
|
||||
"paper": "https://api.papermc.io/v2/projects/paper",
|
||||
"folia": "https://api.papermc.io/v2/projects/folia"
|
||||
},
|
||||
"PROXYRUNNERS": {
|
||||
"waterfall": "https://api.papermc.io/v2/projects/waterfall",
|
||||
"velocity": "https://api.papermc.io/v2/projects/velocity"
|
||||
}
|
||||
}
|
40
podman/apps/pms-cli/init.sls
Normal file
40
podman/apps/pms-cli/init.sls
Normal file
|
@ -0,0 +1,40 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
|
||||
podman_apps_pms-cli_git:
|
||||
git.latest:
|
||||
- name: https://git.noveria.org/Tools/pms-cli.git
|
||||
- target: {{ noveria.app_dir }}/pms-cli
|
||||
- user: root
|
||||
- force_reset: True
|
||||
- require:
|
||||
- directories_apps_dir
|
||||
|
||||
podman_apps_pms-cli_link:
|
||||
file.symlink:
|
||||
- name: {{ noveria.bin_dir }}/pms-cli
|
||||
- target: {{ noveria.app_dir }}/pms-cli/pms-cli
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- podman_apps_pms-cli_git
|
||||
- directories_bin_dir
|
||||
- directories_apps_dir
|
||||
|
||||
podman_apps_pms-cli_config:
|
||||
file.managed:
|
||||
- name: {{ noveria.etc_dir }}/pms-cli/pms-cli.json
|
||||
- source: salt://{{ tpldir }}/files/pms-cli_config.json.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
PODMAN_DIR: "/opt/podman"
|
||||
- mode: '0644'
|
||||
- makedirs: True
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- podman_apps_pms-cli_git
|
||||
- directories_etc_dir
|
4
podman/apps/poddoc/files/poddoc_config.json.jinja
Normal file
4
podman/apps/poddoc/files/poddoc_config.json.jinja
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"GIT_REPOSITORY": "{{ GIT_REPO }}",
|
||||
"PODMAN_DIRECTORY": "{{ PODMAN_DIR }}"
|
||||
}
|
41
podman/apps/poddoc/init.sls
Normal file
41
podman/apps/poddoc/init.sls
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
|
||||
podman_apps_poddoc_git:
|
||||
git.latest:
|
||||
- name: https://git.noveria.org/Tools/poddoc.git
|
||||
- target: {{ noveria.app_dir }}/poddoc
|
||||
- user: root
|
||||
- force_reset: True
|
||||
- require:
|
||||
- directories_apps_dir
|
||||
|
||||
podman_apps_poddoc_link:
|
||||
file.symlink:
|
||||
- name: {{ noveria.bin_dir }}/poddoc
|
||||
- target: {{ noveria.app_dir }}/poddoc/poddoc
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- podman_apps_poddoc_git
|
||||
- directories_bin_dir
|
||||
- directories_apps_dir
|
||||
|
||||
podman_apps_poddoc_config:
|
||||
file.managed:
|
||||
- name: {{ noveria.etc_dir }}/poddoc/poddoc.json
|
||||
- source: salt://{{ tpldir }}/files/poddoc_config.json.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
GIT_REPO: "https://git.noveria.org/Podman"
|
||||
PODMAN_DIR: "/opt/podman"
|
||||
- mode: '0644'
|
||||
- makedirs: True
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- podman_apps_poddoc_git
|
||||
- directories_etc_dir
|
12
podman/directory.sls
Normal file
12
podman/directory.sls
Normal file
|
@ -0,0 +1,12 @@
|
|||
include:
|
||||
- .user
|
||||
|
||||
podman_directory_permissions:
|
||||
file.directory:
|
||||
- name: /opt/podman
|
||||
- user: puser
|
||||
- group: puser
|
||||
- dir_mode: '0755'
|
||||
- file_mode: '0644'
|
||||
- require:
|
||||
- podman_user_puser
|
1
podman/files/files_unprivileged_ports
Normal file
1
podman/files/files_unprivileged_ports
Normal file
|
@ -0,0 +1 @@
|
|||
net.ipv4.ip_unprivileged_port_start=0
|
6
podman/init.sls
Normal file
6
podman/init.sls
Normal file
|
@ -0,0 +1,6 @@
|
|||
include:
|
||||
- .pkg
|
||||
- .rootless
|
||||
- .user
|
||||
- .directory
|
||||
- .service
|
6
podman/pkg.sls
Normal file
6
podman/pkg.sls
Normal file
|
@ -0,0 +1,6 @@
|
|||
podman_pkg:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- podman
|
||||
- podman-openrc
|
||||
- podman-compose
|
45
podman/rootless.sls
Normal file
45
podman/rootless.sls
Normal file
|
@ -0,0 +1,45 @@
|
|||
include:
|
||||
- .pkg
|
||||
- .user
|
||||
|
||||
podman_rootless_cgroup_mode:
|
||||
file.keyvalue:
|
||||
- name: /etc/rc.conf
|
||||
- key_values:
|
||||
rc_cgroup_mode: '"unified"'
|
||||
- separator: '='
|
||||
- uncomment: '#'
|
||||
- key_ignore_case: false
|
||||
- value_ignore_case: false
|
||||
- append_if_not_found: True
|
||||
- require:
|
||||
- podman_pkg
|
||||
|
||||
podman_rootless_cgroups:
|
||||
service.running:
|
||||
- name: cgroups
|
||||
- enable: True
|
||||
- watch:
|
||||
- podman_rootless_cgroup_mode
|
||||
|
||||
podman_rootless_modules:
|
||||
file.append:
|
||||
- name: /etc/modules
|
||||
- text:
|
||||
- tun
|
||||
- fuse
|
||||
- ip_tables
|
||||
|
||||
podman_rootless_subgid:
|
||||
file.append:
|
||||
- name: /etc/subgid
|
||||
- text: puser:100000:65536
|
||||
- require:
|
||||
- podman_user_puser
|
||||
|
||||
podman_rootless_subuid:
|
||||
file.append:
|
||||
- name: /etc/subuid
|
||||
- text: puser:100000:65536
|
||||
- require:
|
||||
- podman_user_puser
|
15
podman/service.sls
Normal file
15
podman/service.sls
Normal file
|
@ -0,0 +1,15 @@
|
|||
include:
|
||||
- .rootless
|
||||
|
||||
podman_service:
|
||||
service.running:
|
||||
- name: podman
|
||||
- enable: True
|
||||
|
||||
podman_service_unprivileged_ports:
|
||||
file.managed:
|
||||
- name: /etc/sysctl.d/podman.conf
|
||||
- source: salt://{{ tpldir }}/files/files_unprivileged_ports
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
25
podman/user.sls
Normal file
25
podman/user.sls
Normal file
|
@ -0,0 +1,25 @@
|
|||
include:
|
||||
- .pkg
|
||||
|
||||
podman_user_puser:
|
||||
user.present:
|
||||
- name: puser
|
||||
- uid: 2000
|
||||
- shell: /bin/zsh
|
||||
- home: /home/puser
|
||||
- password: '*'
|
||||
- hash_password: True
|
||||
- usergroup: True
|
||||
- createhome: True
|
||||
- require:
|
||||
- podman_pkg
|
||||
|
||||
podman_user_openssh_keys:
|
||||
file.managed:
|
||||
- name: /home/puser/.ssh/authorized_keys
|
||||
- source: salt:///openssh/files/openssh_authorized_keys
|
||||
- makedirs: True
|
||||
- user: puser
|
||||
- group: puser
|
||||
- require:
|
||||
- podman_user_puser
|
|
@ -1,4 +0,0 @@
|
|||
file_client: local
|
||||
file_roots:
|
||||
base:
|
||||
- /srv/salt/salt-statetree
|
|
@ -1,5 +0,0 @@
|
|||
include:
|
||||
- .mysql
|
||||
- .podman
|
||||
- .ssh
|
||||
- .salt
|
|
@ -1,19 +0,0 @@
|
|||
include:
|
||||
- system.packages
|
||||
|
||||
system_service_mysql_enable:
|
||||
service.enabled:
|
||||
- name: mariadb
|
||||
- require:
|
||||
- system_packages_install
|
||||
file.directory:
|
||||
- name: /var/lib/mysql
|
||||
- create: False
|
||||
- replace: False
|
||||
- user: mysql
|
||||
- group: mysql
|
||||
- recurse:
|
||||
- user
|
||||
- group
|
||||
- require:
|
||||
- system_packages_install
|
|
@ -1,8 +0,0 @@
|
|||
include:
|
||||
- system.packages
|
||||
|
||||
system_service_podman_enable:
|
||||
service.enabled:
|
||||
- name: podman
|
||||
- require:
|
||||
- system_packages_install
|
|
@ -1,12 +0,0 @@
|
|||
include:
|
||||
- system.packages
|
||||
|
||||
services_salt_file_client_local:
|
||||
file.managed:
|
||||
- name: /etc/salt/minion.d/noveria.conf
|
||||
- source: salt://{{ tpldir }}/files/salt_noveria.conf
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 640
|
||||
- require:
|
||||
- system_packages_install
|
|
@ -1,28 +0,0 @@
|
|||
include:
|
||||
- system.packages
|
||||
|
||||
system_ssh_add_keys:
|
||||
file.managed:
|
||||
- name: /root/.ssh/authorized_keys
|
||||
- source: salt://{{ tpldir }}/files/ssh_authorized_keys
|
||||
- makedirs: True
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- system_packages_install
|
||||
|
||||
system_ssh_configuration:
|
||||
file.managed:
|
||||
- name: /etc/ssh/sshd_config
|
||||
- source: salt://{{ tpldir }}/files/ssh_sshd_config
|
||||
|
||||
system_ssh_enable:
|
||||
service.running:
|
||||
- name: sshd
|
||||
- enable: True
|
||||
- watch:
|
||||
- system_ssh_configuration
|
||||
- system_ssh_add_keys
|
||||
- require:
|
||||
- system_ssh_configuration
|
||||
- system_ssh_add_keys
|
74
system/base.sls
Normal file
74
system/base.sls
Normal file
|
@ -0,0 +1,74 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
|
||||
system_base_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- linux-lts
|
||||
- linux-firmware-none
|
||||
- openjdk17-jre-headless
|
||||
- jq
|
||||
- vim
|
||||
- git
|
||||
- findmnt
|
||||
- util-linux
|
||||
- sudo
|
||||
- curl
|
||||
- rsync
|
||||
- screen
|
||||
|
||||
system_base_systemupdate:
|
||||
file.managed:
|
||||
- name: {{ noveria.app_dir }}/systemupdate
|
||||
- source: salt://{{ tpldir }}/files/base_systemupdate
|
||||
- mode: '0755'
|
||||
- user: root
|
||||
- group: root
|
||||
- require:
|
||||
- directories_apps_dir
|
||||
|
||||
system_base_systemupdate_link:
|
||||
file.symlink:
|
||||
- name: {{ noveria.bin_dir }}/systemupdate
|
||||
- target: {{ noveria.app_dir }}/systemupdate
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
- require:
|
||||
- system_base_systemupdate
|
||||
- directories_bin_dir
|
||||
|
||||
system_base_modules_service:
|
||||
service.running:
|
||||
- name: modules
|
||||
- enable: True
|
||||
|
||||
# TUN permission fix service workaround
|
||||
system_base_tun-perm_service:
|
||||
file.managed:
|
||||
- name: /etc/init.d/tun-perm
|
||||
- source: salt://{{ tpldir }}/files/base_tun-perm.initd
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0755'
|
||||
service.enabled:
|
||||
- name: tun-perm
|
||||
- require:
|
||||
- system_base_modules_service
|
||||
|
||||
system_base_sysctl_service:
|
||||
service.running:
|
||||
- name: sysctl
|
||||
- enable: True
|
||||
|
||||
system_base_syslog_service:
|
||||
service.running:
|
||||
- name: syslog
|
||||
- enable: True
|
||||
|
||||
system_base_sysfs_service:
|
||||
service.running:
|
||||
- name: sysfs
|
||||
- enable: True
|
79
system/bootloader.sls
Normal file
79
system/bootloader.sls
Normal file
|
@ -0,0 +1,79 @@
|
|||
include:
|
||||
- .base
|
||||
|
||||
system_bootloader_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- grub
|
||||
- grub-efi
|
||||
- mkinitfs
|
||||
- mkinitfs-doc
|
||||
- efibootmgr
|
||||
|
||||
{% set CURRENT_SUBVOLUME_TIMESTAMP = salt['cmd.shell']('CURRENT_SUBVOLUME=$(LC_ALL=C btrfs sub show / | LC_ALL=C grep Name: | tr -d \'[:space:]\'); TIMESTAMP_FORMAT=\'[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}_[[:digit:]]{2}-[[:digit:]]{2}-[[:digit:]]{2}\'; echo "$CURRENT_SUBVOLUME" | grep -Eo "$TIMESTAMP_FORMAT"') %}
|
||||
{% set CURRENT_SUBVOLUME_TIMESTAMP_HUMAN = salt['cmd.shell']('CURRENT_SUBVOLUME_TIMESTAMP=\'' + CURRENT_SUBVOLUME_TIMESTAMP + '\'; echo "${CURRENT_SUBVOLUME_TIMESTAMP:0:10} ${CURRENT_SUBVOLUME_TIMESTAMP:11:2}:${CURRENT_SUBVOLUME_TIMESTAMP:14:2}"') %}
|
||||
{% set KERNEL_VERSION = salt['cmd.shell']('uname -r') %}
|
||||
|
||||
system_bootloader_mkinitfs_conf:
|
||||
file.keyvalue:
|
||||
- name: /etc/mkinitfs/mkinitfs.conf
|
||||
- key_values:
|
||||
features: '"ata base btrfs keymap kms mmc nvme scsi usb virtio"'
|
||||
- separator: '='
|
||||
- uncomment: '# '
|
||||
- key_ignore_case: false
|
||||
- value_ignore_case: false
|
||||
- append_if_not_found: True
|
||||
- require:
|
||||
- system_base_pkgs
|
||||
- system_bootloader_pkgs
|
||||
|
||||
system_bootloader_os-release:
|
||||
file.managed:
|
||||
- name: /etc/os-release
|
||||
- source: salt://{{ tpldir }}/files/bootloader_os-release.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
OS_VERSION: {{ salt['cmd.shell']('date "+%Y%m"') }}
|
||||
OS_RELEASE_INFO: '"Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN }} | Kernel: {{ KERNEL_VERSION }}"'
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
|
||||
system_bootloader_motd_dir:
|
||||
file.directory:
|
||||
- name: /etc/motd.d
|
||||
- user: root
|
||||
- group: root
|
||||
- dir_mode: '0755'
|
||||
- file_mode: '0644'
|
||||
- require:
|
||||
- system_bootloader_os-release
|
||||
|
||||
system_bootloader_motd:
|
||||
file.managed:
|
||||
- name: /etc/motd.d/00_noveria.motd
|
||||
- source: salt://{{ tpldir }}/files/bootloader_00_noveria.motd.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
OS_NAME: {{ salt['cmd.shell']('echo NoveriaOS $(date "+%Y%m")') }}
|
||||
OS_RELEASE_INFO: 'Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN }} | Kernel: {{ KERNEL_VERSION }}'
|
||||
OS_ISSUE_URL: 'https://git.noveria.org/NoveriaOS/ISO/issues'
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
- require:
|
||||
- system_bootloader_os-release
|
||||
- system_bootloader_motd_dir
|
||||
|
||||
system_bootloader_issue:
|
||||
file.managed:
|
||||
- name: /etc/issue
|
||||
- source: salt://{{ tpldir }}/files/bootloader_issue.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
OS_NAME: {{ salt['cmd.shell']('echo NoveriaOS $(date "+%Y%m")') }}
|
||||
OS_RELEASE_INFO: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN }}
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
|
@ -1,20 +0,0 @@
|
|||
system_btrfs_create_podman_data_dir:
|
||||
cmd.run:
|
||||
- creates: /opt/podman
|
||||
- name: btrfs subvolume create /opt/podman
|
||||
file.managed:
|
||||
- name: /opt/podman
|
||||
- create: False
|
||||
- replace: False
|
||||
- user: root
|
||||
- group: root
|
||||
|
||||
system_btrfs_create_noveria_home:
|
||||
cmd.run:
|
||||
- creates: /home/noveria
|
||||
- name: btrfs subvolume create /home/noveria
|
||||
|
||||
system_btrfs_create_mysql_data_dir:
|
||||
cmd.run:
|
||||
- creates: /var/lib/mysql
|
||||
- name: btrfs subvolume create /var/lib/mysql
|
37
system/disks.sls
Normal file
37
system/disks.sls
Normal file
|
@ -0,0 +1,37 @@
|
|||
system_disks_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- btrfs-progs
|
||||
|
||||
system_disks_btrfs_module:
|
||||
file.append:
|
||||
- name: /etc/modules
|
||||
- text: "btrfs"
|
||||
- require:
|
||||
- system_base_pkgs
|
||||
|
||||
system_disks_btrfs_mount_permission:
|
||||
file.directory:
|
||||
- name: /btrfs
|
||||
- user: root
|
||||
- group: root
|
||||
- dir_mode: '0755'
|
||||
|
||||
{% set ROOT_UUID = salt['cmd.shell']('lsblk -o LABEL,UUID | grep ROOT | awk \'{print $2}\'') %}
|
||||
{% set ESP_UUID = salt['cmd.shell']('lsblk -o LABEL,UUID | grep EFI | awk \'{print $2}\'') %}
|
||||
|
||||
system_disks_fstab:
|
||||
file.managed:
|
||||
- name: /etc/fstab
|
||||
- source: salt://{{ tpldir }}/files/disks_fstab.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
TIMESTAMP: {{ salt.pillar.get('system.disks.timestamp') }}
|
||||
TMPFS_SIZE: {{ salt.pillar.get('system.disks.tmpfs.size') }}
|
||||
ROOT_UUID: {{ ROOT_UUID }}
|
||||
ESP_UUID: {{ ESP_UUID }}
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
- require:
|
||||
- system_disks_btrfs_mount_permission
|
205
system/files/base_systemupdate
Normal file
205
system/files/base_systemupdate
Normal file
|
@ -0,0 +1,205 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#######################################################################################################################
|
||||
##
|
||||
## Script to full update the system
|
||||
##
|
||||
## 0. Pre checks
|
||||
## 1. Generate new boot environment (BE)
|
||||
## 2. Update and Salt highstate
|
||||
## 3. Clean up
|
||||
##
|
||||
#######################################################################################################################
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
## Definitions
|
||||
#######################################################################################################################
|
||||
|
||||
readonly TEMPDIR=$(mktemp -d /tmp/systemupdate.XXXXXX)
|
||||
readonly LOCK_FILE="${TEMPDIR}/systemupdate.lock"
|
||||
|
||||
readonly TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
|
||||
|
||||
readonly BTRFS_ROOT="/btrfs"
|
||||
readonly CURRENT_SUBVOLUME=$(LC_ALL=C btrfs sub show / | LC_ALL=C grep 'Name' | cut -d: -f2 | awk '{$1=$1};1')
|
||||
readonly NEW_SUBVOLUME="@root_${TIMESTAMP}"
|
||||
readonly MOUNTPOINT='/mnt'
|
||||
|
||||
readonly EFI_DISK=$(findmnt -T /efi -o SOURCE | tail -n 1)
|
||||
readonly ROOT_DISK=$(findmnt / -o SOURCE | cut -d"[" -f1 | tail -n 1)
|
||||
|
||||
readonly BE_HISTORY_COUNT=5
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
## Errorhandling
|
||||
#######################################################################################################################
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# systemupdate failed
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
systemupdateFailed() {
|
||||
echo ""
|
||||
echo "┌──────────────────────────────────────────┐"
|
||||
echo "│ FAILED => clean up │"
|
||||
echo "└──────────────────────────────────────────┘"
|
||||
|
||||
subtaskTitle "Unmount BE if mounted"
|
||||
unmountMountpoint
|
||||
|
||||
subtaskTitle "Remove BE"
|
||||
removeBEFromTimestamp ${TIMESTAMP}
|
||||
|
||||
rm -f ${LOCK_FILE}
|
||||
|
||||
subtaskTitle "Finished with exit code 1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# catch ^C and other signals and clean up
|
||||
trap "echo -e '\n=> Interrupted with CTRL+C' >&2; systemupdateFailed" SIGINT SIGHUP SIGTERM SIGABRT
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
## Helper Functions
|
||||
#######################################################################################################################
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# Subtask title output
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
subtaskTitle() {
|
||||
echo -e "\n=> $1"
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# Unmount ${MOUNTPOINT}
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
unmountMountpoint() {
|
||||
# if mountpoint exists -> umount
|
||||
[[ $(findmnt -M "${MOUNTPOINT}") ]] && umount -R "${MOUNTPOINT}"
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# Recursive subvolume delete
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
btrfsSubDelRecursive() {
|
||||
btrfs sub list -o "${BTRFS_ROOT}/${1}" | cut -d " " -f 9 | while read i; do
|
||||
btrfsSubDelRecursive "$i"
|
||||
done
|
||||
btrfs sub del "${BTRFS_ROOT}/${1}"
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# Remove BE from timestamp
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
removeBEFromTimestamp() {
|
||||
# remove all subvolume with this timestamp
|
||||
for f in $(btrfs sub list -o /btrfs | cut -d " " -f 9 | grep "@root"); do
|
||||
if [[ "$f" =~ "$1" ]]; then
|
||||
btrfsSubDelRecursive "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#######################################################################################################################
|
||||
## Main
|
||||
#######################################################################################################################
|
||||
|
||||
echo "┌──────────────────────────────────────────┐"
|
||||
echo "│ 0. Pre checks │"
|
||||
echo "└──────────────────────────────────────────┘"
|
||||
subtaskTitle "Check if another systemupgrade is in progress"
|
||||
if [ -f ${LOCK_FILE} ]; then
|
||||
echo "[ERROR] Another systemupgrade is in progress (lockfile: ${LOCK_FILE}) => exit" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
subtaskTitle "Check if ${MOUNTPOINT} exists"
|
||||
if [ ! -d ${MOUNTPOINT} ]; then
|
||||
mkdir -p "${MOUNTPOINT}"
|
||||
fi
|
||||
|
||||
subtaskTitle "Check if ${MOUNTPOINT} is already a mountpoint"
|
||||
if [[ $(findmnt -M "${MOUNTPOINT}") ]]; then
|
||||
echo "[ERROR] ${MOUNTPOINT} is already a mountpoint => exit" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
subtaskTitle "Checks finished and update can start"
|
||||
|
||||
# Create lock file
|
||||
touch ${LOCK_FILE} || systemupdateFailed
|
||||
|
||||
|
||||
echo ""
|
||||
echo "┌──────────────────────────────────────────┐"
|
||||
echo "│ 1. Generate new boot environment (BE) │"
|
||||
echo "└──────────────────────────────────────────┘"
|
||||
|
||||
subtaskTitle "Create snapshot of current running system"
|
||||
btrfs subvolume snapshot / ${BTRFS_ROOT}/${NEW_SUBVOLUME} || systemupdateFailed
|
||||
|
||||
subtaskTitle "Mount new BE to ${MOUNTPOINT}"
|
||||
mount -o noatime,nodiratime,discard=async,space_cache=v2,subvol="${NEW_SUBVOLUME}" "${ROOT_DISK}" "${MOUNTPOINT}" || systemupdateFailed
|
||||
mount -o noatime,nodiratime,discard=async,space_cache=v2,subvol=@home "${ROOT_DISK}" "${MOUNTPOINT}/home" || systemupdateFailed
|
||||
mount -o noatime,nodiratime,discard=async,space_cache=v2,subvol=@podman "${ROOT_DISK}" "${MOUNTPOINT}/opt/podman" || systemupdateFailed
|
||||
mount -o noatime,nodiratime,discard=async,space_cache=v2,subvol=@mysql "${ROOT_DISK}" "${MOUNTPOINT}/var/lib/mysql" || systemupdateFailed
|
||||
mount -o noatime,nodiratime,discard=async,space_cache=v2,subvol=/ "${ROOT_DISK}" "${MOUNTPOINT}/btrfs" || systemupdateFailed
|
||||
|
||||
mount -o nodev,nosuid,noexec "${EFI_DISK}" "${MOUNTPOINT}/efi" || systemupdateFailed
|
||||
mount -t proc /proc "${MOUNTPOINT}/proc/" || systemupdateFailed
|
||||
mount -t sysfs /sys "${MOUNTPOINT}/sys/" || systemupdateFailed
|
||||
mount -o bind /sys/firmware/efi/efivars "${MOUNTPOINT}/sys/firmware/efi/efivars/" || systemupdateFailed
|
||||
mount -o bind /dev "${MOUNTPOINT}/dev/" || systemupdateFailed
|
||||
mount -o bind /run "${MOUNTPOINT}/run/" || systemupdateFailed
|
||||
|
||||
subtaskTitle "New BE mounted"
|
||||
|
||||
echo ""
|
||||
echo "┌──────────────────────────────────────────┐"
|
||||
echo "│ 2. Update and Salt highstate │"
|
||||
echo "└──────────────────────────────────────────┘"
|
||||
|
||||
subtaskTitle "Update Saltstack"
|
||||
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "git -C /srv/salt pull" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Update bootloader configs"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "salt-call state.sls system.bootloader" >/dev/null || systemupdateFailed
|
||||
|
||||
subtaskTitle "Alpine repositories & keyring update"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "apk update" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Alpine packages update"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "apk upgrade" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Salt highstate"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "salt-call state.highstate" >/dev/null || systemupdateFailed
|
||||
|
||||
subtaskTitle "Generate new initial ramdisk"
|
||||
latest_kernel="$(chroot "${MOUNTPOINT}" /bin/bash -c 'echo $(apk search linux-lts | head -n1 | cut -d- -f3- | sed "s|r||")-lts')"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "mkinitfs $latest_kernel" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Update motd"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "/usr/local/noveria/bin/generate_motd" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Update GRUB"
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=alpine" || systemupdateFailed
|
||||
chroot "${MOUNTPOINT}" /bin/bash -c "/usr/local/noveria/bin/noveriablcgen --noconfirm" || systemupdateFailed
|
||||
|
||||
subtaskTitle "Update finished"
|
||||
|
||||
subtaskTitle "Unmount BE"
|
||||
unmountMountpoint
|
||||
|
||||
echo ""
|
||||
echo "┌──────────────────────────────────────────┐"
|
||||
echo "│ 3. Clean Up │"
|
||||
echo "└──────────────────────────────────────────┘"
|
||||
|
||||
subtaskTitle "Clean up finished"
|
||||
|
||||
# Remove lock file
|
||||
rm -f ${LOCK_FILE}
|
13
system/files/base_tun-perm.initd
Normal file
13
system/files/base_tun-perm.initd
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/sbin/openrc-run
|
||||
supervisor=supervise-daemon
|
||||
|
||||
name="tun module permission setter"
|
||||
description="setting the permission of /dev/net/tun to 666"
|
||||
|
||||
command=$(which chmod)
|
||||
command_args="0666 /dev/net/tun"
|
||||
command_user="root"
|
||||
|
||||
depend() {
|
||||
need modules
|
||||
}
|
17
system/files/bootloader_00_noveria.motd.jinja
Normal file
17
system/files/bootloader_00_noveria.motd.jinja
Normal file
|
@ -0,0 +1,17 @@
|
|||
╔═══════════════════════════════════════════════╗
|
||||
║ Velkommen til ║
|
||||
║ _ _ _ ║
|
||||
║ | \ | | (_) ║
|
||||
║ | \| | _____ _____ _ __ _ __ _ ║
|
||||
║ | . ` |/ _ \ \ / / _ \ '__| |/ _` | ║
|
||||
║ | |\ | (_) \ V / __/ | | | (_| | ║
|
||||
║ |_| \_|\___/ \_/ \___|_| |_|\__,_| ║
|
||||
║ ║
|
||||
╚═══════════════════════════════════════════════╝
|
||||
|
||||
OS: {{ OS_NAME }}
|
||||
Version: {{ OS_RELEASE_INFO }}
|
||||
|
||||
Report issues on: {{ OS_ISSUE_URL }}
|
||||
|
||||
═════════════════════════════════════════════════
|
2
system/files/bootloader_issue.jinja
Normal file
2
system/files/bootloader_issue.jinja
Normal file
|
@ -0,0 +1,2 @@
|
|||
Velkommen til {{ OS_NAME }}
|
||||
Timestamp: {{ OS_RELEASE_INFO }} | Kernel: \r
|
8
system/files/bootloader_os-release.jinja
Normal file
8
system/files/bootloader_os-release.jinja
Normal file
|
@ -0,0 +1,8 @@
|
|||
NAME="NoveriaOS"
|
||||
ID=noveriaos
|
||||
ID_LIKE=alpine
|
||||
VERSION_ID="{{ OS_VERSION }}"
|
||||
PRETTY_NAME="NoveriaOS {{ OS_VERSION }}"
|
||||
RELEASE_INFO={{ OS_RELEASE_INFO }}
|
||||
HOME_URL="https://noveria.org"
|
||||
BUG_REPORT_URL="https://git.noveria.org/NoveriaOS/ISO/issues"
|
11
system/files/disks_fstab.jinja
Normal file
11
system/files/disks_fstab.jinja
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Static information about the filesystems.
|
||||
# See fstab(5) for details.
|
||||
|
||||
# <file system> <dir> <type> <options> <dump> <pass>
|
||||
UUID={{ ROOT_UUID }} / btrfs noatime,nodiratime,compress=zstd,ssd,shared,discard=async,space_cache=v2,subvol=/@root_{{ TIMESTAMP }} 0 0
|
||||
UUID={{ ESP_UUID }} /efi vfat rw,nosuid,nodev,noexec,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
|
||||
UUID={{ ROOT_UUID }} /home btrfs noatime,nodiratime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=/@home 0 0
|
||||
UUID={{ ROOT_UUID }} /var/lib/mysql btrfs noatime,nodiratime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=/@mysql 0 0
|
||||
UUID={{ ROOT_UUID }} /opt/podman btrfs noatime,nodiratime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=/@podman 0 0
|
||||
UUID={{ ROOT_UUID }} /btrfs btrfs noatime,nodiratime,compress=zstd,ssd,discard=async,space_cache=v2,space_cache=v2,subvol=/ 0 0
|
||||
tmpfs /tmp tmpfs nodev,nosuid,size={{ TMPFS_SIZE }} 0 0
|
10
system/files/salt_minion
Normal file
10
system/files/salt_minion
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
state_verbose: False
|
||||
file_client: local
|
||||
file_roots:
|
||||
base:
|
||||
- /srv/salt
|
||||
pillar_roots:
|
||||
base:
|
||||
- /srv/pillar
|
||||
...
|
34
system/files/shell_profile.jinja
Normal file
34
system/files/shell_profile.jinja
Normal file
|
@ -0,0 +1,34 @@
|
|||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ CUSTOM_BIN }}"
|
||||
|
||||
export PAGER=less
|
||||
export EDITOR=vim
|
||||
umask 022
|
||||
|
||||
# use nicer PS1 for bash and busybox ash
|
||||
if [ -n "$BASH_VERSION" -o "$BB_ASH_VERSION" ]; then
|
||||
PS1='[%n@%m %~]%# '
|
||||
# use nicer PS1 for zsh
|
||||
elif [ -n "$ZSH_VERSION" ]; then
|
||||
PS1='[%n@%m %~]%# '
|
||||
# set up fallback default PS1
|
||||
else
|
||||
: "${HOSTNAME:=$(hostname)}"
|
||||
PS1='${HOSTNAME%%.*}:$PWD'
|
||||
[ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ "
|
||||
fi
|
||||
|
||||
if [ -n "$BASH_VERSION" ] && [ "$BASH" != "/bin/sh" ]; then
|
||||
# if we're bash (and not /bin/sh bash), also source the bashrc
|
||||
# by default, bash sources the bashrc for non-login,
|
||||
# and only /etc/profile on login (-l). so, make it do both on login.
|
||||
# this ensures that login-shell bash (e.g. -bash or bash -l) still sources the
|
||||
# system bashrc, which e.g. loads bash-completion
|
||||
. /etc/bash/bashrc
|
||||
fi
|
||||
|
||||
for script in /etc/profile.d/*.sh ; do
|
||||
if [ -r "$script" ] ; then
|
||||
. "$script"
|
||||
fi
|
||||
done
|
||||
unset script
|
|
@ -1,4 +1,7 @@
|
|||
include:
|
||||
- .btrfs
|
||||
- .base
|
||||
- .bootloader
|
||||
- .disks
|
||||
- .user
|
||||
- .packages
|
||||
- .shell
|
||||
- .salt
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
include:
|
||||
- .btrfs
|
||||
|
||||
system_packages_install:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- podman
|
||||
- cockpit-podman
|
||||
- podman-docker
|
||||
- podman-compose
|
||||
- mariadb-server
|
||||
- java-latest-openjdk-headless
|
||||
- jq
|
||||
- require:
|
||||
- system_btrfs_create_podman_data_dir
|
||||
- system_btrfs_create_mysql_data_dir
|
39
system/salt.sls
Normal file
39
system/salt.sls
Normal file
|
@ -0,0 +1,39 @@
|
|||
include:
|
||||
- system.base
|
||||
|
||||
system_salt_pkg:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- salt-minion
|
||||
- require:
|
||||
- system_base_pkgs
|
||||
|
||||
system_salt_minion_config:
|
||||
file.managed:
|
||||
- name: /etc/salt/minion
|
||||
- source: salt://{{ tpldir }}/files/salt_minion
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
|
||||
system_salt_minon_service:
|
||||
service.disabled:
|
||||
- name: salt-minion
|
||||
- require:
|
||||
- system_salt_pkg
|
||||
|
||||
system_salt_minion_cachedir_permission:
|
||||
file.directory:
|
||||
- name: /var/cache/salt/minion
|
||||
- mode: '0700'
|
||||
- require:
|
||||
- system_salt_pkg
|
||||
|
||||
system_salt_minion_logdir_permission:
|
||||
file.directory:
|
||||
- name: /var/log/salt
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0700'
|
||||
- require:
|
||||
- system_salt_pkg
|
27
system/shell.sls
Normal file
27
system/shell.sls
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% from "map.jinja" import noveria with context %}
|
||||
|
||||
include:
|
||||
- directories
|
||||
- system.base
|
||||
|
||||
system_shell_pkgs:
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- zsh
|
||||
- alpine-zsh-config
|
||||
- bash
|
||||
- require:
|
||||
- system_base_pkgs
|
||||
|
||||
system_shell_profile:
|
||||
file.managed:
|
||||
- name: /etc/profile
|
||||
- source: salt://{{ tpldir }}/files/shell_profile.jinja
|
||||
- template: jinja
|
||||
- context:
|
||||
CUSTOM_BIN: {{ noveria.bin_dir }}
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: '0644'
|
||||
- require:
|
||||
- system_shell_pkgs
|
|
@ -1,22 +1,12 @@
|
|||
include:
|
||||
- .btrfs
|
||||
|
||||
system_user_create:
|
||||
system_user_noveria_create:
|
||||
user.present:
|
||||
- name: noveria
|
||||
- shell: /bin/false
|
||||
- home: /home/noveria
|
||||
- usergroup: True
|
||||
- createhome: False
|
||||
- createhome: True
|
||||
|
||||
system_user_create_home_noveria:
|
||||
file.directory:
|
||||
- name: /home/noveria
|
||||
- user: noveria
|
||||
- group: noveria
|
||||
- mode: 700
|
||||
- recurse:
|
||||
- user
|
||||
- group
|
||||
- require:
|
||||
- system_btrfs_create_noveria_home
|
||||
system_user_root_edit:
|
||||
user.present:
|
||||
- name: root
|
||||
- shell: /bin/zsh
|
7
top.sls
7
top.sls
|
@ -1,4 +1,9 @@
|
|||
base:
|
||||
'*':
|
||||
- directories
|
||||
- system
|
||||
- services
|
||||
- network
|
||||
- apps
|
||||
- openssh
|
||||
- haproxy
|
||||
- serverspecific
|
||||
|
|
Loading…
Reference in a new issue