examples, oneshot services rework

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2018-03-09 02:31:14 +03:00
parent 5506a922c6
commit e227235f46
9 changed files with 104 additions and 94 deletions

11
examples/services/iptables Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env ssm
service_oneshot = true
service_command = /usr/bin/false
service::pre_start() {
cat <<- EOF
Please don't. Use ferm or any other wrapper.
You will just reinvent one in here anyway.
EOF
}

8
examples/services/nginx Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env ssm
service_respawn = on-failure
service_command = /usr/bin/nginx
service_pidfile = /run/nginx.pid
# Do not reload the service if the config test fails.
pre_reload() { "$service_command" -t "$@"; }

9
examples/services/rc.local Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env ssm
service_type = oneshot
service_command = /etc/rc.local
pre_start() {
# Do nothing, successfully, if /etc/rc.local is not executable.
[[ -x "/etc/rc.local" ]] || die 0
}

10
examples/services/sshd Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env ssm
service_respawn = always
service_command = /usr/bin/sshd -D -f "/etc/ssh/sshd_config"
pre_start() {
if ! [[ -e "/etc/ssh/ssh_host_key" ]]; then
ssh-keygen -A
fi
}

7
examples/services/tinc Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env ssm
# This trick was neat back in 2011, I swear
var tinc_network = "${service_name##*-}"
service_respawn = on-failure
service_command = /usr/bin/tincd -D -n "$tinc_network"

11
examples/ssm.conf Normal file
View File

@@ -0,0 +1,11 @@
# This is actually a bash script
# Everything in ssm is a bash script.
# Enable cgroup-related functions.
# This requires quite specific setup that is undocumented as of yet, sorry.
#cgroups = 0
# You can also set service-level options here, as local defaults.
# I really do not advise doing that, but you *can*.
# For example:
#service_workdir = /