* added the Unlicense as valid in misc/share/REGISTER
[t2sde.git] / package / init / runit / rocknet_runit.sh
blob7c7a5e61fccc61a73d36b1b8476f4b96274763a2
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/runit/rocknet_runit.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
11 export CANUSESERVICE=1
13 service_create() {
14 local service_name=$1 runstring="$2" finishstring="$3"
16 mkdir -p $rocknet_tmp_base/$service_name/log
18 # ./run
19 cat <<-EOT > $rocknet_tmp_base/$service_name/run
20 #!/bin/sh
21 exec 2>&1
23 $runstring
24 EOT
26 # ./log/run
27 cat <<-EOT > $rocknet_tmp_base/$service_name/log/run
28 #!/bin/sh
29 exec 2>&1
31 if [ ! -d /var/log/$service_name ]; then
32 mkdir -p /var/log/$service_name
33 chown log /var/log/$service_name
35 exec chpst -ulog svlogd -tt /var/log/$service_name
36 EOT
38 # ./finish
39 if [ "$finishstring" ]; then
40 cat <<-EOT > $rocknet_tmp_base/$service_name/finish
41 #!/bin/sh
42 exec 2>&1
44 $finishstring
45 EOT
46 chmod +x $rocknet_tmp_base/$service_name/finish
49 chmod +x $rocknet_tmp_base/$service_name/{,log/}run
50 ln -nfs $rocknet_tmp_base/$service_name/ /service/$service_name
53 service_destroy() {
54 local service_name=$1 x=
56 for x in . log; do
57 if [ -d /service/$service_name/$x/supervise ]; then
58 runsvctrl d /service/$service_name/$x
59 svwaitdown /service/$service_name/$x
61 done
63 rm -f /service/$service_name
64 rm -rf $rocknet_tmp_base/$service_name/