]> hackdaworld.org Git - hdw-linux/hdw-linux.git/blob - packages/base/udev/init_udev.sh
fixed font problem within ghostscript
[hdw-linux/hdw-linux.git] / packages / base / udev / init_udev.sh
1 #!/bin/sh
2 #
3 # hdw - linux /etc/init.d/udev
4 #
5 # populate /dev directory with device nodes
6 #
7
8 # read udev config
9 . /etc/udev/udev.conf
10
11 prog=udev
12 sysfs_dir=/sys
13 bin=/sbin/udev
14 udevd=/sbin/udevd
15
16 # add some nodes not exported by sysfs
17 run_udev()      {
18         # block devices & partitions
19         for i in ${sysfs_dir}/block/*; do
20                 export DEVPATH=${i#${sysfs_dir}}
21                 $bin block &
22                 for j in $i/*; do
23                         if [ -f $j/dev ]; then
24                                 export DEVPATH=${j#${sysfs_dir}}
25                                 $bin block &
26                         fi
27                 done
28         done
29         # all other devices
30         for i in ${sysfs_dir}/class/*; do
31                 for j in $i/*; do
32                         # cruel hack to not del /dev/null
33                         if [ "$j" != "${sysfs_dir}/class/mem/null" -o \
34                                         "$ACTION" != "remove" ] ; then
35                         if [ -f $j/dev ]; then
36                                 export DEVPATH=${j#${sysfs_dir}}
37                                 CLASS=`echo ${i#${sysfs_dir}} | \
38                                         cut --delimiter='/' --fields=3-`
39                                 $bin $CLASS &
40                         fi
41                         fi
42                 done
43         done
44         return 0
45                 }
46         
47 add_nodes()     {
48         ln -snf /proc/self/fd $udev_root/fd
49         ln -snf /proc/self/fd/0 $udev_root/stdin
50         ln -snf /proc/self/fd/1 $udev_root/stdout
51         ln -snf /proc/self/fd/2 $udev_root/stderr
52         ln -snf /proc/kcore $udev_root/core
53 }
54
55 # delete them when shutting down (not used right now)
56 del_nodes()     {
57         rm -rf $udev_root/{fd,stdin,stdout,stderr,core}
58 }
59
60 # main procedures
61
62 case "$1"
63 in
64         start)
65                 echo -n "starting udev ..."
66                 echo "/sbin/udev" > /proc/sys/kernel/hotplug
67                 if [ ! -d $sysfs_dir/block ] ; then
68                         echo "fatal: sysfs not mounted"
69                         exit 1
70                 fi
71                 rm -f $udev_root/.udev.tdb
72                 [ ! -c ${udev_root}/null ] && \
73                         mknod -m 0660 ${udev_root}/null c 1 3
74                 export ACTION=add
75                 export UDEV_NO_SLEEP=1
76                 run_udev
77                 add_nodes
78                 $udevd &
79                 echo " done"
80                 ;;
81         stop)
82                 echo -n "stopping udev ..."
83                 export ACTION=remove
84                 run_udev
85                 del_nodes
86                 echo " done"
87                 ;;
88         restart)
89                 /etc/init.d/udev stop
90                 /etc/init.d/udev start
91                 ;;
92         status)
93                 if [ -f /var/lock/subsys/udev ]; then
94                         echo "udev running ..."
95                 else
96                         echo "udev not running ..."
97                 fi
98                 ;;
99         *)
100                 echo "usage: $0 { start | stop | restart }"
101                 exit 1
102                 ;;
103 esac
104
105 exit 0