Install hook with ubuntu user?

I am attempting my first charm, and successfully gotten something that is starting to look okay…

I seem to perform su ubuntu , change directories … but when I see the results it is still root

any ideas how to change users and install as ubuntu user?

#!/bin/bash

apt install libxrender1 libxtst6 libxi6 -y
juju-log -l 'INFO' 'XServer Dependencies installed'

su ubuntu
ch /home/ubuntu

curl https://download2.interactivebrokers.com/installers/ibgateway/latest-standalone/ibgateway-latest-standalone-linux-x64.sh --output ibgateway-latest-standalone-linux-x64.sh
chmod +x ibgateway-latest-standalone-linux-x64.sh
chown ubuntu.ubuntu ibgateway-latest-standalone-linux-x64.sh

# Install IB Gateway
yes n | ./ibgateway-latest-standalone-linux-x64.sh

exit

juju-log -l 'INFO' 'IBGateway Installed'

resulting charm

You have chown the script, but the subsequent exec of the script is under root.

You could try one of the methods listed here:

1 Like

I got it to work actually… with this bash technique

sudo -u ubuntu ./ibgateway-latest-standalone-linux-x64.sh

this tells linux to run the command as the user after the -u flag. even setting the owner to ubuntu had not been enough.

Thanks Erik!

1 Like