aboutsummaryrefslogtreecommitdiff
path: root/sh/migrate-to-run.sh.in
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2012-02-22 20:44:32 -0600
committerWilliam Hubbs <williamh@gentoo.org>2012-05-14 13:49:06 -0500
commit82d3918d7a1c625f98fcf607c7a450f18b7e60bd (patch)
tree89866fb3fce5954a52075941d5dc27fe5c60b824 /sh/migrate-to-run.sh.in
parentee1a698451a01772d50a75e95c887520260f8619 (diff)
move rc_svcdir to /run/openrc on Linux systems
If you are not using linux, this should not affect you. If you are using linux, from this point forward, openrc requires the /run directory to be a mounted tmpfs. If it is, you can run @LIBEXECDIR@/sh/migrate-to-run.sh as root to migrate your dependency tree and state information to the new location. If it is not, you must create the /run directory as root with permissions 755 then reboot your system. reported-by: Maxim Kammerer <mk@dee.su> X-Gentoo-Bug: 401059 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401059
Diffstat (limited to 'sh/migrate-to-run.sh.in')
-rw-r--r--sh/migrate-to-run.sh.in50
1 files changed, 50 insertions, 0 deletions
diff --git a/sh/migrate-to-run.sh.in b/sh/migrate-to-run.sh.in
new file mode 100644
index 00000000..f296a5ca
--- /dev/null
+++ b/sh/migrate-to-run.sh.in
@@ -0,0 +1,50 @@
+#!@SHELL@
+# Copyright (c) 2012 William Hubbs <w.d.hubbs@gmail.com>
+# Released under the 2-clause BSD license.
+
+. "@LIBEXECDIR@/sh/functions.sh"
+
+if ! mountinfo -q -f tmpfs "@LIBEXECDIR@/init.d"; then
+ einfo "The OpenRC dependency data has already been migrated."
+ exit 0
+fi
+
+if [ ! -d "@PREFIX@/run" ]; then
+ eerror "'@PREFIX@/run' is not a directory."
+ eerror "This means the OpenRC dependency data cannot be migrated."
+ eerror "Please create the '@PREFIX@/run' directory and reboot the system."
+ exit 1
+fi
+
+if ! mountinfo -q -f tmpfs "@PREFIX@/run"; then
+ local x
+ for x in "@PREFIX@/run/."* "@PREFIX@/run/"*; do
+ case "$x" in
+ "@PREFIX@/run/."|"@PREFIX@/run/..")
+ continue
+ ;;
+ esac
+ if [ -e "$x" ]; then
+ eerror "Your '@PREFIX@/run' directory contains files."
+ eerror "Please reboot the system."
+ exit 1
+ fi
+ done
+
+ mount -t tmpfs -o mode=0755,nosuid,nodev \
+ tmpfs "@PREFIX@/run" 2> /dev/null
+ if [ $? != 0 ]; then
+ eerror "Unable to mount a tmpfs on '@PREFIX@/run'."
+ eerror "This means the OpenRC dependency data cannot be migrated."
+ eerror "Please create the '@PREFIX@/run' directory and reboot the system."
+ exit 1
+ fi
+fi
+
+rm -rf "@PREFIX@/run/openrc"
+cp -a "@LIBEXECDIR@/init.d" "@PREFIX@/run/openrc"
+rc-update -u
+rm -rf "@LIBEXECDIR@/init.d"
+umount "@LIBEXECDIR@/init.d"
+einfo "The OpenRC dependency data was migrated successfully."
+exit 0