migrating away from systemd units... 16 April 2021, 21:41:48 This: http://openrc.run/ doesn't quite get me there...I have systemd units I wrote for starting VMs, networking (WiFi and Wired) and for starting SSH reverse tunnels.They use some of the systemd features that I'm guessing don't correlate in OpenRC?For example:The VM unit is named "[email protected]" so that I can use the %i variable inside the file and type this "systemctl enable vbox@VM_NAME"I have a similar unit file for the reverse ssh tunnel. "[email protected]" allows me to type "systemctl enable autotunnel@80" and port 80 gets forwarded back through the tunnel.This way I have one unit file for every VM I feel like using or port I need to forward, instead of a different, specific unit file for each one.I have other things I need to clear up, but I just want to solve this one issue of "passing the variable" so I can use a single common file to provide multiple services.Maybe Open RC wants to do this in a completely different way... I don't know. I didn't invent these things so I have no idea.
Re: migrating away from systemd units... Reply #1 – 16 April 2021, 21:57:29 Some of this is a bit messy because they wouldn't work according to documentation, and there was no explanation for the failures.Logic and Reason and RTFM brought no solutions, so I just DuckDuckGo'd for similar stuff and jammed options into the unit file(s) until it worked.Sloppy and dumb, yes. But, I've got sh*t to do...Here are the contents of the files:Quote from: [email protected][Unit]Description=VirtualBox VM %iAfter=network.target network-online.target systemd-modules-load.service vboxdrv.serviceBefore=runlevel2.target shutdown.target[Service]User=muhusernameGroup=muhgroupType=forkingRestart=noTimeoutSec=5minIgnoreSIGPIPE=noKillMode=processGuessMainPID=noRemainAfterExit=yesExecStart=/usr/bin/VBoxManage startvm %i --type headlessExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton[Install]WantedBy=multi-user.targetQuote from: [email protected][Unit] Description=autotunnel; autossh reverse ssh tunnel for port %iRequires=network-online.targetAfter=network-online.target[Service]Type=forkingUser=muhusernameExecStart=/usr/bin/autossh -f -M 0 -o ServerAliveInterval=3 -o ServerAliveCountMax=2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=false -NTR %i:localhost:%i [email protected]ExecStop=/usr/bin/pkill -9 -u autotunnelRestart=always[Install]WantedBy=multi-user.targetSince I finally figured out the missing parts of the documentation needed to get Artix running as a headless host AND in a VM, I'd like to get everything switched away from systemd dependent OSes...
Re: migrating away from systemd units... Reply #2 – 16 April 2021, 22:07:35 https://github.com/OpenRC/openrc/blob/master/service-script-guide.md Is a bit of a guide on how to write openrc init scripts. Most of the stuff in unit files can be ignored in general. Keys are the execstart, user and group and also depends(requires), when to start(after/before).