kwindrem / TailscaleGX

tailscale for Victron Energy GX devices
8 stars 2 forks source link

Preparation for Venus OS integration #5

Open mr-manuel opened 1 month ago

mr-manuel commented 1 month ago

Tailscale will be integrated into Venus OS and be part of the normal and large Venus OS image.

Currently I have no version number, with which the integration will be available, but I will provide it to you as soon as I have it. Instead of a version check, you could do it also by checking if the folder /opt/victronenergy/tailscale exists.

The idea for this issue is, that if the SetupHelper recognizes that Tailscale is already present in Venus OS, then it does a migration of the Tailscale settings automatically. After that this plugin is disabled/removed.

Copy config files

The tailscaled state dir is /data/conf/tailscale, so you can move all files from /data/setupOptions/TailscaleGX/state. Check if that directory already exists before copying it, if not you have to create it.

Copy and transform dbus settings

com.victronenergy.settings/Settings/TailscaleGX/IpForwarding -> com.victronenergy.settings/Settings/Services/Tailscale/CustomArguments If 0 a transformation is not needed, if 1 set the value to --advertise-exit-node=true.

com.victronenergy.settings/Settings/TailscaleGX/Enabled -> com.victronenergy.settings/Settings/Services/Tailscale/Enabled.

If you have any questions let me know.

kwindrem commented 1 month ago

Thanks for the heads up. I'll make the suggested changes soon.

mr-manuel commented 1 month ago

You're welcome. I don't expect it to get released before the middle of next week, so it's not that urgent.

kwindrem commented 1 month ago

seems like com.victronenergy.settings/Settings/Services/Tailscale/CustomArguments might include other arguments.

Should I be appending --advertise-exit-node=true to it rather than replacing it’s value? — Kevin

On Aug 20, 2024, at 4:14 AM, Manuel @.***> wrote:

Tailscale will be integrated into Venus OS and be part of the normal and large Venus OS image.

Currently I have no version number, with which the integration will be available, but I will provide it to you as soon as I have it. Instead of a version check, you could do it also by checking if the folder /opt/victronenergy/tailscale exists.

The idea for this issue is, that if the SetupHelper recognizes that Tailscale is already present in Venus OS, then it does a migration of the Tailscale settings automatically. After that this plugin is disabled/removed.

Copy config files

The tailscaled state dir is /data/conf/tailscale, so you can move all files from /data/setupOptions/TailscaleGX/state. Check if that directory already exists before copying it, if not you have to create it.

Copy and transform dbus settings

com.victronenergy.settings/Settings/TailscaleGX/IpForwarding -> com.victronenergy.settings/Settings/Services/Tailscale/CustomArguments If 0 a transformation is not needed, if 1 set the value to --advertise-exit-node=true.

com.victronenergy.settings/Settings/TailscaleGX/Enabled -> com.victronenergy.settings/Settings/Services/Tailscale/Enabled.

If you have any questions let me know.

— Reply to this email directly, view it on GitHub https://github.com/kwindrem/TailscaleGX/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN6TTGZN4UB244JSKPXHVZTZSMQHRAVCNFSM6AAAAABMZVM2UCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TKMZXHAZDIOA. You are receiving this because you are subscribed to this thread.

kwindrem commented 1 month ago

After additional thought I decided if the new setting exists I won’t touch it so won’t need to append to an existing string. — Kevin

On Aug 21, 2024, at 10:11 AM, Kevin Windrem @.***> wrote:

seems like com.victronenergy.settings/Settings/Services/Tailscale/CustomArguments might include other arguments.

Should I be appending --advertise-exit-node=true to it rather than replacing it’s value? — Kevin

On Aug 20, 2024, at 4:14 AM, Manuel @.***> wrote:

Tailscale will be integrated into Venus OS and be part of the normal and large Venus OS image.

Currently I have no version number, with which the integration will be available, but I will provide it to you as soon as I have it. Instead of a version check, you could do it also by checking if the folder /opt/victronenergy/tailscale exists.

The idea for this issue is, that if the SetupHelper recognizes that Tailscale is already present in Venus OS, then it does a migration of the Tailscale settings automatically. After that this plugin is disabled/removed.

Copy config files

The tailscaled state dir is /data/conf/tailscale, so you can move all files from /data/setupOptions/TailscaleGX/state. Check if that directory already exists before copying it, if not you have to create it.

Copy and transform dbus settings

com.victronenergy.settings/Settings/TailscaleGX/IpForwarding -> com.victronenergy.settings/Settings/Services/Tailscale/CustomArguments If 0 a transformation is not needed, if 1 set the value to --advertise-exit-node=true.

com.victronenergy.settings/Settings/TailscaleGX/Enabled -> com.victronenergy.settings/Settings/Services/Tailscale/Enabled.

If you have any questions let me know.

— Reply to this email directly, view it on GitHub https://github.com/kwindrem/TailscaleGX/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN6TTGZN4UB244JSKPXHVZTZSMQHRAVCNFSM6AAAAABMZVM2UCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TKMZXHAZDIOA. You are receiving this because you are subscribed to this thread.

mr-manuel commented 1 month ago

This value will be empty, since on the first time it's present, the migration will happen.

kwindrem commented 1 month ago

I'm having trouble setting .../CustomArgument to --advertise-exit-node=true

This is in a bash script which uses the dbus -y ... SetValue call

I am getting dbus: error: no such option: --advertise-exit-node

mr-manuel commented 1 month ago

To ensure that --advertise-exit-node is interpreted as a value rather than a command-line option, you can use the -- separator, which tells the command-line parser to treat all subsequent arguments as positional parameters rather than options.

dbus -y com.victronenergy.settings /Settings/Services/Tailscale/CustomArguments SetValue -- "--advertise-exit-node"

By adding -- before --advertise-exit-node, you ensure that it is treated as a value rather than an option.

kwindrem commented 1 month ago

Thanks. That worked

kwindrem commented 1 month ago

I've made modifications to TailscaleGX as you suggested but I do have a question regarding migration:

Will the new settings and state already exist in the stock firmware before TailscaleGX or it's setup script have a chance to run?

The reason I ask is my code currently checks for the presence of the stock items and does not migrate from the TailscaleGX ones if they do exist. This would mean tailscale would start up in its default configuration and establishing a connection again. Maybe this would be OK and I don't need to migrate from TailscaleGX.

Comments?

mr-manuel commented 1 month ago

The new settings and state will exists before /data/rc*.local run, therefore no chance that the setup script runs before.

kwindrem commented 1 month ago

I think it may be best then to not attempt any migration. This means the user/installer would need to set up tailscale again but with the QR code this should be fairly painless.

Comments?

kwindrem commented 1 month ago

An alternative would be to update TailscaleGX to migrate to the new settings/state now so they are using them when the firmware includes tailscale natively.

mr-manuel commented 1 month ago

That was the idea, that you update TailscaleGX now to allow a seamless migration.

kwindrem commented 1 month ago

TailscaleGX has been updated to use the new Settings parameters and state location.

Running TailscaleGX-control will migrate the changes, then if /opt/v*/tailscale is detected, it will exit.

Running the setup script if /opt/v*/tailscale exists will fail to install.

When the firmware version that includes tailscale is determined, I'll update TailscaleGX so an install won't even be possible (obsolete version will be set).

These changes are on the latest tag and are currently v1.10. Feel free to test.