[go: up one dir, main page]

File: sysfsutils.init

package info (click to toggle)
sysfsutils 2.1.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 860 kB
  • ctags: 3
  • sloc: sh: 42; makefile: 10; ansic: 9
file content (53 lines) | stat: -rw-r--r-- 1,554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/sh -e
# /etc/init.d/sysfsutils: Set sysfs variables from /etc/sysfs.conf
#
# (c) 2005 Martin Pitt <mpitt@debian.org>

CONFFILE=/etc/sysfs.conf

[ -r "$CONFFILE" ] || exit 0

case "$1" in
    start|restart|force-reload)
	echo -n "Setting sysfs variables..."

	sed  's/#.*$//; /^[[:space:]]*$/d; 
              s/^[[:space:]]*\([^=[:space:]]*\)[[:space:]]*\([^=[:space:]]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1 \2 \3/' \
              $CONFFILE | {
	    while read f1 f2 f3; do
                if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then
                    if [ -f "/sys/$f2" ]; then
                        chmod "$f3" "/sys/$f2"
                    else
                        echo "unknown attribute $f2"
                    fi
                elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then
                    if [ -f "/sys/$f2" ]; then
                        chown "$f3" "/sys/$f2"
                    else
                        echo "unknown attribute $f2"
                    fi
                elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then
                    if [ -f "/sys/$f1" ]; then
                        echo -n "$f2" > "/sys/$f1"
                    else
                        echo "unknown attribute $f1"
                    fi
                else
                    echo "syntax error in $CONFFILE: '$f1' '$f2' '$f3'"
                    exit 1
                fi
	    done
	}

	echo "done."
	;;
    stop)
	;;
    *)
	echo "Usage: /etc/init.d/sysfsutils {start|stop|force-reload|restart}"
	exit 1
	;;
esac