Skip to content

Commit 733e9d0

Browse files
authored
Merge pull request #156 from icedieler/cronie_initd
core::cronie: add sysvinit start script
2 parents 6ca74a0 + 7695fce commit 733e9d0

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

recipes/core/cronie.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SUMMARY = "Cron daemon for executing programs at set times"
22
# HOMEPAGE = "https://github.com/cronie-crond/cronie/"
33

4-
inherit: [autotools]
4+
inherit: [autotools, init]
55

66
metaEnvironment:
77
PKG_DESCRIPTION: "Cronie contains the standard UNIX daemon crond that runs
@@ -23,5 +23,10 @@ buildScript: |
2323
autotoolsBuild $1 \
2424
--prefix=/usr
2525
26+
# add init script
27+
if initIsAnySysvinit; then
28+
install -D -m 0755 $<@cronie/S48cronie.sh@> install/etc/init.d/S48cronie.sh
29+
fi
30+
2631
packageScript: |
2732
autotoolsPackageTgt

recipes/core/cronie/S48cronie.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
#
3+
# Starts cronie (crond) daemon
4+
#
5+
6+
DAEMON="crond"
7+
PIDFILE="/var/run/$DAEMON.pid"
8+
9+
# shellcheck source=/dev/null
10+
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
11+
12+
start() {
13+
printf 'Starting %s: ' "$DAEMON"
14+
# shellcheck disable=SC2086 # we need the word splitting
15+
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON"
16+
status=$?
17+
if [ "$status" -eq 0 ]; then
18+
echo "OK"
19+
else
20+
echo "FAIL"
21+
fi
22+
return "$status"
23+
}
24+
25+
stop() {
26+
printf 'Stopping %s: ' "$DAEMON"
27+
start-stop-daemon -K -q -p "$PIDFILE"
28+
status=$?
29+
if [ "$status" -eq 0 ]; then
30+
rm -f "$PIDFILE"
31+
echo "OK"
32+
else
33+
echo "FAIL"
34+
fi
35+
return "$status"
36+
}
37+
38+
restart() {
39+
stop
40+
sleep 1
41+
start
42+
}
43+
44+
case "$1" in
45+
start|stop|restart)
46+
"$1";;
47+
reload)
48+
# Restart, since there is no true "reload" feature.
49+
restart;;
50+
*)
51+
echo "Usage: $0 {start|stop|restart|reload}"
52+
exit 1
53+
esac

0 commit comments

Comments
 (0)