Add and enable openrc/systemd service via yip files (#505)

This commit is contained in:
Itxaka 2023-10-20 09:44:04 +02:00 committed by GitHub
parent 9e8d950515
commit c6ec9b53d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 200 additions and 158 deletions

View File

@ -1,7 +1,7 @@
packages:
- name: "alpine"
category: "initrd"
version: "3.8.1+1"
version: "3.8.1+2"
description: "Provides custom initrd scripts for alpine"
# This syncs with the alpine version at https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/master/initramfs-init.in?ref_type=heads
# any changes to the initramfs-init.in file should be looked at and backported if necessary

View File

@ -435,11 +435,13 @@ if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline;then
mount -t overlay -o lowerdir=/run/rootfsbase,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
eend $?
sync
rd_break pre-immucore
# immucore to run the initramfs and rootfs stages
ebegin "Run immucore"
immucore
eend $?
# Move current mounts into sysroot mounts
ebegin "Run immucore"
immucore
eend $?
rd_break post-immucore
# Move current mounts into sysroot mounts
# shellcheck disable=SC2002
cat "$ROOT"/proc/mounts 2>/dev/null | while read DEV DIR TYPE OPTS ; do
# shellcheck disable=SC2166

View File

@ -1,4 +1,4 @@
packages:
- name: "kairos-overlay-files"
category: "static"
version: "1.1.6"
version: "1.1.7"

View File

@ -1,10 +1,61 @@
name: "Create openrc services"
stages:
initramfs:
- name: "Create files"
- name: "Create OpenRC services"
if: |
grep -i alpine "/etc/os-release"
[ -f "/sbin/openrc" ]
files:
- path: /etc/init.d/cos-setup-boot
permissions: 0755
owner: 0
group: 0
content: |
#!/sbin/openrc-run
depend() {
provide cos-setup-boot
}
start() {
kairos-agent run-stage boot
eend 0
}
- path: /etc/init.d/cos-setup-network
permissions: 0755
owner: 0
group: 0
content: |
#!/sbin/openrc-run
depend() {
after net
provide cos-setup-network
}
start() {
kairos-agent run-stage network
eend 0
}
- path: /etc/init.d/cos-setup-reconcile
permissions: 0755
owner: 0
group: 0
content: |
#!/sbin/openrc-run
depend() {
provide cos-setup-reconcile
}
supervisor=supervise-daemon
name="cos-setup-reconcile"
command="cos-setup-reconcile"
supervise_daemon_args="--stdout /var/log/cos-setup-reconcile.log --stderr /var/log/cos-setup-reconcile.log"
pidfile="/run/cos-setup-reconcile.pid"
respawn_delay=360
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport
- path: /etc/init.d/kairos-agent
content: |
#!/sbin/openrc-run
@ -45,7 +96,6 @@ stages:
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport
permissions: 0755
owner: 0
group: 0
@ -66,3 +116,12 @@ stages:
permissions: 0755
owner: 0
group: 0
- name: "Enable OpenRC services"
if: |
[ -f "/sbin/openrc" ]
commands:
- mkdir -p /etc/runlevels/default
- ln -sf ../../init.d/cos-setup-boot /etc/runlevels/default/cos-setup-boot
- ln -sf ../../init.d/cos-setup-network /etc/runlevels/default/cos-setup-network
- ln -sf ../../init.d/cos-setup-reconcile /etc/runlevels/default/cos-setup-reconcile
- ln -sf ../../init.d/kairos-agent /etc/runlevels/default/kairos-agent

View File

@ -1,33 +0,0 @@
# Rootfs Kairos OEM configuration file
#
# This file is part of Kairos and will get reset during upgrades.
name: "Default config"
stages:
boot:
- name: "Default sysctl settings"
sysctl:
net.core.rmem_max: 2500000
vm.max_map_count: 262144
initramfs:
- name: "Default systemd config"
if: '[ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]'
systemctl:
enable:
- multi-user.target
- getty@tty1
- iscsid
- systemd-timesyncd
- nohang
- nohang-desktop
- fail2ban
- logrotate.timer
- sshd
mask:
- purge-kernels
commands:
- systemctl set-default multi-user.target
- name: "Generate host keys"
# Make sure the host always has available keys
commands:
- ssh-keygen -A

View File

@ -0,0 +1,129 @@
# Rootfs Kairos OEM configuration file
#
# This file is part of Kairos and will get reset during upgrades.
name: "Default config"
stages:
boot:
- name: "Default sysctl settings"
sysctl:
net.core.rmem_max: 2500000
vm.max_map_count: 262144
initramfs:
- name: "Default systemd config"
if: '[ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]'
systemctl:
enable:
- multi-user.target
- getty@tty1
- iscsid
- systemd-timesyncd
- nohang
- nohang-desktop
- fail2ban
- logrotate.timer
- sshd
mask:
- purge-kernels
commands:
- systemctl set-default multi-user.target
- name: "Generate host keys"
# Make sure the host always has available keys
commands:
- ssh-keygen -A
- name: "Create systemd services"
if: '[ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]'
files:
- path: /etc/systemd/system/cos-setup-boot.service
permissions: 0644
owner: 0
group: 0
content: |
[Unit]
Description=cOS system configuration
Before=getty.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage boot
[Install]
WantedBy=multi-user.target
- path: /etc/systemd/system/cos-setup-fs.service
permissions: 0644
owner: 0
group: 0
content: |
[Unit]
Description=cOS system after FS setup
DefaultDependencies=no
After=local-fs.target
Wants=local-fs.target
Before=sysinit.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage fs
[Install]
WantedBy=sysinit.target
- path: /etc/systemd/system/cos-setup-network.service
permissions: 0644
owner: 0
group: 0
content: |
[Unit]
Description=cOS setup after network
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage network
[Install]
WantedBy=multi-user.target
- path: /etc/systemd/system/cos-setup-reconcile.service
permissions: 0644
owner: 0
group: 0
content: |
[Unit]
Description=cOS setup reconciler
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
Type=oneshot
ExecStart=/bin/bash -c "systemd-inhibit /usr/bin/kairos-agent run-stage reconcile"
TimeoutStopSec=180
KillMode=process
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
- path: /etc/systemd/system/cos-setup-reconcile.timer
permissions: 0644
owner: 0
group: 0
content: |
[Unit]
Description=cOS setup reconciler
[Timer]
OnBootSec=5min
OnUnitActiveSec=60min
Unit=cos-setup-reconcile.service
[Install]
WantedBy=multi-user.target
- name: "Enable systemd services"
if: '[ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]'
commands:
- ln -sf /etc/systemd/system/cos-setup-reconcile.timer /etc/systemd/system/multi-user.target.wants/cos-setup-reconcile.timer
- ln -sf /etc/systemd/system/cos-setup-fs.service /etc/systemd/system/sysinit.target.wants/cos-setup-fs.service
- ln -sf /etc/systemd/system/cos-setup-boot.service /etc/systemd/system/multi-user.target.wants/cos-setup-boot.service
- ln -sf /etc/systemd/system/cos-setup-network.service /etc/systemd/system/multi-user.target.wants/cos-setup-network.service

View File

@ -1,6 +0,0 @@
image: "alpine"
package_dir: "/package"
steps:
- mkdir /package
- cp -rfv files/* /package
- chmod +x /package/usr/bin/cos-setup-reconcile

View File

@ -1,4 +0,0 @@
name: openrc
category: init-svc
version: 0.3.0
description: "Experimental package for openrc support"

View File

@ -1,10 +0,0 @@
#!/sbin/openrc-run
depend() {
provide cos-setup-boot
}
start() {
kairos-agent run-stage boot
eend 0
}

View File

@ -1,11 +0,0 @@
#!/sbin/openrc-run
depend() {
after net
provide cos-setup-network
}
start() {
kairos-agent run-stage network
eend 0
}

View File

@ -1,15 +0,0 @@
#!/sbin/openrc-run
depend() {
provide cos-setup-reconcile
}
supervisor=supervise-daemon
name="cos-setup-reconcile"
command="cos-setup-reconcile"
supervise_daemon_args="--stdout /var/log/cos-setup-reconcile.log --stderr /var/log/cos-setup-reconcile.log"
pidfile="/run/cos-setup-reconcile.pid"
respawn_delay=5
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport

View File

@ -1,6 +0,0 @@
image: "alpine"
steps:
- mkdir -p /etc/systemd/system
- mkdir -p /etc/systemd/network
- cp -rfv services/* /etc/systemd/system
- cp -rfv network/* /etc/systemd/network

View File

@ -1,3 +0,0 @@
name: systemd
category: init-svc
version: 0.9.0

View File

@ -1,11 +0,0 @@
[Unit]
Description=cOS system configuration
Before=getty.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage boot
[Install]
WantedBy=multi-user.target

View File

@ -1,14 +0,0 @@
[Unit]
Description=cOS system after FS setup
DefaultDependencies=no
After=local-fs.target
Wants=local-fs.target
Before=sysinit.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage fs
[Install]
WantedBy=sysinit.target

View File

@ -1,11 +0,0 @@
[Unit]
Description=cOS setup after network
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/kairos-agent run-stage network
[Install]
WantedBy=multi-user.target

View File

@ -1,15 +0,0 @@
[Unit]
Description=cOS setup reconciler
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
Type=oneshot
ExecStart=/bin/bash -c "systemd-inhibit /usr/bin/kairos-agent run-stage reconcile"
TimeoutStopSec=180
KillMode=process
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=cOS setup reconciler
[Timer]
OnBootSec=5min
OnUnitActiveSec=60min
Unit=cos-setup-reconcile.service
[Install]
WantedBy=multi-user.target