From edd094af3d71089dbc5350eaf47c651aea2fbea0 Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Mon, 16 Oct 2023 12:48:38 -0400 Subject: [PATCH] fix --- README | 13 ++++++ etc/everest-release | 1 + etc/group | 26 ++++++++++++ etc/init.d/S01syslogd | 55 +++++++++++++++++++++++++ etc/init.d/S02klogd | 55 +++++++++++++++++++++++++ etc/init.d/S02sysctl | 94 +++++++++++++++++++++++++++++++++++++++++++ etc/init.d/S10mdev | 42 +++++++++++++++++++ etc/init.d/S20urandom | 70 ++++++++++++++++++++++++++++++++ etc/init.d/S40network | 30 ++++++++++++++ etc/init.d/S41dhcpcd | 33 +++++++++++++++ etc/init.d/rcK | 30 ++++++++++++++ etc/init.d/rcS | 31 ++++++++++++++ etc/inittab | 40 ++++++++++++++++++ etc/lsb-release | 3 ++ etc/os-release | 11 +++++ etc/profile | 15 +++++++ 16 files changed, 549 insertions(+) create mode 100644 etc/everest-release create mode 100644 etc/group create mode 100755 etc/init.d/S01syslogd create mode 100755 etc/init.d/S02klogd create mode 100755 etc/init.d/S02sysctl create mode 100755 etc/init.d/S10mdev create mode 100755 etc/init.d/S20urandom create mode 100755 etc/init.d/S40network create mode 100755 etc/init.d/S41dhcpcd create mode 100755 etc/init.d/rcK create mode 100755 etc/init.d/rcS create mode 100644 etc/inittab create mode 100644 etc/lsb-release create mode 100644 etc/os-release create mode 100644 etc/profile diff --git a/README b/README index e69de29..9a9b9a4 100644 --- a/README +++ b/README @@ -0,0 +1,13 @@ ++------+ +| /etc | ++------+ + +/etc skeleton for Everest Linux + ++--------------+ +| Installation | ++--------------+ + +Installing these files on an already-running system is not recommended. + +Installation can be done using spi. diff --git a/etc/everest-release b/etc/everest-release new file mode 100644 index 0000000..91b3724 --- /dev/null +++ b/etc/everest-release @@ -0,0 +1 @@ +1.0.0-busybox diff --git a/etc/group b/etc/group new file mode 100644 index 0000000..6822a27 --- /dev/null +++ b/etc/group @@ -0,0 +1,26 @@ +root:x:0: +daemon:x:1: +bin:x:2: +sys:x:3: +adm:x:4: +tty:x:5: +disk:x:6: +lp:x:7: +mail:x:8: +kmem:x:9: +wheel:x:10:root +cdrom:x:11: +dialout:x:18: +floppy:x:19: +video:x:28: +audio:x:29: +tape:x:32: +www-data:x:33: +operator:x:37: +utmp:x:43: +plugdev:x:46: +staff:x:50: +lock:x:54: +netdev:x:82: +users:x:100: +nobody:x:65534: diff --git a/etc/init.d/S01syslogd b/etc/init.d/S01syslogd new file mode 100755 index 0000000..15006bc --- /dev/null +++ b/etc/init.d/S01syslogd @@ -0,0 +1,55 @@ +#!/bin/sh + +DAEMON="syslogd" +PIDFILE="/var/run/$DAEMON.pid" + +SYSLOGD_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +# BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line +# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \ + -- -n $SYSLOGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/etc/init.d/S02klogd b/etc/init.d/S02klogd new file mode 100755 index 0000000..0677e1e --- /dev/null +++ b/etc/init.d/S02klogd @@ -0,0 +1,55 @@ +#!/bin/sh + +DAEMON="klogd" +PIDFILE="/var/run/$DAEMON.pid" + +KLOGD_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +# BusyBox' klogd does not create a pidfile, so pass "-n" in the command line +# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \ + -- -n $KLOGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/etc/init.d/S02sysctl b/etc/init.d/S02sysctl new file mode 100755 index 0000000..85d9ed5 --- /dev/null +++ b/etc/init.d/S02sysctl @@ -0,0 +1,94 @@ +#!/bin/sh +# +# This script is used by busybox and procps-ng. +# +# With procps-ng, the "--system" option of sysctl also enables "--ignore", so +# errors are not reported via syslog. Use the run_logger function to mimic the +# --system behavior, still reporting errors via syslog. Users not interested +# on error reports can add "-e" to SYSCTL_ARGS. +# +# busybox does not have a "--system" option neither reports errors via syslog, +# so the scripting provides a consistent behavior between the implementations. +# Testing the busybox sysctl exit code is fruitless, as at the moment, since +# its exit status is zero even if errors happen. Hopefully this will be fixed +# in a future busybox version. + +PROGRAM="sysctl" + +SYSCTL_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM" + +# Files are read from directories in the SYSCTL_SOURCES list, in the given +# order. A file may be used more than once, since there can be multiple +# symlinks to it. No attempt is made to prevent this. +SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf" + +# If the logger utility is available all messages are sent to syslog, except +# for the final status. The file redirections do the following: +# +# - stdout is redirected to syslog with facility.level "kern.info" +# - stderr is redirected to syslog with facility.level "kern.err" +# - file dscriptor 4 is used to pass the result to the "start" function. +# +run_logger() { + # shellcheck disable=SC2086 # we need the word splitting + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ + xargs -0 -r -n 1 readlink -f | { + prog_status="OK" + while :; do + read -r file || { + echo "$prog_status" >&4 + break + } + echo "* Applying $file ..." + /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL" + done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err + } 3>&1 | /usr/bin/logger -t sysctl -p kern.info +} + +# If logger is not available all messages are sent to stdout/stderr. +run_std() { + # shellcheck disable=SC2086 # we need the word splitting + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ + xargs -0 -r -n 1 readlink -f | { + prog_status="OK" + while :; do + read -r file || { + echo "$prog_status" >&4 + break + } + echo "* Applying $file ..." + /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL" + done + } +} + +if [ -x /usr/bin/logger ]; then + run_program="run_logger" +else + run_program="run_std" +fi + +start() { + printf '%s %s: ' "$1" "$PROGRAM" + status=$("$run_program" 4>&1) + echo "$status" + if [ "$status" = "OK" ]; then + return 0 + fi + return 1 +} + +case "$1" in + start) + start "Running";; + restart|reload) + start "Rerunning";; + stop) + :;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/etc/init.d/S10mdev b/etc/init.d/S10mdev new file mode 100755 index 0000000..3c6f47c --- /dev/null +++ b/etc/init.d/S10mdev @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Run the mdev daemon +# + +DAEMON="mdev" +PIDFILE="/var/run/$DAEMON.pid" + + +start() { + echo -n "Starting $DAEMON... " + start-stop-daemon -S -b -m -p $PIDFILE -x /sbin/mdev -- -df + [ $? -eq 0 ] && echo "OK" || echo "ERROR" + + # coldplug modules + find /sys/ -name modalias -print0 | \ + xargs -0 sort -u | \ + tr '\n' '\0' | \ + xargs -0 modprobe -abq +} + +stop() { + echo -n "Stopping $DAEMON... " + start-stop-daemon -K -p $PIDFILE + [ $? -eq 0 ] && echo "OK" || echo "ERROR" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1" + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/etc/init.d/S20urandom b/etc/init.d/S20urandom new file mode 100755 index 0000000..6c6aea9 --- /dev/null +++ b/etc/init.d/S20urandom @@ -0,0 +1,70 @@ +#! /bin/sh +# +# Preserve the random seed between reboots. See urandom(4). +# + +# Quietly do nothing if /dev/urandom does not exist +[ -c /dev/urandom ] || exit 0 + +URANDOM_SEED="/var/lib/random-seed" + +# shellcheck source=/dev/null +[ -r "/etc/default/urandom" ] && . "/etc/default/urandom" + +if pool_bits=$(cat /proc/sys/kernel/random/poolsize 2> /dev/null); then + pool_size=$((pool_bits/8)) +else + pool_size=512 +fi + +init_rng() { + [ -f "$URANDOM_SEED" ] || return 0 + printf 'Initializing random number generator: ' + dd if="$URANDOM_SEED" bs="$pool_size" of=/dev/urandom count=1 2> /dev/null + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +save_random_seed() { + printf 'Saving random seed: ' + status=1 + if touch "$URANDOM_SEED.new" 2> /dev/null; then + old_umask=$(umask) + umask 077 + dd if=/dev/urandom of="$URANDOM_SEED.tmp" bs="$pool_size" count=1 2> /dev/null + cat "$URANDOM_SEED" "$URANDOM_SEED.tmp" 2>/dev/null \ + | sha256sum \ + | cut -d ' ' -f 1 > "$URANDOM_SEED.new" && \ + mv "$URANDOM_SEED.new" "$URANDOM_SEED" && status=0 + rm -f "$URANDOM_SEED.tmp" + umask "$old_umask" + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + + else + echo "SKIP (read-only file system detected)" + fi + return "$status" +} + +case "$1" in + start|restart|reload) + # Carry a random seed from start-up to start-up + # Load and then save the whole entropy pool + init_rng && save_random_seed;; + stop) + # Carry a random seed from shut-down to start-up + # Save the whole entropy pool + save_random_seed;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/etc/init.d/S40network b/etc/init.d/S40network new file mode 100755 index 0000000..642c501 --- /dev/null +++ b/etc/init.d/S40network @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Start the network.... +# + +# Debian ifupdown needs the /run/network lock directory +mkdir -p /run/network + +case "$1" in + start) + printf "Starting network: " + /sbin/ifup -a + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + stop) + printf "Stopping network: " + /sbin/ifdown -a + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + restart|reload) + "$0" stop + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + diff --git a/etc/init.d/S41dhcpcd b/etc/init.d/S41dhcpcd new file mode 100755 index 0000000..55794f4 --- /dev/null +++ b/etc/init.d/S41dhcpcd @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Start/stop dhcpcd +# + +DAEMON=/sbin/dhcpcd +CONFIG=/etc/dhcpcd.conf +PIDFILE=/var/run/dhcpcd/pid + +[ -f $CONFIG ] || exit 0 + +case "$1" in + start) + echo "Starting dhcpcd..." + start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" -- -f "$CONFIG" + ;; + stop) + echo "Stopping dhcpcd..." + start-stop-daemon -K -x "$DAEMON" -p "$PIDFILE" -o + ;; + reload|force-reload) + echo "Reloading dhcpcd configuration..." + "$DAEMON" -s reload + ;; + restart) + "$0" stop + sleep 1 # Prevent race condition: ensure dhcpcd stops before start. + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart|reload|force-reload}" + exit 1 +esac diff --git a/etc/init.d/rcK b/etc/init.d/rcK new file mode 100755 index 0000000..da0953d --- /dev/null +++ b/etc/init.d/rcK @@ -0,0 +1,30 @@ +#!/bin/sh + + +# Stop all init scripts in /etc/init.d +# executing them in reversed numerical order. +# + +printf "\033[1;31m[i]\033[m Shutting down...\n" + +for i in $(ls -r /etc/init.d/S??*) ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set stop + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i stop + ;; + esac +done + diff --git a/etc/init.d/rcS b/etc/init.d/rcS new file mode 100755 index 0000000..ee415f9 --- /dev/null +++ b/etc/init.d/rcS @@ -0,0 +1,31 @@ +#!/bin/sh + + +# Start all init scripts in /etc/init.d +# executing them in numerical order. +# + +printf "\033[1;34m[i]\033[m Welcome to Everest Linux\n" +printf "\033[1;34m[i]\033[m Starting system...\n" + +for i in /etc/init.d/S??* ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set start + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i start + ;; + esac +done + diff --git a/etc/inittab b/etc/inittab new file mode 100644 index 0000000..b00ad74 --- /dev/null +++ b/etc/inittab @@ -0,0 +1,40 @@ +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen +# +# Note: BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use +# sysvinit. +# +# Format for each entry: ::: +# +# id == tty to run on, or empty for /dev/console +# runlevels == ignored +# action == one of sysinit, respawn, askfirst, wait, and once +# process == program to run + +# Startup the system +::sysinit:/bin/mount -t proc proc /proc +::sysinit:/bin/mount -o remount,rw / +::sysinit:/bin/mkdir -p /dev/pts /dev/shm +::sysinit:/bin/mount -a +::sysinit:/bin/mkdir -p /run/lock/subsys +::sysinit:/sbin/swapon -a +null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd +null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin +null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout +null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr +::sysinit:/bin/hostname -F /etc/hostname +# now run any rc scripts +::sysinit:/etc/init.d/rcS + +# Put a getty on the serial port +console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL + +# Stuff to do for the 3-finger salute +#::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +::shutdown:/sbin/swapoff -a +::shutdown:/bin/umount -a -r diff --git a/etc/lsb-release b/etc/lsb-release new file mode 100644 index 0000000..db0f9a2 --- /dev/null +++ b/etc/lsb-release @@ -0,0 +1,3 @@ +DISTRIB_ID="Everest" +DISTRIB_RELEASE="1.0.0-busybox" +DISTRIB_DESCRIPTION="Everest Linux" diff --git a/etc/os-release b/etc/os-release new file mode 100644 index 0000000..f43b6df --- /dev/null +++ b/etc/os-release @@ -0,0 +1,11 @@ +NAME="Everest Linux" +PRETTY_NAME="Everest Linux" +ID=ev +BUILD_ID=1.0.0-busybox +ANSI_COLOR="" +HOME_URL="https://everestlinux.org/" +DOCUMENTATION_URL="https://everestlinux.org/" +SUPPORT_URL="https://git.everestlinux.org/" +BUG_REPORT_URL="https://git.everestlinux.org/" +PRIVACY_POLICY_URL="https://everestlinux.org" +LOGO=everestlinux diff --git a/etc/profile b/etc/profile new file mode 100644 index 0000000..f4a7f51 --- /dev/null +++ b/etc/profile @@ -0,0 +1,15 @@ +# +# /etc/profile +# + +# Initial path +PATH=/bin:/sbin:/usr/bin:/usr/sbin + +if [ `id -u` -eq 0 ]; then + PATH=/bin:/sbin:/usr/bin:/usr/sbin + unset HISTFI:E +fi + +export C_INCLUDE_PATH="/include:/usr/include" + +PS1="[everest] \u@\h \w \$ "