Mercurial > vanilla
comparison Templates/init/rc @ 1027:34c9fa83dc08
vanilla: cleanup templates directory
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 29 Aug 2019 21:00:00 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1026:3dfef64b81c1 | 1027:34c9fa83dc08 |
---|---|
1 #!/bin/busybox sh | |
2 # | |
3 # /etc/rc.d/template -- run control script for template | |
4 # | |
5 # Copyright (c) 2019 FirstName LastName <mailaddress> | |
6 # | |
7 # Permission to use, copy, modify, and/or distribute this software for any | |
8 # purpose with or without fee is hereby granted, provided that the above | |
9 # copyright notice and this permission notice appear in all copies. | |
10 # | |
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 # | |
19 | |
20 if [ -f /etc/rc.conf ]; then | |
21 . /etc/rc.conf | |
22 fi | |
23 | |
24 : ${TEMPLATE_CMD:=/bin/template} | |
25 : ${TEMPLATE_ARGS:=--foo} | |
26 : ${TEMPLATE_PID:=/var/run/template.pid} | |
27 | |
28 template_start() | |
29 { | |
30 if [ -s $TEMPLATE_PID ]; then | |
31 echo "template is already running with pid: $(cat $TEMPLATE_PID)" | |
32 else | |
33 echo "Starting template: $TEMPLATE_CMD $TEMPLATE_ARGS" | |
34 $TEMPLATE_CMD $TEMPLATE_ARGS | |
35 fi | |
36 } | |
37 | |
38 template_status() | |
39 { | |
40 if [ -s $TEMPLATE_PID ]; then | |
41 echo "template is running with pid: $(cat $TEMPLATE_PID)" | |
42 else | |
43 echo "template is not running" | |
44 fi | |
45 } | |
46 | |
47 template_stop() | |
48 { | |
49 if [ -s $TEMPLATE_PID ]; then | |
50 echo "Stopping template." | |
51 kill -QUIT $(cat $TEMPLATE_PID) | |
52 fi | |
53 } | |
54 | |
55 template_restart() | |
56 { | |
57 template_stop | |
58 sleep 3 | |
59 template_start | |
60 } | |
61 | |
62 case $1 in | |
63 start) | |
64 template_start | |
65 ;; | |
66 status) | |
67 template_status | |
68 ;; | |
69 stop) | |
70 template_stop | |
71 ;; | |
72 restart) | |
73 template_restart | |
74 ;; | |
75 *) | |
76 echo "usage: $(basename $0) restart|start|status|stop" | |
77 ;; | |
78 esac |