fixed init system detection

This commit is contained in:
jwihardi
2026-09-28 18:43:34 -04:00
parent ad2cb976ca
commit 0504bb8cd4
+38 -28
View File
@@ -27,39 +27,49 @@ v install-python-packages
showfun setup_user_group
v setup_user_group
if [[ ! -z $(systemctl --version) ]]; then
# For Fedora, uinput is required for the virtual keyboard to function, and udev rules enable input group users to utilize it.
if [[ "$OS_GROUP_ID" == "fedora" ]]; then
v bash -c "echo uinput | sudo tee /etc/modules-load.d/uinput.conf"
v bash -c 'echo SUBSYSTEM==\"misc\", KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"input\" | sudo tee /etc/udev/rules.d/99-uinput.rules'
else
v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf"
fi
# TODO: find a proper way for enable Nix installed ydotool. When running `systemctl --user enable ydotool, it errors "Failed to enable unit: Unit ydotool.service does not exist".
if [[ ! "${INSTALL_VIA_NIX}" == true ]]; then
if [[ -d /run/systemd/system ]]; then
if systemctl --version >/dev/null 2>&1; then
# For Fedora, uinput is required for the virtual keyboard to function, and udev rules enable input group users to utilize it.
if [[ "$OS_GROUP_ID" == "fedora" ]]; then
v prepare_systemd_user_service
fi
# When $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR are empty, it commonly means that the current user has been logged in with `su - user` or `ssh user@hostname`. In such case `systemctl --user enable <service>` is not usable. It should be `sudo systemctl --machine=$(whoami)@.host --user enable <service>` instead.
if [[ ! -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
v systemctl --user enable ydotool --now
v bash -c "echo uinput | sudo tee /etc/modules-load.d/uinput.conf"
v bash -c 'echo SUBSYSTEM==\"misc\", KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"input\" | sudo tee /etc/udev/rules.d/99-uinput.rules'
else
v sudo systemctl --machine=$(whoami)@.host --user enable ydotool --now
v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf"
fi
# TODO: find a proper way for enable Nix installed ydotool. When running `systemctl --user enable ydotool, it errors "Failed to enable unit: Unit ydotool.service does not exist".
if [[ ! "${INSTALL_VIA_NIX}" == true ]]; then
if [[ "$OS_GROUP_ID" == "fedora" ]]; then
v prepare_systemd_user_service
fi
# When $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR are empty, it commonly means that the current user has been logged in with `su - user` or `ssh user@hostname`. In such case `systemctl --user enable <service>` is not usable. It should be `sudo systemctl --machine=$(whoami)@.host --user enable <service>` instead.
if [[ ! -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
v systemctl --user enable ydotool --now
else
v sudo systemctl --machine=$(whoami)@.host --user enable ydotool --now
fi
fi
v sudo systemctl enable bluetooth --now
else
echo -e "${STY_RED}Systemd detected, but the systemctl command is unavailable.${STY_RST}"
pause
fi
v sudo systemctl enable bluetooth --now
elif [[ ! -z $(openrc --version) ]]; then
v sudo mkdir -p /etc/modules-load.d
v bash -c "printf '%s\n' i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf"
if [[ -f /etc/conf.d/modules ]]; then
v sudo sed -i '/^modules=i2c-dev$/d' /etc/conf.d/modules
fi
v sudo rc-update add modules boot
v sudo rc-update add ydotool default
v sudo rc-update add bluetooth default
elif [[ -f /run/openrc/softlevel ]]; then
if openrc --version >/dev/null 2>&1; then
v sudo mkdir -p /etc/modules-load.d
v bash -c "printf '%s\n' i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf"
if [[ -f /etc/conf.d/modules ]]; then
v sudo sed -i '/^modules=i2c-dev$/d' /etc/conf.d/modules
fi
v sudo rc-update add modules boot
v sudo rc-update add ydotool default
v sudo rc-update add bluetooth default
x sudo rc-service ydotool start
x sudo rc-service bluetooth start
x sudo rc-service ydotool start
x sudo rc-service bluetooth start
else
echo -e "${STY_RED}OpenRC detected, but the openrc command is unavailable.${STY_RST}"
pause
fi
elif [[ ! -z $(dinitctl --version 2>/dev/null) ]]; then
# Modules loading
v bash -c "echo i2c-dev | sudo tee -a /etc/modules"