Compare commits
2 Commits
0.34.11
...
mount-serv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c9f1add21 | ||
|
|
a643e918dd |
@@ -1,7 +1,7 @@
|
||||
include ../mk/net.mk
|
||||
|
||||
DIR= ${CONFDIR}
|
||||
CONF= bootmisc fsck hostname localmount netmount urandom tmpfiles \
|
||||
CONF= bootmisc fsck hostname localmount mount netmount urandom tmpfiles \
|
||||
${CONF-${OS}}
|
||||
|
||||
ifeq (${MKNET},yes)
|
||||
|
||||
23
conf.d/mount
Normal file
23
conf.d/mount
Normal file
@@ -0,0 +1,23 @@
|
||||
# The mount service is a multiplexed service. This means you must have
|
||||
# symbolic links to it in your init.d directory for each file system you
|
||||
# want to mount. I recommend naming those symbolic links the same as the
|
||||
# paths to the file systems they mount, removing the leading slash and
|
||||
# substituting _ for the remaining slashes, for example:
|
||||
#
|
||||
# cd /etc/init.d
|
||||
# ln -s mount mount.usr
|
||||
# ln -s mount mount.usr_local
|
||||
#
|
||||
# Set up a symbolic link like this for each file system you wish to
|
||||
# mount, then add the symbolic link to the appropriate runlevel. Once
|
||||
# that is done, add the appropriate definitions for the file system to
|
||||
# this file.
|
||||
#
|
||||
#You will need to define the mountpoint and any dependencies for each
|
||||
#filesystem as shown here.
|
||||
#
|
||||
#If the mountpoint does not match an entry in fstab, the mount will be
|
||||
#ignored.
|
||||
#
|
||||
#mount_usr_mountpoint="/usr"
|
||||
#
|
||||
@@ -10,6 +10,6 @@ name="Avahi DNS Configuration Daemon"
|
||||
depend()
|
||||
{
|
||||
use dns
|
||||
need localmount dbus
|
||||
need mount.usr mount.var dbus
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ name="Avahi Service Advertisement Daemon"
|
||||
depend()
|
||||
{
|
||||
use dns
|
||||
need localmount dbus
|
||||
need mount.usr mount.var dbus
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ name="Message Bus Daemon"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount net
|
||||
need mount.usr mount.var net
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ name="DHCP Client Daemon"
|
||||
depend()
|
||||
{
|
||||
provide net
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
use logger
|
||||
after bootmisc modules
|
||||
before dns
|
||||
|
||||
@@ -12,7 +12,7 @@ extra_started_commands="reload"
|
||||
depend()
|
||||
{
|
||||
provide dns
|
||||
need localmount net
|
||||
need mount.usr mount.var net
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ esac
|
||||
depend()
|
||||
{
|
||||
provide dns
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ name="Network Time Protocol Daemon"
|
||||
depend()
|
||||
{
|
||||
use dns
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc ntp-client
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ fi
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount net
|
||||
need mount.usr mount.var net
|
||||
use dns
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ name="WPA Supplicant Daemon"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
use logger
|
||||
after bootmisc modules
|
||||
before dns dhcpcd net
|
||||
|
||||
1
init.d/.gitignore
vendored
1
init.d/.gitignore
vendored
@@ -4,6 +4,7 @@ hostname
|
||||
local
|
||||
localmount
|
||||
loopback
|
||||
mount
|
||||
moused
|
||||
netmount
|
||||
network
|
||||
|
||||
@@ -2,7 +2,7 @@ include ../mk/net.mk
|
||||
|
||||
DIR= ${INITDIR}
|
||||
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in loopback.in \
|
||||
netmount.in osclock.in root.in savecache.in swap.in swapfiles.in \
|
||||
mount.in netmount.in osclock.in root.in savecache.in swap.in swapfiles.in \
|
||||
tmpfiles.setup.in swclock.in sysctl.in urandom.in s6-svscan.in ${SRCS-${OS}}
|
||||
BIN= ${OBJS}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
before logger
|
||||
after clock root sysctl
|
||||
keyword -prefix -timeout
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Sets a font for the consoles."
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount termencoding
|
||||
need mount.usr mount.var termencoding
|
||||
after hotplug bootmisc
|
||||
keyword -openvz -prefix -systemd-nspawn -uml -vserver -xenu -lxc
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ command_args=$devd_args
|
||||
name="Device State Change Daemon"
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
before net.lo0
|
||||
keyword -jail -prefix
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Creates the dev database"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Applies a keymap for the consoles."
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount termencoding
|
||||
need mount.usr mount.var termencoding
|
||||
after bootmisc
|
||||
keyword -openvz -prefix -systemd-nspawn -uml -vserver -xenu -lxc
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ extra_commands="restore"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -jail -prefix
|
||||
}
|
||||
|
||||
|
||||
118
init.d/mount.in
Normal file
118
init.d/mount.in
Normal file
@@ -0,0 +1,118 @@
|
||||
#!@SBINDIR@/openrc-run
|
||||
# Copyright (c) 2015 William Hubbs <w.d.hubbs@gmail.com>
|
||||
# Released under the 2-clause BSD license.
|
||||
|
||||
description="Mount a file system defined in @SYSCONFDIR@/fstab"
|
||||
extra_commands="generate"
|
||||
|
||||
depend()
|
||||
{
|
||||
need fsck
|
||||
use modules mtab
|
||||
after modules
|
||||
keyword -jail -prefix -vserver -lxc
|
||||
}
|
||||
|
||||
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
||||
|
||||
start_pre()
|
||||
{
|
||||
# Do not start this service as "mount"
|
||||
if [ "$rc_svcname" = mount ]; then
|
||||
eerror "The mount service should not be started directly"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
if [ "$rc_svcname" = mount-generate-symlinks ]; then
|
||||
generate
|
||||
return $?
|
||||
fi
|
||||
|
||||
local mountname=${rc_svcname#*.}
|
||||
local fspath=${mount_${mountname}_mountpoint}
|
||||
|
||||
# for now, make sure fspath is in fstab
|
||||
if [ ! fstabinfo -q $fspath ]; then
|
||||
einfo "$rc_svcname: $fspath is not in @SYSCONFDIR@/fstab"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Is the file system mounted?
|
||||
if mountinfo -q $fspath; then
|
||||
action=remount
|
||||
msg=Remounting
|
||||
else
|
||||
action=mount
|
||||
msg=Mounting
|
||||
fi
|
||||
|
||||
ebegin "$msg $fspath according to @SYSCONFDIR@/fstab"
|
||||
fstabinfo --$action $fspath
|
||||
eend $? "$fspath failed to $action"
|
||||
}
|
||||
|
||||
stop_pre()
|
||||
{
|
||||
# Do not stop this service as "mount"
|
||||
if [ "$rc_svcname" = mount ]; then
|
||||
eerror "The mount service should not be stopped directly"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
yesno $RC_GOINGDOWN || return 0
|
||||
local mountname=${rc_svcname#*.}
|
||||
local fspath=${mount_${mountname}_mountpoint}
|
||||
|
||||
# make sure fspath is in fstab
|
||||
if ! fstabinfo -q $fspath; then
|
||||
einfo "$rc_svcname: $fspath is not in @SYSCONFDIR@/fstab"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Is the file system mounted?
|
||||
mountinfo -q $fspath || return 0
|
||||
|
||||
# Flush all pending disk writes now
|
||||
sync
|
||||
|
||||
ebegin "Unmounting $fspath"
|
||||
do_unmount umount $fspath
|
||||
eend $? "Unable to umount $fspath"
|
||||
return 0
|
||||
}
|
||||
|
||||
generate()
|
||||
{
|
||||
local fslist="$(fstabinfo)"
|
||||
local fs fsopts rc=0
|
||||
local svcpath=${RC_SVCNAME%/*}
|
||||
ebegin "Generating mount symlinks"
|
||||
for fs in $fslist; do
|
||||
case $fs in
|
||||
/) ;;
|
||||
/*)
|
||||
fsopts="$(fstabinfo -o $fs)"
|
||||
case "$fsopts" in
|
||||
*noauto*) ;;
|
||||
*)
|
||||
local name="${fs#/}"
|
||||
name="$(echo $name | sed 's#/#.#g')"
|
||||
einfo ln -snf mount "${svcpath}/${name}"
|
||||
rc=$?
|
||||
[ $rc -ne 0 ] && break
|
||||
*) ;;
|
||||
esac
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
eend $rc "Failed to generate symlinks for all mounts"
|
||||
return $rc
|
||||
}
|
||||
@@ -14,7 +14,7 @@ name="Console Mouse Daemon"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
keyword -jail -prefix
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ __nl="
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
if [ -n "$(interfaces)" ]; then
|
||||
provide net
|
||||
|
||||
@@ -6,7 +6,7 @@ required_files="/etc/newsyslog.conf"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -prefix
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ name="Name Service Cache Daemon"
|
||||
extra_started_commands="flush"
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
use net dns ldap ypbind
|
||||
after bootmisc
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -openvz -prefix -systemd-nspawn -vserver -lxc
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ extra_commands="checkconfig showstatus"
|
||||
extra_started_commands="reload"
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -jail -prefix
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ name="Power Control Daemon"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
use logger
|
||||
after bootmisc
|
||||
keyword -jail -prefix
|
||||
|
||||
@@ -7,7 +7,7 @@ description="Mounts misc filesystems in /proc."
|
||||
depend()
|
||||
{
|
||||
use modules devfs
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -openvz -prefix -systemd-nspawn -vserver -lxc
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ command_background=YES
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
need net
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount net
|
||||
need mount.usr mount.var net
|
||||
after *
|
||||
before local
|
||||
keyword -prefix
|
||||
|
||||
@@ -9,7 +9,7 @@ name="RPC program number mapper"
|
||||
depend()
|
||||
{
|
||||
provide rpc
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
use net logger dns
|
||||
before inetd xinetd ntpd ntp-client
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ pidfile=/var/run/s6-svscan.pid
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
}
|
||||
|
||||
start_pre()
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Saves a kernel dump."
|
||||
|
||||
depend()
|
||||
{
|
||||
need dumpon localmount
|
||||
need dumpon mount.usr mount.var
|
||||
before encswap
|
||||
keyword -jail -prefix
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
before localmount
|
||||
before mount.usr mount.var
|
||||
keyword -jail -openvz -prefix -systemd-nspawn -vserver -lxc
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -jail -openvz -prefix -systemd-nspawn -vserver -lxc
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Released under the 2-clause BSD license.
|
||||
|
||||
depend() {
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -jail -prefix
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ depend()
|
||||
{
|
||||
provide logger
|
||||
use net newsyslog
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
after bootmisc
|
||||
keyword -prefix
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Set up tmpfiles.d entries"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -7,7 +7,7 @@ description="Initializes the random number generator."
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -jail -lxc -openvz -prefix -systemd-nspawn
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need mount.usr mount.var
|
||||
keyword -prefix
|
||||
}
|
||||
|
||||
|
||||
@@ -487,8 +487,8 @@ _need_dbus()
|
||||
|
||||
depend()
|
||||
{
|
||||
# We write a pidfile and to /var/cache, so we need localmount.
|
||||
need localmount
|
||||
# We write a pidfile and to /var/cache, so we need mount.var.
|
||||
need mount.var
|
||||
# We can optionally use the network, but it's not essential.
|
||||
use net
|
||||
# We should be after bootmisc so that /var/run is cleaned before
|
||||
|
||||
46
mount-service.md
Normal file
46
mount-service.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# New Mount Service
|
||||
|
||||
This is definitely considered testing code, so if you use it on your
|
||||
system and it breaks, you have been warned.
|
||||
|
||||
This document will evolve as the testing proceeds and will be removed
|
||||
once the script goes mainline.
|
||||
|
||||
Since this is on a topic branch, this branch will be subject to
|
||||
rebasing, merging commits, etc. When it goes to master, everything here
|
||||
will be in one commit.
|
||||
|
||||
The goal of this is to replace the localmount and metmount services with
|
||||
a single mount service which will be multiplexed so that there is one
|
||||
service for each file system that will be mounted.
|
||||
|
||||
- rc-service mount generate
|
||||
|
||||
scans your fstab and attempts to generate symbolic links in /etc/init.d
|
||||
for each file system you want to mount.
|
||||
|
||||
Then you must edit /etc/conf.d/mount to list all of your file systems
|
||||
and the dependencies they have by using
|
||||
rc_mount_foo_before/after/need/use settings.
|
||||
|
||||
rc-service mount.foo start
|
||||
|
||||
tries to mount a file system and
|
||||
|
||||
rc-service mount.foo stop
|
||||
|
||||
tries to unmount it if your system is going down.
|
||||
|
||||
I'm considering automating the generation of symlinks into the boot
|
||||
process, but I'm not sure yet whether this is a good idea.
|
||||
|
||||
I haven't decided yet exactly how I want to handle the transition from
|
||||
localmount/netmount to this new mount service yet, so you will
|
||||
definitely not have a clean boot if you try to boot with this.
|
||||
|
||||
Another question is whether I want to try automating adding the mount
|
||||
services to runlevels; I think no, but let me know if you feel
|
||||
differently.
|
||||
|
||||
Any suggestions would be helpful.
|
||||
|
||||
@@ -939,9 +939,9 @@ svc_stop_real(void)
|
||||
{
|
||||
bool stopped;
|
||||
|
||||
/* If we're stopping localmount, set LC_ALL=C so that
|
||||
/* If we're stopping mount.*, set LC_ALL=C so that
|
||||
* bash doesn't load anything blocking the unmounting of /usr */
|
||||
if (strcmp(applet, "localmount") == 0)
|
||||
if (strncmp(applet, "mount.", 6) == 0)
|
||||
setenv("LC_ALL", "C", 1);
|
||||
|
||||
if (ibsave)
|
||||
|
||||
Reference in New Issue
Block a user