forked from community-ssu/alarmd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
alarmd.init
101 lines (88 loc) · 2.68 KB
/
alarmd.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/sh
# ============================================================================
#
# This file is part of Alarmd
#
# Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
#
# Contact: Simo Piiroinen <[email protected]>
#
# Alarmd is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# version 2.1 as published by the Free Software Foundation.
#
# Alarmd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with Alarmd; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
#
# ============================================================================
### BEGIN INIT INFO
# Provides: alarmd
# Required-Start: $remote_fs $syslog dbus clockd
# Required-Stop: $remote_fs $syslog dbus clockd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Alarm daemon
# Description: This init script starts the alarm daemon software
# used on the maemo platform.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=@SBINDIR@/alarmd.wrapper
NAME=alarmd
DESC="Alarm Daemon"
INITFILE=/etc/init.d/$NAME
DSMETOOL=/usr/sbin/dsmetool
DAEMON_OPTS=""
# abort if simple command fails
set -e
# abort if no executable exists
test -x $DAEMON
# only use dsmetool if it exists
test -x $DSMETOOL || USE_DSMETOOL="no"
start_alarmd()
{
if [ -h /targets/links/scratchbox.config ]; then
echo "SCRATCHBOX: you need to start $DAEMON manually"
elif [ "$USE_DSMETOOL" = "no" ]; then
start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
else
$DSMETOOL -U user -G users -f "$DAEMON $DAEMON_OPTS"
fi
}
stop_alarmd()
{
if [ -h /targets/links/scratchbox.config ]; then
echo "SCRATCHBOX: you need to stop $DAEMON manually"
elif [ "$USE_DSMETOOL" = "no" ]; then
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
else
$DSMETOOL -U user -G users -k "$DAEMON $DAEMON_OPTS"
fi
}
case "$1" in
start)
printf "Starting $DESC: $NAME\n"
start_alarmd
;;
stop)
printf "Stopping: $DESC: $NAME\n"
stop_alarmd
;;
restart|force-reload)
printf "Restarting $DESC: $NAME\n"
stop_alarmd
sleep 2
start_alarmd
;;
*)
printf >&2 "Usage: $INITFILE {start|stop|restart|force-reload}\n"
exit 1
;;
esac
exit 0