Skip to content

Misterhouse on DD WRT with Optware

Lieven Hollevoet edited this page Sep 22, 2014 · 1 revision
    • Misterhouse on DD-WRT with Optware**
__**Basics**__ Hardware: Asus R**T**-N16 with attached USB HDD DD-WRT DD-WRT v24-sp2 (01/10/12) kingkong - build 18050M Kernel for this build is 2.6.24.111 I had chosen the kingkong build as it included Samba 3.0 and a Mini-DLNA server Optware OTRW, installed following the DD-WRT Advanced How-To

__**Adding a non-Root User**__ Optware add packages ipkg install whoami for mkpasswd ipkg install adduser to add user Discussion The files passwd and group are located in /tmp/etc, which is ram (and lost on reboot). Running adduser adds a user row to the passwd file, but does not implement a password. For example, adduser carl adds the row **carl:*:1000:100:carl:/opt/home/carl:/bin/sh to /tmp/etc/passwd.** To add a password for the new user, run mkpasswd -m md5 yourpasswdhere, copy the resulting output and paste it into the password field in **/tmp/etc/passwd** with vi or your favorite solution: **carl:$1$ePWKAcpI$unqZlptY6rDu6/:1000:100:carl:/opt/home/carl:/bin/sh** Group management is also a bit limited. For compatibility with my openSUSE desktop, which I use to manage my RT-N16, I edited the original user:group for my new user from 1000:1000 to 1000:100 in file passwd. I then edited in a row to the file **/tmp/etc/group** **users:x:100:** With these modifications in place, I was able to log in as user carl over an ssh connection. Automation: To deal with the passwd and group files being volitile, I made copies in a location on my HDD. I then created the following startup script

root@RT-N16_2:/opt/etc/init.d# ll S60fix_user_and_group_cjm

    • -rwxr-xr-x 1 root root 326 Dec 16 12:32 S60fix_user_and_group_cjm**
root@RT-N16_2:/opt/etc/init.d# cat S60fix_user_and_group_cjm
    • #!/bin/sh**
    • SCRIPT=${0##*/}**
    • optlog "${SCRIPT}" "copying passwd and group files to enable user login"**
    • #cjm Multiusr fixup for Optware**
    • #This script copies the manually created files to /tmp/etc where dd-wrt expects to find them**
    • cp /opt/home/carl/bin/passwd /tmp/etc/passwd**
    • cp /opt/home/carl/bin/group /tmp/etc/group**
    • exit 0**
The script runs on startup. The non-volitile files must manually be kept up to date if changes are made.

__**Adding Misterhouse**__ Following the Misterhouse Installation Wiki, I installed a current SVN of the Misterhouse code in my user directory /opt/home/carl/Misterhouse.

    • Perl **
Optware has several Perl packages available. So far, I have the following installed root@RT-N16_2:/opt/etc/init.d# ipkg list_installed |grep perl
    • perl - 5.8.8-24 - Practical Extraction and Report Language.**
    • perl-compress-zlib - 1.42-3 - Compress-Zlib - Interface to zlib compression library.**
    • perl-gd - 2.35-2 - GD - Interface to Gd Graphics Library**
    • perl-html-parser - 3.60-1 - A collection of modules that parse and extract information from HTML documents.**
    • perl-html-tagset - 3.04-4 - This module contains data tables useful in dealing with HTML.**
    • perl-io-multiplex - 1.09-1 - IO-Multiplex - Manage IO on many file handles**
    • perl-io-socket-ssl - 0.999-1 - IO-Socket-SSL - Nearly transparent SSL encapsulation for IO::Socket::INET**
    • perl-io-string - 1.08-2 - IO-String - Emulate file interface for in-core strings.**
    • perl-io-stringy - 2.110-2 - IO-stringy - I/O on in-core objects like strings and arrays**
    • perl-io-zlib - 1.09-1 - IO-Zlib - IO:: style interface to Compress::Zlib.**
    • perl-libwww - 5.825-1 - libwww-perl - The World-Wide Web library for Perl**
    • perl-net-ssleay - 1.30-1 - Net_SSLeay - Perl extension for using OpenSSL**
    • perl-timedate - 1.16-1 - A date and time module for perl.**
    • perl-uri - 1.35-3 - URI - <module_description>&lt;/span&gt;</module_description>**
With these Misterhouse runs, I can't say for sure they are all needed or if this list is complete as I am still testing. **PLM ** I use a 2412U USB PLM Getting my USB connected PLM up and running was an adventure. The base DD-WRT setup is plug and play for USB storage and printers but not for serial interfaces. After flailing a bit, a dd-wrt forum post pointed me in the right direction.
  • Two kernel modules need to be manually installed
  • mknode must be run to set up the /dev interface
  • The permissions on the new node must be adjusted to give my non-root user access to the PLM.
The process is best described in the script I created to automate the procedure on bootup

Note: The Optware package modutils does not run on kernel 2.6 so we have limited module manipulation functions to work with from Busybox. root@RT-N16_2:/opt/etc/init.d# ll S60modutils_cjm

    • -rwxr-xr-x 1 root root 1511 Dec 16 12:37 S60modutils_cjm**
root@RT-N16_2:/opt/etc/init.d# cat S60modutils_cjm
    • #!/bin/sh**
    • SCRIPT=${0##*/}**
    • #cjm**
    • #This script hacked by starting with S01modutils from the modutils package which does not run on kernel 2.6 on dd-wrt**
    • # script to manually load additional modules at boot**
    • PATH="/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin"**
    • optlog "${SCRIPT}" "Inserting ftdi and serial modules and doing mknode and permissions fixup cjm"**
    • # Load kernel modules provided by the dd-wrt distribution - they don't auto load**
    • insmod /lib/modules/2.6.24.111/kernel/drivers/usb/serial/usbserial.ko**
    • insmod /lib/modules/2.6.24.111/kernel/drivers/usb/serial/ftdi_sio.ko**
    • # Although dmesg shows the ftdi serial interface(the device used in the PLM) connected to ttyUSB0 after above, a node does not get created**
    • # create a node**
    • mknod /dev/usb/ttyUSB0 c 188 0**
    • # mknod creates the node with permissions CRW-R--R--**
    • # we want a user to be able to access it, so add permissions**
    • chmod 666 /dev/usb/ttyUSB0**
    • exit 0**
    • Misterhouse**
Misterhouse could now be executed in the usual manner my navigating to ~/Misterhouse/mh/bin and running sh ./mhl as my normal user I then created the following service script to automatically start Misterhouse on boot as my non-root user, assuming that the service was enabled by the Opware service management process

Note: Optware does not have a daemon command for kernel 2.26.

root@RT-N16_2:/opt/etc/init.d# ll S99cjm_misterhouse

    • -rwxr-xr-x 1 root root 2781 Dec 16 12:54 S99cjm_misterhouse**
root@RT-N16_2:/opt/etc/init.d# ll K99cjm_misterhouse
    • lrwxrwxrwx 1 root root 18 Dec 15 20:20 K99cjm_misterhouse -> S99cjm_misterhouse**
root@RT-N16_2:/opt/etc/init.d# cat S99cjm_misterhouse
    • #!/bin/sh**
    • NAME=Misterhouse**
    • # The above will identify this script to the Optware service mechanism**
    • #**
    • # mrHouse This shell script takes care of starting and stopping **
    • # MisterHouse Home Automation Software.**
    • [-x] || exit 0**
    • PIDFILE=/opt/home/carl/Misterhouse/cjm_local/data/mh.pid**
    • LOCKFILE=/opt/home/carl/Misterhouse/cjm_local/data/mh.lock**
    • DESC="Misterhouse "**
    • prog=mh**
    • export mh_parms=/opt/home/carl/Misterhouse/cjm_local/mh.private_cjm.ini**
    • RETVAL=0**
    • #cjm how were we called?**
    • if [-z] ; then**
    • case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in**
    • S??*) rc="start" ;;**
    • K??*) rc="stop" ;;**
    • *) rc="usage" ;;**
    • esac**
    • else**
    • rc="$1"**
    • fi**
    • start () {**
    • # start daemon**
    • export LANG=en_US**
    • cd /opt/home/carl/Misterhouse/mh/bin/**
    • #daemon --user=carl --pidfile=$PIDFILE --stdout=/opt/home/carl/Misterhouse/cjm_local/data/logs/cjm_mh.out /opt/home/carl/Misterhouse/mh/bin/mh &**
    • sudo -u carl mh_parms=/opt/home/carl/Misterhouse/cjm_local/mh.private_cjm.ini nohup /opt/home/carl/Misterhouse/mh/bin/mh > /opt/home/carl/Misterhouse/cjm_local/data/logs/cjm_mh.out &**
    • RETVAL=$?**
    • echo -n $"Starting $prog: "**
    • echo**
    • [$RETVAL] && touch $LOCKFILE**
    • return $RETVAL**
    • }**
    • stop () {**
    • # stop daemon**
    • #killproc /opt/home/carl/Misterhous/mh/bin/mh**
    • kill `cat $PIDFILE`**
    • RETVAL=$?**
    • echo -n $"Stopping $prog: "**
    • echo**
    • [$RETVAL] && rm -f $LOCKFILE**
    • return $RETVAL**
    • }**
    • restart () {**
    • stop**
    • sleep 5**
    • start **
    • RETVAL=$?**
    • return $RETVAL**
    • }**
    • # Based on how we were called. **
    • case "$rc" in**
    • start)**
    • start**
    • ;;**
    • stop)**
    • stop**
    • ;;**
    • status)**
    • echo -n "Status of $DESC: "**
    • if [!]; then**
    • echo "$NAME is not running."**
    • exit 3**
    • fi**
    • if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then**
    • echo "$NAME is running."**
    • exit 0**
    • else**
    • echo "$NAME is not running but $PIDFILE exists."**
    • exit 1**
    • fi**
    • ;;**
    • restart)**
    • restart**
    • ;;**
    • *)**
    • echo $"Usage: $0 {start|stop|restart|status}"**
    • RETVAL=1**
    • esac**
    • exit $RETVAL**
Clone this wiki locally