summaryrefslogtreecommitdiff
path: root/user/eudev/udev-postmount.initd
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-05 01:08:52 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-07-05 01:08:52 -0500
commit518c42acde0f5889d0dc4b41a55a2c9356c3d6cd (patch)
tree5e9333f39fedefbaabe6113a206fef44096d838c /user/eudev/udev-postmount.initd
parent7b2a62c315b590bb9514735c3aef209e1dafaa92 (diff)
downloadpackages-518c42acde0f5889d0dc4b41a55a2c9356c3d6cd.tar.gz
packages-518c42acde0f5889d0dc4b41a55a2c9356c3d6cd.tar.bz2
packages-518c42acde0f5889d0dc4b41a55a2c9356c3d6cd.tar.xz
packages-518c42acde0f5889d0dc4b41a55a2c9356c3d6cd.zip
user/eudev: fix up and merge udev-init-scripts in (why was that ever separate?)
Diffstat (limited to 'user/eudev/udev-postmount.initd')
-rw-r--r--user/eudev/udev-postmount.initd55
1 files changed, 55 insertions, 0 deletions
diff --git a/user/eudev/udev-postmount.initd b/user/eudev/udev-postmount.initd
new file mode 100644
index 000000000..f1f94f489
--- /dev/null
+++ b/user/eudev/udev-postmount.initd
@@ -0,0 +1,55 @@
+#!/sbin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend()
+{
+ need localmount
+ keyword -vserver -lxc
+}
+
+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()
+{
+ # create /etc/udev/rules.d if it does not exist and /etc/udev is writable
+ [ -d /etc/udev/rules.d ] || \
+ dir_writeable /etc/udev && \
+ mkdir -p /etc/udev/rules.d
+
+ # only continue if rules-directory is writable
+ dir_writeable /etc/udev/rules.d || return 0
+
+ local file dest
+ for file in /run/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 /run/udev ] || return 0
+
+ # store persistent-rules that got created while booting
+ # when / was still read-only
+ store_persistent_rules
+}
+
+stop()
+{
+ return 0
+}
+
+# vim:ts=4