From a3437967a2ae4730ba638cc80328055e9805e7c9 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 12 Apr 2018 06:40:39 +0200 Subject: Rely on PATH variable for running init programs Signed-off-by: David Oberhollenzer --- scripts/Makemodule.am | 2 ++ scripts/devfs.sh.in | 26 +++++++++++++------------- scripts/overlay.sh | 21 +++++++++++++++++++++ scripts/overlay.sh.in | 21 --------------------- scripts/trymount.sh | 7 +++++++ scripts/trymount.sh.in | 7 ------- 6 files changed, 43 insertions(+), 41 deletions(-) create mode 100644 scripts/overlay.sh delete mode 100644 scripts/overlay.sh.in create mode 100644 scripts/trymount.sh delete mode 100644 scripts/trymount.sh.in (limited to 'scripts') diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am index 6832788..dd3fa0b 100644 --- a/scripts/Makemodule.am +++ b/scripts/Makemodule.am @@ -3,3 +3,5 @@ helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh if PYGOSCFG helper_SCRIPTS += scripts/overlay.sh endif + +EXTRA_DIST += scripts/trymount.sh scripts/overlay.sh diff --git a/scripts/devfs.sh.in b/scripts/devfs.sh.in index a39d3ea..af002f6 100644 --- a/scripts/devfs.sh.in +++ b/scripts/devfs.sh.in @@ -1,20 +1,20 @@ #!/bin/sh -@SBINPATH@/mount -t devtmpfs none /dev +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 +[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 +[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 +[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 +[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 +[ -e /dev/fd ] || ln -snf /proc/self/fd /dev/fd +[ -e /dev/stdin ] || ln -snf /proc/self/fd/0 /dev/stdin +[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout +[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr +[ -e /proc/kcore ] && 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 +mkdir -p /dev/mqueue -m 1777 +mkdir -p /dev/pts -m 0755 +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" diff --git a/scripts/overlay.sh b/scripts/overlay.sh new file mode 100644 index 0000000..090671c --- /dev/null +++ b/scripts/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/scripts/overlay.sh.in b/scripts/overlay.sh.in deleted file mode 100644 index b53eea7..0000000 --- a/scripts/overlay.sh.in +++ /dev/null @@ -1,21 +0,0 @@ -#!/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/scripts/trymount.sh b/scripts/trymount.sh new file mode 100644 index 0000000..9be77f6 --- /dev/null +++ b/scripts/trymount.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -d "$1" ]; then + if grep -qsE "[[:space:]]+$2$" "/proc/filesystems"; then + mount -n -t "$2" -o "$3" "$2" "$1" + fi +fi diff --git a/scripts/trymount.sh.in b/scripts/trymount.sh.in deleted file mode 100644 index a382792..0000000 --- a/scripts/trymount.sh.in +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 -- cgit v1.2.3