]> git.netwichtig.de Git - user/henk/code/puppet/modules/s6.git/commitdiff
initial
authorHendrik Jäger <gitcommit@henk.geekmail.org>
Wed, 20 Apr 2022 12:06:19 +0000 (14:06 +0200)
committerHendrik Jäger <gitcommit@henk.geekmail.org>
Sun, 22 May 2022 17:29:02 +0000 (19:29 +0200)
files/etc/init.d/s6 [new file with mode: 0644]
files/usr/local/bin/s6-svscanboot [new file with mode: 0644]
manifests/init.pp [new file with mode: 0644]
manifests/install.pp [new file with mode: 0644]
manifests/service.pp [new file with mode: 0644]

diff --git a/files/etc/init.d/s6 b/files/etc/init.d/s6
new file mode 100644 (file)
index 0000000..59de3fa
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env /lib/init/init-d-script
+
+### BEGIN INIT INFO
+# Provides:          s6
+# Required-Start:    $remote_fs $syslog nftables
+# Required-Stop:     $remote_fs $syslog nftables
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start s6 service supervision suite
+# Description:       Start s6 service supervision suite
+### END INIT INFO
+
+DAEMON="/usr/local/bin/s6-svscanboot"
+DAEMON_ARGS="/etc/s6-services"
+
+do_stop_cmd_override() {
+       /usr/bin/s6-svscanctl -t /etc/s6-services/
+}
diff --git a/files/usr/local/bin/s6-svscanboot b/files/usr/local/bin/s6-svscanboot
new file mode 100644 (file)
index 0000000..7a5f549
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/execlineb -S1
+
+foreground { redirfd -w 2 /dev/null mkdir -p /run/uncaught-logs }
+if { chown s6-logs:s6-logs /run/uncaught-logs }
+if { chmod 2700 /run/uncaught-logs }
+foreground { redirfd -w 2 /dev/null mkdir -p ${1}/.s6-svscan ${1}/s6-svscan-log }
+foreground { redirfd -w 2 /dev/null ln -sf /bin/false ${1}/.s6-svscan/crash }
+if
+{
+  redirfd -w 1 ${1}/.s6-svscan/finish
+  heredoc 0 "#!/bin/execlineb -P\ns6-svc -x -- \"${1}/s6-svscan-log\"\n"
+  cat
+}
+if { chmod 0755 ${1}/.s6-svscan/finish }
+foreground { redirfd -w 2 /dev/null mkfifo -m 0600 ${1}/s6-svscan-log/fifo }
+if
+{
+  redirfd -w 1 ${1}/s6-svscan-log/run
+  heredoc 0 "#!/bin/execlineb -P
+redirfd -w 2 /dev/console
+redirfd -rnb 0 fifo
+s6-setuidgid s6-logs
+exec -c
+s6-log t /run/uncaught-logs\n"
+  cat
+}
+if { chmod 0755 ${1}/s6-svscan-log/run }
+
+redirfd -r 0 /dev/null
+redirfd -wnb 1 ${1}/s6-svscan-log/fifo
+fdmove -c 2 1
+s6-svscan -- ${1}
+
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644 (file)
index 0000000..cd36656
--- /dev/null
@@ -0,0 +1,10 @@
+class s6 {
+  require 'execline'
+
+  class {
+    "${name}::install":
+      notify => Class["${name}::service"],
+    ;
+    "${name}::service": ;
+  }
+}
diff --git a/manifests/install.pp b/manifests/install.pp
new file mode 100644 (file)
index 0000000..de016ee
--- /dev/null
@@ -0,0 +1,32 @@
+class s6::install {
+  package {
+    's6':
+      ensure => installed,
+    ;
+  }
+  file {
+    '/usr/local/bin/s6-svscanboot':
+      ensure  => present,
+      source  => 'puppet:///modules/s6/usr/local/bin/s6-svscanboot',
+      mode    => '0755',
+      require => Package['s6'],
+    ;
+    '/etc/init.d/s6':
+      ensure  => present,
+      source  => 'puppet:///modules/s6/etc/init.d/s6',
+      mode    => '0755',
+      require => Package['s6'],
+    ;
+    '/etc/s6-services/':
+      ensure => directory,
+    ;
+  }
+  user {
+    's6-logs':
+      ensure => present,
+      home   => '/nonexistant',
+      shell  => '/usr/sbin/nologin',
+      system => true,
+    ;
+  }
+}
diff --git a/manifests/service.pp b/manifests/service.pp
new file mode 100644 (file)
index 0000000..0e90664
--- /dev/null
@@ -0,0 +1,8 @@
+class s6::service {
+  service {
+    's6':
+      ensure => running,
+      enable => true,
+    ;
+  }
+}