A minimal Linux init system, made in C.
To compile InitRC from source and install it, first make sure you have a C compiler and the Linux kernel headers. Then run either
make
sudo make install
to do it with make
or
sudo mv /bin/init /bin/init.old
sudo cc initrc.c -o /bin/init -O3
if you want to compile it manually.
On bootup, initrc will first mount the pseudofilesystems, then run /etc/initrc/rc
, then /etc/initrc/networkrc
, then run /etc/initrc/user
. After killing TTY1, InitRC will run /etc/initrc/shutdown
and then poweroff the machine.
initrc/rc
is meant to start essenial services, such as the dbus, set the time, hostname, etc.
initrc/networkrc
is meant to, well, start the network.
initrc/user
is meant to run user-created scripts in the initrc
directory that arent essential to the system bootup, so it gets ran as last.
initrc/shutdown
is for stopping processes and preparing to shutdown. As an example, you can use this script to stop sshd before shutting down.
InitRC doesnt have default rc files, you have to make those yourself.
User scripts are a new feature in initrc v0.5. First, create your userscripts in /etc/initrc/
, then in /etc/initrc/user
add a line that starts it, for example:
#!/bin/bash
sh -c "/etc/initrc/userscipt-X" # you dont have to call it userscript-X but this is an example
exit