simple-init

A set of init binaries for linux
git clone git://depsterr.com/git/simple-init
Log | Files | Refs | README | LICENSE

commit 972e078fabc3cb2d6fdc06439dc8d89d28368a2b
parent 78e8fdb290cfcfce5737dbcbecb23c65151cfa1f
Author: depsterr <depsterr@protonmail.com>
Date:   Sat,  6 Jun 2020 16:13:26 +0200

added some options

Diffstat:
A.gitmodules | 3+++
AMakefile | 3+++
Minitscripts/Makefile | 8++++----
Ainitscripts/config.h | 9+++++++++
Ainitscripts/config.mk | 7+++++++
Minitscripts/init.c | 5+++++
Minitscripts/shutdown.c | 1+
Minitscripts/util.h | 6+++++-
Asinit | 1+
9 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "sinit"] + path = sinit + url = git://suckless.org/sinit diff --git a/Makefile b/Makefile @@ -0,0 +1,3 @@ +default: + @echo "PLEASE MAKE SURE WHAT YOU ARE DOING." + @echo "If you do, then run make build or make install." diff --git a/initscripts/Makefile b/initscripts/Makefile @@ -1,7 +1,4 @@ -CC=c99 -DESTDIR=/usr/lib/init -INIT=rc.init -SHUTDOWN=rc.shutdown +include config.mk default: ${INIT} ${SHUTDOWN} @@ -11,6 +8,9 @@ install: default chmod 755 ${DESTDIR}/${INIT} chmod 755 ${DESTDIR}/${INIT} +clean: + rm rc.* + ${INIT}: init.c util.c ${CC} $^ -o $@ diff --git a/initscripts/config.h b/initscripts/config.h @@ -0,0 +1,9 @@ +/* + Change the contents of this file to do some basic configuration. + For more advanced configuration, change the source. +*/ + +#define GETTY +#define UDEV +// #define AGETTY +// #define MDEV diff --git a/initscripts/config.mk b/initscripts/config.mk @@ -0,0 +1,7 @@ +# Change this if you want to install to a custom path. +DESTDIR=/usr/lib/init + +CC=cc +INIT=rc.init +SHUTDOWN=rc.shutdown + diff --git a/initscripts/init.c b/initscripts/init.c @@ -71,8 +71,13 @@ int main() { wait_for_children(); log_message("Boot completed, starting ttys"); +#if defined GETTY char* tty1[] = { "/bin/getty", "38400", "tty1", 0 }; char* tty2[] = { "/bin/getty", "38400", "tty2", 0 }; +#elif defined AGETTY + char* tty1[] = { "/bin/agetty", "38400", "tty1", 0 }; + char* tty2[] = { "/bin/agetty", "38400", "tty2", 0 }; +#endif respawn_process(tty1); respawn_process(tty2); } diff --git a/initscripts/shutdown.c b/initscripts/shutdown.c @@ -1,5 +1,6 @@ #include <sys/reboot.h> #include <sys/types.h> +#include <sys/wait.h> #include <signal.h> #include <unistd.h> diff --git a/initscripts/util.h b/initscripts/util.h @@ -1,4 +1,4 @@ -#include <sys/wait.h> +#include "config.h" /* Waits for children to exit. If children exit unsuccessfully it drops the user into an emergency shell */ @@ -8,6 +8,10 @@ void wait_for_children(); process's pid */ int spawn_process(char** argv); +/* Runs the given argv as a new process and restarts the new + process as soon as it terminates. */ +void respawn_process(char** argv); + /* mkdir -p */ void make_path(char* path); diff --git a/sinit b/sinit @@ -0,0 +1 @@ +Subproject commit 28c44b6b94a870f2942c37f9cfbae8b770595712