Import evilham's runit types as it
This commit is contained in:
parent
d3bf8512ec
commit
367cbde75b
10 changed files with 184 additions and 0 deletions
7
type/__evilham_runit/explorer/runit-etc
Executable file
7
type/__evilham_runit/explorer/runit-etc
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
runit_etc_dir="/etc/runit"
|
||||
|
||||
if [ -d "${runit_etc_dir}" ]; then
|
||||
echo "YES"
|
||||
fi
|
7
type/__evilham_runit/explorer/svdir-exists
Executable file
7
type/__evilham_runit/explorer/svdir-exists
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
svdir="/var/service"
|
||||
|
||||
if [ -d "${svdir}" ]; then
|
||||
echo "YES"
|
||||
fi
|
21
type/__evilham_runit/gencode-remote
Executable file
21
type/__evilham_runit/gencode-remote
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
svdir="/var/service"
|
||||
svdir_exists="$(cat "${__object}/explorer/svdir-exists")"
|
||||
runit_etc="$(cat "${__object}/explorer/runit-etc")"
|
||||
|
||||
if [ -z "${svdir_exists}" ]; then
|
||||
echo "mkdir '${svdir}'"
|
||||
sv_restart="YES"
|
||||
fi
|
||||
if [ -z "${runit_etc}" ]; then
|
||||
echo "cp -R '/usr/local/etc/runit' '/etc/runit'"
|
||||
sv_restart="YES"
|
||||
fi
|
||||
if grep -q "^__key_value/runsvdir_enable" "${__messages_in}"; then
|
||||
sv_restart="YES"
|
||||
fi
|
||||
|
||||
if [ -n "${sv_restart}" ]; then
|
||||
echo "service runsvdir restart || service runsvdir start"
|
||||
fi
|
46
type/__evilham_runit/man.rst
Normal file
46
type/__evilham_runit/man.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
cdist-type__evilham_runit(7)
|
||||
============================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__evilham_runit - Install and configure runit
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This is a singleton type.
|
||||
|
||||
Install and configure runit, not as an init system, but as a service monitor.
|
||||
It configures and if necessary starts runsvdir as documented for the
|
||||
Operating System.
|
||||
|
||||
This type currently heavily focuses on FreeBSD, support for other Operating
|
||||
Systems can be achieved but no effort whatsoever has been put into it.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
__evilham_runit
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`cdist-type__evilham_runit_service`\ (7)
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Evilham <cvs--@--evilham.com>
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2020 Evilham. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
10
type/__evilham_runit/manifest
Executable file
10
type/__evilham_runit/manifest
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
__package "runit"
|
||||
|
||||
__key_value \
|
||||
--file "/etc/rc.conf" \
|
||||
--key "runsvdir_enable" \
|
||||
--delimiter "=" \
|
||||
--value "yes" \
|
||||
"runsvdir_enable"
|
0
type/__evilham_runit/singleton
Normal file
0
type/__evilham_runit/singleton
Normal file
58
type/__evilham_runit_service/man.rst
Normal file
58
type/__evilham_runit_service/man.rst
Normal file
|
@ -0,0 +1,58 @@
|
|||
cdist-type__evilham_runit_service(7)
|
||||
====================================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__evilham_runit_service - Create a runit-compatible service dir.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Create a directory structure compatible with runit-like service management.
|
||||
|
||||
Note that sv(8) and runsvdir(8) must be present on the target system, this can
|
||||
be achieved with e.g. `__runit`.
|
||||
|
||||
The `__object_id` will be used as the service name.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
source
|
||||
File to save as <servicedir>/run. If set to '-', standard input will be used.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
log
|
||||
Setup logging with `svlogd -tt ./main`.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
require="__evilham_runit" __evilham_runit_service tasksched \
|
||||
--source - << EOF
|
||||
#!/bin/sh -e
|
||||
cd "${HOME}/.local/share/tasksched"
|
||||
exec ./server.js 2>&1
|
||||
EOF
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`cdist-type__evilham_runit`\ (7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Evilham <cvs--@--evilham.com>
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2020 Evilham. You can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
33
type/__evilham_runit_service/manifest
Executable file
33
type/__evilham_runit_service/manifest
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
svdir="/var/service"
|
||||
sv="${__object_id}"
|
||||
state="present"
|
||||
run_file="${svdir}/${sv}/run"
|
||||
|
||||
source="$(cat "$__object/parameter/source")"
|
||||
if [ "$source" = "-" ]; then
|
||||
source="$__object/stdin"
|
||||
fi
|
||||
|
||||
# Create this service's directory
|
||||
__directory --state "${state}" "${svdir}/${sv}"
|
||||
|
||||
export require="__directory${svdir}/${sv}"
|
||||
|
||||
|
||||
if [ -f "${__object}/parameter/log" ]; then
|
||||
# Setup logger if requested
|
||||
__directory --parents "${svdir}/${sv}/log/main"
|
||||
export require="${require} __directory${svdir}/${sv}/log/main"
|
||||
__file "${svdir}/${sv}/log/run" \
|
||||
--state "${state}" \
|
||||
--mode 0755 \
|
||||
--source "-" <<EOF
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Setup run file
|
||||
__file --state "${state}" --mode 0755 --source "${source}" "${run_file}"
|
1
type/__evilham_runit_service/parameter/boolean
Normal file
1
type/__evilham_runit_service/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
|||
log
|
1
type/__evilham_runit_service/parameter/required
Normal file
1
type/__evilham_runit_service/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
source
|
Loading…
Reference in a new issue