Lines 1-31
Link Here
|
1 |
#!/bin/bash |
1 |
#!/sbin/runscript |
|
|
2 |
# Copyright 1999-2011 Gentoo Foundation |
3 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# $Header: $ |
2 |
|
5 |
|
3 |
case "$1" in |
6 |
DESCRIPTION="This utility is used to create a low cost home automation system controlled by computer" |
4 |
start) |
7 |
HOMEPAGE="http://openplacos.tuxfamily.org" |
5 |
echo "Starting OpenplacOS" |
8 |
|
6 |
su -l openplacos -s /bin/sh -c "dbus-launch /usr/bin/openplacos-server -f /etc/default/openplacos &" |
9 |
SVCNAME="openplacos-server" |
7 |
if [ $? -gt 0 ]; then |
10 |
USER=openplacos |
8 |
exit 1 |
11 |
DAEMON=/usr/bin/openplacos-server |
9 |
else |
12 |
DBUS_LAUNCHER=/usr/bin/dbus-launch |
10 |
exit 0 |
13 |
PIDFILE=/var/run/openplacos.pid |
11 |
fi |
14 |
CONFIGFILE=/etc/default/openplacos |
12 |
;; |
15 |
LOGFILE=/tmp/openplacos.log |
13 |
stop) |
16 |
|
14 |
echo "Stopping OpenplacOS" |
17 |
depend() { |
15 |
pkill openplacos -u openplacos |
18 |
need dbus |
16 |
if [ $? -gt 0 ]; then |
19 |
after logger |
17 |
exit 1 |
20 |
} |
18 |
else |
21 |
|
19 |
exit 0 |
22 |
checkconfig() { |
20 |
fi |
23 |
if [ ! -r ${CONFIGFILE} ]; then |
21 |
|
24 |
eerror "ERROR: Unable to read configuration file: ${CONFIGFILE}" |
22 |
;; |
25 |
return 1 |
23 |
restart) |
26 |
fi |
24 |
$0 stop |
27 |
} |
25 |
sleep 1 |
28 |
|
26 |
$0 start |
29 |
start() { |
27 |
;; |
30 |
ebegin "Starting openplacos" |
28 |
*) |
31 |
start-stop-daemon --start --quiet --user ${USER} \ |
29 |
echo "usage: $0 {start|stop|restart}" |
32 |
--exec ${DBUS_LAUNCHER} ${DAEMON} \ |
30 |
esac |
33 |
--background --stdout ${LOGFILE} \ |
31 |
exit 0 |
34 |
--pidfile ${PIDFILE} --make-pidfile |
|
|
35 |
eend $? "Failed to start openplacos !" |
36 |
} |
37 |
|
38 |
stop() { |
39 |
ebegin "Stopping openplacos" |
40 |
start-stop-daemon --stop --quiet --user ${USER} --pidfile ${PIDFILE} |
41 |
eend $? "Failed to stop openplacos !" |
42 |
} |