Custom linux command in Torizon OS

Hello

I am using TorizonCore Builder to create my custom Torizon OS using a tcbuild.yaml file.

I want to add a linux command to the OS for the torizon user (for example: my-command).
The idea is that when I log in with the torizon user that I can use my-command (and it even autocompletes with tab).
Behind the command should be something of the form docker exec torizon-my-app-1 ./my-app.

I tried using aliases or bash scripts, but end up with permission issues.

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello!

To capture configuration changes on your Toradex device and include them in your tcbuild.yaml file, you can follow these steps:

  1. Make Changes on the Target Device: Begin by implementing the desired changes on your target device, such as creating a command or script. You can find more details on this process in the Torizon documentation.

  2. Capture Changes Using the Isolate Command: Use the isolate command to capture these changes:

    $ torizoncore-builder isolate --remote-host 192.168.1.10 --remote-username torizon --remote-password torizon --changes-directory changes1
    

    This command will collect the changes into a specified directory. For more information, refer to the prerequisites section.

  3. Include Changes in tcbuild.yaml: Add the captured changes to your tcbuild.yaml file as follows:

    input:
      easy-installer:
        local: images/torizon-core-docker-colibri-imx6-Tezi_5.3.0-devel-202105+build.12.tar
    
    customization:
      filesystem:
         - changes1/
    
    output:
      easy-installer:
        local: torizon-core-docker-colibri-imx6-custom
    

    This setup will ensure that any configuration changes in /etc and other system directories are included, allowing you to set up your custom command with the correct permissions. More examples of configuration changes can be found in the Torizon documentation.

I hope this helps you with your customization process!

Best regards,
Toradex AI Assistant

Greetings @i.staehli,

Just to get a baseline understanding, what exactly have you tried so far?

As for what you want, you basically want to have something like alias foo=bar and then when you type fo and hit tab it should autocomplete to foo, correct? But you want this to be setup as part of the image on first boot, correct?

Best Regards,
Jeremias

Hi @jeremias.tx

What I have tried so far:

  1. Adding a bash script under /usr/bin with the filesystem changes of torizoncore-builder. This doesn’t autocomplete and only works with sudo. The script looked like this:
#!/bin/sh
docker exec torizon-my-app-1 ./my-app
  1. Adding a script under /usr/etc/profile.d with
alias my-command="docker exec torizon-my-app-1 ./my-app"

This only works when changing the permissions to 644. But when building with torizoncore-builder it will automatically “remove” the permissions for the torizon user.

  1. Adding a bash script under /usr/local/bin would work in principle. But I can’t place a file there, because it’s actually /var/usrlocal/bin and the OS update can’t touch those files.

What you wrote is exactly what I want to achieve.

Kind regards,
Ian

Dear @i.staehli,

I believe this indeed has to do with the permissions granted and the persistency of configurations within OStree. I believe you might be able to use the “.tcattr” file to permit access.
We have a developer page entry, which describes how you are able to grant permissions to files via attributes.

Please let me know how you fare with this.

Best regards,
Collin

1 Like

@collin.tx Thanks!

Using the .tcattr together with my option 2 seems to work.

1 Like

Perfect, glad to see it was something relatively simple with the permissions.

Best Regards,
Jeremias