Skip to main content
Topic: Various dinit service scripts (Read 1097 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Various dinit service scripts

Over my time using Artix (which has been awhile), I've made several of my own services for various things I use. I figured it was time to contribute and asked on the IRC how I should share these and was told to post a topic here, so here is the topic.

Some of these are slightly incomplete, only have a system service or a user service (where they could have both), and may need some minor corrections, but they should be something at the least.

cdemu-daemon-dinit (depends on extra/cdemu-daemon)
user/cdemu-daemon
Code: [Select]
type				= process
load-options = sub-vars
command = /usr/bin/cdemu-daemon
restart = true
smooth-recovery = true
depends-on = dbus
log-type = buffer

icecast-dinit (depends on icecast)
icecast
Code: [Select]
type				= process
command = /usr/bin/icecast -c /etc/icecast.xml
run-as = icecast
smooth-recovery = true
logfile = /var/log/dinit/icecast.log
depends-on = network.target
Icecast is not in the Arch or Artix repositories. Requesting packaging, please.

inspircd-dinit (depends on inspircd)
inspircd-pre
Code: [Select]
type		= scripted
command = /usr/bin/install -dm0755 -o inspircd -g inspircd /run/inspircd
after = pseudofs
inspircd
Code: [Select]
type				= process
command = /usr/bin/inspircd --runasroot --nofork
smooth-recovery = true
logfile = /var/log/dinit/inspircd.log
depends-on = inspircd-pre
depends-on = network.target
Inspircd is not in the Arch or Artix repositories. Requesting packaging, please.

jellyfin-dinit (depends on extra/jellyfin-server)
user/jellyfin
Code: [Select]
type				= process
command = /usr/bin/jellyfin
smooth-recovery = true
log-type = buffer
This could also be a system service and it is meant to be one, but I run it as a user.

monero-dinit (depends on extra/monero)
monerod
Code: [Select]
type				= process
command = /usr/bin/monerod --config-file /etc/monerod.conf --non-interactive
run-as = monero
smooth-recovery = yes
restart = yes
after = login.target
user/monerod
Code: [Select]
type				= process
command = /usr/bin/monerod --non-interactive
smooth-recovery = yes
restart = yes

opendkim-dinit (depends on extra/opendkim)
opendkim-pre
Code: [Select]
type			= scripted
command = /usr/bin/install -dm0775 -o opendkim -g opendkim /run/opendkim
depends-on = root-rw
opendkim
Code: [Select]
type				= bgprocess
command = /usr/bin/opendkim -x /etc/opendkim/opendkim.conf -u opendkim -f
pid-file = /run/opendkim/opendkim.pid
smooth-recovery = true
logfile = /var/log/dinit/opendkim.log
depends-on = opendkim-pre
depends-on = network.target
run-as = opendkim

opendmarc-dinit (depends on extra/opendmarc)
opendmarc-pre
Code: [Select]
type			= scripted
command = /usr/bin/install -dm0755 -o opendmarc -g opendmarc /run/opendmarc
depends-on = root-rw
opendmarc
Code: [Select]
type				= process
command = /usr/bin/opendmarc -c /etc/opendmarc/opendmarc.conf -f
smooth-recovery = true
logfile = /var/log/dinit/opendmarc.log
depends-on = network.target
depends-on = opendmarc-pre
run-as = opendmarc

wivrn-dinit (depends on wivrn-server)
user/wivrnd
Code: [Select]
type				= process
command = /usr/bin/wivrn-server
smooth-recovery = yes
restart = yes
log-type = buffer
WiVRn is not in the Arch or Artix repositories. Requesting packaging of wivrn-server (and optionally wivrn-dashboard), please.

yggdrasil-dinit (depends on extra/yggdrasil)
yggdrasil
Code: [Select]
type				= process
command = /usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
pid-file = /run/yggdrasil.pid
smooth-recovery = true
logfile = /var/log/dinit/yggdrasil.log
after = network.target

Hopefully most if not all of these are adequate, as well as some of my packaging requests. If not, at the very least hope these help somebody. Thanks!


Re: Various dinit service scripts

Reply #2
Looks like a great thread, and I'd like to contribute.

I've been using Artix (dinit) as my daily driver for over a year.
I also like to use Windows XP and 7 as virtual machines, because that's where I migrated from.
NOTE: Please do not allow these operating systems that lack security updates to be connected the internet.

I use VMware Workstation from the AUR, since it has better support for these operating systems than VirtualBox.



If you try to use VMware on Artix (non OpenRC, OpenRC has a dedicated package vmware-workstation-openrc), you'll likely run into connectivity issues for network and USB.
The following service description files will enable the use of networking and USB connectivity on Linux systems using dinit as the init system.

vmware-workstation-dinit (depends on vmware-workstation)
/etc/dinit.d/vmware-networks-configuration
Code: [Select]
before       = login.target
command      = /usr/bin/vmware-networks --postinstall vmware-player,0,1
depends-on   = vmware-networks-pre
type         = process

/etc/dinit.d/vmware-networks-pre
Code: [Select]
command      = /usr/bin/modprobe vmnet
depends-on   = network.target
type         = scripted

/etc/dinit.d/vmware-networks
Code: [Select]
before       = login.target
command      = /usr/bin/vmware-networks --start
depends-on   = vmware-networks-pre
stop-command = /usr/bin/vmware-networks --stop
type         = process
waits-for    = vmware-networks-configuration

/etc/dinit.d/vmware-usbarbitrator
Code: [Select]
before       = login.target
command      = /usr/bin/vmware-usbarbitrator
depends-on   = local.target
stop-command = /usr/bin/vmware-usbarbitrator --kill
type         = scripted



Installation procedure:
  • Install vmware-workstation from the AUR.
  • Reboot to ensure kernel modules have been loaded.
  • Copy the scripts to the paths specified above.
  • Enable the services in the following order:
    Code: [Select]
    dinitctl enable vmware-networks-configuration
    dinitctl enable vmware-networks-pre
    dinitctl enable vmware-networks
    dinitctl enable vmware-usbarbitrator

Everything should work immediately, but you may reboot again to be sure.
I created these scripts with my extremely limited knowledge of dinit and Linux, so they may not be optimal but I have validated that they do work.



A little summary of what they do and alternatives to create a working configuration:
  • vmware-networks-configuration creates a base network configuration file (/etc/vmware/networking) for VMware to use, if not already present.
    • Alternatively, the network configuration file can be placed manually, since there is no merit to a use-once service (a no-op on following system starts) other than recovering from a corrupted state.
  • vmware-networks-pre forces the vmnet kernel module to be loaded. This module performs all networking related operations.
    • Alternatively, a .conf file with the content vmnet can be placed manually inside /etc/modules-load.d, eliminating the need for another service.
  • vmware-networks starts the helper responsible for configuring and managing the network settings to be run in conjunction with the kernel module.
  • vmware-usbarbitrator starts the USB arbitration service that handles external device connectivity to the VMs.

I hope these help someone to run VMware on any Linux system using dinit, or at least help them understand how to write init scripts for VMware on any other init system.
But I would love to see VMware as a native package for Artix, if possible.