Skip to content
mstovenour edited this page Nov 22, 2014 · 2 revisions

This section defines a simple startup script and configures things so that MisterHouse will be automatically started at boot time. The startup script that we will be using is based on several that come with the MisterHouse distribution. If you want to see them, look for this files named: mh/bin/misterhouse_*.rc.

__Make festival server start at boot-up__

Working as root on the mh box edit the festival start-up script: //**root@mh_server:/#**// sudo nano /etc/init.d/festival

Find the line "exit 0" near the top of the file and comment it out:


# Comment out the next line to start a Festival server at boot time.
#exit 0
# NOTE: Not just anybody can connect to your server; the list of allowed
# hostnames is a regexp. Check /usr/share/festival/festival.scm for more
# helpful comments; add your settings to /etc/festival.scm.
#

Start the festival server: //**root@mh_server:/#**// sudo /etc/init.d/festival start

__Prepare init Script__

Instead of following the instructions below, you may follow the instructions in INITTAB Startup Method to set up an alternate method of starting MisterHouse such that it will be restarted by a built-in feature of Unix if MisterHouse crashes. However, since newer MisterHouses will restart themselves under most circumstances, the disadvantages of the INITTAB method probably outweigh the advantages and you should follow the guide below unless you have problems with MisterHouse crashing and not restarting. Another method of keeping MisterHouse running if you have problems is described on the Watch Dog page.

Working as root on the mh box, open an empty file: //**root@mh_server:/#**// sudo nano /etc/init.d/mh

In it place the following text:


#/etc/init.d/mh
# Starts and stops misterhouse

# Misterhouse automatically generates a PID file here:
PID=/opt/misterhouse/data/mh.pid

# Use this command to start the proxy
# this just calls another script that does the real work
DAEMON=/opt/misterhouse/mh.sh

# Start mh
start(){
 echo "Starting Misterhouse"
 start-stop-daemon --start --background --quiet --chuid mh --exec $DAEMON
 echo ""
}

# Stop mh
stop(){
 echo "Stopping Misterhouse"
 start-stop-daemon --stop --quiet --pidfile $PID
}


case "$1" in
start)
 start
;;
stop)
 stop
;;
restart)
 stop
 sleep 5
 start
;;
*) # Display a usage option.
 echo "Usage: /etc/init.d/mh {start|stop|restart}"
 exit 1
;;
esac
exit 0

Save and close the file and make it executable: //**root@mh_server:/#**// sudo chmod +x /etc/init.d/mh

Use rcconf to run the startup script at boot time: //**root@mh_server:/#**// sudo rcconf

This is an intuitive text user interface used to enable/disable scripts at boot time. You should see a line for the mh script you just created. Tab down to it and select it with the spacebar.

__Prepare mh.sh script__

The init script above really just runs a script called /opt/misterhouse/mh.sh that starts misterhouse as the user 'mh'. We are now going to write the script that actually starts misterhouse.

Change users to 'mh' //**root@mh_server:/#**// su mh //**mh@mh_server:/#**// nano /opt/misterhouse/mh.sh

Copy-paste the following text into this file:


#!/bin/sh

# This is the script used to start misterhouse. It is called at boot by /etc/init.d/mh
export mh_parms=/opt/misterhouse/mh.private.ini


# Save the old log file in case there was a crash
cp -f /opt/misterhouse/data/mh.log /opt/misterhouse/data/mh.old.log

# Start misterhouse
/opt/misterhouse/mh/bin/mh > /opt/misterhouse/data/mh.log 2>&1 &

Make the startup script executable: //**mh@mh_server:/#**//chmod +x /opt/misterhouse/mh.sh

This completes the basic installation and setup. Test the startup script by typing: //**mh@mh_server:/#**///etc/init.d/mh start

The check that mh is up and running by watching the log file: //**mh@mh_server:/#**//tail -f /opt/misterhouse/data/mh.log

You should see load of start up diagnostics followed by as "Saving object states..." messages every minute. If you do see the "Saving object states..." messages then mh is running correctly. If not, there's a problem. Back track over the previous pages and make sure everything is correctly configured.

This //should// stop MH //**mh@mh_server:/#**///etc/init.d/mh stop

If this works then reboot and make sure that everything starts as expected, by watching the mh log again.

Congratulations. You have now installed MisterHouse and your home automation adventure literally starts here... :)

Next: First Steps Back: Configure Misterhouse Return to Index

Clone this wiki locally