Advertisement
Guest User

Initscript OPOS

a guest
Apr 16th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/sbin/runscript
  2. # Copyright 1999-2011 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: $
  5.  
  6. DESCRIPTION="This utility is used to create a low cost home automation system controlled by computer"
  7. HOMEPAGE="http://openplacos.tuxfamily.org"
  8.  
  9. SVCNAME="openplacos-server"
  10. USER=openplacos
  11. DAEMON=$(which ${SVCNAME})
  12. PIDFILE=/var/run/openplacos.pid
  13. CONFIGFILE=/etc/default/openplacos
  14. LOGFILE=/tmp/openplacos.log
  15.  
  16. depend() {
  17.         need dbus mysql
  18.         after logger
  19. }
  20.  
  21. checkconfig() {
  22.         if [ ! -r ${CONFIGFILE} ]; then
  23.                 eerror "ERROR: Unable to read configuration file: ${CONFIGFILE}"
  24.                 return 1
  25.         fi
  26. }
  27.  
  28. checkprocess() {
  29.         if [ $(ps ax | grep ${SVCNAME} | grep -v grep | wc -l) -eq 0 ]; then
  30.                 eerror "ERROR: Please, check logfile: ${LOGFILE}"
  31.                 return 1
  32.         fi
  33. }
  34.  
  35. start() {
  36.         checkconfig || return $?
  37.  
  38.         ebegin "Starting openplacos"
  39.         export RUBYOPT="rubygems"
  40.         start-stop-daemon --start --user ${USER} --exec `dbus-launcher ${DAEMON}` \
  41.         --pidfile ${PIDFILE} --make-pidfile --background --stdout ${LOGFILE}
  42.  
  43.         sleep 3
  44.         checkprocess || return $?
  45.  
  46.         eend $? "Failed to start openplacos !"
  47. }
  48.  
  49. stop() {
  50.         ebegin "Stopping openplacos"
  51.         start-stop-daemon --stop --quiet --user ${USER} --exec `dbus-launcher {DAEMON}`     --pidfile ${PIDFILE}
  52.         eend $? "Failed to stop openplacos !"
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement