ventoy / PXE

The open source part of iVentoy.
451 stars 32 forks source link

iVentoy Autostart #4

Open MelonicOverlord opened 1 year ago

MelonicOverlord commented 1 year ago

As far as I can tell, there is no realistic way of launching iVentoy at boot as of right now. In my case, and likely in many other people's case, my server goes down overnight to save energy, and when it comes up in the morning I have no way of starting iVentoy other than to SSH in, and then go to the webpanel to start the DHCP. It would be cool to see the integration of a SystemD and OpenRC script which can automatically start the iVentoy service and DHCP server. This would also make it handy if any servers go offline at any point, and when they come back online the PXE services do not have to be started again manually.

Not really an issue, more of a suggesdtion but still.

ventoy commented 1 year ago

You can integrate the following cmd in any autostart script.

bash iventoy.sh -R start

with -R option, it will auto start the service with last saved parameters.

Or you can send command by curl to emulate the web behavior, you can refer: https://forums.ventoy.net/showthread.php?tid=2496

MelonicOverlord commented 1 year ago

Ah, thanks - I did not see that anywhere on the website's documentation. Am I also purely limited to 20 devices or is there a way of resetting that/having them overwrite each other?

Starbase12 commented 11 months ago

Saved my day. I was able to configure automatic boot within linux:

104ru commented 6 months ago

Nothing prevents you from writhing a systemd service unit for iventoy yourself. Here is what I came up with:

# /etc/systemd/system/iventoy.service
[Unit]
Description=iVentoy PXE Booter
Documentation=https://www.iventoy.com
Wants=network-online.target

[Service]
Type=forking
Environment=IVENTOY_API_ALL=1
Environment=IVENTOY_AUTO_RUN=1
Environment=LIBRARY_PATH=/path/to/iventoy/lib/lin64
Environment=LD_LIBRARY_PATH=/path/to/iventoy/lib/lin64
ExecStart=/path/to/iventoy/lib/iventoy
WorkingDirectory=/path/to/iventoy
Restart=on-failure

[Install]
WantedBy=multi-user.target

Of course, replace /path/to/iventoy with a real location of iventoy directory on your system.

jeffshead commented 6 months ago

Nothing prevents you from writhing a systemd service unit for iventoy yourself. Here is what I came up with: ... Of course, replace /path/to/iventoy with a real location of iventoy directory on your system.

Using your code for running as a service on AlmaLinux doesn't fully work for me. It starts and I'm able to access the webpage but the IP address is not detected.

2024-03-02_23-27-31

Is there a fix for this?

104ru commented 6 months ago

Evidently the error you are getting has nothing to do with the systemd unit since the service has started and running. Otherwise you won't see a web interface. The machine you are running iventoy on must have a wired connection to the network. iVentoy believes that your machine does not.

jeffshead commented 6 months ago

@104ru - It's wired. I do not have this issue when I disable the service and start iVentoy with the script ./iventoy.sh -R start

Only happens when I try to run iVentoy as a service, using the code that you provided. Wonder why it works for your system but not mine? My system is an AlmaLinux 9.3 VM. Maybe Wants=network-online.target is not sufficient for AlmaLinux???

jeffshead commented 6 months ago

So far, changing from Wants=network-online.target to After=network-online.target seems to have fixed the issue with the service.

MelonicOverlord commented 5 months ago

Hi,

Just an update - have added this startup service on my server and it is doing the same as jeff's system and not detecting the NIC anymore, but strangely only after a fresh reboot/start of the server. It worked just fine initially starting the script after adding it.

I'm running OpenMediaVault (basically just Debian underneath) since it is easier for management of the drives on my NAS.

Changing Wants to After has fixed the issue for me as well.

I also have an issue where dnsmasq is occupying the DHCP port before iVentoy can get to it, meaning the actual service doesn't start automatically still. But this must be a configuration issue somewhere else my end. Dnsmasq was pulled in by I believe qemu and even though I have removed it, somehow it is still finding a way to start. Maybe I just need to properly reinstall dnsmasq and change the port it's using.

MelonicOverlord commented 5 months ago

The dnsmasq issue appears to be libvirt using its own built-in version of dnsmasq to supply the virtual networks. Since I rarely use the VM on this server, the virtual network can just be set to not load on boot and need to be manually activated.

Can now confirm that everything is starting on system boot - but it is no longer recognising the interface again. If I manually reload the service it does get the IP Configuration. Strange