aboutsummaryrefslogtreecommitdiffstats
path: root/main/udev/udev-postmount.initd
blob: b716af228bac5ddffddf6316f8af608b14ede248 (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
48
49
#!/sbin/openrc-run
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/164/udev-postmount.initd,v 1.1 2010/10/30 13:53:54 zzam Exp $

depend() {
	need localmount
}

dir_writeable()
{
        touch "$1"/.test.$$ 2>/dev/null && rm "$1"/.test.$$
}

# store persistent-rules that got created while booting
# when / was still read-only
store_persistent_rules() {
	# only continue if rules-directory is writable
	dir_writeable /etc/udev/rules.d || return 0

	local file dest
	for file in /dev/.udev/tmp-rules--*; do
		dest=${file##*tmp-rules--}
		[ "$dest" = '*' ] && break
		type=${dest##70-persistent-}
		type=${type%%.rules}
		ebegin "Saving udev persistent ${type} rules to /etc/udev/rules.d"
		cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file"
		eend $? "Failed moving persistent rules!"
	done
}


start() {
	# check if this system uses udev
	[ -d /dev/.udev/ ] || return 0

	einfo "Doing udev cleanups"

	# store persistent-rules that got created while booting
	# when / was still read-only
	store_persistent_rules
}

stop() {
	:
}

# vim:ts=4