From d0764e77b265bc1fc99456ddd3d3e3a088ef1f78 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 6 Apr 2018 22:18:02 +0200 Subject: [PATCH] Add pygos specific overlay fs setup Signed-off-by: David Oberhollenzer --- .gitignore | 3 +++ Makefile.am | 2 ++ configure.ac | 3 +++ scripts/Makemodule.am | 2 +- scripts/overlay.sh.in | 21 +++++++++++++++++++++ services/Makemodule.am | 3 ++- services/rootusr.in | 5 +++++ services/tmpfsrun.in | 1 + services/tmpfsvar.in | 10 ++++++++++ 9 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 scripts/overlay.sh.in create mode 100644 services/rootusr.in create mode 100644 services/tmpfsvar.in diff --git a/.gitignore b/.gitignore index 2ad2130..23ba8cd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,9 @@ services/procfs services/sysfs services/tmpfs services/tmpfsrun +services/tmpfsvar +services/rootusr scripts/devfs.sh +scripts/overlay.sh scripts/trymount.sh diff --git a/Makefile.am b/Makefile.am index cd45a47..42111b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,8 @@ install-data-local: $(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs $(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs $(LN_S) $(TEMPLATEDIR)/tmpfsrun $(DESTDIR)$(SVCDIR)/tmpfsrun + $(LN_S) $(TEMPLATEDIR)/tmpfsvar $(DESTDIR)$(SVCDIR)/tmpfsvar + $(LN_S) $(TEMPLATEDIR)/rootusr $(DESTDIR)$(SVCDIR)/rootusr $(LN_S) $(TEMPLATEDIR)/vfs $(DESTDIR)$(SVCDIR)/vfs $(LN_S) $(TEMPLATEDIR)/shutdown $(DESTDIR)$(SVCDIR)/shutdown $(LN_S) $(TEMPLATEDIR)/reboot $(DESTDIR)$(SVCDIR)/reboot diff --git a/configure.ac b/configure.ac index 65921f2..3ac614a 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,10 @@ AC_CONFIG_FILES([services/devfs]) AC_CONFIG_FILES([services/procfs]) AC_CONFIG_FILES([services/tmpfs]) AC_CONFIG_FILES([services/tmpfsrun]) +AC_CONFIG_FILES([services/tmpfsvar]) +AC_CONFIG_FILES([services/rootusr]) AC_CONFIG_FILES([scripts/devfs.sh]) +AC_CONFIG_FILES([scripts/overlay.sh]) AC_CONFIG_FILES([scripts/trymount.sh]) AC_OUTPUT([Makefile]) diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am index e6de18d..d09b603 100644 --- a/scripts/Makemodule.am +++ b/scripts/Makemodule.am @@ -1,2 +1,2 @@ scriptdir = @SCRIPTDIR@ -script_SCRIPTS = scripts/devfs.sh scripts/trymount.sh +script_SCRIPTS = scripts/devfs.sh scripts/trymount.sh scripts/overlay.sh diff --git a/scripts/overlay.sh.in b/scripts/overlay.sh.in new file mode 100644 index 0000000..b53eea7 --- /dev/null +++ b/scripts/overlay.sh.in @@ -0,0 +1,21 @@ +#!/bin/sh + +lower=/cfg/preserve/${1} +upper=/cfg/overlay/${1} +work=/cfg/overlay/${1}_work +target=${2} + +if [ ! -d "$target" ]; then + exit +fi + +if [ -d "$lower" ]; then + if [ -d "$upper" ]; then + @BINPATH@/mkdir -p "$work" + @SBINPATH@/mount -t overlay overlay \ + -olowerdir=${lower},upperdir=${upper},workdir=${work} \ + ${target} + else + @SBINPATH@/mount --bind "$lower" "$target" + fi +fi diff --git a/services/Makemodule.am b/services/Makemodule.am index f2a15c8..a19d833 100644 --- a/services/Makemodule.am +++ b/services/Makemodule.am @@ -4,6 +4,7 @@ init_DATA += services/sysctl services/hwclock services/sysinit init_DATA += services/reboot services/shutdown services/sigkill init_DATA += services/sigterm services/sync services/devfs init_DATA += services/sysfs services/procfs services/tmpfs -init_DATA += services/tmpfsrun services/vfs +init_DATA += services/tmpfsrun services/tmpfsvar services/vfs +init_DATA += services/rootusr EXTRA_DIST += services/sysinit services/vfs diff --git a/services/rootusr.in b/services/rootusr.in new file mode 100644 index 0000000..fb173db --- /dev/null +++ b/services/rootusr.in @@ -0,0 +1,5 @@ +description "mount /root" +type wait +target boot +before vfs +exec "@SCRIPTDIR@/overlay.sh" root /root diff --git a/services/tmpfsrun.in b/services/tmpfsrun.in index d20e782..c34eccb 100644 --- a/services/tmpfsrun.in +++ b/services/tmpfsrun.in @@ -2,6 +2,7 @@ description "mount /run" type wait target boot before vfs +after tmpfsvar exec "@SBINPATH@/mount" -t tmpfs none /run exec "@BINPATH@/mkdir" /run/lock -m 0755 exec "@BINPATH@/ln" -s /run /var/run diff --git a/services/tmpfsvar.in b/services/tmpfsvar.in new file mode 100644 index 0000000..7942286 --- /dev/null +++ b/services/tmpfsvar.in @@ -0,0 +1,10 @@ +description "mount /var" +type wait +target boot +before vfs +exec "@SBINPATH@/mount" -t tmpfs none /var +exec "@BINPATH@/mkdir" /var/log -m 0755 +exec "@BINPATH@/mkdir" /var/spool -m 0755 +exec "@BINPATH@/mkdir" /var/lib -m 0755 +exec "@BINPATH@/mkdir" /var/tmp -m 0755 +exec "@SCRIPTDIR@/overlay.sh" var_lib /var/lib