Running mod-host from a script

Friends

In my efforts to write a button initiated script that runs mod-host I am having errors connecting to jack

The button initiated scripts run as root so I am using runuser to run mod-host as patch user.

My script is:

#!/bin/bash                                                                                                                                                              
runuser -l patch -c "export LV2_PATH=/usr/modep/lv2 &&  /home/patch/mod-host/mod-host"                                                                                  

But

$ sudo ./runMod.sh
Forking... child PID: 14465
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

Running from the command line as patch is OK

patch@patchbox:~/ModHostPedal $ export LV2_PATH=/usr/modep/lv2 &&  /home/patch/mod-host/mod-host
Forking... child PID: 14481
patch@patchbox:~/ModHostPedal $ mod-host ready!

Hi, it’s possibly missing the environment variable from /etc/environment. Try using this command to preserve the environment:

sudo -E ./runMod.sh

Sadly that makes no difference.

Then add export JACK_PROMISCUOUS_SERVER=jack

That is in my environment.

The -E preserves it

I have changed the script runMod.sh to use the Modep mod-host, incase I have corrupted my local copy

No change. When I run mod-host from a terminal it works as it should.

#!/bin/bash                                                                                                                                                              
echo DBUS_SESSION_BUS_ADDRESS $DBUS_SESSION_BUS_ADDRESS
echo JACK_PROMISCUOUS_SERVER: $JACK_PROMISCUOUS_SERVER
runuser -l patch -c "export LV2_PATH=/usr/modep/lv2 &&  /usr/bin/mod-host -v"                                                                                          

Then runuser must be resetting the environment. Try adding --preserve-environment to it.

1 Like

Almost perfect

--preserve-environment cashes with -l and -c clashes with -u but the command can be simplified since we are preserving the environment.

Made a change in the script using all the above and the problem is solved

export LV2_PATH=/usr/modep/lv2
runuser  --preserve-environment -u patch  /usr/bin/mod-host

Complete script (for this example)

#!/bin/bash                                                                                                                                                              
echo DBUS_SESSION_BUS_ADDRESS $DBUS_SESSION_BUS_ADDRESS
echo JACK_PROMISCUOUS_SERVER: $JACK_PROMISCUOUS_SERVER
export LV2_PATH=/usr/modep/lv2
runuser  --preserve-environment -u patch  /usr/bin/mod-host
1 Like

It is the environment variable JACK_PROMISCUOUS_SERVER that is important’

The following does not need the -E for sudo

#!/bin/bash                                                                                                                                                              
export JACK_PROMISCUOUS_SERVER=jack
export LV2_PATH=/usr/modep/lv2
runuser  --preserve-environment -u patch  /usr/bin/mod-host
2 Likes