Skip to content

Commit

Permalink
Add printer services and many README changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kcghost committed Jul 23, 2022
1 parent 55119c1 commit 4be8f36
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 73 deletions.
1 change: 0 additions & 1 deletion NixOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ exec startlxqt

```
exec startxfce4
```

#### MATE
Expand Down
161 changes: 90 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,52 @@ busyrc - minimalistic rc script
The original minirc can be found [here.](https://github.com/hut/minirc)

The script "rc" is a minimalistic init script made for use with busybox init.
It starts up udev, sets the hostname, mounts the file systems, starts the
daemons and so on.
It starts up udev, sets the hostname, mounts the file systems, starts the daemons and so on.

Later, in the user space, you can use it to list currently running daemons and
individually start or stop them.
Later, in the user space, you can use it to list currently running daemons and individually start or stop them.

It was originally developed for Arch linux to get rid of systemd.
This fork primarily supports Ubuntu Focal now, but it *should* still support
Arch and other distributions. At least it is meant to be as generic as possible.
This fork primarily supports Ubuntu Focal now, but it *should* still support Arch and other distributions.
At least it is meant to be as generic as possible.
It previously targeted NixOS, and *should* still work, but it is untested.
Read [this document](NixOS.md) for NixOS install instructions and notes.

![screenshot](screenshot.png)

**WARNING**: This project is experimental and you are practically guaranteed to encounter some issues using it.
You should have a Live USB on hand to make changes to the disk and undo installation if necessary if the system is unbootable.
I also recommend setting up SSH access in case just your terminal gets hosed.

**WARNING**: It is unknown if this project still works on Arch.
You may want to look at the [original project](https://github.com/hut/minirc) that has an AUR package.

Installing on Ubuntu or most normal Linux distributions
--------------------------------------------------------------------------------

**WARNING**: This whole project is experimental and you are practically
guaranteed to encounter some issues using it. You should have a Live USB on
hand to make changes to the disk and undo installation if necessary if the
system is unbootable.

**WARNING**: It is unknown if this project still works on Arch. You may want to
look at the [original project](https://github.com/hut/minirc) that has an AUR
package.

Dependencies: busybox, optionally eudev or systemd (for udev)
```
sudo apt install busybox busybox-syslogd
sudo make install
sudo make install-conf
# For most systems, but this could be different depending on initrd:
sudo ln -fs /bin/busybox /sbin/init
# Going back to systemd on most systems:
sudo ln -fs /lib/systemd/systemd /sbin/init
sudo make install
```

Note that the true init on most Linux distributions is actually in initrd.
Usually a script in initrd will execute some traditional init, *probably*
`/sbin/init`. But you may need to find out which for your distribution.
Usually a script in initrd will execute some traditional init, *probably* `/sbin/init`.
`make install` assumes that is the case, but you may need to find out which for your distribution.

By default `make install-conf` attempts to autodetermine NETWORK_INTERFACES
and WIRELESS_INTERFACES based on active interfaces,
setting them up for basic ifplugd DHCP support and wpa_supplicant support.
By default `make install-conf` attempts to autodetermine NETWORK_INTERFACES and WIRELESS_INTERFACES based on active interfaces.
It sets them up for basic ifplugd DHCP support and wpa_supplicant support.

You will want to configure `/etc/busyrc/busyrc.conf` to your needs. It contains
information on how to define new daemons or override existing ones.
See sections [Dealing with services](#dealing-with-services) and
[Further configuration](#further-configuration).
You will want to configure `/etc/busyrc/busyrc.conf` to your needs.
It contains information on how to define new daemons or override existing ones.
See sections [Dealing with services](#dealing-with-services) and [Further configuration](#further-configuration).

You will likely want to configure user some [user services](#user-services) as
well. It is recommended to use `startx` to start X from a user profile
rather than use a display manager, as well as start pulseaudio as a normal user.
You will likely want to configure user some [user services](#user-services) as well.
It is recommended to use `startx` to start X from a user profile rather than use a display manager, as well as start pulseaudio as a normal user.

Reboot. When moving from systemd to busyrc, `sudo reboot` will not work.
Reboot.
When moving from systemd to busyrc, `sudo reboot` will not work.
Try `sudo kill -s SIGINT 1` instead.

Uninstalling
Expand All @@ -76,86 +63,118 @@ And/or reinstall the systemd init package: `apt install --reinstall systemd-sysv
Dealing with services
---------------------

The variable DAEMONS contains a space-separated list of services that busyrc
lists when you ask which services currently run.
The variable DAEMONS contains a space-separated list of services that busyrc lists when you ask which services are currently running.

The variable ENABLED contains a space-separated list of services that are started on boot.
Using an @ symbol in front of the daemon ensures it will run as a background process rather than sequentially.
This is preferred most of the time so you can boot quickly, but it may require additional logic to wait for another service or resource first.

You can override DAEMONS, ENABLED, and define or override services in /etc/busyrc/busyrc.conf.
This file is simply sourced by the script right after defining the default variables.

The variable ENABLED contains a space-separated list of services that are
started on boot. Using an @ symbol in front of the daemon ensures it will run
as a background process rather than sequentially. This is preferred most of the
time so you can boot quickly, but it may require additional logic to wait for
another service or resource first.
To add or override another service you may need to define the appropriate actions of that service.
See the comments in [src/busyrc.conf.sh](busyrc.conf) for details.

You can override DAEMONS, ENABLED, and define or override services in
/etc/busyrc/busyrc.conf. This file is simply sourced by the script right after
defining the default variables.
Debugging
---------

To add or override another service you must define the appropriate actions of
that service. See the comments in [src/busyrc.conf.sh](busyrc.conf) for details.
The main rc script logs to `/var/log/rc/initlog`, and each backgrounded service prints to `/var/log/rc/service_name`.
The default configuration also starts up `syslogd` and `klogd`, with many services configured to use it.
Therefore many messages should show up in `/var/log/messages`.

Further configuration
---------------------

### udev

You need to decide what to use to set up the devices and load the modules.
busyrc supports busybox's mdev, systemd's udev, and a fork of udev, eudev,
by default. You can change the udev system by writing UDEV=busybox,
UDEV=systemd, or UDEV=eudev respectively into /etc/busyrc.conf.
busyrc supports busybox's mdev, systemd's udev, and a fork of udev, eudev, by default.
You can change the udev system by writing UDEV=busybox, UDEV=systemd, or UDEV=eudev respectively into /etc/busyrc.conf.

eudev and systemd's udev work out of the box, so they are recommended. To
set up mdev, you can use
[this as a reference](https://github.com/slashbeast/mdev-like-a-boss).
eudev and systemd's udev work out of the box, so they are recommended.
To set up mdev, you can use [this as a reference](https://github.com/slashbeast/mdev-like-a-boss).

### Local startup script

Busyrc will run `/etc/rc.local` on boot if the file exists and has the
executable bit set. This allows the user to run commands in addition to the
basic startup that busyrc provides. This is a good place to load modules if
udev does not detect that they should be loaded on boot.
Busyrc will run `/etc/rc.local` on boot if the file exists and has the executable bit set.
This allows the user to run arbitrary commands in addition to the basic startup that busyrc provides.

In particular this is a good place to load modules not automatically integrated by udev, such as these for VirtualBox:
```
modprobe vboxdrv
modprobe vboxnetflt
```

It will similiarly run `/etc/rc.local_shutdown` on shutdown.


Usage of the user space program
-------------------------------

Run "rc --help" for information. Never run "rc init" except during the boot
process, when called by busybox init.
Run "rc --help" for information. Never run "rc init" except during the boot process, when called by busybox init.

User services
-------------

The default inittab configuration starts console login shells on TTYs 1-7.
It is recommended to change the TTY7 line to automatically login your primary
user:
It is recommended to change the TTY7 line to automatically login your primary user:
```
tty7::respawn:agetty -a your_username tty7 linux
```

Instead of starting a display manager, it is recommended to start X11 directly
as a user, as well as pulseaudio. To do this, you should add your primary user
to the `video`, `input`, and `audio` groups:
Instead of starting a display manager, it is recommended to start X11 directly as a user, as well as pulseaudio.
To do this, you should add your primary user to the `video`, `input`, and `audio` groups.
For printer support, you should also add your user to the `lp` group.

```
usermod -a -G video your_username
usermod -a -G input your_username
usermod -a -G audio your_username
usermod -a -G lp your_username
```

Then to actually start services on autologin, add a block like this to
`~/.profile` or other login shell initialization file:
Then to actually start services on autologin, add a block like this to `~/.profile` or other login shell initialization file:
```
if [ -z "${DISPLAY}" ] && [ "$(tty)" = "/dev/tty7" ]; then
pulseaudio -D
startx
fi
```

Note that [other guides online](https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login)
often include `exec startx`. I recommend against that, as a failing X
configuration will cause X to continually attempt to start and potentially
lock the user out of practical access to the terminal. It is better to fail out
to a console.
Note that [other guides online](https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login) often include `exec startx`.
I recommend against that, as a failing X configuration will cause X to continually attempt to start and potentially lock the user out of practical access to the terminal.
It is better to fail out to a console.

You will also need a `~/.xinitrc`, here is a typical one that starts cinnamon, with some examples for other desktop managers:
```
[ -f ~/.xprofile ] && . ~/.xprofile
[ -f ~/.Xresources ] && xrdb -merge ~/.Xresources
if [ -z "${DBUS_SESSION_BUS_ADDRESS-}" ] && type dbus-launch >/dev/null; then
eval $(dbus-launch --sh-syntax --exit-with-session)
fi
# For debugging:
#exec xterm -maximized
#exec startxfce4
#exec openbox-session
#exec mate-session
#exec startlxqt
#export DESKTOP_SESSION=plasma
#exec startplasma-x11
#export XDG_SESSION_TYPE=x11
#export GDK_BACKEND=x11
#exec gnome-session
exec cinnamon-session
```

**Note**: I have not tested many desktop managers for Ubuntu Focal, only Cinnamon from [Cinnamon remix](https://ubuntucinnamon.org/).
I presume most work, though I do recall I couldn't find a way to start GNOME in NixOS.
I hope that is not the case in Ubuntu.

About
-----
Expand Down
2 changes: 1 addition & 1 deletion src/busyrc.conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# This is a space-separated list of daemons which are run on boot. You may
# prefix a daemon name with a "@" character to make it run in the background.
ENABLED="@syslogd @klogd @alsa @dbus @upowerd @systemd-tmpfiles @systemd-modules-load @udhcpc @sshd"
ENABLED="@syslogd @klogd @alsa @dbus @upowerd @systemd-tmpfiles @systemd-modules-load @udhcpc @sshd @cupsd @avahi-daemon @cups-browsed"

# Choose the udev implementation."auto" prefers systemd to eudev to busybox
#UDEV="auto"
Expand Down
8 changes: 8 additions & 0 deletions src/services/avahi-daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

avahi_daemon_start() {
wait_on dbus_poll
avahi-daemon
}

# Hyphens are not supported in function names, but are in aliases for some reason (ash)
alias avahi-daemon_start="avahi_daemon_start"

0 comments on commit 4be8f36

Please sign in to comment.