[Solved] Running a command at boot?


I borked my installation by auto enabling Wireguard every time at boot which is not letting me SSH into the system or access any of the services running on my device.

I’d like to run a simple command at boot that would disable Wireguard from running automatically. Then after rebooting the device, I would be able to SSH into it like normal. This would need to be done by editing a config file on the MicroSD that runs the command after all services have been started.

How do I do this?


EDIT: Solved my own problem.

Opened up the ‘postboot’ file on my SD card in the dietpi folder, added a line right after the ‘start services’ command.
Turned on the Pi. Waited at least 5 minutes.
Turned off the Pi. Turned it back on.
Tried SSH and voilá it works and Wireguard is off thanks to the command I got it to run after starting all services when the boot finished. Phew.

Could you explain what you put where exactly?

I want to schiebe the oppposite, i.e. start wireguard after boot. (Starting the service fails for some reason, If I start by hand once boot is finished, it works, so ist could be a timing issue)

I could with an Idea how to do that. (Starting a service once boot is finished)

Many thanks in advance.


I think I found one way I am happy with for now.


I simply added a script into the dietpi postboot.d folder.
And within that one-line-script I start wireguard service via systemctl start wg-quick@wg0.

Works reliably for me.

Sorry I didn’t get to you in time, but I’m glad you sorted it out quickly. Actually it just so happens that I am having a serious problem with Wireguard.

My thread is here: Wireguard + Mullvad. How to?

Would you happen to know what the problem is?