blob: 1cc6b03bf27f2f7332625fda708296bdd6e79d8e (
plain)
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
|
#!/bin/sh
# scripts that moves devices to the $1/ subdir.
# usage: subdir_dev [-ln] DIR [NEW_NAME]
# options:
# -l create link (i.e. /dev/pcm0 -> /dev/snd/pcm0)
# -n devicename from number (i.e. /dev/loop0 => /dev/loop/0)
while getopts "ln" opt; do
case "$opt" in
l) link=1
;;
n) dev=${MDEV%[0-9]*}
new_name=${MDEV#${dev}}
;;
esac
done
shift $(( $OPTIND - 1 ))
if [ -n "$2" ]; then
new_name="$2"
fi
if [ -z "$new_name" ]; then
new_name=$MDEV
fi
case "$ACTION" in
add|"")
if [ ! -b "$MDEV" ] && [ ! -c "$MDEV" ]; then
exit
fi
mkdir -p $1
mv $MDEV $1/$new_name
if [ "$link" = 1 ] ; then
ln -snf $1/$new_name $MDEV
fi
;;
remove)
if [ "$link" = 1 ] ; then
rm -f $MDEV
fi
mv $1/$new_name $MDEV
rmdir $1 2>/dev/null
;;
esac
|