Home

Forums

Statistics

Surveys

Top Ten

Your Account


Login
Nickname

Password

Security Code: Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like a private journal and posting comments or additions to articles.

Who's Online
There are currently, 8 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

Donations
If you find the information here useful,
help keep this web site online with a donation!
YTD Donations
$1.00
Thank You!

Host referer


  
Creating a startup script for MisterHouse - or any program
Posted on Saturday, February 25 @ 22:22:06 CST
Topic: 3: More Magnia / Linux stuff

Starting and stopping MisterHouse automatically

This example applies to any program or service you wish to have started every time the system boots.
This example applies to Redhat linux RH7.3 or higher. It may work with other builds.

First you need to create a script and save it in the init.d directory.
With WebMin you can use File Manager to navigate to the directory and create a new file named "MisterHouse"
(you want the "New" button that looks like a piece of paper)
and just copy/paste the script into it.

Initialization script to be created in:

/etc/rc.d/init.d/



#!/bin/sh
#
# MisterHouse          MisterHouse home automation software
#
# set runlevels 345 to 99-last for startup and 01-first for shutdown
#
# chkconfig: 345 99 01
#
# description:   Start and Stop MisterHouse
#           
# Source profile to get PERL5LIB
. /etc/profile
  
# ////////////////////////////////////////////////////////////
start()
{
	echo -n "Starting MisterHouse... "
# go to default RPM misterhouse directory
	cd /usr/local/mh/bin
# setting to stop memory leak problem in RH 8 and 9
	export LANG=C
# start misterhouse redirecting output to null
# the final & sign tells shell to continue and not wait for output
	perl mh >>/dev/null 2>&1 &
	echo "Started." 
# give misterhouse time to open serial port
	sleep 3
	echo -n "Serial Port Parameters..." 
# sometimes serial port opened with default settings - which don't work, fix it
	stty 4800 -icrnl -ixon -iuclc -ixany -opost -isig -icanon -iexten -echo 
< /dev/ttyr00
# you MUST change ttyXX to your serial port - same as cm11
	echo "set"
	touch /var/lock/subsys/MisterHouse
	echo "Done"
}
# ////////////////////////////////////////////////////////////
stop()
{
	echo -n "Stopping MisterHouse... "
# get process id from default RPM location
	read pid < /usr/local/mh/data/mh.pid
	kill -TERM $pid 
	rm -f /var/lock/subsys/MisterHouse
	echo -n "Done"
}	

# ////////////////////////////////////////////////////////////
restart()
{
  	stop
	sleep 5
	start
}	

# ////////////////////////////////////////////////////////////

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  *)
	echo "Usage: MisterHouse (start|stop|restart}"
	exit 1
esac

exit $?
# ////////////////////////////////////////////////////////////
# ////////////////////////////////////////////////////////////
# ////////////////////////////////////////////////////////////

Once the file is created, set chmod to 0755.
You also have to issue some commands to install and verify initialization script:
(use telnet session or VNC session on Magnia)


[root@myserver root]# chkconfig MisterHouse --add
[root@myserver root]# chkconfig MisterHouse on
[root@myserver root]# for i in 1 2 3 4 5 6; do ls /etc/rc.d/rc$i.d/*ouse*; done
/etc/rc.d/rc1.d/K01MisterHouse@
/etc/rc.d/rc2.d/S99MisterHouse@
/etc/rc.d/rc3.d/S99MisterHouse@
/etc/rc.d/rc4.d/S99MisterHouse@
/etc/rc.d/rc5.d/S99MisterHouse@
/etc/rc.d/rc6.d/K01MisterHouse@


if output matches above, you're all set!

Remember: Questions can be posted in the FORUM section !


 
Related Links
· More about 3: More Magnia / Linux stuff
· News by anoldman


Most read story about 3: More Magnia / Linux stuff:
UPDATED: Forwarding Ports on your Magnia SG20


Article Rating
Average Score: 5
Votes: 2


Please take a second and vote for this article:

Excellent
Very Good
Good
Regular
Bad


Options

 Printer Friendly Printer Friendly

 Send to a Friend Send to a Friend


Associated Topics

2: Toshiba Magnia hacks

Please take a second and vote for this article.
Web site powered by PHP-Nuke

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2003 by AnOldMan.com
PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.07 Seconds