1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-22 11:19:45 +01:00

Rely on PATH variable for running init programs

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-04-12 06:40:39 +02:00
parent 55d4a328c9
commit a3437967a2
23 changed files with 53 additions and 74 deletions

12
.gitignore vendored
View file

@ -20,26 +20,14 @@ reboot
shutdown shutdown
killall5 killall5
services/agetty
services/hostname
services/loopback
services/sysctl
services/hwclock
services/shutdown
services/reboot
services/sigkill services/sigkill
services/sigterm services/sigterm
services/sync
services/devfs services/devfs
services/procfs services/procfs
services/sysfs services/sysfs
services/tmpfs
services/tmpfsrun
services/tmpfsvar services/tmpfsvar
services/rootusr services/rootusr
scripts/devfs.sh scripts/devfs.sh
scripts/overlay.sh
scripts/trymount.sh
etc/initd.env etc/initd.env

View file

@ -55,26 +55,14 @@ AC_DEFINE_DIR(BINPATH, bindir, [Fully evaluated bin directory])
AC_DEFINE_DIR(SBINPATH, sbindir, [Fully evaluated sbin directory]) AC_DEFINE_DIR(SBINPATH, sbindir, [Fully evaluated sbin directory])
AC_DEFINE_DIR(ETCPATH, sysconfdir, [Fulle evaluated etc directory]) AC_DEFINE_DIR(ETCPATH, sysconfdir, [Fulle evaluated etc directory])
AC_CONFIG_FILES([services/agetty])
AC_CONFIG_FILES([services/hostname])
AC_CONFIG_FILES([services/loopback])
AC_CONFIG_FILES([services/sysctl])
AC_CONFIG_FILES([services/hwclock])
AC_CONFIG_FILES([services/reboot])
AC_CONFIG_FILES([services/shutdown])
AC_CONFIG_FILES([services/sigkill]) AC_CONFIG_FILES([services/sigkill])
AC_CONFIG_FILES([services/sigterm]) AC_CONFIG_FILES([services/sigterm])
AC_CONFIG_FILES([services/sync])
AC_CONFIG_FILES([services/sysfs]) AC_CONFIG_FILES([services/sysfs])
AC_CONFIG_FILES([services/devfs]) AC_CONFIG_FILES([services/devfs])
AC_CONFIG_FILES([services/procfs]) AC_CONFIG_FILES([services/procfs])
AC_CONFIG_FILES([services/tmpfs])
AC_CONFIG_FILES([services/tmpfsrun])
AC_CONFIG_FILES([services/tmpfsvar]) AC_CONFIG_FILES([services/tmpfsvar])
AC_CONFIG_FILES([services/rootusr]) AC_CONFIG_FILES([services/rootusr])
AC_CONFIG_FILES([scripts/devfs.sh]) AC_CONFIG_FILES([scripts/devfs.sh])
AC_CONFIG_FILES([scripts/overlay.sh])
AC_CONFIG_FILES([scripts/trymount.sh])
AC_CONFIG_FILES([etc/initd.env]) AC_CONFIG_FILES([etc/initd.env])
AC_OUTPUT([Makefile]) AC_OUTPUT([Makefile])

View file

@ -24,8 +24,6 @@
#include "init.h" #include "init.h"
extern char **environ;
static int child_setup(const char *ctty) static int child_setup(const char *ctty)
{ {
sigset_t mask; sigset_t mask;
@ -65,7 +63,7 @@ static NORETURN void argv_exec(exec_t *e)
argv[i] = ptr; argv[i] = ptr;
argv[i] = NULL; argv[i] = NULL;
execve(argv[0], argv, environ); execvp(argv[0], argv);
perror(argv[0]); perror(argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View file

@ -3,3 +3,5 @@ helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh
if PYGOSCFG if PYGOSCFG
helper_SCRIPTS += scripts/overlay.sh helper_SCRIPTS += scripts/overlay.sh
endif endif
EXTRA_DIST += scripts/trymount.sh scripts/overlay.sh

View file

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

View file

@ -11,11 +11,11 @@ fi
if [ -d "$lower" ]; then if [ -d "$lower" ]; then
if [ -d "$upper" ]; then if [ -d "$upper" ]; then
@BINPATH@/mkdir -p "$work" mkdir -p "$work"
@SBINPATH@/mount -t overlay overlay \ mount -t overlay overlay \
-olowerdir=${lower},upperdir=${upper},workdir=${work} \ -olowerdir=${lower},upperdir=${upper},workdir=${work} \
${target} ${target}
else else
@SBINPATH@/mount --bind "$lower" "$target" mount --bind "$lower" "$target"
fi fi
fi fi

View file

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

View file

@ -10,4 +10,7 @@ if PYGOSCFG
init_DATA += services/rootusr services/tmpfsrun services/tmpfsvar init_DATA += services/rootusr services/tmpfsrun services/tmpfsvar
endif endif
EXTRA_DIST += services/sysinit services/vfs EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname
EXTRA_DIST += services/hwclock services/loopback services/reboot
EXTRA_DIST += services/shutdown services/sync services/sysctl services/tmpfs
EXTRA_DIST += services/tmpfsrun

View file

@ -1,5 +1,5 @@
description agetty on %0 description agetty on %0
exec "@SBINPATH@/agetty" %0 linux exec agetty %0 linux
type respawn type respawn
target boot target boot
after sysinit after sysinit

View file

@ -1,5 +1,5 @@
description reload hostname description reload hostname
exec "@BINPATH@/hostname" --file /etc/hostname exec hostname --file /etc/hostname
type wait type wait
target boot target boot
before sysinit before sysinit

View file

@ -1,5 +1,5 @@
description restore time from RTC description restore time from RTC
exec "@SBINPATH@/hwclock" --hctosys --utc exec hwclock --hctosys --utc
type wait type wait
target boot target boot
before sysinit before sysinit

View file

@ -5,6 +5,6 @@ before sysinit
after hwclock hostname vfs after hwclock hostname vfs
exec { exec {
"@SBINPATH@/ip" addr add 127.0.0.1/8 dev lo brd + ip addr add 127.0.0.1/8 dev lo brd +
"@SBINPATH@/ip" link set lo up ip link set lo up
} }

View file

@ -4,6 +4,6 @@ target boot
before vfs before vfs
exec { exec {
"@SBINPATH@/mount" -t proc proc /proc mount -t proc proc /proc
"@SCRIPTDIR@/trymount.sh" /proc/sys/fs/binfmt_misc binfmt_misc nodev,noexec,nosuid "@SCRIPTDIR@/trymount.sh" /proc/sys/fs/binfmt_misc binfmt_misc nodev,noexec,nosuid
} }

View file

@ -1,5 +1,5 @@
description system reboot description system reboot
exec "@SBINPATH@/shutdown" -nrf exec shutdown -nrf
type wait type wait
target reboot target reboot
after sync sigkill sigterm after sync sigkill sigterm

View file

@ -1,5 +1,5 @@
description system shutdown description system shutdown
exec "@SBINPATH@/shutdown" -npf exec shutdown -npf
type wait type wait
target shutdown target shutdown
after sync sigkill sigterm after sync sigkill sigterm

View file

@ -5,5 +5,5 @@ before sigkill sync reboot shutdown
exec { exec {
"@SCRIPTDIR@/killall5" 15 "@SCRIPTDIR@/killall5" 15
"@BINPATH@/sleep" 5 sleep 5
} }

View file

@ -1,5 +1,5 @@
description sync description sync
exec "@BINPATH@/sync" exec sync
type wait type wait
target %0 target %0
after sigkill sigterm after sigkill sigterm

View file

@ -1,5 +1,5 @@
description configure kernel paramters description configure kernel paramters
exec "@SBINPATH@/sysctl" --system exec sysctl --system
type wait type wait
target boot target boot
before sysinit before sysinit

View file

@ -5,7 +5,7 @@ after procfs
before vfs before vfs
exec { exec {
"@SBINPATH@/mount" -t sysfs sysfs /sys mount -t sysfs sysfs /sys
"@SCRIPTDIR@/trymount.sh" /sys/kernel/security securityfs nodev,noexec,nosuid "@SCRIPTDIR@/trymount.sh" /sys/kernel/security securityfs nodev,noexec,nosuid
"@SCRIPTDIR@/trymount.sh" /sys/kernel/config configfs nodev,noexec,nosuid "@SCRIPTDIR@/trymount.sh" /sys/kernel/config configfs nodev,noexec,nosuid
"@SCRIPTDIR@/trymount.sh" /sys/fs/fuse/connections fusectl nodev,noexec,nosuid "@SCRIPTDIR@/trymount.sh" /sys/fs/fuse/connections fusectl nodev,noexec,nosuid

View file

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

11
services/tmpfsrun Normal file
View file

@ -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
}

View file

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

View file

@ -3,10 +3,10 @@ type wait
target boot target boot
before vfs before vfs
exec { exec {
"@SBINPATH@/mount" -t tmpfs none /var mount -t tmpfs none /var
"@BINPATH@/mkdir" /var/log -m 0755 mkdir /var/log -m 0755
"@BINPATH@/mkdir" /var/spool -m 0755 mkdir /var/spool -m 0755
"@BINPATH@/mkdir" /var/lib -m 0755 mkdir /var/lib -m 0755
"@BINPATH@/mkdir" /var/tmp -m 0755 mkdir /var/tmp -m 0755
"@SCRIPTDIR@/overlay.sh" var_lib /var/lib "@SCRIPTDIR@/overlay.sh" var_lib /var/lib
} }