Mercurial > vanilla
changeset 557:73e25417284b
core/etc: take init scripts from sysvinit
Init scripts are usable with both busybox's init and sysvinit so install them
with the core/etc package rather than sysvinit.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 05 Jul 2019 20:21:00 +0200 |
parents | dea7c4365bbe |
children | a85759a313b1 |
files | core/etc/etc.sh core/etc/rc.conf core/etc/rc.init core/etc/rc.shutdown core/etc/rc.start core/sysvinit/rc.conf core/sysvinit/rc.init core/sysvinit/rc.shutdown core/sysvinit/rc.start core/sysvinit/sysvinit.sh |
diffstat | 10 files changed, 228 insertions(+), 216 deletions(-) [+] |
line wrap: on
line diff
--- a/core/etc/etc.sh Fri Jul 05 20:20:00 2019 +0200 +++ b/core/etc/etc.sh Fri Jul 05 20:21:00 2019 +0200 @@ -22,9 +22,13 @@ PKGSUMMARY="base system configuration files" PKGPROTECT="etc/issue etc/fstab + etc/group etc/passwd - etc/group etc/profile + etc/rc.conf + etc/rc.init + etc/rc.shutdown + etc/rc.start etc/securetty etc/shadow etc/shells" @@ -32,13 +36,18 @@ build() { install -d $DESTDIR/etc - install -m 644 fstab $DESTDIR/etc - install -m 644 group $DESTDIR/etc - install -m 644 issue $DESTDIR/etc - install -m 644 passwd $DESTDIR/etc - install -m 644 securetty $DESTDIR/etc - install -m 600 shadow $DESTDIR/etc - install -m 644 shells $DESTDIR/etc - install -m 644 profile $DESTDIR/etc + install -d $DESTDIR/etc/rc.d + install -m0755 rc.conf $DESTDIR/etc/rc.conf + install -m0755 rc.init $DESTDIR/etc/rc.init + install -m0755 rc.shutdown $DESTDIR/etc/rc.shutdown + install -m0755 rc.start $DESTDIR/etc/rc.start + install -m0600 shadow $DESTDIR/etc + install -m0644 fstab $DESTDIR/etc + install -m0644 group $DESTDIR/etc + install -m0644 issue $DESTDIR/etc + install -m0644 passwd $DESTDIR/etc + install -m0644 profile $DESTDIR/etc + install -m0644 securetty $DESTDIR/etc + install -m0644 shells $DESTDIR/etc ln -sf /proc/self/mounts $DESTDIR/etc/mtab }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/etc/rc.conf Fri Jul 05 20:21:00 2019 +0200 @@ -0,0 +1,12 @@ +# +# /etc/rc.conf: system configuration +# + +# System hostname. +HOSTNAME="localhost" + +# System timezone. +TIMEZONE="UTC" + +# Services to start at boot. +SERVICES=""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/etc/rc.init Fri Jul 05 20:21:00 2019 +0200 @@ -0,0 +1,111 @@ +# +# /etc/rc.init: system initialization script +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ -f /etc/rc.conf ]; then + . /etc/rc.conf +fi + +if [ "${BANNER:-yes}" = "yes" ]; then + printf "\nWelcome to \033[34mVanilla Linux\033[0m\n\n" +fi + +if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then + echo "Setting hostname: $HOSTNAME" + /bin/hostname "$HOSTNAME" +fi + +if [ -x /bin/sysctl ]; then + echo "Setting kernel parameters." + /bin/sysctl -p >/dev/null 2>&1 +fi + +if [ -x /bin/mountpoint ]; then + echo -n "Mounting filesystems: " + + if ! /bin/mountpoint /dev >/dev/null 2>&1; then + /bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1 + echo -n "/dev " + fi + + if ! /bin/mountpoint /proc >/dev/null 2>&1; then + /bin/mount -t proc proc /proc >/dev/null 2>&1 + echo -n "/proc " + fi + + if ! /bin/mountpoint /sys >/dev/null 2>&1; then + /bin/mount -t sysfs sysfs /sys >/dev/null 2>&1 + echo -n "/sys " + fi + + if ! /bin/mountpoint /run >/dev/null 2>&1; then + /bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1 + echo -n "/run " + fi + + echo "done." +fi + +# +# Start a device service. Both eudev and busybox's mdev are supported but only +# one at a time must be enabled. +# +if [ -x /etc/rc.d/udevd ] && [ -x /etc/rc.d/mdev ]; then + echo "Warning: both /etc/rc.d/udevd and /etc/rc.mdev are enabled" 1>&2 + echo "Warning: using udevd instead" 1>&2 +fi + +if [ -x /etc/rc.d/udevd ]; then + /etc/rc.d/udevd start +elif [ -x /etc/rc.d/mdev ]; then + /etc/rc.d/mdev start +fi + +if [ -x /bin/fsck ]; then + # Make sure / is ro in case of initrd. + /bin/mount -o remount,ro / + + # If /etc/forcefsck is there, force check. + if [ -f /etc/forcefsck ]; then + force="-f" + fi + + /bin/fsck $force -A -T -C -a >/dev/null 2>&1 + + if [ "$?" -gt 1 ]; then + echo "* Filesystem check failed" + /bin/sulogin -p + fi +fi + +# Remount / and enable swap as the system is ready. +/bin/mount -o remount,rw / +/bin/swapon -a + +if [ -n "$TIMEZONE" ]; then + echo -n "Setting timezone: " + + if [ -f /share/zoneinfo/$TIMEZONE ]; then + /bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime + echo "$TIMEZONE." + else + echo "$TIMEZONE not found." + fi +fi + +# cleanup some files. +rm -f /etc/forcefsck
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/etc/rc.shutdown Fri Jul 05 20:21:00 2019 +0200 @@ -0,0 +1,40 @@ +# +# /etc/rc.shutdown: reboot and halt script +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ -f /etc/rc.conf ]; then + source /etc/rc.conf +fi + +echo "Terminating all processes." +/bin/killall5 -15 + +echo "Unmounting all filesystems." +/bin/halt -w +/bin/swapoff -a + +if [ -x /bin/mount ]; then + /bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs + /bin/umount -a -r + /bin/mount -o remount,ro / +fi + +if [ "$1" = "0" ]; then + /bin/poweroff -d -f -i +else + /bin/reboot -d -f -i +fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/etc/rc.start Fri Jul 05 20:21:00 2019 +0200 @@ -0,0 +1,46 @@ +# +# /etc/rc.start: runlevel control script +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ "$#" -ne 1 ]; then + echo "usage: $0 runlevel" 1>&2 + exit 1 +fi + +if [ -f /etc/rc.conf ]; then + source /etc/rc.conf +fi + +# Start user services requested in rc.conf(5). +for s in $SERVICES; do + # + # Services are requested in the form name[:runlevel], if runlevel is + # specified the service is started only if the system runlevel is + # greater or equal to the request. + # + name="${s%%:*}" + level="${s##*:}" + + # No minimum level, set to requested. + if [ "$level" = "$name" ]; then + level="$1" + fi + + if [ -x /etc/rc.d/$name ] && [ "$level" -le "$1" ]; then + /etc/rc.d/$name start + fi +done
--- a/core/sysvinit/rc.conf Fri Jul 05 20:20:00 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -# -# /etc/rc.conf: system configuration -# - -# System hostname. -HOSTNAME="localhost" - -# System timezone. -TIMEZONE="UTC" - -# Services to start at boot. -SERVICES=""
--- a/core/sysvinit/rc.init Fri Jul 05 20:20:00 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -# -# /etc/rc.init: system initialization script -# -# Copyright (c) 2019 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -if [ -f /etc/rc.conf ]; then - . /etc/rc.conf -fi - -if [ "${BANNER:-yes}" = "yes" ]; then - printf "\nWelcome to \033[34mVanilla Linux\033[0m\n\n" -fi - -if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then - echo "Setting hostname: $HOSTNAME" - /bin/hostname "$HOSTNAME" -fi - -if [ -x /bin/sysctl ]; then - echo "Setting kernel parameters." - /bin/sysctl -p >/dev/null 2>&1 -fi - -if [ -x /bin/mountpoint ]; then - echo -n "Mounting filesystems: " - - if ! /bin/mountpoint /dev >/dev/null 2>&1; then - /bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1 - echo -n "/dev " - fi - - if ! /bin/mountpoint /proc >/dev/null 2>&1; then - /bin/mount -t proc proc /proc >/dev/null 2>&1 - echo -n "/proc " - fi - - if ! /bin/mountpoint /sys >/dev/null 2>&1; then - /bin/mount -t sysfs sysfs /sys >/dev/null 2>&1 - echo -n "/sys " - fi - - if ! /bin/mountpoint /run >/dev/null 2>&1; then - /bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1 - echo -n "/run " - fi - - echo "done." -fi - -if [ -x /etc/rc.d/udevd ]; then - /etc/rc.d/udevd start -fi - -if [ -x /bin/fsck ]; then - # Make sure / is ro in case of initrd. - /bin/mount -o remount,ro / - - # If /etc/forcefsck is there, force check. - if [ -f /etc/forcefsck ]; then - force="-f" - fi - - /bin/fsck $force -A -T -C -a >/dev/null 2>&1 - - if [ "$?" -gt 1 ]; then - echo "* Filesystem check failed" - /bin/sulogin -p - fi -fi - -# Remount / and enable swap as the system is ready. -/bin/mount -o remount,rw / -/bin/swapon -a - -if [ -n "$TIMEZONE" ]; then - echo -n "Setting timezone: " - - if [ -f /share/zoneinfo/$TIMEZONE ]; then - /bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime - echo "$TIMEZONE." - else - echo "$TIMEZONE not found." - fi -fi - -# cleanup some files. -rm -f /etc/forcefsck
--- a/core/sysvinit/rc.shutdown Fri Jul 05 20:20:00 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -# -# /etc/rc.shutdown: reboot and halt script -# -# Copyright (c) 2019 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -if [ -f /etc/rc.conf ]; then - source /etc/rc.conf -fi - -echo "Terminating all processes." -/bin/killall5 -15 - -echo "Unmounting all filesystems." -/bin/halt -w -/bin/swapoff -a - -if [ -x /bin/mount ]; then - /bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs - /bin/umount -a -r - /bin/mount -o remount,ro / -fi - -if [ "$1" = "0" ]; then - /bin/poweroff -d -f -i -else - /bin/reboot -d -f -i -fi
--- a/core/sysvinit/rc.start Fri Jul 05 20:20:00 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -# -# /etc/rc.start: runlevel control script -# -# Copyright (c) 2019 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -if [ "$#" -ne 1 ]; then - echo "usage: $0 runlevel" 1>&2 - exit 1 -fi - -if [ -f /etc/rc.conf ]; then - source /etc/rc.conf -fi - -# Start user services requested in rc.conf(5). -for s in $SERVICES; do - # - # Services are requested in the form name[:runlevel], if runlevel is - # specified the service is started only if the system runlevel is - # greater or equal to the request. - # - name="${s%%:*}" - level="${s##*:}" - - # No minimum level, set to requested. - if [ "$level" = "$name" ]; then - level="$1" - fi - - if [ -x /etc/rc.d/$name ] && [ "$level" -le "$1" ]; then - /etc/rc.d/$name start - fi -done
--- a/core/sysvinit/sysvinit.sh Fri Jul 05 20:20:00 2019 +0200 +++ b/core/sysvinit/sysvinit.sh Fri Jul 05 20:21:00 2019 +0200 @@ -21,11 +21,7 @@ PKGLICENSE="GPLv2+" PKGSUMMARY="traditional System V init" PKGDOWNLOAD="http://download.savannah.nongnu.org/releases/$PKGNAME/$PKGNAME-$PKGVERSION.tar.xz" -PKGPROTECT="etc/inittab - etc/rc.conf - etc/rc.init - etc/rc.shutdown - etc/rc.start" +PKGPROTECT="etc/inittab" : ${CC:=clang} : ${CFLAGS:=-O2} @@ -42,10 +38,6 @@ make CC="$CC" CFLAGS="$CFLAGS" make install ROOT=$DESTDIR install -Dm0644 ../inittab $DESTDIR/etc/inittab - install -Dm0755 ../rc.conf $DESTDIR/etc/rc.conf - install -Dm0755 ../rc.init $DESTDIR/etc/rc.init - install -Dm0755 ../rc.shutdown $DESTDIR/etc/rc.shutdown - install -Dm0755 ../rc.start $DESTDIR/etc/rc.start popd rm -rf $PKGNAME-$PKGVERSION