1#!/bin/sh
2#
3# OWFS setup routines for SUSE systems
4# Written by Paul Alfille and others.
5# udev routines by Peter Kropf
6# GPL v2 license (like all of OWFS)
7# copyrite 12/2006 Paul H Alfille
8#
9### ------------------
10### -- Constants -----
11### ------------------
12OWFS_GROUP=ow
13#
14#
15###  -----------------
16###  -- Group --------
17###  -----------------
18groupadd $OWFS_GROUP
19#
20###  -----------------
21###  -- Links --------
22###  -----------------
23# Put all the ninaries in /usr/bin
24#  make them part of the "ow" group
25#  and let only their owner and group read or execute them
26OWFS_bin="owfs owhttpd owftpd owserver owread owwrite owpresent owdir"
27for x in $OWFS_bin
28  do
29  ln -sfv /opt/owfs/bin/$x /usr/bin/$x
30done
31#
32###  -----------------
33###  -- Rules --------
34###  -----------------
35cat >/etc/udev/rules.d/46_ds2490.rules << RULES
36BUS=="usb", SYSFS=="04fa", SYSFS=="2490", GROUP="users", MODE="0774", PROGRAM="/bin/sh -c 'K=%k; K=\$\$; printf bus/usb/%%03i/%%03i \$\$ \$\$'", NAME="%c", RUN="/etc/udev/ds2490 '%c'"
37RULES
38#
39###  -----------------
40###  -- Shell --------
41###  -----------------
42cat >/etc/udev/ds2490 << SHELL
43#! /bin/sh -x
44    /sbin/rmmod ds9490r
45    MATCH="no"
46    if [ "\$1" != "" ]; then
47        if [ -f /proc/\$1 ]; then
48            chgrp $OWFS_GROUP /proc/\$1 && \
49            chmod g+rw /proc/\$1 && \
50            logger ow udev: group set to $OWFS_GROUP and permission g+rw on /proc/\$1
51            MATCH="yes"
52        fi
53
54        if [ -e /dev/\$1 ]; then
55            chgrp $OWFS_GROUP /dev/\$1 && \
56            chmod g+rw /dev/\$1 && \
57            logger ow udev: group set to $OWFS_GROUP and permission g+rw on /dev/\$1
58            MATCH="yes"
59        fi
60    fi
61
62    if [ "\$MATCH" = "no" ]; then
63        echo ow udev: no device file found for "\$1"
64        logger ow udev: no device file found for "\$1"
65    fi
66SHELL
67chmod 755 /etc/udev/ds2490
68