Skip to content

Commit

Permalink
Add and enable openrc/systemd service via yip files (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Oct 20, 2023
1 parent 9e8d950 commit c6ec9b5
Show file tree
Hide file tree
Showing 22 changed files with 200 additions and 158 deletions.
2 changes: 1 addition & 1 deletion packages/alpine/collection.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions packages/alpine/files/initramfs-init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/static/kairos-overlay-files/collection.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:
- name: "kairos-overlay-files"
category: "static"
version: "1.1.6"
version: "1.1.7"
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions packages/system/init-svc/openrc/cos-setup/build.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions packages/system/init-svc/openrc/cos-setup/definition.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions packages/system/init-svc/systemd/build.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions packages/system/init-svc/systemd/definition.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions packages/system/init-svc/systemd/services/cos-setup-boot.service

This file was deleted.

14 changes: 0 additions & 14 deletions packages/system/init-svc/systemd/services/cos-setup-fs.service

This file was deleted.

This file was deleted.

Loading

0 comments on commit c6ec9b5

Please sign in to comment.