procd: setup /dev/stdin, /dev/stdout and /dev/stderr symlinks
[openwrt/staging/chunkeey.git] / package / system / procd / files / hotplug.json
1 [
2 [ "case", "ACTION", {
3 "add": [
4 [ "if",
5 [ "and",
6 [ "has", "MAJOR" ],
7 [ "has", "MINOR" ]
8 ],
9 [
10 [ "if",
11 [ "eq", "DEVNAME", "null" ],
12 [
13 [ "makedev", "/dev/%DEVNAME%", "0666" ],
14 [ "exec", "/bin/ln", "-s", "/proc/self/fd/0", "/dev/stdin" ],
15 [ "exec", "/bin/ln", "-s", "/proc/self/fd/1", "/dev/stdout" ],
16 [ "exec", "/bin/ln", "-s", "/proc/self/fd/2", "/dev/stderr" ],
17 [ "return" ]
18 ]
19 ],
20 [ "if",
21 [ "eq", "DEVNAME",
22 [ "full", "ptmx", "zero", "tty", "net", "random", "urandom" ]
23 ],
24 [
25 [ "makedev", "/dev/%DEVNAME%", "0666" ],
26 [ "return" ]
27 ]
28 ],
29 [ "if",
30 [ "regex", "DEVNAME", "^snd" ],
31 [ "makedev", "/dev/%DEVNAME%", "0660", "audio" ]
32 ],
33 [ "if",
34 [ "regex", "DEVNAME", "^tty" ],
35 [ "makedev", "/dev/%DEVNAME%", "0660", "dialout" ]
36 ],
37 [ "if",
38 [ "has", "DEVNAME" ],
39 [ "makedev", "/dev/%DEVNAME%", "0600" ]
40 ]
41 ]
42 ],
43 [ "if",
44 [ "has", "FIRMWARE" ],
45 [
46 [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
47 [ "load-firmware", "/lib/firmware" ],
48 [ "return" ]
49 ]
50 ],
51 [ "if",
52 [ "regex", "DEVNAME", "^ttyGS" ],
53 [ "start-console", "%DEVNAME%" ]
54 ]
55 ],
56 "remove" : [
57 [ "if",
58 [ "and",
59 [ "has", "DEVNAME" ],
60 [ "has", "MAJOR" ],
61 [ "has", "MINOR" ]
62 ],
63 [ "rm", "/dev/%DEVNAME%" ]
64 ]
65 ]
66 } ],
67 [ "if",
68 [ "and",
69 [ "has", "BUTTON" ],
70 [ "eq", "SUBSYSTEM", "button" ]
71 ],
72 [ "button", "/etc/rc.button/%BUTTON%" ]
73 ],
74 [ "if",
75 [ "and",
76 [ "eq", "SUBSYSTEM", "usb-serial" ],
77 [ "regex", "DEVNAME",
78 [ "^ttyUSB", "^ttyACM" ]
79 ]
80 ],
81 [ "exec", "/sbin/hotplug-call", "tty" ],
82 [ "if",
83 [ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
84 [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
85 ]
86 ]
87 ]