Creating a startup script for MisterHouse - or any program

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:


# 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 
# ////////////////////////////////////////////////////////////
	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"
# ////////////////////////////////////////////////////////////
	echo -n "Stopping MisterHouse... "

	# get process id from default RPM location
	read pid < /usr/local/mh/data/
	kill -TERM $pid
	rm -f /var/lock/subsys/MisterHouse
	echo -n "Done"
# ////////////////////////////////////////////////////////////
	sleep 5
# ////////////////////////////////////////////////////////////
case "$1" in
	echo "Usage: MisterHouse (start|stop|restart}"
	exit 1

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

if output matches above, you're all set!