1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-12-22 07:10:49 +01:00

Add VFS setup scripts

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-04-06 18:40:09 +02:00
parent 212d3022e7
commit 4f4a377d7a
17 changed files with 100 additions and 5 deletions

8
.gitignore vendored
View file

@ -30,3 +30,11 @@ services/reboot
services/sigkill
services/sigterm
services/sync
services/devfs
services/procfs
services/sysfs
services/tmpfs
services/tmpfsrun
scripts/devfs.sh
scripts/trymount.sh

View file

@ -13,6 +13,7 @@ helper_PROGRAMS =
include lib/Makemodule.am
include cmd/Makemodule.am
include initd/Makemodule.am
include scripts/Makemodule.am
include services/Makemodule.am
include servicecmd/Makemodule.am
@ -22,6 +23,12 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/hostname $(DESTDIR)$(SVCDIR)/hostname
$(LN_S) $(TEMPLATEDIR)/sysctl $(DESTDIR)$(SVCDIR)/sysctl
$(LN_S) $(TEMPLATEDIR)/sysinit $(DESTDIR)$(SVCDIR)/sysinit
$(LN_S) $(TEMPLATEDIR)/procfs $(DESTDIR)$(SVCDIR)/procfs
$(LN_S) $(TEMPLATEDIR)/sysfs $(DESTDIR)$(SVCDIR)/sysfs
$(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs
$(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs
$(LN_S) $(TEMPLATEDIR)/tmpfsrun $(DESTDIR)$(SVCDIR)/tmpfsrun
$(LN_S) $(TEMPLATEDIR)/vfs $(DESTDIR)$(SVCDIR)/vfs
$(LN_S) $(TEMPLATEDIR)/shutdown $(DESTDIR)$(SVCDIR)/shutdown
$(LN_S) $(TEMPLATEDIR)/reboot $(DESTDIR)$(SVCDIR)/reboot
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@shutdown

View file

@ -29,5 +29,12 @@ AC_CONFIG_FILES([services/shutdown])
AC_CONFIG_FILES([services/sigkill])
AC_CONFIG_FILES([services/sigterm])
AC_CONFIG_FILES([services/sync])
AC_CONFIG_FILES([services/sysfs])
AC_CONFIG_FILES([services/devfs])
AC_CONFIG_FILES([services/procfs])
AC_CONFIG_FILES([services/tmpfs])
AC_CONFIG_FILES([services/tmpfsrun])
AC_CONFIG_FILES([scripts/devfs.sh])
AC_CONFIG_FILES([scripts/trymount.sh])
AC_OUTPUT([Makefile])

2
scripts/Makemodule.am Normal file
View file

@ -0,0 +1,2 @@
scriptdir = @SCRIPTDIR@
script_SCRIPTS = scripts/devfs.sh scripts/trymount.sh

21
scripts/devfs.sh.in Normal file
View file

@ -0,0 +1,21 @@
#!/bin/sh
@SBINPATH@/mount -t devtmpfs none /dev
[ -c /dev/console ] || @SBINPATH@/mknod -m 600 /dev/console c 5 1
[ -c /dev/tty ] || @SBINPATH@/mknod -m 666 /dev/tty c 5 0
[ -c /dev/null ] || @SBINPATH@/mknod -m 666 /dev/null c 1 3
[ -c /dev/kmsg ] || @SBINPATH@/mknod -m 660 /dev/kmsg c 1 11
[ -e /dev/fd ] || @BINPATH@/ln -snf /proc/self/fd /dev/fd
[ -e /dev/stdin ] || @BINPATH@/ln -snf /proc/self/fd/0 /dev/stdin
[ -e /dev/stdout ] || @BINPATH@/ln -snf /proc/self/fd/1 /dev/stdout
[ -e /dev/stderr ] || @BINPATH@/ln -snf /proc/self/fd/2 /dev/stderr
[ -e /proc/kcore ] && @BINPATH@/ln -snf /proc/kcore /dev/core
@BINPATH@/mkdir -p /dev/mqueue -m 1777
@BINPATH@/mkdir -p /dev/pts -m 0755
@BINPATH@/mkdir -p /dev/shm -m 1777
@SCRIPTDIR@/trymount.sh "/dev/mqueue" "mqueue" "noexec,nosuid,nodev"
@SCRIPTDIR@/trymount.sh "/dev/pts" "devpts" "noexec,nosuid,gid=5,mode=0620"
@SCRIPTDIR@/trymount.sh "/dev/shm" "tmpfs" "noexec,nosuid,nodev,mode=1777"

7
scripts/trymount.sh.in Normal file
View file

@ -0,0 +1,7 @@
#!/bin/sh
if [ -d "$1" ]; then
if @BINPATH@/grep -qsE "[[:space:]]+$2$" "/proc/filesystems"; then
mount -n -t "$2" -o "$3" "$2" "$1"
fi
fi

View file

@ -2,6 +2,8 @@ initdir = @TEMPLATEDIR@
init_DATA = services/agetty services/hostname services/loopback
init_DATA += services/sysctl services/hwclock services/sysinit
init_DATA += services/reboot services/shutdown services/sigkill
init_DATA += services/sigterm services/sync
init_DATA += services/sigterm services/sync services/devfs
init_DATA += services/sysfs services/procfs services/tmpfs
init_DATA += services/tmpfsrun services/vfs
EXTRA_DIST += services/sysinit
EXTRA_DIST += services/sysinit services/vfs

6
services/devfs.in Normal file
View file

@ -0,0 +1,6 @@
description "mount /dev"
type wait
target boot
after procfs sysfs
before vfs
exec "@SCRIPTDIR@/devfs.sh"

View file

@ -3,4 +3,4 @@ exec "@BINPATH@/hostname" --file /etc/hostname
type wait
target boot
before sysinit
after hwclock
after hwclock vfs

View file

@ -3,3 +3,4 @@ exec "@SBINPATH@/hwclock" --hctosys --utc
type wait
target boot
before sysinit
after vfs

View file

@ -2,7 +2,7 @@ description configure network loopback device
type wait
target boot
before sysinit
after hwclock hostname
after hwclock hostname vfs
exec "@SBINPATH@/ip" addr add 127.0.0.1/8 dev lo brd +
exec "@SBINPATH@/ip" link set lo up

7
services/procfs.in Normal file
View file

@ -0,0 +1,7 @@
description "mount /proc"
type wait
target boot
before vfs
exec "@SBINPATH@/mount" -t proc proc /proc
exec "@SCRIPTDIR@/trymount.sh" "/proc/sys/fs/binfmt_misc" "binfmt_misc" "nodev,noexec,nosuid"

View file

@ -3,4 +3,4 @@ exec "@SBINPATH@/sysctl" --system
type wait
target boot
before sysinit
after hwclock hostname
after hwclock hostname vfs

11
services/sysfs.in Normal file
View file

@ -0,0 +1,11 @@
description "mount /sys"
type wait
target boot
after procfs
before vfs
exec "@SBINPATH@/mount" -t sysfs sysfs /sys
exec "@SCRIPTDIR@/trymount.sh" "/sys/kernel/security" "securityfs" "nodev,noexec,nosuid"
exec "@SCRIPTDIR@/trymount.sh" "/sys/kernel/config" "configfs" "nodev,noexec,nosuid"
exec "@SCRIPTDIR@/trymount.sh" "/sys/fs/fuse/connections" "fusectl" "nodev,noexec,nosuid"
exec "@SCRIPTDIR@/trymount.sh" "/sys/firmware/efi/efivars" "efivarfs" "ro"

5
services/tmpfs.in Normal file
View file

@ -0,0 +1,5 @@
description "mount /tmp"
type wait
target boot
before vfs
exec "@SBINPATH@/mount" -t tmpfs none /tmp

8
services/tmpfsrun.in Normal file
View file

@ -0,0 +1,8 @@
description "mount /run"
type wait
target boot
before vfs
exec "@SBINPATH@/mount" -t tmpfs none /run
exec "@BINPATH@/mkdir" /run/lock -m 0755
exec "@BINPATH@/ln" -s /run /var/run
exec "@BINPATH@/ln" -s /run/lock /var/lock

3
services/vfs Normal file
View file

@ -0,0 +1,3 @@
description VFS setup done
type once
target boot