Skip to main content
Topic: migrating away from systemd units... (Read 1108 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

migrating away from systemd units...

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
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 %i
After=network.target network-online.target systemd-modules-load.service vboxdrv.service
Before=runlevel2.target shutdown.target

[Service]
User=muhusername
Group=muhgroup
Type=forking

Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes

ExecStart=/usr/bin/VBoxManage startvm %i --type headless
ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton

[Install]
WantedBy=multi-user.target
Quote from: [email protected]
[Unit]
Description=autotunnel; autossh reverse ssh tunnel for port %i
Requires=network-online.target
After=network-online.target

[Service]
Type=forking
User=muhusername
ExecStart=/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 autotunnel
Restart=always

[Install]
WantedBy=multi-user.target
Since 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...