From 1389c74f95c8de5121b4423cea789de42cd6325c Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 21 Apr 2018 19:39:48 +0200 Subject: [PATCH] Add pygos specific init setup to init package Signed-off-by: David Oberhollenzer --- pkg/init/build | 2 +- pkg/init/etc/init.d/mountusr | 1 + pkg/init/etc/init.d/tmpfsrun | 1 + pkg/init/etc/init.d/tmpfsvar | 1 + pkg/init/etc/initd.env | 1 + pkg/init/lib/libexec/init/overlay.sh | 21 +++++++++++++++++++++ pkg/init/share/init/mountusr | 5 +++++ pkg/init/share/init/tmpfsrun | 11 +++++++++++ pkg/init/share/init/tmpfsvar | 12 ++++++++++++ 9 files changed, 54 insertions(+), 1 deletion(-) create mode 120000 pkg/init/etc/init.d/mountusr create mode 120000 pkg/init/etc/init.d/tmpfsrun create mode 120000 pkg/init/etc/init.d/tmpfsvar create mode 100644 pkg/init/etc/initd.env create mode 100755 pkg/init/lib/libexec/init/overlay.sh create mode 100644 pkg/init/share/init/mountusr create mode 100644 pkg/init/share/init/tmpfsrun create mode 100644 pkg/init/share/init/tmpfsvar diff --git a/pkg/init/build b/pkg/init/build index 59207b0..8b695d1 100755 --- a/pkg/init/build +++ b/pkg/init/build @@ -26,7 +26,7 @@ deploy() { make DESTDIR="$DEPLOY" install-strip - mkdir -p "$DEPLOY/etc/init.d" + cp -r ${SCRIPTDIR}/pkg/${PKGNAME}/{etc,lib,share} "$DEPLOY" if [ -e "$SCRIPTDIR/board/$BOARD/INIT" ]; then source "$SCRIPTDIR/board/$BOARD/INIT" diff --git a/pkg/init/etc/init.d/mountusr b/pkg/init/etc/init.d/mountusr new file mode 120000 index 0000000..33d4846 --- /dev/null +++ b/pkg/init/etc/init.d/mountusr @@ -0,0 +1 @@ +/share/init/mountusr \ No newline at end of file diff --git a/pkg/init/etc/init.d/tmpfsrun b/pkg/init/etc/init.d/tmpfsrun new file mode 120000 index 0000000..3c4d418 --- /dev/null +++ b/pkg/init/etc/init.d/tmpfsrun @@ -0,0 +1 @@ +/share/init/tmpfsrun \ No newline at end of file diff --git a/pkg/init/etc/init.d/tmpfsvar b/pkg/init/etc/init.d/tmpfsvar new file mode 120000 index 0000000..76fe5d9 --- /dev/null +++ b/pkg/init/etc/init.d/tmpfsvar @@ -0,0 +1 @@ +/share/init/tmpfsvar \ No newline at end of file diff --git a/pkg/init/etc/initd.env b/pkg/init/etc/initd.env new file mode 100644 index 0000000..c31cb70 --- /dev/null +++ b/pkg/init/etc/initd.env @@ -0,0 +1 @@ +PATH=/bin \ No newline at end of file diff --git a/pkg/init/lib/libexec/init/overlay.sh b/pkg/init/lib/libexec/init/overlay.sh new file mode 100755 index 0000000..090671c --- /dev/null +++ b/pkg/init/lib/libexec/init/overlay.sh @@ -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 + mkdir -p "$work" + mount -t overlay overlay \ + -olowerdir=${lower},upperdir=${upper},workdir=${work} \ + ${target} + else + mount --bind "$lower" "$target" + fi +fi diff --git a/pkg/init/share/init/mountusr b/pkg/init/share/init/mountusr new file mode 100644 index 0000000..5c0c676 --- /dev/null +++ b/pkg/init/share/init/mountusr @@ -0,0 +1,5 @@ +description "mount /usr" +type wait +target boot +before vfs +exec /lib/libexec/init/overlay.sh usr /usr diff --git a/pkg/init/share/init/tmpfsrun b/pkg/init/share/init/tmpfsrun new file mode 100644 index 0000000..07dbd0a --- /dev/null +++ b/pkg/init/share/init/tmpfsrun @@ -0,0 +1,11 @@ +description "mount /run" +type wait +target boot +before vfs +after tmpfsvar +exec { + mount -t tmpfs none /run + mkdir /run/lock -m 0755 + ln -s /run /var/run + ln -s /run/lock /var/lock +} diff --git a/pkg/init/share/init/tmpfsvar b/pkg/init/share/init/tmpfsvar new file mode 100644 index 0000000..219c81c --- /dev/null +++ b/pkg/init/share/init/tmpfsvar @@ -0,0 +1,12 @@ +description "mount /var" +type wait +target boot +before vfs +exec { + mount -t tmpfs none /var + mkdir /var/log -m 0755 + mkdir /var/spool -m 0755 + mkdir /var/lib -m 0755 + mkdir /var/tmp -m 0755 + /lib/libexec/init/overlay.sh var_lib /var/lib +}